his_api_controller.go 1.6MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879
  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/3260", &HisApiController{}, "get:Get3260")
  116. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  117. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  118. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  119. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  120. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  121. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  122. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  123. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  124. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  125. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  126. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  127. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  128. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  129. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  130. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  131. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  132. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  133. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  134. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  135. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  136. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  137. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  138. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  139. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  140. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  141. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  142. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  143. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  144. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  145. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  146. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  147. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  148. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  149. //库盘和变更
  150. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  151. //删除库盘和变更
  152. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  153. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  154. //药品变更
  155. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  156. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  157. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  158. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  159. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  160. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  161. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  162. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  163. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  164. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  165. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  166. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  167. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  168. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  169. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. 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)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  185. //return
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "msg": "成功",
  188. })
  189. }
  190. func (c *HisApiController) Get3508() {
  191. admin_user_id, _ := c.GetInt64("admin_user_id")
  192. drug_id, _ := c.GetInt64("id")
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. adminUser := c.GetAdminUserInfo()
  196. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  198. drug, _ := service.GetDrugByID(drug_id)
  199. var struct3508 models.Struct3508
  200. struct3508.OrgName = miConfig.OrgName
  201. struct3508.FixmedinsCode = miConfig.Code
  202. struct3508.AccessKey = miConfig.AccessKey
  203. struct3508.Opter = curRoles.UserName
  204. struct3508.RequestUrl = miConfig.Url
  205. struct3508.Url = miConfig.Url
  206. struct3508.AppId = miConfig.Cainfo
  207. struct3508.AppSecret = miConfig.AppSecret
  208. struct3508.Enckey = miConfig.EncKey
  209. struct3508.SignKey = miConfig.SignKey
  210. struct3508.SecretKey = miConfig.SecretKey
  211. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  212. struct3508.Begndate = start_time
  213. struct3508.Enddate = end_time
  214. result1, result2, _ := service.FJyb3508(struct3508)
  215. saveLog(result1, result2, "3508", "3508")
  216. var res models.Result3508
  217. var respJSON2 map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. userJSONBytes2, _ := json.Marshal(respJSON2)
  224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode == -1 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. } else {
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "info": res.Output,
  237. })
  238. }
  239. }
  240. func (c *HisApiController) Get3509() {
  241. admin_user_id, _ := c.GetInt64("admin_user_id")
  242. drug_id, _ := c.GetInt64("id")
  243. start_time := c.GetString("start_time")
  244. end_time := c.GetString("end_time")
  245. adminUser := c.GetAdminUserInfo()
  246. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  248. drug, _ := service.GetDrugByID(drug_id)
  249. var struct3508 models.Struct3509
  250. struct3508.OrgName = miConfig.OrgName
  251. struct3508.FixmedinsCode = miConfig.Code
  252. struct3508.AccessKey = miConfig.AccessKey
  253. struct3508.Opter = curRoles.UserName
  254. struct3508.RequestUrl = miConfig.Url
  255. struct3508.Url = miConfig.Url
  256. struct3508.AppId = miConfig.Cainfo
  257. struct3508.AppSecret = miConfig.AppSecret
  258. struct3508.Enckey = miConfig.EncKey
  259. struct3508.SignKey = miConfig.SignKey
  260. struct3508.SecretKey = miConfig.SecretKey
  261. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  262. struct3508.Begndate = start_time
  263. struct3508.Enddate = end_time
  264. result1, result2, _ := service.FJyb3509(struct3508)
  265. saveLog(result1, result2, "3509", "3509")
  266. var res models.Result3509
  267. var respJSON2 map[string]interface{}
  268. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  271. return
  272. }
  273. userJSONBytes2, _ := json.Marshal(respJSON2)
  274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  275. utils.ErrorLog("解析失败:%v", err)
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  277. return
  278. }
  279. if res.Infcode == -1 {
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "failed_code": -10,
  282. "msg": res.ErrMsg,
  283. })
  284. } else {
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "info": res.Output,
  287. })
  288. }
  289. }
  290. func (c *HisApiController) Get3510() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. drug_id, _ := c.GetInt64("id")
  293. start_time := c.GetString("start_time")
  294. end_time := c.GetString("end_time")
  295. adminUser := c.GetAdminUserInfo()
  296. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  298. drug, _ := service.GetDrugByID(drug_id)
  299. var struct3508 models.Struct3510
  300. struct3508.FixmedinsCode = miConfig.Code
  301. struct3508.OrgName = miConfig.OrgName
  302. struct3508.AccessKey = miConfig.AccessKey
  303. struct3508.Opter = curRoles.UserName
  304. struct3508.RequestUrl = miConfig.Url
  305. struct3508.Url = miConfig.Url
  306. struct3508.AppId = miConfig.Cainfo
  307. struct3508.AppSecret = miConfig.AppSecret
  308. struct3508.Enckey = miConfig.EncKey
  309. struct3508.SignKey = miConfig.SignKey
  310. struct3508.SecretKey = miConfig.SecretKey
  311. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  312. struct3508.Begndate = start_time
  313. struct3508.Enddate = end_time
  314. result1, result2, _ := service.FJyb3510(struct3508)
  315. saveLog(result1, result2, "3510", "3510")
  316. var res models.Result3510
  317. var respJSON2 map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  321. return
  322. }
  323. userJSONBytes2, _ := json.Marshal(respJSON2)
  324. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == -1 {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": res.ErrMsg,
  333. })
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "info": res.Output,
  337. })
  338. }
  339. }
  340. func (c *HisApiController) Get3511() {
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. drug_id, _ := c.GetInt64("id")
  343. start_time := c.GetString("start_time")
  344. end_time := c.GetString("end_time")
  345. adminUser := c.GetAdminUserInfo()
  346. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  348. drug, _ := service.GetDrugByID(drug_id)
  349. var struct3508 models.Struct3511
  350. struct3508.FixmedinsCode = miConfig.Code
  351. struct3508.OrgName = miConfig.OrgName
  352. struct3508.AccessKey = miConfig.AccessKey
  353. struct3508.Opter = curRoles.UserName
  354. struct3508.RequestUrl = miConfig.Url
  355. struct3508.Url = miConfig.Url
  356. struct3508.AppId = miConfig.Cainfo
  357. struct3508.AppSecret = miConfig.AppSecret
  358. struct3508.Enckey = miConfig.EncKey
  359. struct3508.SignKey = miConfig.SignKey
  360. struct3508.SecretKey = miConfig.SecretKey
  361. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  362. struct3508.Begndate = start_time
  363. struct3508.Enddate = end_time
  364. result1, result2, _ := service.FJyb3511(struct3508)
  365. saveLog(result1, result2, "3511", "3511")
  366. var res models.Result3511
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode == -1 {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. } else {
  385. c.ServeSuccessJSON(map[string]interface{}{
  386. "info": res.Output,
  387. })
  388. }
  389. }
  390. func (c *HisApiController) Get3512() {
  391. admin_user_id, _ := c.GetInt64("admin_user_id")
  392. drug_id, _ := c.GetInt64("id")
  393. start_time := c.GetString("start_time")
  394. end_time := c.GetString("end_time")
  395. adminUser := c.GetAdminUserInfo()
  396. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  398. drug, _ := service.GetDrugByID(drug_id)
  399. var struct3508 models.Struct3512
  400. struct3508.FixmedinsCode = miConfig.Code
  401. struct3508.OrgName = miConfig.OrgName
  402. struct3508.AccessKey = miConfig.AccessKey
  403. struct3508.Opter = curRoles.UserName
  404. struct3508.RequestUrl = miConfig.Url
  405. struct3508.Url = miConfig.Url
  406. struct3508.AppId = miConfig.Cainfo
  407. struct3508.AppSecret = miConfig.AppSecret
  408. struct3508.Enckey = miConfig.EncKey
  409. struct3508.SignKey = miConfig.SignKey
  410. struct3508.SecretKey = miConfig.SecretKey
  411. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  412. struct3508.Begndate = start_time
  413. struct3508.Enddate = end_time
  414. result1, result2, _ := service.FJyb3512(struct3508)
  415. saveLog(result1, result2, "3512", "3512")
  416. var res models.Result3512
  417. var respJSON2 map[string]interface{}
  418. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  421. return
  422. }
  423. userJSONBytes2, _ := json.Marshal(respJSON2)
  424. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == -1 {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "failed_code": -10,
  432. "msg": res.ErrMsg,
  433. })
  434. } else {
  435. c.ServeSuccessJSON(map[string]interface{}{
  436. "info": res.Output,
  437. })
  438. }
  439. }
  440. func (c *HisApiController) Get3513() {
  441. admin_user_id, _ := c.GetInt64("admin_user_id")
  442. drug_id, _ := c.GetInt64("id")
  443. start_time := c.GetString("start_time")
  444. end_time := c.GetString("end_time")
  445. adminUser := c.GetAdminUserInfo()
  446. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  448. drug, _ := service.GetDrugByID(drug_id)
  449. var struct3508 models.Struct3513
  450. struct3508.FixmedinsCode = miConfig.Code
  451. struct3508.OrgName = miConfig.OrgName
  452. struct3508.AccessKey = miConfig.AccessKey
  453. struct3508.Opter = curRoles.UserName
  454. struct3508.RequestUrl = miConfig.Url
  455. struct3508.Url = miConfig.Url
  456. struct3508.AppId = miConfig.Cainfo
  457. struct3508.AppSecret = miConfig.AppSecret
  458. struct3508.Enckey = miConfig.EncKey
  459. struct3508.SignKey = miConfig.SignKey
  460. struct3508.SecretKey = miConfig.SecretKey
  461. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  462. struct3508.Begndate = start_time
  463. struct3508.Enddate = end_time
  464. result1, result2, _ := service.FJyb3513(struct3508)
  465. saveLog(result1, result2, "3513", "3513")
  466. var res models.Result3513
  467. var respJSON2 map[string]interface{}
  468. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  471. return
  472. }
  473. userJSONBytes2, _ := json.Marshal(respJSON2)
  474. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. return
  478. }
  479. if res.Infcode == -1 {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "failed_code": -10,
  482. "msg": res.ErrMsg,
  483. })
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "info": res.Output,
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get35081() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. drug_id, _ := c.GetInt64("id")
  493. //start_time := c.GetString("start_time")
  494. //end_time := c.GetString("end_time")
  495. page, _ := c.GetInt("page")
  496. adminUser := c.GetAdminUserInfo()
  497. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  499. drug, _ := service.GetDrugByID(drug_id)
  500. var struct3508 models.Struct35081
  501. struct3508.FixmedinsCode = miConfig.Code
  502. struct3508.OrgName = miConfig.OrgName
  503. struct3508.AccessKey = miConfig.AccessKey
  504. struct3508.Opter = curRoles.UserName
  505. struct3508.RequestUrl = miConfig.Url
  506. struct3508.Url = miConfig.Url
  507. struct3508.AppId = miConfig.Cainfo
  508. struct3508.AppSecret = miConfig.AppSecret
  509. struct3508.Enckey = miConfig.EncKey
  510. struct3508.SignKey = miConfig.SignKey
  511. struct3508.SecretKey = miConfig.SecretKey
  512. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  513. struct3508.PageNum = page
  514. struct3508.PageSize = 10
  515. result1, result2, _ := service.FJyb35081(struct3508)
  516. saveLog(result1, result2, "35081", "35081")
  517. var res models.Result35081
  518. var respJSON2 map[string]interface{}
  519. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. userJSONBytes2, _ := json.Marshal(respJSON2)
  525. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  526. utils.ErrorLog("解析失败:%v", err)
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  528. return
  529. }
  530. if res.Infcode == -1 {
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "failed_code": -10,
  533. "msg": res.ErrMsg,
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "info": res.Output,
  538. })
  539. }
  540. }
  541. func (c *HisApiController) Get35082() {
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. drug_id, _ := c.GetInt64("id")
  544. //start_time := c.GetString("start_time")
  545. //end_time := c.GetString("end_time")
  546. page, _ := c.GetInt("page")
  547. adminUser := c.GetAdminUserInfo()
  548. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. drug, _ := service.GetDrugByID(drug_id)
  551. var struct3508 models.Struct35082
  552. struct3508.FixmedinsCode = miConfig.Code
  553. struct3508.OrgName = miConfig.OrgName
  554. struct3508.AccessKey = miConfig.AccessKey
  555. struct3508.Opter = curRoles.UserName
  556. struct3508.RequestUrl = miConfig.Url
  557. struct3508.Url = miConfig.Url
  558. struct3508.AppId = miConfig.Cainfo
  559. struct3508.AppSecret = miConfig.AppSecret
  560. struct3508.Enckey = miConfig.EncKey
  561. struct3508.SignKey = miConfig.SignKey
  562. struct3508.SecretKey = miConfig.SecretKey
  563. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  564. struct3508.PageNum = page
  565. struct3508.PageSize = 10
  566. result1, result2, _ := service.FJyb35082(struct3508)
  567. saveLog(result1, result2, "35082", "35082")
  568. var res models.Result35082
  569. var respJSON2 map[string]interface{}
  570. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. userJSONBytes2, _ := json.Marshal(respJSON2)
  576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  577. utils.ErrorLog("解析失败:%v", err)
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  579. return
  580. }
  581. if res.Infcode == -1 {
  582. c.ServeSuccessJSON(map[string]interface{}{
  583. "failed_code": -10,
  584. "msg": res.ErrMsg,
  585. })
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "info": res.Output,
  589. })
  590. }
  591. }
  592. func (c *HisApiController) FJ3501AND3502() {
  593. ids := c.GetString("ids")
  594. admin_user_id, _ := c.GetInt64("admin_user_id")
  595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  596. id_arr := strings.Split(ids, ",")
  597. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  599. //库盘
  600. var errs []string
  601. for _, drug := range drugs {
  602. if drug.IsPc == 0 {
  603. var res2 ResultSix
  604. var res3 ResultSix
  605. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  606. var struct3501 models.Struct3501
  607. struct3501.Code = miConfig.Code
  608. struct3501.OrgName = miConfig.OrgName
  609. struct3501.AccessKey = miConfig.AccessKey
  610. struct3501.Opter = roles.UserName
  611. struct3501.RequestUrl = miConfig.Url
  612. struct3501.Url = miConfig.Url
  613. struct3501.AppId = miConfig.Cainfo
  614. struct3501.AppSecret = miConfig.AppSecret
  615. struct3501.Enckey = miConfig.EncKey
  616. struct3501.SignKey = miConfig.SignKey
  617. struct3501.SecretKey = miConfig.SecretKey
  618. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  621. struct3501.RxFlag = "1"
  622. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  623. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  624. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  625. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  626. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  627. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  628. struct3501.FixmedinsBchno = number
  629. struct3501.DrugTracCodg = drug.DrugCode
  630. memo := make(map[string]interface{})
  631. memo["pric"] = drug.Price
  632. bytesData, _ := json.Marshal(memo)
  633. struct3501.Memo = string(bytesData)
  634. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  635. result1, result2, _ := service.FJyb3501(struct3501)
  636. saveLog(result1, result2, "3501", "3501")
  637. //saveLog(result, requestLog, "2201", "挂号")
  638. var respJSON2 map[string]interface{}
  639. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. userJSONBytes2, _ := json.Marshal(respJSON2)
  645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  646. utils.ErrorLog("解析失败:%v", err)
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  648. return
  649. }
  650. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  651. data := make(map[string]interface{})
  652. data["struct_3501s"] = struct3501
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. if miConfig.MdtrtareaAdmvs == "320921" {
  657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. } else {
  659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  660. }
  661. resp, _ := client.Do(req)
  662. defer resp.Body.Close()
  663. body, ioErr := ioutil.ReadAll(resp.Body)
  664. if ioErr != nil {
  665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  666. }
  667. var respJSON map[string]interface{}
  668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var resSix10265 ResultSix10265 //1101结果
  674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  675. result, _ := json.Marshal(respJSON)
  676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  677. utils.ErrorLog("解析失败:%v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  682. res2.Output = resSix10265.Output
  683. res2.ErrMsg = resSix10265.ErrMsg
  684. res2.Cainfo = resSix10265.Cainfo
  685. res2.WarnMsg = resSix10265.WarnMsg
  686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  687. res2.Infcode = infocode
  688. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  689. data := make(map[string]interface{})
  690. data["struct_3501s"] = struct3501
  691. client := &http.Client{}
  692. bytesData, _ := json.Marshal(data)
  693. var req *http.Request
  694. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  695. resp, _ := client.Do(req)
  696. defer resp.Body.Close()
  697. body, ioErr := ioutil.ReadAll(resp.Body)
  698. if ioErr != nil {
  699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. var resSix10265 ResultSix10265 //1101结果
  708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  709. result, _ := json.Marshal(respJSON)
  710. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  711. utils.ErrorLog("解析失败:%v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  716. res2.Output = resSix10265.Output
  717. res2.ErrMsg = resSix10265.ErrMsg
  718. res2.Cainfo = resSix10265.Cainfo
  719. res2.WarnMsg = resSix10265.WarnMsg
  720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  721. res2.Infcode = infocode
  722. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  723. data := make(map[string]interface{})
  724. data["struct_3501s"] = struct3501
  725. client := &http.Client{}
  726. bytesData, _ := json.Marshal(data)
  727. var req *http.Request
  728. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  750. res2.Output = resSix10265.Output
  751. res2.ErrMsg = resSix10265.ErrMsg
  752. res2.Cainfo = resSix10265.Cainfo
  753. res2.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res2.Infcode = infocode
  756. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  757. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  758. saveLog(result1, result2, "3501", "3501")
  759. //saveLog(result, requestLog, "2201", "挂号")
  760. var respJSON2 map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. userJSONBytes2, _ := json.Marshal(respJSON2)
  767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  768. utils.ErrorLog("解析失败:%v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. }
  773. if res2.Infcode != -1 {
  774. drug.IsPc = 1
  775. drug.Bchno = number
  776. drug.PcDate = time.Now().Unix()
  777. err := service.SaveW(drug)
  778. if err == nil {
  779. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  780. var struct3502 models.Struct3502
  781. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  784. struct3502.FixmedinsCode = miConfig.Code
  785. struct3502.Code = miConfig.Code
  786. struct3502.RxFlag = "0"
  787. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  788. struct3502.OrgName = miConfig.OrgName
  789. struct3502.Opter = roles.UserName
  790. struct3502.AccessKey = miConfig.AccessKey
  791. struct3502.RequestUrl = miConfig.Url
  792. struct3502.SecretKey = miConfig.SecretKey
  793. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  794. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  795. struct3502.Url = miConfig.Url
  796. struct3502.AppId = miConfig.Cainfo
  797. struct3502.AppSecret = miConfig.AppSecret
  798. struct3502.Enckey = miConfig.EncKey
  799. struct3502.SignKey = miConfig.SignKey
  800. struct3502.SecretKey = miConfig.SecretKey
  801. struct3502.DrugTracCodg = drug.DrugCode
  802. struct3502.Memo = ""
  803. struct3502.InvChgType = "108"
  804. struct3502.FixmedinsBchno = bg_number
  805. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  806. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  807. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  808. result11, result22, _ := service.FJyb3502(struct3502)
  809. saveLog(result11, result22, "3502", "3502")
  810. var respJSON3 map[string]interface{}
  811. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. userJSONBytes3, _ := json.Marshal(respJSON3)
  817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  818. utils.ErrorLog("解析失败:%v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  823. data := make(map[string]interface{})
  824. data["struct_3502s"] = struct3502
  825. client := &http.Client{}
  826. bytesData, _ := json.Marshal(data)
  827. var req *http.Request
  828. if miConfig.MdtrtareaAdmvs == "320921" {
  829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. } else {
  831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  832. }
  833. resp, _ := client.Do(req)
  834. defer resp.Body.Close()
  835. body, ioErr := ioutil.ReadAll(resp.Body)
  836. if ioErr != nil {
  837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  838. }
  839. var respJSON map[string]interface{}
  840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. var resSix10265 ResultSix10265 //1101结果
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. result, _ := json.Marshal(respJSON)
  848. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  849. utils.ErrorLog("解析失败:%v", err)
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  851. return
  852. }
  853. res3.InfRefmsgid = resSix10265.InfRefmsgid
  854. res3.Output = resSix10265.Output
  855. res3.ErrMsg = resSix10265.ErrMsg
  856. res3.Cainfo = resSix10265.Cainfo
  857. res3.WarnMsg = resSix10265.WarnMsg
  858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  859. res3.Infcode = infocode
  860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  861. data := make(map[string]interface{})
  862. data["struct_3502s"] = struct3502
  863. client := &http.Client{}
  864. bytesData, _ := json.Marshal(data)
  865. var req *http.Request
  866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  867. resp, _ := client.Do(req)
  868. defer resp.Body.Close()
  869. body, ioErr := ioutil.ReadAll(resp.Body)
  870. if ioErr != nil {
  871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  872. }
  873. var respJSON map[string]interface{}
  874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. var resSix10265 ResultSix10265 //1101结果
  880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  881. result, _ := json.Marshal(respJSON)
  882. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  883. utils.ErrorLog("解析失败:%v", err)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. res3.InfRefmsgid = resSix10265.InfRefmsgid
  888. res3.Output = resSix10265.Output
  889. res3.ErrMsg = resSix10265.ErrMsg
  890. res3.Cainfo = resSix10265.Cainfo
  891. res3.WarnMsg = resSix10265.WarnMsg
  892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  893. res3.Infcode = infocode
  894. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  895. data := make(map[string]interface{})
  896. data["struct_3501s"] = struct3501
  897. client := &http.Client{}
  898. bytesData, _ := json.Marshal(data)
  899. var req *http.Request
  900. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  901. resp, _ := client.Do(req)
  902. defer resp.Body.Close()
  903. body, ioErr := ioutil.ReadAll(resp.Body)
  904. if ioErr != nil {
  905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  906. }
  907. var respJSON map[string]interface{}
  908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var resSix10265 ResultSix10265 //1101结果
  914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  915. result, _ := json.Marshal(respJSON)
  916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  917. utils.ErrorLog("解析失败:%v", err)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  922. res2.Output = resSix10265.Output
  923. res2.ErrMsg = resSix10265.ErrMsg
  924. res2.Cainfo = resSix10265.Cainfo
  925. res2.WarnMsg = resSix10265.WarnMsg
  926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  927. res2.Infcode = infocode
  928. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  929. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  930. saveLog(result11, result22, "3502", "3502")
  931. var respJSON3 map[string]interface{}
  932. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. userJSONBytes3, _ := json.Marshal(respJSON3)
  938. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. }
  944. if res3.Infcode == -1 {
  945. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res3.ErrMsg,
  949. })
  950. } else {
  951. drug.IsBg = 1
  952. drug.BgBchno = bg_number
  953. service.SaveW(drug)
  954. }
  955. }
  956. } else {
  957. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  958. }
  959. }
  960. //变更
  961. }
  962. if len(errs) == 0 {
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "msg": "盘存变更成功",
  965. })
  966. } else {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "failed_code": -10,
  969. "msg": errs,
  970. })
  971. }
  972. }
  973. func (c *HisApiController) DeletePCandBG() {
  974. ids := c.GetString("ids")
  975. id_arr := strings.Split(ids, ",")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. var err []string
  981. for _, item := range drugs {
  982. if item.IsPc == 1 && item.IsBg == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "1"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.Code = miConfig.Code
  994. struct3507.SecretKey = miConfig.SecretKey
  995. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  996. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  997. struct3507.Url = miConfig.Url
  998. struct3507.AppId = miConfig.Cainfo
  999. struct3507.AppSecret = miConfig.AppSecret
  1000. struct3507.Enckey = miConfig.EncKey
  1001. struct3507.SignKey = miConfig.SignKey
  1002. struct3507.SecretKey = miConfig.SecretKey
  1003. if miConfig.MdtrtareaAdmvs == "350500" {
  1004. result, result1, _ := service.FJyb3507(struct3507)
  1005. saveLog(result, result1, "3507", "3507")
  1006. var respJSON2 map[string]interface{}
  1007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. userJSONBytes2, _ := json.Marshal(respJSON2)
  1013. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. } else {
  1019. data := make(map[string]interface{})
  1020. data["struct_3507s"] = struct3507
  1021. client := &http.Client{}
  1022. bytesData, _ := json.Marshal(data)
  1023. var req *http.Request
  1024. if miConfig.MdtrtareaAdmvs == "320921" {
  1025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1026. } else {
  1027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1028. }
  1029. resp, _ := client.Do(req)
  1030. defer resp.Body.Close()
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. }
  1035. var respJSON map[string]interface{}
  1036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. var resSix10265 ResultSix10265 //1101结果
  1042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1043. result, _ := json.Marshal(respJSON)
  1044. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. res.InfRefmsgid = resSix10265.InfRefmsgid
  1050. //res.Output = resSix10265.Output
  1051. res.ErrMsg = resSix10265.ErrMsg
  1052. res.Cainfo = resSix10265.Cainfo
  1053. res.WarnMsg = resSix10265.WarnMsg
  1054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1055. res.Infcode = infocode
  1056. }
  1057. if res.Infcode == 0 {
  1058. item.IsPc = 0
  1059. err2 := service.SaveW(item)
  1060. if err2 == nil {
  1061. var struct3507_2 models.Struct3507
  1062. struct3507_2.OrgName = miConfig.OrgName
  1063. struct3507_2.AccessKey = miConfig.AccessKey
  1064. struct3507_2.RequestUrl = miConfig.Url
  1065. struct3507_2.Opter = roles.UserName
  1066. struct3507_2.FixmedinsCode = miConfig.Code
  1067. struct3507_2.Code = miConfig.Code
  1068. struct3507_2.SecretKey = miConfig.SecretKey
  1069. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1070. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1071. struct3507_2.Url = miConfig.Url
  1072. struct3507_2.AppId = miConfig.Cainfo
  1073. struct3507_2.AppSecret = miConfig.AppSecret
  1074. struct3507_2.Enckey = miConfig.EncKey
  1075. struct3507_2.SignKey = miConfig.SignKey
  1076. struct3507_2.SecretKey = miConfig.SecretKey
  1077. struct3507_2.FixmedinsBchno = item.BgBchno
  1078. struct3507_2.InvDataType = "2"
  1079. if miConfig.MdtrtareaAdmvs == "350500" {
  1080. result11, result22, _ := service.FJyb3507(struct3507_2)
  1081. saveLog(result11, result22, "3507", "3507")
  1082. var respJSON3 map[string]interface{}
  1083. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. userJSONBytes3, _ := json.Marshal(respJSON3)
  1089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1090. utils.ErrorLog("解析失败:%v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. } else {
  1095. data := make(map[string]interface{})
  1096. data["struct_3507s"] = struct3507_2
  1097. client := &http.Client{}
  1098. bytesData, _ := json.Marshal(data)
  1099. var req *http.Request
  1100. if miConfig.MdtrtareaAdmvs == "320921" {
  1101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1102. } else {
  1103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1104. }
  1105. resp, _ := client.Do(req)
  1106. defer resp.Body.Close()
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. }
  1111. var respJSON map[string]interface{}
  1112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1115. return
  1116. }
  1117. var resSix10265 ResultSix10265 //1101结果
  1118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1119. result, _ := json.Marshal(respJSON)
  1120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1121. utils.ErrorLog("解析失败:%v", err)
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1123. return
  1124. }
  1125. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1126. //res2.Output = resSix10265.Output
  1127. res2.ErrMsg = resSix10265.ErrMsg
  1128. res2.Cainfo = resSix10265.Cainfo
  1129. res2.WarnMsg = resSix10265.WarnMsg
  1130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1131. res2.Infcode = infocode
  1132. }
  1133. if res2.Infcode != -1 {
  1134. item.IsBg = 0
  1135. item.Bchno = ""
  1136. item.BgBchno = ""
  1137. item.PcDate = 0
  1138. service.SaveW(item)
  1139. } else {
  1140. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1141. }
  1142. }
  1143. } else {
  1144. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1145. }
  1146. }
  1147. if item.IsPc == 1 && item.IsBg == 0 {
  1148. var res FJ3507Result
  1149. var struct3507 models.Struct3507
  1150. struct3507.FixmedinsBchno = item.Bchno
  1151. struct3507.InvDataType = "1"
  1152. struct3507.Opter = roles.UserName
  1153. struct3507.FixmedinsCode = miConfig.Code
  1154. struct3507.Code = miConfig.Code
  1155. struct3507.OrgName = miConfig.OrgName
  1156. struct3507.AccessKey = miConfig.AccessKey
  1157. struct3507.RequestUrl = miConfig.Url
  1158. struct3507.SecretKey = miConfig.SecretKey
  1159. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507.Url = miConfig.Url
  1162. struct3507.AppId = miConfig.Cainfo
  1163. struct3507.AppSecret = miConfig.AppSecret
  1164. struct3507.Enckey = miConfig.EncKey
  1165. struct3507.SignKey = miConfig.SignKey
  1166. struct3507.SecretKey = miConfig.SecretKey
  1167. //result, result1, _ := service.FJyb3507(struct3507)
  1168. //saveLog(result, result1, "3507", "3507")
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result, result1, _ := service.FJyb3507(struct3507)
  1171. saveLog(result, result1, "3507", "3507")
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. } else {
  1185. data := make(map[string]interface{})
  1186. data["struct_3507s"] = struct3507
  1187. client := &http.Client{}
  1188. bytesData, _ := json.Marshal(data)
  1189. var req *http.Request
  1190. if miConfig.MdtrtareaAdmvs == "320921" {
  1191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1192. } else {
  1193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. }
  1195. resp, _ := client.Do(req)
  1196. defer resp.Body.Close()
  1197. body, ioErr := ioutil.ReadAll(resp.Body)
  1198. if ioErr != nil {
  1199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1200. }
  1201. var respJSON map[string]interface{}
  1202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. var resSix10265 ResultSix10265 //1101结果
  1208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1209. result, _ := json.Marshal(respJSON)
  1210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. res.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res.Output = resSix10265.Output
  1217. res.ErrMsg = resSix10265.ErrMsg
  1218. res.Cainfo = resSix10265.Cainfo
  1219. res.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res.Infcode = infocode
  1222. }
  1223. if res.Infcode == 0 {
  1224. item.IsPc = 0
  1225. item.Bchno = ""
  1226. item.BgBchno = ""
  1227. item.PcDate = 0
  1228. service.SaveW(item)
  1229. } else {
  1230. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1231. }
  1232. }
  1233. if item.IsPc == 0 && item.IsBg == 1 {
  1234. var res FJ3507Result
  1235. var struct3507 models.Struct3507
  1236. struct3507.FixmedinsBchno = item.BgBchno
  1237. struct3507.InvDataType = "2"
  1238. struct3507.Opter = roles.UserName
  1239. struct3507.FixmedinsCode = miConfig.Code
  1240. struct3507.OrgName = miConfig.OrgName
  1241. struct3507.AccessKey = miConfig.AccessKey
  1242. struct3507.RequestUrl = miConfig.Url
  1243. struct3507.SecretKey = miConfig.SecretKey
  1244. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3507.Url = miConfig.Url
  1247. struct3507.AppId = miConfig.Cainfo
  1248. struct3507.AppSecret = miConfig.AppSecret
  1249. struct3507.Enckey = miConfig.EncKey
  1250. struct3507.SignKey = miConfig.SignKey
  1251. struct3507.SecretKey = miConfig.SecretKey
  1252. //result, result1, _ := service.FJyb3507(struct3507)
  1253. //saveLog(result, result1, "3507", "3507")
  1254. if miConfig.MdtrtareaAdmvs == "350500" {
  1255. result, result1, _ := service.FJyb3507(struct3507)
  1256. saveLog(result, result1, "3507", "3507")
  1257. var respJSON2 map[string]interface{}
  1258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. userJSONBytes2, _ := json.Marshal(respJSON2)
  1264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. } else {
  1270. data := make(map[string]interface{})
  1271. data["struct_3507s"] = struct3507
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. }
  1286. var respJSON map[string]interface{}
  1287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var resSix10265 ResultSix10265 //1101结果
  1293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1294. result, _ := json.Marshal(respJSON)
  1295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1296. utils.ErrorLog("解析失败:%v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. res.InfRefmsgid = resSix10265.InfRefmsgid
  1301. //res.Output = resSix10265.Output
  1302. res.ErrMsg = resSix10265.ErrMsg
  1303. res.Cainfo = resSix10265.Cainfo
  1304. res.WarnMsg = resSix10265.WarnMsg
  1305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1306. res.Infcode = infocode
  1307. }
  1308. if res.Infcode == 0 {
  1309. item.IsBg = 0
  1310. item.Bchno = ""
  1311. item.BgBchno = ""
  1312. item.PcDate = 0
  1313. service.SaveW(item)
  1314. } else {
  1315. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1316. }
  1317. }
  1318. }
  1319. if len(err) == 0 {
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "msg": "删除盘存变更成功",
  1322. })
  1323. } else {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": err,
  1327. })
  1328. }
  1329. }
  1330. func (c *HisApiController) DeleteXSandBG() {
  1331. ids := c.GetString("ids")
  1332. id_arr := strings.Split(ids, ",")
  1333. admin_user_id, _ := c.GetInt64("admin_user_id")
  1334. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1337. var err []string
  1338. for _, item := range flows {
  1339. if item.IsSale == 1 && item.IsChange == 1 {
  1340. var res FJ3507Result
  1341. var res2 FJ3507Result
  1342. var struct3507 models.Struct3507
  1343. struct3507.FixmedinsBchno = item.Bchno
  1344. struct3507.InvDataType = "4"
  1345. struct3507.Opter = roles.UserName
  1346. struct3507.OrgName = miConfig.OrgName
  1347. struct3507.AccessKey = miConfig.AccessKey
  1348. struct3507.RequestUrl = miConfig.Url
  1349. struct3507.FixmedinsCode = miConfig.Code
  1350. struct3507.SecretKey = miConfig.SecretKey
  1351. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1352. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1353. struct3507.Url = miConfig.Url
  1354. struct3507.AppId = miConfig.Cainfo
  1355. struct3507.AppSecret = miConfig.AppSecret
  1356. struct3507.Enckey = miConfig.EncKey
  1357. struct3507.SignKey = miConfig.SignKey
  1358. struct3507.SecretKey = miConfig.SecretKey
  1359. //result, result1, _ := service.FJyb3507(struct3507)
  1360. //saveLog(result, result1, "3507", "3507")
  1361. if miConfig.MdtrtareaAdmvs == "350500" {
  1362. result, result1, _ := service.FJyb3507(struct3507)
  1363. saveLog(result, result1, "3507", "3507")
  1364. var respJSON2 map[string]interface{}
  1365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. userJSONBytes2, _ := json.Marshal(respJSON2)
  1371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1372. utils.ErrorLog("解析失败:%v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. } else {
  1377. data := make(map[string]interface{})
  1378. data["struct_3507s"] = struct3507
  1379. client := &http.Client{}
  1380. bytesData, _ := json.Marshal(data)
  1381. var req *http.Request
  1382. if miConfig.MdtrtareaAdmvs == "320921" {
  1383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1384. } else {
  1385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1386. }
  1387. resp, _ := client.Do(req)
  1388. defer resp.Body.Close()
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. }
  1393. var respJSON map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. var resSix10265 ResultSix10265 //1101结果
  1400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1401. result, _ := json.Marshal(respJSON)
  1402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. res.InfRefmsgid = resSix10265.InfRefmsgid
  1408. //res.Output = resSix10265.Output
  1409. res.ErrMsg = resSix10265.ErrMsg
  1410. res.Cainfo = resSix10265.Cainfo
  1411. res.WarnMsg = resSix10265.WarnMsg
  1412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1413. res.Infcode = infocode
  1414. }
  1415. if res.Infcode == 0 {
  1416. item.IsSale = 0
  1417. item.SaleDate = ""
  1418. item.Bchno = ""
  1419. err2 := service.SaveDF(item)
  1420. if err2 == nil {
  1421. var struct3507_2 models.Struct3507
  1422. struct3507_2.OrgName = miConfig.OrgName
  1423. struct3507_2.AccessKey = miConfig.AccessKey
  1424. struct3507_2.RequestUrl = miConfig.Url
  1425. struct3507_2.Opter = roles.UserName
  1426. struct3507_2.FixmedinsCode = miConfig.Code
  1427. struct3507_2.Code = miConfig.Code
  1428. struct3507_2.SecretKey = miConfig.SecretKey
  1429. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1430. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1431. struct3507_2.Url = miConfig.Url
  1432. struct3507_2.AppId = miConfig.Cainfo
  1433. struct3507_2.AppSecret = miConfig.AppSecret
  1434. struct3507_2.Enckey = miConfig.EncKey
  1435. struct3507_2.SignKey = miConfig.SignKey
  1436. struct3507_2.SecretKey = miConfig.SecretKey
  1437. struct3507_2.FixmedinsBchno = item.BgBchno
  1438. struct3507_2.InvDataType = "2"
  1439. if miConfig.MdtrtareaAdmvs == "350500" {
  1440. result11, result22, _ := service.FJyb3507(struct3507_2)
  1441. saveLog(result11, result22, "3507", "3507")
  1442. var respJSON3 map[string]interface{}
  1443. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. userJSONBytes3, _ := json.Marshal(respJSON3)
  1449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1450. utils.ErrorLog("解析失败:%v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. } else {
  1455. data := make(map[string]interface{})
  1456. data["struct_3507s"] = struct3507_2
  1457. client := &http.Client{}
  1458. bytesData, _ := json.Marshal(data)
  1459. var req *http.Request
  1460. if miConfig.MdtrtareaAdmvs == "320921" {
  1461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1462. } else {
  1463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. }
  1465. resp, _ := client.Do(req)
  1466. defer resp.Body.Close()
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. }
  1471. var respJSON map[string]interface{}
  1472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. var resSix10265 ResultSix10265 //1101结果
  1478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1479. result, _ := json.Marshal(respJSON)
  1480. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1481. utils.ErrorLog("解析失败:%v", err)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1486. //res.Output = resSix10265.Output
  1487. res2.ErrMsg = resSix10265.ErrMsg
  1488. res2.Cainfo = resSix10265.Cainfo
  1489. res2.WarnMsg = resSix10265.WarnMsg
  1490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1491. res2.Infcode = infocode
  1492. }
  1493. if res2.Infcode == 0 {
  1494. item.IsChange = 0
  1495. item.BgBchno = ""
  1496. service.SaveDF2(item)
  1497. } else {
  1498. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1499. }
  1500. }
  1501. } else {
  1502. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1503. }
  1504. }
  1505. if item.IsSale == 2 && item.IsChange == 1 {
  1506. var res FJ3507Result
  1507. var res2 FJ3507Result
  1508. var struct3507 models.Struct3507
  1509. struct3507.FixmedinsBchno = item.Bchno
  1510. struct3507.InvDataType = "4"
  1511. struct3507.Opter = roles.UserName
  1512. struct3507.OrgName = miConfig.OrgName
  1513. struct3507.AccessKey = miConfig.AccessKey
  1514. struct3507.RequestUrl = miConfig.Url
  1515. struct3507.FixmedinsCode = miConfig.Code
  1516. struct3507.Code = miConfig.Code
  1517. struct3507.SecretKey = miConfig.SecretKey
  1518. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1519. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1520. struct3507.Url = miConfig.Url
  1521. struct3507.AppId = miConfig.Cainfo
  1522. struct3507.AppSecret = miConfig.AppSecret
  1523. struct3507.Enckey = miConfig.EncKey
  1524. struct3507.SignKey = miConfig.SignKey
  1525. struct3507.SecretKey = miConfig.SecretKey
  1526. //result, result1, _ := service.FJyb3507(struct3507)
  1527. //saveLog(result, result1, "3507", "3507")
  1528. //
  1529. //var respJSON2 map[string]interface{}
  1530. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. // return
  1534. //}
  1535. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1536. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. if miConfig.MdtrtareaAdmvs == "350500" {
  1542. result, result1, _ := service.FJyb3507(struct3507)
  1543. saveLog(result, result1, "3507", "3507")
  1544. var respJSON2 map[string]interface{}
  1545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. userJSONBytes2, _ := json.Marshal(respJSON2)
  1551. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. } else {
  1557. data := make(map[string]interface{})
  1558. data["struct_3507s"] = struct3507
  1559. client := &http.Client{}
  1560. bytesData, _ := json.Marshal(data)
  1561. var req *http.Request
  1562. if miConfig.MdtrtareaAdmvs == "320921" {
  1563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1564. } else {
  1565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1566. }
  1567. resp, _ := client.Do(req)
  1568. defer resp.Body.Close()
  1569. body, ioErr := ioutil.ReadAll(resp.Body)
  1570. if ioErr != nil {
  1571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. return
  1578. }
  1579. var resSix10265 ResultSix10265 //1101结果
  1580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1581. result, _ := json.Marshal(respJSON)
  1582. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. res.InfRefmsgid = resSix10265.InfRefmsgid
  1588. //res.Output = resSix10265.Output
  1589. res.ErrMsg = resSix10265.ErrMsg
  1590. res.Cainfo = resSix10265.Cainfo
  1591. res.WarnMsg = resSix10265.WarnMsg
  1592. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. }
  1595. if res.Infcode == 0 {
  1596. item.IsSale = 0
  1597. item.SaleDate = ""
  1598. item.Bchno = ""
  1599. err2 := service.SaveDF(item)
  1600. if err2 == nil {
  1601. var struct3507_2 models.Struct3507
  1602. struct3507_2.OrgName = miConfig.OrgName
  1603. struct3507_2.AccessKey = miConfig.AccessKey
  1604. struct3507_2.RequestUrl = miConfig.Url
  1605. struct3507_2.Opter = roles.UserName
  1606. struct3507_2.FixmedinsCode = miConfig.Code
  1607. struct3507_2.Code = miConfig.Code
  1608. struct3507_2.SecretKey = miConfig.SecretKey
  1609. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507_2.Url = miConfig.Url
  1612. struct3507_2.AppId = miConfig.Cainfo
  1613. struct3507_2.AppSecret = miConfig.AppSecret
  1614. struct3507_2.Enckey = miConfig.EncKey
  1615. struct3507_2.SignKey = miConfig.SignKey
  1616. struct3507_2.SecretKey = miConfig.SecretKey
  1617. struct3507_2.FixmedinsBchno = item.BgBchno
  1618. struct3507_2.InvDataType = "2"
  1619. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1620. //saveLog(result11, result22, "3507", "3507")
  1621. //var respJSON3 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1628. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result11, result22, _ := service.FJyb3507(struct3507_2)
  1635. saveLog(result11, result22, "3507", "3507")
  1636. var respJSON3 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes3, _ := json.Marshal(respJSON3)
  1643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507_2
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res2.ErrMsg = resSix10265.ErrMsg
  1682. res2.Cainfo = resSix10265.Cainfo
  1683. res2.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res2.Infcode = infocode
  1686. }
  1687. if res2.Infcode == 0 {
  1688. item.IsChange = 0
  1689. item.BgBchno = ""
  1690. service.SaveDF2(item)
  1691. } else {
  1692. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1693. }
  1694. }
  1695. } else {
  1696. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1697. }
  1698. }
  1699. if item.IsSale == 1 && item.IsChange == 0 {
  1700. var res FJ3507Result
  1701. var struct3507 models.Struct3507
  1702. struct3507.FixmedinsBchno = item.Bchno
  1703. struct3507.InvDataType = "4"
  1704. struct3507.Opter = roles.UserName
  1705. struct3507.FixmedinsCode = miConfig.Code
  1706. struct3507.Code = miConfig.Code
  1707. struct3507.OrgName = miConfig.OrgName
  1708. struct3507.AccessKey = miConfig.AccessKey
  1709. struct3507.RequestUrl = miConfig.Url
  1710. struct3507.SecretKey = miConfig.SecretKey
  1711. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1712. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1713. struct3507.Url = miConfig.Url
  1714. struct3507.AppId = miConfig.Cainfo
  1715. struct3507.AppSecret = miConfig.AppSecret
  1716. struct3507.Enckey = miConfig.EncKey
  1717. struct3507.SignKey = miConfig.SignKey
  1718. struct3507.SecretKey = miConfig.SecretKey
  1719. //result, result1, _ := service.FJyb3507(struct3507)
  1720. //saveLog(result, result1, "3507", "3507")
  1721. //
  1722. //var respJSON3 map[string]interface{}
  1723. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. // return
  1727. //}
  1728. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1729. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1730. // utils.ErrorLog("解析失败:%v", err)
  1731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. // return
  1733. //}
  1734. if miConfig.MdtrtareaAdmvs == "350500" {
  1735. result, result1, _ := service.FJyb3507(struct3507)
  1736. saveLog(result, result1, "3507", "3507")
  1737. var respJSON2 map[string]interface{}
  1738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. return
  1742. }
  1743. userJSONBytes2, _ := json.Marshal(respJSON2)
  1744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. } else {
  1750. data := make(map[string]interface{})
  1751. data["struct_3507s"] = struct3507
  1752. client := &http.Client{}
  1753. bytesData, _ := json.Marshal(data)
  1754. var req *http.Request
  1755. if miConfig.MdtrtareaAdmvs == "320921" {
  1756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1757. } else {
  1758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1759. }
  1760. resp, _ := client.Do(req)
  1761. defer resp.Body.Close()
  1762. body, ioErr := ioutil.ReadAll(resp.Body)
  1763. if ioErr != nil {
  1764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. var resSix10265 ResultSix10265 //1101结果
  1773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. result, _ := json.Marshal(respJSON)
  1775. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. res.InfRefmsgid = resSix10265.InfRefmsgid
  1781. //res.Output = resSix10265.Output
  1782. res.ErrMsg = resSix10265.ErrMsg
  1783. res.Cainfo = resSix10265.Cainfo
  1784. res.WarnMsg = resSix10265.WarnMsg
  1785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1786. res.Infcode = infocode
  1787. }
  1788. if res.Infcode == 0 {
  1789. item.IsSale = 0
  1790. item.SaleDate = ""
  1791. service.SaveDF(item)
  1792. } else {
  1793. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1794. }
  1795. }
  1796. if item.IsSale == 2 && item.IsChange == 0 {
  1797. var res FJ3507Result
  1798. var struct3507 models.Struct3507
  1799. struct3507.FixmedinsBchno = item.Bchno
  1800. struct3507.InvDataType = "4"
  1801. struct3507.Opter = roles.UserName
  1802. struct3507.FixmedinsCode = miConfig.Code
  1803. struct3507.Code = miConfig.Code
  1804. struct3507.OrgName = miConfig.OrgName
  1805. struct3507.AccessKey = miConfig.AccessKey
  1806. struct3507.RequestUrl = miConfig.Url
  1807. struct3507.SecretKey = miConfig.SecretKey
  1808. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1809. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1810. struct3507.Url = miConfig.Url
  1811. struct3507.AppId = miConfig.Cainfo
  1812. struct3507.AppSecret = miConfig.AppSecret
  1813. struct3507.Enckey = miConfig.EncKey
  1814. struct3507.SignKey = miConfig.SignKey
  1815. struct3507.SecretKey = miConfig.SecretKey
  1816. //result, result1, _ := service.FJyb3507(struct3507)
  1817. //saveLog(result, result1, "3507", "3507")
  1818. //
  1819. //var respJSON3 map[string]interface{}
  1820. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1821. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1826. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1827. // utils.ErrorLog("解析失败:%v", err)
  1828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. // return
  1830. //}
  1831. if miConfig.MdtrtareaAdmvs == "350500" {
  1832. result, result1, _ := service.FJyb3507(struct3507)
  1833. saveLog(result, result1, "3507", "3507")
  1834. var respJSON2 map[string]interface{}
  1835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. userJSONBytes2, _ := json.Marshal(respJSON2)
  1841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. } else {
  1847. data := make(map[string]interface{})
  1848. data["struct_3507s"] = struct3507
  1849. client := &http.Client{}
  1850. bytesData, _ := json.Marshal(data)
  1851. var req *http.Request
  1852. if miConfig.MdtrtareaAdmvs == "320921" {
  1853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1854. } else {
  1855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. }
  1857. resp, _ := client.Do(req)
  1858. defer resp.Body.Close()
  1859. body, ioErr := ioutil.ReadAll(resp.Body)
  1860. if ioErr != nil {
  1861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1862. }
  1863. var respJSON map[string]interface{}
  1864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. var resSix10265 ResultSix10265 //1101结果
  1870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1871. result, _ := json.Marshal(respJSON)
  1872. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1873. utils.ErrorLog("解析失败:%v", err)
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1875. return
  1876. }
  1877. res.InfRefmsgid = resSix10265.InfRefmsgid
  1878. //res.Output = resSix10265.Output
  1879. res.ErrMsg = resSix10265.ErrMsg
  1880. res.Cainfo = resSix10265.Cainfo
  1881. res.WarnMsg = resSix10265.WarnMsg
  1882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1883. res.Infcode = infocode
  1884. }
  1885. if res.Infcode == 0 {
  1886. item.IsSale = 0
  1887. item.SaleDate = ""
  1888. item.Bchno = ""
  1889. service.SaveDF(item)
  1890. } else {
  1891. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1892. }
  1893. }
  1894. if item.IsSale == 0 && item.IsChange == 1 {
  1895. var res FJ3507Result
  1896. var struct3507 models.Struct3507
  1897. struct3507.FixmedinsBchno = item.BgBchno
  1898. struct3507.InvDataType = "2"
  1899. struct3507.Opter = roles.UserName
  1900. struct3507.FixmedinsCode = miConfig.Code
  1901. struct3507.Code = miConfig.Code
  1902. struct3507.OrgName = miConfig.OrgName
  1903. struct3507.AccessKey = miConfig.AccessKey
  1904. struct3507.RequestUrl = miConfig.Url
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1907. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1908. struct3507.Url = miConfig.Url
  1909. struct3507.AppId = miConfig.Cainfo
  1910. struct3507.AppSecret = miConfig.AppSecret
  1911. struct3507.Enckey = miConfig.EncKey
  1912. struct3507.SignKey = miConfig.SignKey
  1913. struct3507.SecretKey = miConfig.SecretKey
  1914. //result, result1, _ := service.FJyb3507(struct3507)
  1915. //saveLog(result, result1, "3507", "3507")
  1916. //
  1917. //var respJSON3 map[string]interface{}
  1918. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1924. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1925. // utils.ErrorLog("解析失败:%v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. if miConfig.MdtrtareaAdmvs == "350500" {
  1930. result, result1, _ := service.FJyb3507(struct3507)
  1931. saveLog(result, result1, "3507", "3507")
  1932. var respJSON2 map[string]interface{}
  1933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. userJSONBytes2, _ := json.Marshal(respJSON2)
  1939. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1940. utils.ErrorLog("解析失败:%v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. } else {
  1945. data := make(map[string]interface{})
  1946. data["struct_3507s"] = struct3507
  1947. client := &http.Client{}
  1948. bytesData, _ := json.Marshal(data)
  1949. var req *http.Request
  1950. if miConfig.MdtrtareaAdmvs == "320921" {
  1951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1952. } else {
  1953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1954. }
  1955. resp, _ := client.Do(req)
  1956. defer resp.Body.Close()
  1957. body, ioErr := ioutil.ReadAll(resp.Body)
  1958. if ioErr != nil {
  1959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1960. }
  1961. var respJSON map[string]interface{}
  1962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. var resSix10265 ResultSix10265 //1101结果
  1968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1969. result, _ := json.Marshal(respJSON)
  1970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1971. utils.ErrorLog("解析失败:%v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. res.InfRefmsgid = resSix10265.InfRefmsgid
  1976. //res.Output = resSix10265.Output
  1977. res.ErrMsg = resSix10265.ErrMsg
  1978. res.Cainfo = resSix10265.Cainfo
  1979. res.WarnMsg = resSix10265.WarnMsg
  1980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1981. res.Infcode = infocode
  1982. }
  1983. if res.Infcode == 0 {
  1984. item.IsChange = 0
  1985. item.BgBchno = ""
  1986. service.SaveDF2(item)
  1987. } else {
  1988. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1989. }
  1990. }
  1991. }
  1992. if len(err) == 0 {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "msg": "删除销售变更成功",
  1995. })
  1996. } else {
  1997. c.ServeSuccessJSON(map[string]interface{}{
  1998. "failed_code": -10,
  1999. "msg": err,
  2000. })
  2001. }
  2002. }
  2003. //func (c *HisApiController) BatchFJ3501AND3502() {
  2004. // //ids := c.GetString("ids")
  2005. // start_time := c.GetString("start_time")
  2006. // end_time := c.GetString("end_time")
  2007. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2008. //
  2009. //
  2010. // timeLayout := "2006-01-02"
  2011. // loc, _ := time.LoadLocation("Local")
  2012. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2013. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2014. //
  2015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. // //id_arr := strings.Split(ids, ",")
  2017. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. // //库盘
  2020. // var errs []string
  2021. // for _, drug := range drugs {
  2022. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2023. // var res2 ResultSix
  2024. // var res3 ResultSix
  2025. //
  2026. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2027. // var struct3501 models.Struct3501
  2028. // struct3501.Code = miConfig.Code
  2029. // struct3501.OrgName = miConfig.OrgName
  2030. // struct3501.AccessKey = miConfig.AccessKey
  2031. // struct3501.Opter = roles.UserName
  2032. // struct3501.RequestUrl = miConfig.Url
  2033. // struct3501.Url = miConfig.Url
  2034. // struct3501.AppId = miConfig.Cainfo
  2035. // struct3501.AppSecret = miConfig.AppSecret
  2036. // struct3501.Enckey = miConfig.EncKey
  2037. // struct3501.SignKey = miConfig.SignKey
  2038. // struct3501.SecretKey = miConfig.SecretKey
  2039. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2042. // struct3501.RxFlag = "1"
  2043. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2044. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2045. //
  2046. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2047. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2048. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2049. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2050. // struct3501.FixmedinsBchno = number
  2051. // struct3501.DrugTracCodg = drug.DrugCode
  2052. // memo := make(map[string]interface{})
  2053. // memo["pric"] = drug.Price
  2054. // bytesData, _ := json.Marshal(memo)
  2055. // struct3501.Memo = string(bytesData)
  2056. //
  2057. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2058. //
  2059. // result1, result2, _ := service.FJyb3501(struct3501)
  2060. // saveLog(result1, result2, "3501", "3501")
  2061. // //saveLog(result, requestLog, "2201", "挂号")
  2062. //
  2063. // var respJSON2 map[string]interface{}
  2064. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. // return
  2068. // }
  2069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2071. // utils.ErrorLog("解析失败:%v", err)
  2072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. // return
  2074. // }
  2075. //
  2076. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2077. // data := make(map[string]interface{})
  2078. // data["struct_3501s"] = struct3501
  2079. // client := &http.Client{}
  2080. // bytesData, _ := json.Marshal(data)
  2081. // var req *http.Request
  2082. // if miConfig.MdtrtareaAdmvs == "320921" {
  2083. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2084. // } else {
  2085. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2086. // }
  2087. //
  2088. // resp, _ := client.Do(req)
  2089. // defer resp.Body.Close()
  2090. // body, ioErr := ioutil.ReadAll(resp.Body)
  2091. // if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // }
  2094. // var respJSON map[string]interface{}
  2095. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. // return
  2099. // }
  2100. // var resSix10265 ResultSix10265 //1101结果
  2101. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2102. // result, _ := json.Marshal(respJSON)
  2103. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2104. // utils.ErrorLog("解析失败:%v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. // }
  2108. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2109. // res2.Output = resSix10265.Output
  2110. // res2.ErrMsg = resSix10265.ErrMsg
  2111. // res2.Cainfo = resSix10265.Cainfo
  2112. // res2.WarnMsg = resSix10265.WarnMsg
  2113. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2114. // res2.Infcode = infocode
  2115. //
  2116. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2117. // data := make(map[string]interface{})
  2118. // data["struct_3501s"] = struct3501
  2119. // client := &http.Client{}
  2120. // bytesData, _ := json.Marshal(data)
  2121. // var req *http.Request
  2122. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2123. // resp, _ := client.Do(req)
  2124. // defer resp.Body.Close()
  2125. // body, ioErr := ioutil.ReadAll(resp.Body)
  2126. // if ioErr != nil {
  2127. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2128. // }
  2129. // var respJSON map[string]interface{}
  2130. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2131. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2133. // return
  2134. // }
  2135. // var resSix10265 ResultSix10265 //1101结果
  2136. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. // result, _ := json.Marshal(respJSON)
  2138. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2139. // utils.ErrorLog("解析失败:%v", err)
  2140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. // return
  2142. // }
  2143. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2144. // res2.Output = resSix10265.Output
  2145. // res2.ErrMsg = resSix10265.ErrMsg
  2146. // res2.Cainfo = resSix10265.Cainfo
  2147. // res2.WarnMsg = resSix10265.WarnMsg
  2148. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2149. // res2.Infcode = infocode
  2150. //
  2151. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3501s"] = struct3501
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2158. // resp, _ := client.Do(req)
  2159. // defer resp.Body.Close()
  2160. // body, ioErr := ioutil.ReadAll(resp.Body)
  2161. // if ioErr != nil {
  2162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. // }
  2164. // var respJSON map[string]interface{}
  2165. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. // return
  2169. // }
  2170. // var resSix10265 ResultSix10265 //1101结果
  2171. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. // result, _ := json.Marshal(respJSON)
  2173. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. // utils.ErrorLog("解析失败:%v", err)
  2175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. // return
  2177. // }
  2178. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2179. // res2.Output = resSix10265.Output
  2180. // res2.ErrMsg = resSix10265.ErrMsg
  2181. // res2.Cainfo = resSix10265.Cainfo
  2182. // res2.WarnMsg = resSix10265.WarnMsg
  2183. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. // res2.Infcode = infocode
  2185. //
  2186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2187. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2188. // saveLog(result1, result2, "3501", "3501")
  2189. // //saveLog(result, requestLog, "2201", "挂号")
  2190. //
  2191. // var respJSON2 map[string]interface{}
  2192. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2195. // return
  2196. // }
  2197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. //
  2204. // }
  2205. //
  2206. // if res2.Infcode != -1 {
  2207. // drug.IsPc = 1
  2208. // drug.Bchno = number
  2209. // drug.PcDate = time.Now().Unix()
  2210. // err := service.SaveW(drug)
  2211. // if err == nil {
  2212. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2213. // var struct3502 models.Struct3502
  2214. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2217. // struct3502.FixmedinsCode = miConfig.Code
  2218. // struct3502.Code = miConfig.Code
  2219. //
  2220. // struct3502.RxFlag = "0"
  2221. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2222. // struct3502.OrgName = miConfig.OrgName
  2223. // struct3502.Opter = roles.UserName
  2224. // struct3502.AccessKey = miConfig.AccessKey
  2225. // struct3502.RequestUrl = miConfig.Url
  2226. // struct3502.SecretKey = miConfig.SecretKey
  2227. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2228. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2229. // struct3502.Url = miConfig.Url
  2230. // struct3502.AppId = miConfig.Cainfo
  2231. // struct3502.AppSecret = miConfig.AppSecret
  2232. // struct3502.Enckey = miConfig.EncKey
  2233. // struct3502.SignKey = miConfig.SignKey
  2234. // struct3502.SecretKey = miConfig.SecretKey
  2235. // struct3502.DrugTracCodg = drug.DrugCode
  2236. //
  2237. // struct3502.Memo = ""
  2238. // struct3502.InvChgType = "108"
  2239. // struct3502.FixmedinsBchno = bg_number
  2240. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2241. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2242. //
  2243. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2244. // result11, result22, _ := service.FJyb3502(struct3502)
  2245. // saveLog(result11, result22, "3502", "3502")
  2246. //
  2247. // var respJSON3 map[string]interface{}
  2248. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. // return
  2252. // }
  2253. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2254. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2255. // utils.ErrorLog("解析失败:%v", err)
  2256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2257. // return
  2258. // }
  2259. //
  2260. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2261. // data := make(map[string]interface{})
  2262. // data["struct_3502s"] = struct3502
  2263. // client := &http.Client{}
  2264. // bytesData, _ := json.Marshal(data)
  2265. // var req *http.Request
  2266. // if miConfig.MdtrtareaAdmvs == "320921" {
  2267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2268. // } else {
  2269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2270. // }
  2271. //
  2272. // resp, _ := client.Do(req)
  2273. // defer resp.Body.Close()
  2274. // body, ioErr := ioutil.ReadAll(resp.Body)
  2275. // if ioErr != nil {
  2276. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2277. // }
  2278. // var respJSON map[string]interface{}
  2279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2282. // return
  2283. // }
  2284. // var resSix10265 ResultSix10265 //1101结果
  2285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2286. // result, _ := json.Marshal(respJSON)
  2287. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2288. // utils.ErrorLog("解析失败:%v", err)
  2289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. // return
  2291. // }
  2292. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2293. // res3.Output = resSix10265.Output
  2294. // res3.ErrMsg = resSix10265.ErrMsg
  2295. // res3.Cainfo = resSix10265.Cainfo
  2296. // res3.WarnMsg = resSix10265.WarnMsg
  2297. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2298. // res3.Infcode = infocode
  2299. //
  2300. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2301. //
  2302. // data := make(map[string]interface{})
  2303. // data["struct_3502s"] = struct3502
  2304. // client := &http.Client{}
  2305. // bytesData, _ := json.Marshal(data)
  2306. // var req *http.Request
  2307. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2308. // resp, _ := client.Do(req)
  2309. // defer resp.Body.Close()
  2310. // body, ioErr := ioutil.ReadAll(resp.Body)
  2311. // if ioErr != nil {
  2312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2313. // }
  2314. // var respJSON map[string]interface{}
  2315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2318. // return
  2319. // }
  2320. // var resSix10265 ResultSix10265 //1101结果
  2321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2322. // result, _ := json.Marshal(respJSON)
  2323. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2324. // utils.ErrorLog("解析失败:%v", err)
  2325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // return
  2327. // }
  2328. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2329. // res3.Output = resSix10265.Output
  2330. // res3.ErrMsg = resSix10265.ErrMsg
  2331. // res3.Cainfo = resSix10265.Cainfo
  2332. // res3.WarnMsg = resSix10265.WarnMsg
  2333. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2334. // res3.Infcode = infocode
  2335. //
  2336. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2337. //
  2338. // data := make(map[string]interface{})
  2339. // data["struct_3501s"] = struct3501
  2340. // client := &http.Client{}
  2341. // bytesData, _ := json.Marshal(data)
  2342. // var req *http.Request
  2343. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2344. // resp, _ := client.Do(req)
  2345. // defer resp.Body.Close()
  2346. // body, ioErr := ioutil.ReadAll(resp.Body)
  2347. // if ioErr != nil {
  2348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2349. // }
  2350. // var respJSON map[string]interface{}
  2351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // var resSix10265 ResultSix10265 //1101结果
  2357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2358. // result, _ := json.Marshal(respJSON)
  2359. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2360. // utils.ErrorLog("解析失败:%v", err)
  2361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. // return
  2363. // }
  2364. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2365. // res2.Output = resSix10265.Output
  2366. // res2.ErrMsg = resSix10265.ErrMsg
  2367. // res2.Cainfo = resSix10265.Cainfo
  2368. // res2.WarnMsg = resSix10265.WarnMsg
  2369. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2370. // res2.Infcode = infocode
  2371. //
  2372. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2373. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2374. // saveLog(result11, result22, "3502", "3502")
  2375. //
  2376. // var respJSON3 map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2383. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // }
  2389. // if res3.Infcode == -1 {
  2390. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2391. // c.ServeSuccessJSON(map[string]interface{}{
  2392. // "failed_code": -10,
  2393. // "msg": res3.ErrMsg,
  2394. // })
  2395. // } else {
  2396. // drug.IsBg = 1
  2397. // drug.BgBchno = bg_number
  2398. // service.SaveW(drug)
  2399. // }
  2400. // }
  2401. // } else {
  2402. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2403. // }
  2404. // }
  2405. // //变更
  2406. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2407. // var res3 ResultSix
  2408. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2409. //
  2410. // var struct3502 models.Struct3502
  2411. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2414. // struct3502.FixmedinsCode = miConfig.Code
  2415. // struct3502.Code = miConfig.Code
  2416. //
  2417. // struct3502.Opter = roles.UserName
  2418. // struct3502.RxFlag = "0"
  2419. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2420. // struct3502.OrgName = miConfig.OrgName
  2421. // struct3502.AccessKey = miConfig.AccessKey
  2422. // struct3502.RequestUrl = miConfig.Url
  2423. // struct3502.SecretKey = miConfig.SecretKey
  2424. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2425. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2426. // struct3502.InvChgType = "108"
  2427. // struct3502.DrugTracCodg = drug.DrugCode
  2428. //
  2429. // struct3502.Url = miConfig.Url
  2430. // struct3502.AppId = miConfig.Cainfo
  2431. // struct3502.AppSecret = miConfig.AppSecret
  2432. // struct3502.Enckey = miConfig.EncKey
  2433. // struct3502.SignKey = miConfig.SignKey
  2434. // struct3502.SecretKey = miConfig.SecretKey
  2435. //
  2436. // struct3502.FixmedinsBchno = bg_number
  2437. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2438. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2439. //
  2440. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2441. // result1, result2, _ := service.FJyb3502(struct3502)
  2442. // saveLog(result1, result2, "3502", "3502")
  2443. // var respJSON3 map[string]interface{}
  2444. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2445. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. // return
  2448. // }
  2449. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2450. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2451. // utils.ErrorLog("解析失败:%v", err)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3502s"] = struct3502
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2465. // }
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // res3.Output = resSix10265.Output
  2488. // res3.ErrMsg = resSix10265.ErrMsg
  2489. // res3.Cainfo = resSix10265.Cainfo
  2490. // res3.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res3.Infcode = infocode
  2493. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2494. //
  2495. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2498. //
  2499. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2500. //
  2501. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2502. // saveLog(result1, result2, "3501", "3501")
  2503. // //saveLog(result, requestLog, "2201", "挂号")
  2504. //
  2505. // var respJSON2 map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2512. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. //
  2518. // }
  2519. // if res3.Infcode == -1 {
  2520. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2521. // } else {
  2522. // drug.IsBg = 1
  2523. // drug.BgBchno = bg_number
  2524. // service.SaveW(drug)
  2525. // }
  2526. // }
  2527. // }
  2528. //
  2529. // if len(errs) == 0 {
  2530. // c.ServeSuccessJSON(map[string]interface{}{
  2531. // "msg": "盘存变更成功",
  2532. // })
  2533. // } else {
  2534. // c.ServeSuccessJSON(map[string]interface{}{
  2535. // "failed_code": -10,
  2536. // "msg": errs,
  2537. // })
  2538. // }
  2539. //}
  2540. func (c *HisApiController) DeleteXSandBGTwo() {
  2541. patient_id, _ := c.GetInt64("patient_id")
  2542. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. times := c.GetString("time", "")
  2544. timeLayout := "2006-01-02"
  2545. loc, _ := time.LoadLocation("Local")
  2546. var stime, etime int64
  2547. if times == "" {
  2548. stime, etime = GetNowTime()
  2549. } else {
  2550. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2551. stime = stmp.Unix()
  2552. etime = stime + 86399
  2553. }
  2554. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2555. var flows []*models.DrugFlow
  2556. for _, item := range advicelist {
  2557. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2558. flows = append(flows, flow...)
  2559. }
  2560. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2563. var err []string
  2564. for _, item := range flows {
  2565. if item.IsSale == 1 {
  2566. var res FJ3507Result
  2567. var struct3507 models.Struct3507
  2568. struct3507.FixmedinsBchno = item.Bchno
  2569. struct3507.InvDataType = "4"
  2570. struct3507.Opter = roles.UserName
  2571. struct3507.OrgName = miConfig.OrgName
  2572. struct3507.AccessKey = miConfig.AccessKey
  2573. struct3507.RequestUrl = miConfig.Url
  2574. struct3507.FixmedinsCode = miConfig.Code
  2575. struct3507.SecretKey = miConfig.SecretKey
  2576. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2577. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2578. struct3507.Url = miConfig.Url
  2579. struct3507.AppId = miConfig.Cainfo
  2580. struct3507.AppSecret = miConfig.AppSecret
  2581. struct3507.Enckey = miConfig.EncKey
  2582. struct3507.SignKey = miConfig.SignKey
  2583. struct3507.SecretKey = miConfig.SecretKey
  2584. if miConfig.MdtrtareaAdmvs == "350500" {
  2585. result, result1, _ := service.FJyb3507(struct3507)
  2586. saveLog(result, result1, "3507", "3507")
  2587. var respJSON2 map[string]interface{}
  2588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. userJSONBytes2, _ := json.Marshal(respJSON2)
  2594. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2600. data := make(map[string]interface{})
  2601. data["struct_3507s"] = struct3507
  2602. client := &http.Client{}
  2603. bytesData, _ := json.Marshal(data)
  2604. var req *http.Request
  2605. if miConfig.MdtrtareaAdmvs == "320921" {
  2606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2607. } else {
  2608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2609. }
  2610. resp, _ := client.Do(req)
  2611. defer resp.Body.Close()
  2612. body, ioErr := ioutil.ReadAll(resp.Body)
  2613. if ioErr != nil {
  2614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2615. }
  2616. var respJSON map[string]interface{}
  2617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2620. return
  2621. }
  2622. var resSix10265 ResultSix10265 //1101结果
  2623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.InfRefmsgid = resSix10265.InfRefmsgid
  2631. //res.Output = resSix10265.Output
  2632. res.ErrMsg = resSix10265.ErrMsg
  2633. res.Cainfo = resSix10265.Cainfo
  2634. res.WarnMsg = resSix10265.WarnMsg
  2635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2638. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2639. saveLog(result2, result1, "3507", "3507")
  2640. var respJSON2 map[string]interface{}
  2641. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. userJSONBytes2, _ := json.Marshal(respJSON2)
  2647. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2648. utils.ErrorLog("解析失败:%v", err)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2653. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2654. saveLog(result2, result1, "3507", "3507")
  2655. var respJSON2 map[string]interface{}
  2656. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. userJSONBytes2, _ := json.Marshal(respJSON2)
  2662. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2668. result1, result2 := service.Jxyb3507(struct3507)
  2669. saveLog(result2, result1, "3507", "3507")
  2670. var respJSON2 map[string]interface{}
  2671. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. userJSONBytes2, _ := json.Marshal(respJSON2)
  2677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2678. utils.ErrorLog("解析失败:%v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2683. result1, result2 := service.AHyb3507(struct3507)
  2684. saveLog(result2, result1, "3507", "3507")
  2685. var respJSON2 map[string]interface{}
  2686. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. userJSONBytes2, _ := json.Marshal(respJSON2)
  2692. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2693. utils.ErrorLog("解析失败:%v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. return
  2696. }
  2697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2698. data := make(map[string]interface{})
  2699. data["struct_3507s"] = struct3507
  2700. client := &http.Client{}
  2701. bytesData, _ := json.Marshal(data)
  2702. var req *http.Request
  2703. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2704. resp, _ := client.Do(req)
  2705. defer resp.Body.Close()
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. }
  2710. var respJSON map[string]interface{}
  2711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. }
  2714. var resSix10265 ResultSix10265 //1101结果
  2715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2716. result, _ := json.Marshal(respJSON)
  2717. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. res.InfRefmsgid = resSix10265.InfRefmsgid
  2723. res.ErrMsg = resSix10265.ErrMsg
  2724. res.Cainfo = resSix10265.Cainfo
  2725. res.WarnMsg = resSix10265.WarnMsg
  2726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2727. res.Infcode = infocode
  2728. }
  2729. if res.Infcode == 0 {
  2730. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2731. item.IsSale = 0
  2732. item.SaleDate = ""
  2733. item.Bchno = ""
  2734. service.SaveDF(item)
  2735. } else {
  2736. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2737. }
  2738. }
  2739. }
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "删除销售数据成功",
  2742. })
  2743. }
  2744. // 删除
  2745. func (c *HisApiController) DeleteXSandBGThree() {
  2746. id, _ := c.GetInt64("id")
  2747. admin_user_id, _ := c.GetInt64("admin_user_id")
  2748. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2749. var flows []*models.DrugFlow
  2750. for _, item := range advicelist {
  2751. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2752. flows = append(flows, flow...)
  2753. }
  2754. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2755. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. var err []string
  2758. for _, item := range flows {
  2759. if item.IsSale == 1 {
  2760. var res FJ3507Result
  2761. var struct3507 models.Struct3507
  2762. struct3507.FixmedinsBchno = item.Bchno
  2763. struct3507.InvDataType = "4"
  2764. struct3507.Opter = roles.UserName
  2765. struct3507.OrgName = miConfig.OrgName
  2766. struct3507.AccessKey = miConfig.AccessKey
  2767. struct3507.RequestUrl = miConfig.Url
  2768. struct3507.FixmedinsCode = miConfig.Code
  2769. struct3507.SecretKey = miConfig.SecretKey
  2770. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2771. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2772. struct3507.Url = miConfig.Url
  2773. struct3507.AppId = miConfig.Cainfo
  2774. struct3507.AppSecret = miConfig.AppSecret
  2775. struct3507.Enckey = miConfig.EncKey
  2776. struct3507.SignKey = miConfig.SignKey
  2777. struct3507.SecretKey = miConfig.SecretKey
  2778. if miConfig.MdtrtareaAdmvs == "350500" {
  2779. result, result1, _ := service.FJyb3507(struct3507)
  2780. saveLog(result, result1, "3507", "3507")
  2781. var respJSON2 map[string]interface{}
  2782. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. return
  2786. }
  2787. userJSONBytes2, _ := json.Marshal(respJSON2)
  2788. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2789. utils.ErrorLog("解析失败:%v", err)
  2790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. return
  2792. }
  2793. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2794. data := make(map[string]interface{})
  2795. data["struct_3507s"] = struct3507
  2796. client := &http.Client{}
  2797. bytesData, _ := json.Marshal(data)
  2798. var req *http.Request
  2799. if miConfig.MdtrtareaAdmvs == "320921" {
  2800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2801. } else {
  2802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2803. }
  2804. resp, _ := client.Do(req)
  2805. defer resp.Body.Close()
  2806. body, ioErr := ioutil.ReadAll(resp.Body)
  2807. if ioErr != nil {
  2808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2809. }
  2810. var respJSON map[string]interface{}
  2811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. return
  2815. }
  2816. var resSix10265 ResultSix10265 //1101结果
  2817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2818. result, _ := json.Marshal(respJSON)
  2819. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2820. utils.ErrorLog("解析失败:%v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. res.InfRefmsgid = resSix10265.InfRefmsgid
  2825. //res.Output = resSix10265.Output
  2826. res.ErrMsg = resSix10265.ErrMsg
  2827. res.Cainfo = resSix10265.Cainfo
  2828. res.WarnMsg = resSix10265.WarnMsg
  2829. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2830. res.Infcode = infocode
  2831. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2832. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2833. saveLog(result2, result1, "3507", "3507")
  2834. var respJSON2 map[string]interface{}
  2835. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2838. return
  2839. }
  2840. userJSONBytes2, _ := json.Marshal(respJSON2)
  2841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2842. utils.ErrorLog("解析失败:%v", err)
  2843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2844. return
  2845. }
  2846. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2847. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2848. saveLog(result2, result1, "3507", "3507")
  2849. var respJSON2 map[string]interface{}
  2850. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2853. return
  2854. }
  2855. userJSONBytes2, _ := json.Marshal(respJSON2)
  2856. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2857. utils.ErrorLog("解析失败:%v", err)
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2859. return
  2860. }
  2861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2862. result1, result2 := service.Jxyb3507(struct3507)
  2863. saveLog(result2, result1, "3507", "3507")
  2864. var respJSON2 map[string]interface{}
  2865. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. userJSONBytes2, _ := json.Marshal(respJSON2)
  2871. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2872. utils.ErrorLog("解析失败:%v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2877. result1, result2 := service.AHyb3507(struct3507)
  2878. saveLog(result2, result1, "3507", "3507")
  2879. var respJSON2 map[string]interface{}
  2880. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2883. return
  2884. }
  2885. userJSONBytes2, _ := json.Marshal(respJSON2)
  2886. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2887. utils.ErrorLog("解析失败:%v", err)
  2888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2889. return
  2890. }
  2891. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2892. data := make(map[string]interface{})
  2893. data["struct_3507s"] = struct3507
  2894. client := &http.Client{}
  2895. bytesData, _ := json.Marshal(data)
  2896. var req *http.Request
  2897. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2898. resp, _ := client.Do(req)
  2899. defer resp.Body.Close()
  2900. body, ioErr := ioutil.ReadAll(resp.Body)
  2901. if ioErr != nil {
  2902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2903. }
  2904. var respJSON map[string]interface{}
  2905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2907. }
  2908. var resSix10265 ResultSix10265 //1101结果
  2909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2910. result, _ := json.Marshal(respJSON)
  2911. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2912. utils.ErrorLog("解析失败:%v", err)
  2913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. return
  2915. }
  2916. res.InfRefmsgid = resSix10265.InfRefmsgid
  2917. res.ErrMsg = resSix10265.ErrMsg
  2918. res.Cainfo = resSix10265.Cainfo
  2919. res.WarnMsg = resSix10265.WarnMsg
  2920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2921. res.Infcode = infocode
  2922. }
  2923. if res.Infcode == 0 {
  2924. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2925. item.IsSale = 0
  2926. item.SaleDate = ""
  2927. item.Bchno = ""
  2928. service.SaveDF(item)
  2929. } else {
  2930. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2931. }
  2932. }
  2933. }
  2934. c.ServeSuccessJSON(map[string]interface{}{
  2935. "msg": "删除销售数据成功",
  2936. })
  2937. }
  2938. // 获取当天起止时间戳
  2939. func GetNowTime() (int64, int64) {
  2940. t := time.Now()
  2941. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2942. timesamp := addTime.Unix()
  2943. return timesamp, timesamp + 86399
  2944. }
  2945. func (c *HisApiController) ChangeDrugfour() {
  2946. patient_id, _ := c.GetInt64("patient_id")
  2947. admin_user_id, _ := c.GetInt64("admin_user_id")
  2948. times := c.GetString("time", "")
  2949. timeLayout := "2006-01-02"
  2950. loc, _ := time.LoadLocation("Local")
  2951. var stime, etime int64
  2952. if times == "" {
  2953. stime, etime = GetNowTime()
  2954. } else {
  2955. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2956. stime = stmp.Unix()
  2957. etime = stime + 86399
  2958. }
  2959. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2960. var flows []*models.DrugFlow
  2961. for _, item := range advicelist {
  2962. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2963. flows = append(flows, flow...)
  2964. }
  2965. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2966. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2967. var err []string
  2968. for _, item := range flows {
  2969. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2970. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2971. if prescription.OrderStatus == 2 {
  2972. if item.IsSale == 0 {
  2973. var res FJ3507Result
  2974. var res3507for10188 FJ3507ResultFor10188
  2975. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2976. //进行商品销售接口
  2977. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2978. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2979. var respJSON3 map[string]interface{}
  2980. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. userJSONBytes3, _ := json.Marshal(respJSON3)
  2986. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2987. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. //if res3507for10188.Infcode
  2993. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2994. //res.Output = resSix10265.Output
  2995. res.ErrMsg = res3507for10188.ErrMsg
  2996. res.Cainfo = res3507for10188.Cainfo
  2997. res.WarnMsg = res3507for10188.WarnMsg
  2998. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2999. res.Infcode = infocode
  3000. } else {
  3001. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3002. utils.ErrorLog("解析失败:%v", err)
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3004. return
  3005. }
  3006. }
  3007. if res.Infcode == 0 {
  3008. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3009. item.IsSale = 1
  3010. item.Bchno = number
  3011. item.SaleDate = time.Now().Format("2006-01-02")
  3012. service.SaveDF(item)
  3013. } else {
  3014. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3015. }
  3016. }
  3017. } else { //还没结,提示用户去结算,并药品追溯上传
  3018. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3019. }
  3020. }
  3021. }
  3022. str := strings.Join(err, " ")
  3023. saveLog(str, str, "3505", "3505自动上传日志")
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "status": "1",
  3026. "msg": err,
  3027. })
  3028. }
  3029. func (c *HisApiController) ChangeDrugFive() {
  3030. id, _ := c.GetInt64("id")
  3031. admin_user_id, _ := c.GetInt64("admin_user_id")
  3032. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3033. var flows []*models.DrugFlow
  3034. for _, item := range advicelist {
  3035. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3036. flows = append(flows, flow...)
  3037. }
  3038. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3040. var err []string
  3041. for _, item := range flows {
  3042. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3043. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3044. if prescription.OrderStatus == 2 {
  3045. if item.IsSale == 0 {
  3046. var res FJ3507Result
  3047. var res3507for10188 FJ3507ResultFor10188
  3048. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3049. //进行商品销售接口
  3050. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3051. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3052. var respJSON3 map[string]interface{}
  3053. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. return
  3057. }
  3058. userJSONBytes3, _ := json.Marshal(respJSON3)
  3059. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3060. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3061. utils.ErrorLog("解析失败:%v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. //if res3507for10188.Infcode
  3066. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3067. //res.Output = resSix10265.Output
  3068. res.ErrMsg = res3507for10188.ErrMsg
  3069. res.Cainfo = res3507for10188.Cainfo
  3070. res.WarnMsg = res3507for10188.WarnMsg
  3071. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3072. res.Infcode = infocode
  3073. } else {
  3074. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3075. utils.ErrorLog("解析失败:%v", err)
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3077. return
  3078. }
  3079. }
  3080. if res.Infcode == 0 {
  3081. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3082. item.IsSale = 1
  3083. item.Bchno = number
  3084. item.SaleDate = time.Now().Format("2006-01-02")
  3085. service.SaveDF(item)
  3086. } else {
  3087. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3088. }
  3089. }
  3090. } else { //还没结,提示用户去结算,并药品追溯上传
  3091. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3092. }
  3093. }
  3094. }
  3095. str := strings.Join(err, " ")
  3096. saveLog(str, str, "3505", "3505自动上传日志")
  3097. c.ServeSuccessJSON(map[string]interface{}{
  3098. "status": "1",
  3099. "msg": err,
  3100. })
  3101. }
  3102. //func (c *HisApiController) ChangeDrugfour() {
  3103. // patient_id, _ := c.GetInt64("patient_id")
  3104. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3105. // //id_arr := strings.Split(ids, ",")
  3106. // times := c.GetString("time", "")
  3107. // timeLayout := "2006-01-02"
  3108. // loc, _ := time.LoadLocation("Local")
  3109. // var stime, etime int64
  3110. // if times == "" {
  3111. // stime, etime = GetNowTime()
  3112. // } else {
  3113. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3114. // stime = stmp.Unix()
  3115. // etime = stime + 86399
  3116. // }
  3117. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3118. // var flows []*models.DrugFlow
  3119. // for _, item := range advicelist {
  3120. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3121. // flows = append(flows, flow...)
  3122. // }
  3123. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3124. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3125. // var err []string
  3126. //
  3127. // for _, item := range flows {
  3128. // var res3 ResultSix
  3129. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3130. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3131. // if prescription.OrderStatus == 2 {
  3132. // //已经结算
  3133. // //判断是否已经销售
  3134. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3135. // //是否已经变更 1是 0否
  3136. // if item.IsChange == 0 { //没变更,进行变更操作
  3137. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3138. //
  3139. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3140. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3141. // var respJSON3 map[string]interface{}
  3142. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3145. // return
  3146. // }
  3147. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3148. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3149. // utils.ErrorLog("解析失败:%v", err)
  3150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3151. // return
  3152. // }
  3153. // if res3.Infcode == 0 {
  3154. // item.IsChange = 1
  3155. // item.BgBchno = bg_number
  3156. // service.SaveDF2(item)
  3157. // } else {
  3158. //
  3159. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3160. // }
  3161. // }
  3162. // } else { //没销售,
  3163. // var res FJ3507Result
  3164. // var res3507for10188 FJ3507ResultFor10188
  3165. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3166. //
  3167. // //进行商品销售接口
  3168. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3169. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3170. // var respJSON3 map[string]interface{}
  3171. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. // return
  3175. // }
  3176. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3177. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3178. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3179. // utils.ErrorLog("解析失败:%v", err)
  3180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. // return
  3182. // }
  3183. // //if res3507for10188.Infcode
  3184. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3185. // //res.Output = resSix10265.Output
  3186. // res.ErrMsg = res3507for10188.ErrMsg
  3187. // res.Cainfo = res3507for10188.Cainfo
  3188. // res.WarnMsg = res3507for10188.WarnMsg
  3189. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3190. // res.Infcode = infocode
  3191. // } else {
  3192. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3193. // utils.ErrorLog("解析失败:%v", err)
  3194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3195. // return
  3196. // }
  3197. //
  3198. // }
  3199. // if res.Infcode == 0 {
  3200. // item.IsSale = 1
  3201. // item.Bchno = number
  3202. // item.SaleDate = time.Now().Format("2006-01-02")
  3203. //
  3204. // err5 := service.SaveDF(item)
  3205. // if err5 == nil {
  3206. // if item.IsChange == 0 { //没变更,进行变更操作
  3207. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3208. //
  3209. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3210. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3211. //
  3212. // var respJSON3 map[string]interface{}
  3213. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3214. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3216. // return
  3217. // }
  3218. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3219. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3220. // utils.ErrorLog("解析失败:%v", err)
  3221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3222. // return
  3223. // }
  3224. // //if res3507for10188.Infcode
  3225. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3226. // //res.Output = resSix10265.Output
  3227. // res3.ErrMsg = res3507for10188.ErrMsg
  3228. // res3.Cainfo = res3507for10188.Cainfo
  3229. // res3.WarnMsg = res3507for10188.WarnMsg
  3230. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3231. // res3.Infcode = infocode
  3232. // } else {
  3233. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3234. // utils.ErrorLog("解析失败:%v", err)
  3235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. // return
  3237. // }
  3238. // }
  3239. // if res3.Infcode == 0 {
  3240. // item.IsChange = 1
  3241. // item.BgBchno = bg_number
  3242. // service.SaveDF2(item)
  3243. // } else {
  3244. //
  3245. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3246. // }
  3247. // }
  3248. // }
  3249. // } else {
  3250. //
  3251. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3252. // }
  3253. // }
  3254. //
  3255. // } else { //还没结,提示用户去结算,并药品追溯上传
  3256. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3257. // }
  3258. // }
  3259. // }
  3260. // if len(err) == 0 {
  3261. // c.ServeSuccessJSON(map[string]interface{}{
  3262. // "msg": "销售变更成功",
  3263. // })
  3264. // } else {
  3265. // c.ServeSuccessJSON(map[string]interface{}{
  3266. // "failed_code": -10,
  3267. // "msg": err,
  3268. // })
  3269. // }
  3270. //}
  3271. func (c *HisApiController) ChangeDrug() {
  3272. ids := c.GetString("ids")
  3273. id_arr := strings.Split(ids, ",")
  3274. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3275. admin_user_id, _ := c.GetInt64("admin_user_id")
  3276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3278. var err []string
  3279. for _, item := range flows {
  3280. var res3 ResultSix
  3281. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3282. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3283. if prescription.OrderStatus == 2 {
  3284. //已经结算
  3285. //判断是否已经销售
  3286. if item.IsSale == 1 { //是否已经销售,1是 0否
  3287. //是否已经变更 1是 0否
  3288. if item.IsChange == 0 { //没变更,进行变更操作
  3289. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3290. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3291. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3292. var respJSON3 map[string]interface{}
  3293. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3296. return
  3297. }
  3298. userJSONBytes3, _ := json.Marshal(respJSON3)
  3299. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3300. utils.ErrorLog("解析失败:%v", err)
  3301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3302. return
  3303. }
  3304. if res3.Infcode == 0 {
  3305. item.IsChange = 1
  3306. item.BgBchno = bg_number
  3307. service.SaveDF2(item)
  3308. } else {
  3309. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3310. }
  3311. }
  3312. } else { //没销售,
  3313. var res FJ3507Result
  3314. var res3507for10188 FJ3507ResultFor10188
  3315. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3316. //进行商品销售接口
  3317. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3318. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3319. var respJSON3 map[string]interface{}
  3320. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. return
  3324. }
  3325. userJSONBytes3, _ := json.Marshal(respJSON3)
  3326. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3327. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3328. utils.ErrorLog("解析失败:%v", err)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3330. return
  3331. }
  3332. //if res3507for10188.Infcode
  3333. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3334. //res.Output = resSix10265.Output
  3335. res.ErrMsg = res3507for10188.ErrMsg
  3336. res.Cainfo = res3507for10188.Cainfo
  3337. res.WarnMsg = res3507for10188.WarnMsg
  3338. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3339. res.Infcode = infocode
  3340. } else {
  3341. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. }
  3347. if res.Infcode == 0 {
  3348. item.IsSale = 1
  3349. item.Bchno = number
  3350. item.SaleDate = time.Now().Format("2006-01-02")
  3351. err5 := service.SaveDF(item)
  3352. if err5 == nil {
  3353. if item.IsChange == 0 { //没变更,进行变更操作
  3354. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3355. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3356. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3357. var respJSON3 map[string]interface{}
  3358. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. userJSONBytes3, _ := json.Marshal(respJSON3)
  3364. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3365. utils.ErrorLog("解析失败:%v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3370. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3371. utils.ErrorLog("解析失败:%v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. //if res3507for10188.Infcode
  3376. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3377. //res.Output = resSix10265.Output
  3378. res3.ErrMsg = res3507for10188.ErrMsg
  3379. res3.Cainfo = res3507for10188.Cainfo
  3380. res3.WarnMsg = res3507for10188.WarnMsg
  3381. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3382. res3.Infcode = infocode
  3383. } else {
  3384. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3385. utils.ErrorLog("解析失败:%v", err)
  3386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3387. return
  3388. }
  3389. }
  3390. if res3.Infcode == 0 {
  3391. item.IsChange = 1
  3392. item.BgBchno = bg_number
  3393. service.SaveDF2(item)
  3394. } else {
  3395. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3396. }
  3397. }
  3398. }
  3399. } else {
  3400. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3401. }
  3402. }
  3403. } else { //还没结算
  3404. var res3507for10188 FJ3507ResultFor10188
  3405. if item.IsChange == 0 { //没变更,进行变更操作
  3406. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3407. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3408. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3409. var respJSON3 map[string]interface{}
  3410. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. return
  3414. }
  3415. userJSONBytes3, _ := json.Marshal(respJSON3)
  3416. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3417. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3418. utils.ErrorLog("解析失败:%v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. //if res3507for10188.Infcode
  3423. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3424. //res.Output = resSix10265.Output
  3425. res3.ErrMsg = res3507for10188.ErrMsg
  3426. res3.Cainfo = res3507for10188.Cainfo
  3427. res3.WarnMsg = res3507for10188.WarnMsg
  3428. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3429. res3.Infcode = infocode
  3430. } else {
  3431. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3432. utils.ErrorLog("解析失败:%v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. }
  3437. if res3.Infcode == 0 {
  3438. item.IsChange = 1
  3439. item.BgBchno = bg_number
  3440. service.SaveDF2(item)
  3441. } else {
  3442. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3443. }
  3444. }
  3445. }
  3446. } else if item.ConsumableType == 7 {
  3447. var res3507for10188 FJ3507ResultFor10188
  3448. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3449. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3450. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3451. //判断是否已经销售
  3452. if item.IsSale == 2 { //是否已经销售,1是 0否
  3453. //是否已经变更 1是 0否
  3454. if item.IsChange == 0 { //没变更,进行变更操作
  3455. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3456. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3457. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3458. var respJSON3 map[string]interface{}
  3459. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. userJSONBytes3, _ := json.Marshal(respJSON3)
  3465. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3466. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3467. utils.ErrorLog("解析失败:%v", err)
  3468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. return
  3470. }
  3471. //if res3507for10188.Infcode
  3472. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3473. //res.Output = resSix10265.Output
  3474. res3.ErrMsg = res3507for10188.ErrMsg
  3475. res3.Cainfo = res3507for10188.Cainfo
  3476. res3.WarnMsg = res3507for10188.WarnMsg
  3477. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3478. res3.Infcode = infocode
  3479. } else {
  3480. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3481. utils.ErrorLog("解析失败:%v", err)
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. }
  3486. if res3.Infcode == 0 {
  3487. item.IsChange = 1
  3488. item.BgBchno = bg_number
  3489. service.SaveDF2(item)
  3490. } else {
  3491. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3492. }
  3493. }
  3494. } else { //没销售,
  3495. //进行商品销售退货接口
  3496. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3497. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3498. saveLog(result111, result222, "3506", "销售退货")
  3499. var res7 FJ3507Result
  3500. //进行商品销售接口
  3501. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3502. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3503. var respJSON3 map[string]interface{}
  3504. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. return
  3508. }
  3509. userJSONBytes3, _ := json.Marshal(respJSON3)
  3510. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3512. utils.ErrorLog("解析失败:%v", err)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. //if res3507for10188.Infcode
  3517. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3518. //res.Output = resSix10265.Output
  3519. res7.ErrMsg = res3507for10188.ErrMsg
  3520. res7.Cainfo = res3507for10188.Cainfo
  3521. res7.WarnMsg = res3507for10188.WarnMsg
  3522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3523. res7.Infcode = infocode
  3524. } else {
  3525. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3526. utils.ErrorLog("解析失败:%v", err)
  3527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3528. return
  3529. }
  3530. }
  3531. if res7.Infcode == 0 {
  3532. item.IsSale = 2
  3533. item.SaleDate = item.SaleDate
  3534. item.Bchno = number
  3535. service.SaveDF(item)
  3536. if item.IsChange == 0 { //没变更,进行变更操作
  3537. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3538. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3539. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3540. var respJSON3 map[string]interface{}
  3541. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. userJSONBytes3, _ := json.Marshal(respJSON3)
  3547. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3548. // utils.ErrorLog("解析失败:%v", err)
  3549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3550. // return
  3551. //}
  3552. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3553. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3554. utils.ErrorLog("解析失败:%v", err)
  3555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3556. return
  3557. }
  3558. //if res3507for10188.Infcode
  3559. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3560. //res.Output = resSix10265.Output
  3561. res3.ErrMsg = res3507for10188.ErrMsg
  3562. res3.Cainfo = res3507for10188.Cainfo
  3563. res3.WarnMsg = res3507for10188.WarnMsg
  3564. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3565. res3.Infcode = infocode
  3566. } else {
  3567. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3568. utils.ErrorLog("解析失败:%v", err)
  3569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3570. return
  3571. }
  3572. }
  3573. if res3.Infcode == 0 {
  3574. item.IsChange = 1
  3575. item.BgBchno = bg_number
  3576. service.SaveDF2(item)
  3577. } else {
  3578. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3579. }
  3580. }
  3581. } else {
  3582. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3583. }
  3584. }
  3585. } else { //还没结算
  3586. if item.IsChange == 0 { //没变更,进行变更操作
  3587. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3588. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3589. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3590. var respJSON3 map[string]interface{}
  3591. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3594. return
  3595. }
  3596. userJSONBytes3, _ := json.Marshal(respJSON3)
  3597. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3598. // utils.ErrorLog("解析失败:%v", err)
  3599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3600. // return
  3601. //}
  3602. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3603. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. //if res3507for10188.Infcode
  3609. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3610. //res.Output = resSix10265.Output
  3611. res3.ErrMsg = res3507for10188.ErrMsg
  3612. res3.Cainfo = res3507for10188.Cainfo
  3613. res3.WarnMsg = res3507for10188.WarnMsg
  3614. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3615. res3.Infcode = infocode
  3616. } else {
  3617. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3618. utils.ErrorLog("解析失败:%v", err)
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3620. return
  3621. }
  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. }
  3632. }
  3633. }
  3634. if len(err) == 0 {
  3635. c.ServeSuccessJSON(map[string]interface{}{
  3636. "msg": "销售变更成功",
  3637. })
  3638. } else {
  3639. c.ServeSuccessJSON(map[string]interface{}{
  3640. "failed_code": -10,
  3641. "msg": err,
  3642. })
  3643. }
  3644. }
  3645. func (c *HisApiController) ChangeDrugtwo() {
  3646. //ids := c.GetString("ids")
  3647. //id_arr := strings.Split(ids, ",")
  3648. flows, _ := service.GetNewDrugFlowInfothree123()
  3649. admin_user_id, _ := c.GetInt64("admin_user_id")
  3650. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3652. var err []string
  3653. for _, item := range flows {
  3654. var res3 ResultSix
  3655. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3656. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3657. if prescription.OrderStatus == 2 {
  3658. //已经结算
  3659. //判断是否已经销售
  3660. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3661. // //是否已经变更 1是 0否
  3662. // if item.IsChange == 0 { //没变更,进行变更操作
  3663. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3664. //
  3665. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3666. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3667. // var respJSON3 map[string]interface{}
  3668. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3669. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. // return
  3672. // }
  3673. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3674. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3675. // utils.ErrorLog("解析失败:%v", err)
  3676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. // return
  3678. // }
  3679. // if res3.Infcode == 0 {
  3680. // item.IsChange = 1
  3681. // item.BgBchno = bg_number
  3682. // service.SaveDF2(item)
  3683. // } else {
  3684. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3685. // }
  3686. // }
  3687. //}
  3688. //else
  3689. { //没销售,
  3690. var res FJ3507Result
  3691. var res3507for10188 FJ3507ResultFor10188
  3692. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3693. //进行商品销售接口
  3694. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3695. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3696. var respJSON3 map[string]interface{}
  3697. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. userJSONBytes3, _ := json.Marshal(respJSON3)
  3703. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3704. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. //if res3507for10188.Infcode
  3710. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3711. //res.Output = resSix10265.Output
  3712. res.ErrMsg = res3507for10188.ErrMsg
  3713. res.Cainfo = res3507for10188.Cainfo
  3714. res.WarnMsg = res3507for10188.WarnMsg
  3715. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3716. res.Infcode = infocode
  3717. } else {
  3718. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3719. utils.ErrorLog("解析失败:%v", err)
  3720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. return
  3722. }
  3723. }
  3724. if res.Infcode == 0 {
  3725. item.IsSale = 1
  3726. item.Bchno = number
  3727. item.SaleDate = time.Now().Format("2006-01-02")
  3728. service.SaveDF(item)
  3729. //if err5 == nil {
  3730. // if item.IsChange == 0 { //没变更,进行变更操作
  3731. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3732. //
  3733. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3734. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3735. //
  3736. // var respJSON3 map[string]interface{}
  3737. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3738. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. // return
  3741. // }
  3742. //
  3743. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3744. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3745. // utils.ErrorLog("解析失败:%v", err)
  3746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. // return
  3748. // }
  3749. // //if res3507for10188.Infcode
  3750. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3751. // //res.Output = resSix10265.Output
  3752. // res3.ErrMsg = res3507for10188.ErrMsg
  3753. // res3.Cainfo = res3507for10188.Cainfo
  3754. // res3.WarnMsg = res3507for10188.WarnMsg
  3755. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3756. // res3.Infcode = infocode
  3757. // } else {
  3758. //
  3759. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3760. // utils.ErrorLog("解析失败:%v", err)
  3761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. // return
  3763. // }
  3764. //
  3765. // }
  3766. //
  3767. // if res3.Infcode == 0 {
  3768. // item.IsChange = 1
  3769. // item.BgBchno = bg_number
  3770. // service.SaveDF2(item)
  3771. // } else {
  3772. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3773. // }
  3774. // }
  3775. //}
  3776. } else {
  3777. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3778. }
  3779. }
  3780. } else { //还没结算
  3781. var res3507for10188 FJ3507ResultFor10188
  3782. if item.IsChange == 0 { //没变更,进行变更操作
  3783. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3784. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3785. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3786. var respJSON3 map[string]interface{}
  3787. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3790. return
  3791. }
  3792. userJSONBytes3, _ := json.Marshal(respJSON3)
  3793. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3794. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3795. utils.ErrorLog("解析失败:%v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. //if res3507for10188.Infcode
  3800. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3801. //res.Output = resSix10265.Output
  3802. res3.ErrMsg = res3507for10188.ErrMsg
  3803. res3.Cainfo = res3507for10188.Cainfo
  3804. res3.WarnMsg = res3507for10188.WarnMsg
  3805. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3806. res3.Infcode = infocode
  3807. } else {
  3808. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3809. utils.ErrorLog("解析失败:%v", err)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. }
  3814. if res3.Infcode == 0 {
  3815. item.IsChange = 1
  3816. item.BgBchno = bg_number
  3817. service.SaveDF2(item)
  3818. } else {
  3819. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3820. }
  3821. }
  3822. }
  3823. }
  3824. //if item.ConsumableType == 7 {
  3825. // var res3507for10188 FJ3507ResultFor10188
  3826. //
  3827. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3828. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3829. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3830. // //判断是否已经销售
  3831. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3832. // //是否已经变更 1是 0否
  3833. // if item.IsChange == 0 { //没变更,进行变更操作
  3834. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3835. //
  3836. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3837. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3838. //
  3839. // var respJSON3 map[string]interface{}
  3840. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. // return
  3844. // }
  3845. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3847. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3848. // utils.ErrorLog("解析失败:%v", err)
  3849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. // return
  3851. // }
  3852. // //if res3507for10188.Infcode
  3853. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3854. // //res.Output = resSix10265.Output
  3855. // res3.ErrMsg = res3507for10188.ErrMsg
  3856. // res3.Cainfo = res3507for10188.Cainfo
  3857. // res3.WarnMsg = res3507for10188.WarnMsg
  3858. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3859. // res3.Infcode = infocode
  3860. // } else {
  3861. //
  3862. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3863. // utils.ErrorLog("解析失败:%v", err)
  3864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3865. // return
  3866. // }
  3867. //
  3868. // }
  3869. // if res3.Infcode == 0 {
  3870. // item.IsChange = 1
  3871. // item.BgBchno = bg_number
  3872. // service.SaveDF2(item)
  3873. // } else {
  3874. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3875. // }
  3876. // }
  3877. // } else { //没销售,
  3878. // //进行商品销售退货接口
  3879. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3880. //
  3881. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3882. // saveLog(result111, result222, "3506", "销售退货")
  3883. // var res7 FJ3507Result
  3884. //
  3885. // //进行商品销售接口
  3886. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3887. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3888. // var respJSON3 map[string]interface{}
  3889. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3890. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. // return
  3893. // }
  3894. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3895. //
  3896. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3897. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3898. // utils.ErrorLog("解析失败:%v", err)
  3899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3900. // return
  3901. // }
  3902. // //if res3507for10188.Infcode
  3903. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3904. // //res.Output = resSix10265.Output
  3905. // res7.ErrMsg = res3507for10188.ErrMsg
  3906. // res7.Cainfo = res3507for10188.Cainfo
  3907. // res7.WarnMsg = res3507for10188.WarnMsg
  3908. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3909. // res7.Infcode = infocode
  3910. // } else {
  3911. //
  3912. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3913. // utils.ErrorLog("解析失败:%v", err)
  3914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. // return
  3916. // }
  3917. //
  3918. // }
  3919. // if res7.Infcode == 0 {
  3920. // item.IsSale = 2
  3921. // item.SaleDate = item.SaleDate
  3922. // item.Bchno = number
  3923. // service.SaveDF(item)
  3924. // if item.IsChange == 0 { //没变更,进行变更操作
  3925. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3926. //
  3927. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3928. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3929. //
  3930. // var respJSON3 map[string]interface{}
  3931. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3932. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. // return
  3935. // }
  3936. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3937. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3938. // // utils.ErrorLog("解析失败:%v", err)
  3939. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. // // return
  3941. // //}
  3942. //
  3943. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3944. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3945. // utils.ErrorLog("解析失败:%v", err)
  3946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. // return
  3948. // }
  3949. // //if res3507for10188.Infcode
  3950. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3951. // //res.Output = resSix10265.Output
  3952. // res3.ErrMsg = res3507for10188.ErrMsg
  3953. // res3.Cainfo = res3507for10188.Cainfo
  3954. // res3.WarnMsg = res3507for10188.WarnMsg
  3955. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3956. // res3.Infcode = infocode
  3957. // } else {
  3958. //
  3959. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3960. // utils.ErrorLog("解析失败:%v", err)
  3961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. // return
  3963. // }
  3964. //
  3965. // }
  3966. // if res3.Infcode == 0 {
  3967. // item.IsChange = 1
  3968. // item.BgBchno = bg_number
  3969. // service.SaveDF2(item)
  3970. // } else {
  3971. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3972. // }
  3973. // }
  3974. // } else {
  3975. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3976. // }
  3977. // }
  3978. // } else { //还没结算
  3979. // if item.IsChange == 0 { //没变更,进行变更操作
  3980. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3981. //
  3982. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3983. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3984. //
  3985. // var respJSON3 map[string]interface{}
  3986. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3987. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. // return
  3990. // }
  3991. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3992. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3993. // // utils.ErrorLog("解析失败:%v", err)
  3994. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. // // return
  3996. // //}
  3997. //
  3998. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3999. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4000. // utils.ErrorLog("解析失败:%v", err)
  4001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. // return
  4003. // }
  4004. // //if res3507for10188.Infcode
  4005. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4006. // //res.Output = resSix10265.Output
  4007. // res3.ErrMsg = res3507for10188.ErrMsg
  4008. // res3.Cainfo = res3507for10188.Cainfo
  4009. // res3.WarnMsg = res3507for10188.WarnMsg
  4010. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4011. // res3.Infcode = infocode
  4012. // } else {
  4013. //
  4014. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4015. // utils.ErrorLog("解析失败:%v", err)
  4016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. // return
  4018. // }
  4019. //
  4020. // }
  4021. // if res3.Infcode == 0 {
  4022. // item.IsChange = 1
  4023. // item.BgBchno = bg_number
  4024. // service.SaveDF2(item)
  4025. // } else {
  4026. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4027. // }
  4028. // }
  4029. // }
  4030. //}
  4031. }
  4032. if len(err) == 0 {
  4033. c.ServeSuccessJSON(map[string]interface{}{
  4034. "msg": "销售变更成功",
  4035. })
  4036. } else {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": err,
  4040. })
  4041. }
  4042. }
  4043. func (c *HisApiController) ChangeDrugthree() {
  4044. //ids := c.GetString("ids")
  4045. //id_arr := strings.Split(ids, ",")
  4046. flows, _ := service.GetNewDrugFlowInfothree()
  4047. admin_user_id, _ := c.GetInt64("admin_user_id")
  4048. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4050. var err []string
  4051. for _, item := range flows {
  4052. var res3 ResultSix
  4053. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4054. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4055. if prescription.OrderStatus == 2 {
  4056. //已经结算
  4057. //判断是否已经销售
  4058. if item.IsSale == 1 { //是否已经销售,1是 0否
  4059. //是否已经变更 1是 0否
  4060. if item.IsChange == 0 { //没变更,进行变更操作
  4061. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4062. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4063. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4064. var respJSON3 map[string]interface{}
  4065. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4068. return
  4069. }
  4070. userJSONBytes3, _ := json.Marshal(respJSON3)
  4071. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4072. utils.ErrorLog("解析失败:%v", err)
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. return
  4075. }
  4076. if res3.Infcode == 0 {
  4077. item.IsChange = 1
  4078. item.BgBchno = bg_number
  4079. service.SaveDF2(item)
  4080. } else {
  4081. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4082. }
  4083. }
  4084. } else { //没销售,
  4085. var res FJ3507Result
  4086. var res3507for10188 FJ3507ResultFor10188
  4087. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4088. //进行商品销售接口
  4089. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4090. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4091. var respJSON3 map[string]interface{}
  4092. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4095. return
  4096. }
  4097. userJSONBytes3, _ := json.Marshal(respJSON3)
  4098. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4099. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4100. utils.ErrorLog("解析失败:%v", err)
  4101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4102. return
  4103. }
  4104. //if res3507for10188.Infcode
  4105. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4106. //res.Output = resSix10265.Output
  4107. res.ErrMsg = res3507for10188.ErrMsg
  4108. res.Cainfo = res3507for10188.Cainfo
  4109. res.WarnMsg = res3507for10188.WarnMsg
  4110. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4111. res.Infcode = infocode
  4112. } else {
  4113. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4114. utils.ErrorLog("解析失败:%v", err)
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4116. return
  4117. }
  4118. }
  4119. if res.Infcode == 0 {
  4120. item.IsSale = 1
  4121. item.Bchno = number
  4122. item.SaleDate = time.Now().Format("2006-01-02")
  4123. err5 := service.SaveDF(item)
  4124. if err5 == nil {
  4125. if item.IsChange == 0 { //没变更,进行变更操作
  4126. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4127. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4128. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4129. var respJSON3 map[string]interface{}
  4130. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4136. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. //if res3507for10188.Infcode
  4142. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4143. //res.Output = resSix10265.Output
  4144. res3.ErrMsg = res3507for10188.ErrMsg
  4145. res3.Cainfo = res3507for10188.Cainfo
  4146. res3.WarnMsg = res3507for10188.WarnMsg
  4147. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4148. res3.Infcode = infocode
  4149. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4150. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4151. utils.ErrorLog("解析失败:%v", err)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. //if res3507for10188.Infcode
  4156. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4157. //res.Output = resSix10265.Output
  4158. res3.ErrMsg = res3507for10188.ErrMsg
  4159. res3.Cainfo = res3507for10188.Cainfo
  4160. res3.WarnMsg = res3507for10188.WarnMsg
  4161. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4162. res3.Infcode = infocode
  4163. } else {
  4164. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4165. utils.ErrorLog("解析失败:%v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. }
  4170. if res3.Infcode == 0 {
  4171. item.IsChange = 1
  4172. item.BgBchno = bg_number
  4173. service.SaveDF2(item)
  4174. } else {
  4175. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4176. }
  4177. }
  4178. }
  4179. } else {
  4180. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4181. }
  4182. }
  4183. } else { //还没结算
  4184. var res3507for10188 FJ3507ResultFor10188
  4185. if item.IsChange == 0 { //没变更,进行变更操作
  4186. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4187. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4188. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4189. var respJSON3 map[string]interface{}
  4190. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4193. return
  4194. }
  4195. userJSONBytes3, _ := json.Marshal(respJSON3)
  4196. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4197. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. //if res3507for10188.Infcode
  4203. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4204. //res.Output = resSix10265.Output
  4205. res3.ErrMsg = res3507for10188.ErrMsg
  4206. res3.Cainfo = res3507for10188.Cainfo
  4207. res3.WarnMsg = res3507for10188.WarnMsg
  4208. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4209. res3.Infcode = infocode
  4210. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4211. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4212. utils.ErrorLog("解析失败:%v", err)
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. //if res3507for10188.Infcode
  4217. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4218. //res.Output = resSix10265.Output
  4219. res3.ErrMsg = res3507for10188.ErrMsg
  4220. res3.Cainfo = res3507for10188.Cainfo
  4221. res3.WarnMsg = res3507for10188.WarnMsg
  4222. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4223. res3.Infcode = infocode
  4224. } else {
  4225. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4226. utils.ErrorLog("解析失败:%v", err)
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. return
  4229. }
  4230. }
  4231. if res3.Infcode == 0 {
  4232. item.IsChange = 1
  4233. item.BgBchno = bg_number
  4234. service.SaveDF2(item)
  4235. } else {
  4236. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4237. }
  4238. }
  4239. }
  4240. } else if item.ConsumableType == 7 {
  4241. var res3507for10188 FJ3507ResultFor10188
  4242. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4243. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4244. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4245. //判断是否已经销售
  4246. if item.IsSale == 2 { //是否已经销售,1是 0否
  4247. //是否已经变更 1是 0否
  4248. if item.IsChange == 0 { //没变更,进行变更操作
  4249. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4250. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4251. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4252. var respJSON3 map[string]interface{}
  4253. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. userJSONBytes3, _ := json.Marshal(respJSON3)
  4259. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4260. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4261. utils.ErrorLog("解析失败:%v", err)
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. return
  4264. }
  4265. //if res3507for10188.Infcode
  4266. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4267. //res.Output = resSix10265.Output
  4268. res3.ErrMsg = res3507for10188.ErrMsg
  4269. res3.Cainfo = res3507for10188.Cainfo
  4270. res3.WarnMsg = res3507for10188.WarnMsg
  4271. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4272. res3.Infcode = infocode
  4273. } else {
  4274. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4275. utils.ErrorLog("解析失败:%v", err)
  4276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4277. return
  4278. }
  4279. }
  4280. if res3.Infcode == 0 {
  4281. item.IsChange = 1
  4282. item.BgBchno = bg_number
  4283. service.SaveDF2(item)
  4284. } else {
  4285. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4286. }
  4287. }
  4288. } else { //没销售,
  4289. //进行商品销售退货接口
  4290. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4291. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4292. saveLog(result111, result222, "3506", "销售退货")
  4293. var res7 FJ3507Result
  4294. //进行商品销售接口
  4295. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4296. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4297. var respJSON3 map[string]interface{}
  4298. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. userJSONBytes3, _ := json.Marshal(respJSON3)
  4304. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4305. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4306. utils.ErrorLog("解析失败:%v", err)
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. return
  4309. }
  4310. //if res3507for10188.Infcode
  4311. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4312. //res.Output = resSix10265.Output
  4313. res7.ErrMsg = res3507for10188.ErrMsg
  4314. res7.Cainfo = res3507for10188.Cainfo
  4315. res7.WarnMsg = res3507for10188.WarnMsg
  4316. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4317. res7.Infcode = infocode
  4318. } else {
  4319. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4320. utils.ErrorLog("解析失败:%v", err)
  4321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. return
  4323. }
  4324. }
  4325. if res7.Infcode == 0 {
  4326. item.IsSale = 2
  4327. item.SaleDate = item.SaleDate
  4328. item.Bchno = number
  4329. service.SaveDF(item)
  4330. if item.IsChange == 0 { //没变更,进行变更操作
  4331. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4332. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4333. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4334. var respJSON3 map[string]interface{}
  4335. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. userJSONBytes3, _ := json.Marshal(respJSON3)
  4341. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4342. // utils.ErrorLog("解析失败:%v", err)
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // return
  4345. //}
  4346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4347. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4348. utils.ErrorLog("解析失败:%v", err)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. //if res3507for10188.Infcode
  4353. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4354. //res.Output = resSix10265.Output
  4355. res3.ErrMsg = res3507for10188.ErrMsg
  4356. res3.Cainfo = res3507for10188.Cainfo
  4357. res3.WarnMsg = res3507for10188.WarnMsg
  4358. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4359. res3.Infcode = infocode
  4360. } else {
  4361. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. }
  4367. if res3.Infcode == 0 {
  4368. item.IsChange = 1
  4369. item.BgBchno = bg_number
  4370. service.SaveDF2(item)
  4371. } else {
  4372. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4373. }
  4374. }
  4375. } else {
  4376. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4377. }
  4378. }
  4379. } else { //还没结算
  4380. if item.IsChange == 0 { //没变更,进行变更操作
  4381. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4382. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4383. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4384. var respJSON3 map[string]interface{}
  4385. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. userJSONBytes3, _ := json.Marshal(respJSON3)
  4391. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4392. // utils.ErrorLog("解析失败:%v", err)
  4393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. // return
  4395. //}
  4396. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4397. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4398. utils.ErrorLog("解析失败:%v", err)
  4399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4400. return
  4401. }
  4402. //if res3507for10188.Infcode
  4403. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4404. //res.Output = resSix10265.Output
  4405. res3.ErrMsg = res3507for10188.ErrMsg
  4406. res3.Cainfo = res3507for10188.Cainfo
  4407. res3.WarnMsg = res3507for10188.WarnMsg
  4408. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4409. res3.Infcode = infocode
  4410. } else {
  4411. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4412. utils.ErrorLog("解析失败:%v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. }
  4417. if res3.Infcode == 0 {
  4418. item.IsChange = 1
  4419. item.BgBchno = bg_number
  4420. service.SaveDF2(item)
  4421. } else {
  4422. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4423. }
  4424. }
  4425. }
  4426. }
  4427. }
  4428. if len(err) == 0 {
  4429. c.ServeSuccessJSON(map[string]interface{}{
  4430. "msg": "销售变更成功",
  4431. })
  4432. } else {
  4433. c.ServeSuccessJSON(map[string]interface{}{
  4434. "failed_code": -10,
  4435. "msg": err,
  4436. })
  4437. }
  4438. }
  4439. func (c *HisApiController) ChangeDrugTen() {
  4440. start_time_str := c.GetString("start_time")
  4441. end_time_str := c.GetString("end_time")
  4442. //ids := c.GetString("ids")
  4443. //id_arr := strings.Split(ids, ",")
  4444. timeLayout := "2006-01-02"
  4445. loc, _ := time.LoadLocation("Local")
  4446. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4447. recordStartTime := theStartTime.Unix()
  4448. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4449. recordEndTime := theEndTime.Unix()
  4450. //timestamp := int64(1729612800)
  4451. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4452. admin_user_id, _ := c.GetInt64("admin_user_id")
  4453. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4455. var err []string
  4456. for _, item := range flows {
  4457. var res3 ResultSix
  4458. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4459. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4460. continue
  4461. }
  4462. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4463. continue
  4464. }
  4465. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4466. if prescription.OrderStatus == 2 {
  4467. //已经结算
  4468. //判断 是否已经销售
  4469. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4470. ////是否已经变更 1是 0否
  4471. //if item.IsChange == 0 { //没变更,进行变更操作
  4472. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4473. //
  4474. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4475. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4476. // var respJSON3 map[string]interface{}
  4477. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4478. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. // return
  4481. // }
  4482. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4483. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4484. // utils.ErrorLog("解析失败:%v", err)
  4485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. // return
  4487. // }
  4488. // if res3.Infcode == 0 {
  4489. // item.IsChange = 1
  4490. // item.BgBchno = bg_number
  4491. // service.SaveDF2(item)
  4492. // } else {
  4493. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4494. // }
  4495. //}
  4496. //} else
  4497. if item.IsSale == 0 { //没销售,
  4498. var res FJ3507Result
  4499. var res3507for10188 FJ3507ResultFor10188
  4500. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4501. //进行商品销售接口
  4502. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4503. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4504. var respJSON3 map[string]interface{}
  4505. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. userJSONBytes3, _ := json.Marshal(respJSON3)
  4511. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4512. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4513. utils.ErrorLog("解析失败:%v", err)
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4515. return
  4516. }
  4517. //if res3507for10188.Infcode
  4518. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4519. //res.Output = resSix10265.Output
  4520. res.ErrMsg = res3507for10188.ErrMsg
  4521. res.Cainfo = res3507for10188.Cainfo
  4522. res.WarnMsg = res3507for10188.WarnMsg
  4523. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4524. res.Infcode = infocode
  4525. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4526. } else {
  4527. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4528. utils.ErrorLog("解析失败:%v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. }
  4533. if res.Infcode == 0 {
  4534. item.IsSale = 1
  4535. item.Bchno = number
  4536. item.SaleDate = time.Now().Format("2006-01-02")
  4537. err5 := service.SaveDF(item)
  4538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4539. //if err5 == nil {
  4540. //
  4541. // if item.IsChange == 1 { //没变更,进行变更操作
  4542. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4543. //
  4544. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4545. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4546. //
  4547. // var respJSON3 map[string]interface{}
  4548. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4549. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. // return
  4552. // }
  4553. //
  4554. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4555. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4556. // utils.ErrorLog("解析失败:%v", err)
  4557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4558. // return
  4559. // }
  4560. // //if res3507for10188.Infcode
  4561. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4562. // //res.Output = resSix10265.Output
  4563. // res3.ErrMsg = res3507for10188.ErrMsg
  4564. // res3.Cainfo = res3507for10188.Cainfo
  4565. // res3.WarnMsg = res3507for10188.WarnMsg
  4566. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4567. // res3.Infcode = infocode
  4568. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4569. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4570. // utils.ErrorLog("解析失败:%v", err)
  4571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4572. // return
  4573. // }
  4574. // //if res3507for10188.Infcode
  4575. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4576. // //res.Output = resSix10265.Output
  4577. // res3.ErrMsg = res3507for10188.ErrMsg
  4578. // res3.Cainfo = res3507for10188.Cainfo
  4579. // res3.WarnMsg = res3507for10188.WarnMsg
  4580. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4581. // res3.Infcode = infocode
  4582. //
  4583. // } else {
  4584. //
  4585. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4586. // utils.ErrorLog("解析失败:%v", err)
  4587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. // return
  4589. // }
  4590. //
  4591. // }
  4592. //
  4593. // if res3.Infcode == 0 {
  4594. // item.IsChange = 1
  4595. // item.BgBchno = bg_number
  4596. // service.SaveDF2(item)
  4597. // return
  4598. // } else {
  4599. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4600. // }
  4601. // }
  4602. //}
  4603. } else {
  4604. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4605. }
  4606. }
  4607. }
  4608. } else if item.ConsumableType == 7 {
  4609. var res3507for10188 FJ3507ResultFor10188
  4610. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4611. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4612. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4613. //判断是否已经销售
  4614. if item.IsSale == 2 { //是否已经销售,1是 0否
  4615. //是否已经变更 1是 0否
  4616. if item.IsChange == 0 { //没变更,进行变更操作
  4617. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4618. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4619. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4620. var respJSON3 map[string]interface{}
  4621. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4624. return
  4625. }
  4626. userJSONBytes3, _ := json.Marshal(respJSON3)
  4627. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4628. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4629. utils.ErrorLog("解析失败:%v", err)
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. //if res3507for10188.Infcode
  4634. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4635. //res.Output = resSix10265.Output
  4636. res3.ErrMsg = res3507for10188.ErrMsg
  4637. res3.Cainfo = res3507for10188.Cainfo
  4638. res3.WarnMsg = res3507for10188.WarnMsg
  4639. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4640. res3.Infcode = infocode
  4641. } else {
  4642. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4643. utils.ErrorLog("解析失败:%v", err)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. }
  4648. if res3.Infcode == 0 {
  4649. item.IsChange = 1
  4650. item.BgBchno = bg_number
  4651. service.SaveDF2(item)
  4652. } else {
  4653. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4654. }
  4655. }
  4656. } else { //没销售,
  4657. //进行商品销售退货接口
  4658. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4659. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4660. saveLog(result111, result222, "3506", "销售退货")
  4661. var res7 FJ3507Result
  4662. //进行商品销售接口
  4663. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4664. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4665. var respJSON3 map[string]interface{}
  4666. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4669. return
  4670. }
  4671. userJSONBytes3, _ := json.Marshal(respJSON3)
  4672. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4673. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4674. utils.ErrorLog("解析失败:%v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. //if res3507for10188.Infcode
  4679. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4680. //res.Output = resSix10265.Output
  4681. res7.ErrMsg = res3507for10188.ErrMsg
  4682. res7.Cainfo = res3507for10188.Cainfo
  4683. res7.WarnMsg = res3507for10188.WarnMsg
  4684. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4685. res7.Infcode = infocode
  4686. } else {
  4687. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4688. utils.ErrorLog("解析失败:%v", err)
  4689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4690. return
  4691. }
  4692. }
  4693. if res7.Infcode == 0 {
  4694. item.IsSale = 2
  4695. item.SaleDate = item.SaleDate
  4696. item.Bchno = number
  4697. service.SaveDF(item)
  4698. if item.IsChange == 0 { //没变更,进行变更操作
  4699. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4700. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4701. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4702. var respJSON3 map[string]interface{}
  4703. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4706. return
  4707. }
  4708. userJSONBytes3, _ := json.Marshal(respJSON3)
  4709. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4710. // utils.ErrorLog("解析失败:%v", err)
  4711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. // return
  4713. //}
  4714. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4715. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4716. utils.ErrorLog("解析失败:%v", err)
  4717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4718. return
  4719. }
  4720. //if res3507for10188.Infcode
  4721. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4722. //res.Output = resSix10265.Output
  4723. res3.ErrMsg = res3507for10188.ErrMsg
  4724. res3.Cainfo = res3507for10188.Cainfo
  4725. res3.WarnMsg = res3507for10188.WarnMsg
  4726. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4727. res3.Infcode = infocode
  4728. } else {
  4729. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4730. utils.ErrorLog("解析失败:%v", err)
  4731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4732. return
  4733. }
  4734. }
  4735. if res3.Infcode == 0 {
  4736. item.IsChange = 1
  4737. item.BgBchno = bg_number
  4738. service.SaveDF2(item)
  4739. } else {
  4740. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4741. }
  4742. }
  4743. } else {
  4744. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4745. }
  4746. }
  4747. } else { //还没结算
  4748. if item.IsChange == 0 { //没变更,进行变更操作
  4749. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4750. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4751. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4752. var respJSON3 map[string]interface{}
  4753. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4756. return
  4757. }
  4758. userJSONBytes3, _ := json.Marshal(respJSON3)
  4759. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4760. // utils.ErrorLog("解析失败:%v", err)
  4761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4762. // return
  4763. //}
  4764. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4765. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4766. utils.ErrorLog("解析失败:%v", err)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. //if res3507for10188.Infcode
  4771. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4772. //res.Output = resSix10265.Output
  4773. res3.ErrMsg = res3507for10188.ErrMsg
  4774. res3.Cainfo = res3507for10188.Cainfo
  4775. res3.WarnMsg = res3507for10188.WarnMsg
  4776. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4777. res3.Infcode = infocode
  4778. } else {
  4779. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4780. utils.ErrorLog("解析失败:%v", err)
  4781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4782. return
  4783. }
  4784. }
  4785. if res3.Infcode == 0 {
  4786. item.IsChange = 1
  4787. item.BgBchno = bg_number
  4788. service.SaveDF2(item)
  4789. } else {
  4790. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4791. }
  4792. }
  4793. }
  4794. }
  4795. }
  4796. if len(err) == 0 {
  4797. c.ServeSuccessJSON(map[string]interface{}{
  4798. "msg": "销售变更成功",
  4799. })
  4800. } else {
  4801. c.ServeSuccessJSON(map[string]interface{}{
  4802. "failed_code": -10,
  4803. "msg": err,
  4804. })
  4805. }
  4806. }
  4807. func ChangeDrugTenone() {
  4808. //ids := c.GetString("ids")
  4809. //id_arr := strings.Split(ids, ",")
  4810. now := time.Now()
  4811. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4812. //timestamp := int64(1729612800)
  4813. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4814. admin_user_id := int64(2463)
  4815. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4816. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4817. var err []string
  4818. for _, item := range flows {
  4819. var res3 ResultSix
  4820. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4821. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4822. continue
  4823. }
  4824. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4825. continue
  4826. }
  4827. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4828. if prescription.OrderStatus == 2 {
  4829. //已经结算
  4830. //判断是否已经销售
  4831. if item.IsSale == 1 { //是否已经销售,1是 0否
  4832. //是否已经变更 1是 0否
  4833. if item.IsChange == 0 { //没变更,进行变更操作
  4834. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4835. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4836. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4837. var respJSON3 map[string]interface{}
  4838. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4840. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4841. return
  4842. }
  4843. userJSONBytes3, _ := json.Marshal(respJSON3)
  4844. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4845. utils.ErrorLog("解析失败:%v", err)
  4846. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. return
  4848. }
  4849. if res3.Infcode == 0 {
  4850. item.IsChange = 1
  4851. item.BgBchno = bg_number
  4852. service.SaveDF2(item)
  4853. } else {
  4854. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4855. }
  4856. }
  4857. } else { //没销售,
  4858. var res FJ3507Result
  4859. var res3507for10188 FJ3507ResultFor10188
  4860. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4861. //进行商品销售接口
  4862. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4863. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4864. var respJSON3 map[string]interface{}
  4865. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4867. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4868. return
  4869. }
  4870. userJSONBytes3, _ := json.Marshal(respJSON3)
  4871. {
  4872. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4873. utils.ErrorLog("解析失败:%v", err)
  4874. return
  4875. }
  4876. //if res3507for10188.Infcode
  4877. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4878. //res.Output = resSix10265.Output
  4879. res.ErrMsg = res3507for10188.ErrMsg
  4880. res.Cainfo = res3507for10188.Cainfo
  4881. res.WarnMsg = res3507for10188.WarnMsg
  4882. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4883. res.Infcode = infocode
  4884. }
  4885. if res.Infcode == 0 {
  4886. item.IsSale = 1
  4887. item.Bchno = number
  4888. item.SaleDate = time.Now().Format("2006-01-02")
  4889. err5 := service.SaveDF(item)
  4890. if err5 == nil {
  4891. if item.IsChange == 1 { //没变更,进行变更操作
  4892. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4893. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4894. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4895. var respJSON3 map[string]interface{}
  4896. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4898. return
  4899. }
  4900. {
  4901. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4902. utils.ErrorLog("解析失败:%v", err)
  4903. return
  4904. }
  4905. //if res3507for10188.Infcode
  4906. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4907. //res.Output = resSix10265.Output
  4908. res3.ErrMsg = res3507for10188.ErrMsg
  4909. res3.Cainfo = res3507for10188.Cainfo
  4910. res3.WarnMsg = res3507for10188.WarnMsg
  4911. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4912. res3.Infcode = infocode
  4913. }
  4914. if res3.Infcode == 0 {
  4915. item.IsChange = 1
  4916. item.BgBchno = bg_number
  4917. service.SaveDF2(item)
  4918. } else {
  4919. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4920. }
  4921. }
  4922. }
  4923. } else {
  4924. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. }
  4931. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4932. var struct3502 models.Struct3502
  4933. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4935. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4936. struct3502.FixmedinsCode = miConfig.Code
  4937. struct3502.Code = miConfig.Code
  4938. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4939. struct3502.Opter = role.UserName
  4940. struct3502.RxFlag = "1"
  4941. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4942. struct3502.OrgName = miConfig.OrgName
  4943. struct3502.AccessKey = miConfig.AccessKey
  4944. struct3502.RequestUrl = miConfig.Url
  4945. struct3502.SecretKey = miConfig.SecretKey
  4946. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4947. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4948. struct3502.Url = miConfig.Url
  4949. struct3502.AppId = miConfig.Cainfo
  4950. struct3502.AppSecret = miConfig.AppSecret
  4951. struct3502.Enckey = miConfig.EncKey
  4952. struct3502.SignKey = miConfig.SignKey
  4953. struct3502.SecretKey = miConfig.SecretKey
  4954. struct3502.InvChgType = chgType
  4955. struct3502.FixmedinsBchno = number
  4956. struct3502.Cnt = strconv.FormatInt(count, 10)
  4957. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4958. //result1, result2, _ := service.FJyb3502(struct3502)
  4959. if miConfig.MdtrtareaAdmvs == "350500" {
  4960. result1, result2, _ := service.FJyb3502(struct3502)
  4961. //saveLog(result1, result2, "3502", "3502")
  4962. return result1, result2
  4963. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4964. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4965. return result1, result2
  4966. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4967. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4968. return result1, result2
  4969. } else {
  4970. data := make(map[string]interface{})
  4971. data["struct_3502s"] = struct3502
  4972. client := &http.Client{}
  4973. bytesData, _ := json.Marshal(data)
  4974. var req *http.Request
  4975. if miConfig.MdtrtareaAdmvs == "320921" {
  4976. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4977. } else {
  4978. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4979. }
  4980. resp, _ := client.Do(req)
  4981. defer resp.Body.Close()
  4982. body, ioErr := ioutil.ReadAll(resp.Body)
  4983. if ioErr != nil {
  4984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4985. }
  4986. var respJSON map[string]interface{}
  4987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4989. }
  4990. //var resSix10265 ResultSix10265 //1101结果
  4991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4992. result, _ := json.Marshal(respJSON)
  4993. return string(result), ""
  4994. }
  4995. }
  4996. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4997. var struct3505 models.Struct3505
  4998. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5000. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5001. struct3505.FixmedinsBchno = number
  5002. struct3505.Opter = role.UserName
  5003. struct3505.Bchno = "---"
  5004. struct3505.FixmedinsCode = miConfig.Code
  5005. struct3505.Code = miConfig.Code
  5006. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5007. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5008. struct3505.PrscDrName = roles.UserName
  5009. if org_id == 10191 {
  5010. struct3505.PharName = "刘水山"
  5011. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5012. }
  5013. if org_id == 10188 {
  5014. struct3505.PharName = "李汉清"
  5015. struct3505.PharPracCertNo = "30220200932022010034"
  5016. }
  5017. if org_id == 10217 {
  5018. struct3505.PharName = "张敏"
  5019. struct3505.PharPracCertNo = "30220230432090100108"
  5020. }
  5021. if org_id == 10318 {
  5022. struct3505.PharName = "邹刘阳"
  5023. struct3505.PharPracCertNo = "210441200001378"
  5024. }
  5025. if org_id == 10402 {
  5026. struct3505.PharName = "刘韶健"
  5027. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5028. }
  5029. if org_id == 9919 {
  5030. struct3505.PharName = "周君权"
  5031. struct3505.PharPracCertNo = "089644396094401375"
  5032. }
  5033. if org_id == 10644 {
  5034. struct3505.PharName = "陈金娣"
  5035. struct3505.PharPracCertNo = "20181441500320100066"
  5036. }
  5037. if org_id == 10567 {
  5038. struct3505.PharName = "范小兰"
  5039. struct3505.PharPracCertNo = "0200102079485"
  5040. }
  5041. if org_id == 10721 {
  5042. struct3505.PharName = "孙莉侠"
  5043. struct3505.PharPracCertNo = "060399"
  5044. }
  5045. if org_id == 10726 {
  5046. struct3505.PharName = "彭建福"
  5047. struct3505.PharPracCertNo = "D445281006261"
  5048. }
  5049. if org_id == 10265 {
  5050. struct3505.PharName = "李彩星"
  5051. struct3505.PharPracCertNo = "20171110600110100019"
  5052. }
  5053. if org_id == 10028 {
  5054. struct3505.PharName = "曾细平"
  5055. struct3505.PharPracCertNo = "D440307022134"
  5056. }
  5057. if org_id == 10138 {
  5058. struct3505.PharName = "彭斯遥"
  5059. struct3505.PharPracCertNo = "30220200943042010052"
  5060. }
  5061. if org_id == 10278 {
  5062. struct3505.PharName = "彭斯遥"
  5063. struct3505.PharPracCertNo = "30220200943042010052"
  5064. }
  5065. if org_id == 10610 {
  5066. struct3505.PharName = "彭斯遥"
  5067. struct3505.PharPracCertNo = "30220200943042010052"
  5068. }
  5069. if org_id == 10537 {
  5070. struct3505.PharName = "彭斯遥"
  5071. struct3505.PharPracCertNo = "30220200943042010052"
  5072. }
  5073. if org_id == 9504 {
  5074. struct3505.PharName = "资美红"
  5075. struct3505.PharPracCertNo = "D440904006635"
  5076. }
  5077. if org_id == 10480 {
  5078. struct3505.PharName = "陈思"
  5079. struct3505.PharPracCertNo = "30220240434110010470"
  5080. }
  5081. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5082. struct3505.SetlId = order.SetlId
  5083. struct3505.MdtrtSn = order.MdtrtId
  5084. struct3505.ManuLotnum = drug.BatchNumber
  5085. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5086. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5087. struct3505.RxFlag = "1"
  5088. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5089. struct3505.TrdnFlag = "0"
  5090. } else {
  5091. struct3505.TrdnFlag = "1"
  5092. }
  5093. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5094. struct3505.TrdnFlag = "1"
  5095. }
  5096. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5097. struct3505.TrdnFlag = "0"
  5098. }
  5099. struct3505.RtalDocno = order.Number
  5100. struct3505.PsnCertType = "01"
  5101. struct3505.CertNo = order.Certno
  5102. struct3505.PsnNo = order.PsnNo
  5103. struct3505.PsnName = order.PsnName
  5104. struct3505.Url = miConfig.Url
  5105. struct3505.AppId = miConfig.Cainfo
  5106. struct3505.AppSecret = miConfig.AppSecret
  5107. struct3505.Enckey = miConfig.EncKey
  5108. struct3505.SignKey = miConfig.SignKey
  5109. struct3505.SecretKey = miConfig.SecretKey
  5110. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5111. struct3505.SelRetnCnt = strValue
  5112. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5113. struct3505.SelRetnOpterName = role.UserName
  5114. if order.IsMedicineInsurance == 1 {
  5115. struct3505.MdtrtSetlType = "1"
  5116. } else {
  5117. struct3505.MdtrtSetlType = "2"
  5118. }
  5119. struct3505.OrgName = miConfig.OrgName
  5120. struct3505.AccessKey = miConfig.AccessKey
  5121. struct3505.RequestUrl = miConfig.Url
  5122. struct3505.SecretKey = miConfig.SecretKey
  5123. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5124. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5125. struct3505.Cainfo = miConfig.Cainfo
  5126. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5127. if miConfig.MdtrtareaAdmvs == "350500" {
  5128. result1, result2, _ := service.FJyb3505(struct3505)
  5129. return result1, result2
  5130. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5131. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5132. return result1, result2
  5133. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5134. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5135. return result1, result2
  5136. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5137. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5138. return result1, result2
  5139. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5140. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5141. return result1, result2
  5142. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5143. data := make(map[string]interface{})
  5144. data["struct_3505s"] = struct3505
  5145. client := &http.Client{}
  5146. bytesData, _ := json.Marshal(data)
  5147. var req *http.Request
  5148. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5149. resp, _ := client.Do(req)
  5150. defer resp.Body.Close()
  5151. body, ioErr := ioutil.ReadAll(resp.Body)
  5152. if ioErr != nil {
  5153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5154. }
  5155. var respJSON map[string]interface{}
  5156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5158. }
  5159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5160. result, _ := json.Marshal(respJSON)
  5161. return string(result), ""
  5162. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5163. data := make(map[string]interface{})
  5164. data["struct_3505s"] = struct3505
  5165. client := &http.Client{}
  5166. bytesData, _ := json.Marshal(data)
  5167. var req *http.Request
  5168. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5169. resp, _ := client.Do(req)
  5170. defer resp.Body.Close()
  5171. body, ioErr := ioutil.ReadAll(resp.Body)
  5172. if ioErr != nil {
  5173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5174. }
  5175. var respJSON map[string]interface{}
  5176. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5178. }
  5179. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5180. if status == "0" {
  5181. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5182. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5183. }
  5184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5185. result, _ := json.Marshal(respJSON)
  5186. return string(result), ""
  5187. } else {
  5188. data := make(map[string]interface{})
  5189. data["struct_3505s"] = struct3505
  5190. client := &http.Client{}
  5191. bytesData, _ := json.Marshal(data)
  5192. var req *http.Request
  5193. if miConfig.MdtrtareaAdmvs == "320921" {
  5194. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5195. } else {
  5196. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5197. }
  5198. resp, _ := client.Do(req)
  5199. defer resp.Body.Close()
  5200. body, ioErr := ioutil.ReadAll(resp.Body)
  5201. if ioErr != nil {
  5202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5203. }
  5204. var respJSON map[string]interface{}
  5205. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5207. }
  5208. //var resSix10265 ResultSix10265 //1101结果
  5209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5210. result, _ := json.Marshal(respJSON)
  5211. return string(result), ""
  5212. }
  5213. }
  5214. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5215. var struct3505 models.Struct3505
  5216. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5217. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5218. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5219. struct3505.FixmedinsBchno = number
  5220. struct3505.Opter = role.UserName
  5221. struct3505.FixmedinsCode = miConfig.Code
  5222. struct3505.Code = miConfig.Code
  5223. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5224. struct3505.PrscDrName = roles.UserName
  5225. if org_id == 10191 {
  5226. struct3505.PharName = "刘水山"
  5227. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5228. }
  5229. if org_id == 10188 {
  5230. struct3505.PharName = "李汉清"
  5231. struct3505.PharPracCertNo = "30220200932022010034"
  5232. }
  5233. if org_id == 10217 {
  5234. struct3505.PharName = "张敏"
  5235. struct3505.PharPracCertNo = "30220230432090100108"
  5236. }
  5237. if org_id == 10318 {
  5238. struct3505.PharName = "邹刘阳"
  5239. struct3505.PharPracCertNo = "210441200001378"
  5240. }
  5241. if org_id == 10402 {
  5242. struct3505.PharName = "刘韶健"
  5243. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5244. }
  5245. if org_id == 9919 {
  5246. struct3505.PharName = "周君权"
  5247. struct3505.PharPracCertNo = "089644396094401375"
  5248. }
  5249. if org_id == 10644 {
  5250. struct3505.PharName = "陈金娣"
  5251. struct3505.PharPracCertNo = "20181441500320100066"
  5252. }
  5253. if org_id == 10567 {
  5254. struct3505.PharName = "范小兰"
  5255. struct3505.PharPracCertNo = "0200102079485"
  5256. }
  5257. if org_id == 10721 {
  5258. struct3505.PharName = "孙莉侠"
  5259. struct3505.PharPracCertNo = "060399"
  5260. }
  5261. if org_id == 10726 {
  5262. struct3505.PharName = "彭建福"
  5263. struct3505.PharPracCertNo = "D445281006261"
  5264. }
  5265. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5266. struct3505.SetlId = order.SetlId
  5267. struct3505.MdtrtSn = order.MdtrtId
  5268. struct3505.ManuLotnum = drug.Number
  5269. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5270. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5271. struct3505.RxFlag = "1"
  5272. struct3505.TrdnFlag = "0"
  5273. struct3505.RtalDocno = order.Number
  5274. struct3505.PsnCertType = "01"
  5275. struct3505.CertNo = order.Certno
  5276. struct3505.PsnNo = order.PsnNo
  5277. struct3505.PsnName = order.PsnName
  5278. struct3505.Url = miConfig.Url
  5279. struct3505.AppId = miConfig.Cainfo
  5280. struct3505.AppSecret = miConfig.AppSecret
  5281. struct3505.Enckey = miConfig.EncKey
  5282. struct3505.SignKey = miConfig.SignKey
  5283. struct3505.SecretKey = miConfig.SecretKey
  5284. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5285. struct3505.SelRetnCnt = strValue
  5286. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5287. struct3505.SelRetnOpterName = role.UserName
  5288. if order.IsMedicineInsurance == 1 {
  5289. struct3505.MdtrtSetlType = "1"
  5290. } else {
  5291. struct3505.MdtrtSetlType = "2"
  5292. }
  5293. struct3505.OrgName = miConfig.OrgName
  5294. struct3505.AccessKey = miConfig.AccessKey
  5295. struct3505.RequestUrl = miConfig.Url
  5296. struct3505.SecretKey = miConfig.SecretKey
  5297. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5298. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5299. struct3505.Cainfo = miConfig.Cainfo
  5300. struct3505.DrugTracCodg = drug.DrugCode
  5301. if miConfig.MdtrtareaAdmvs == "350500" {
  5302. result1, result2, _ := service.FJyb3505(struct3505)
  5303. return result1, result2
  5304. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5305. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5306. return result1, result2
  5307. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5308. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5309. return result1, result2
  5310. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5311. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5312. return result1, result2
  5313. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5314. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5315. return result1, result2
  5316. } else {
  5317. data := make(map[string]interface{})
  5318. data["struct_3505s"] = struct3505
  5319. client := &http.Client{}
  5320. bytesData, _ := json.Marshal(data)
  5321. var req *http.Request
  5322. if miConfig.MdtrtareaAdmvs == "320921" {
  5323. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5324. } else {
  5325. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5326. }
  5327. resp, _ := client.Do(req)
  5328. defer resp.Body.Close()
  5329. body, ioErr := ioutil.ReadAll(resp.Body)
  5330. if ioErr != nil {
  5331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5332. }
  5333. var respJSON map[string]interface{}
  5334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5336. }
  5337. //var resSix10265 ResultSix10265 //1101结果
  5338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5339. result, _ := json.Marshal(respJSON)
  5340. return string(result), ""
  5341. }
  5342. }
  5343. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5344. var struct3506 models.Struct3506
  5345. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5346. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5347. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5348. struct3506.FixmedinsCode = miConfig.Code
  5349. struct3506.Code = miConfig.Code
  5350. struct3506.FixmedinsBchno = number
  5351. struct3506.Opter = role.UserName
  5352. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5353. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5354. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5355. struct3506.MdtrtSn = order.MdtrtId
  5356. struct3506.ExpyEnd = ""
  5357. struct3506.RxFlag = "0"
  5358. struct3506.TrdnFlag = "1"
  5359. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5360. struct3506.SelRetnCnt = strValue
  5361. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5362. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5363. struct3506.SelRetnOpterName = role.UserName
  5364. struct3506.OrgName = miConfig.OrgName
  5365. struct3506.AccessKey = miConfig.AccessKey
  5366. struct3506.RequestUrl = miConfig.Url
  5367. struct3506.SecretKey = miConfig.SecretKey
  5368. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5369. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5370. struct3506.Url = miConfig.Url
  5371. struct3506.AppId = miConfig.Cainfo
  5372. struct3506.AppSecret = miConfig.AppSecret
  5373. struct3506.Enckey = miConfig.EncKey
  5374. struct3506.SignKey = miConfig.SignKey
  5375. struct3506.SecretKey = miConfig.SecretKey
  5376. struct3506.DrugTracCodg = drug.DrugCode
  5377. if miConfig.MdtrtareaAdmvs == "350500" {
  5378. result1, result2, _ := service.FJyb3506(struct3506)
  5379. return result1, result2
  5380. } else {
  5381. data := make(map[string]interface{})
  5382. data["struct_3506s"] = struct3506
  5383. client := &http.Client{}
  5384. bytesData, _ := json.Marshal(data)
  5385. var req *http.Request
  5386. if miConfig.MdtrtareaAdmvs == "320921" {
  5387. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5388. } else {
  5389. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5390. }
  5391. resp, _ := client.Do(req)
  5392. defer resp.Body.Close()
  5393. body, ioErr := ioutil.ReadAll(resp.Body)
  5394. if ioErr != nil {
  5395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5396. }
  5397. var respJSON map[string]interface{}
  5398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5400. }
  5401. //var resSix10265 ResultSix10265 //1101结果
  5402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5403. result, _ := json.Marshal(respJSON)
  5404. return string(result), ""
  5405. }
  5406. }
  5407. func (c *HisApiController) Get1318() {
  5408. adminUser := c.GetAdminUserInfo()
  5409. admin_user_id, _ := c.GetInt64("admin_user_id")
  5410. code := c.GetString("code")
  5411. code = ""
  5412. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5414. api := ""
  5415. if miConfig.MdtrtareaAdmvs == "320921" {
  5416. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5417. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5418. } else {
  5419. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5420. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5421. }
  5422. resp, requestErr := http.Get(api)
  5423. if requestErr != nil {
  5424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5425. return
  5426. }
  5427. body, ioErr := ioutil.ReadAll(resp.Body)
  5428. if ioErr != nil {
  5429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. var respJSON map[string]interface{}
  5434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5437. return
  5438. }
  5439. //var res Result2406
  5440. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5441. result, _ := json.Marshal(respJSON)
  5442. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5443. utils.ErrorLog("解析失败:%v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. if res.Infcode == "0" {
  5448. c.ServeSuccessJSON(map[string]interface{}{
  5449. "result": "",
  5450. })
  5451. } else {
  5452. c.ServeSuccessJSON(map[string]interface{}{
  5453. "failed_code": -10,
  5454. "msg": res.ErrMsg,
  5455. })
  5456. */return
  5457. //}
  5458. }
  5459. func (c *HisApiController) Get2503() {
  5460. adminUser := c.GetAdminUserInfo()
  5461. admin_user_id, _ := c.GetInt64("admin_user_id")
  5462. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5464. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5465. }
  5466. func (c *HisApiController) Get2406() {
  5467. id, _ := c.GetInt64("id")
  5468. record_time := c.GetString("record_time")
  5469. his_patient_id, _ := c.GetInt64("his_patient_id")
  5470. admin_user_id, _ := c.GetInt64("admin_user_id")
  5471. diagnosis_id := c.GetString("diagnosis")
  5472. timeLayout := "2006-01-02"
  5473. loc, _ := time.LoadLocation("Local")
  5474. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5475. if err != nil {
  5476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5477. return
  5478. }
  5479. recordDateTime := theTime.Unix()
  5480. adminUser := c.GetAdminUserInfo()
  5481. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5482. var config []*models.HisXtDiagnoseConfig
  5483. for _, item := range diagnosis_ids {
  5484. id, _ := strconv.ParseInt(item, 10, 64)
  5485. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5486. config = append(config, &diagnosisConfig)
  5487. }
  5488. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5489. fmt.Println(his_patient_id)
  5490. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5491. //timestamp := time.Now().Unix()
  5492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5493. var patientPrescription models.HisPrescriptionInfo
  5494. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5495. if patientPrescription.ID == 0 {
  5496. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5497. }
  5498. var res2 Result2406
  5499. if miConfig.MdtrtareaAdmvs == "341203" {
  5500. data := make(map[string]interface{})
  5501. client := &http.Client{}
  5502. data["psn_no"] = his.PsnNo
  5503. data["mdtrt_id"] = his.Number
  5504. data["operator"] = roles.UserName
  5505. data["cert_no"] = his.IdCardNo
  5506. data["org_name"] = miConfig.OrgName
  5507. data["psn_name"] = his.Name
  5508. data["ipt_otp_no"] = his.IptOtpNo
  5509. data["ipt_psn_sp_flag_type"] = "0901"
  5510. data["ipt_psn_sp_flag"] = "1"
  5511. data["fixmedins_code"] = miConfig.Code
  5512. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5513. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5514. data["url"] = miConfig.Url
  5515. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5516. bytesData, _ := json.Marshal(data)
  5517. var req *http.Request
  5518. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5519. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5520. resp, _ := client.Do(req)
  5521. defer resp.Body.Close()
  5522. body, ioErr := ioutil.ReadAll(resp.Body)
  5523. if ioErr != nil {
  5524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5526. return
  5527. }
  5528. var respJSON map[string]interface{}
  5529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5532. return
  5533. }
  5534. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5535. if status == "0" {
  5536. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5537. c.ServeSuccessJSON(map[string]interface{}{
  5538. "failed_code": -10,
  5539. "msg": err_msg,
  5540. })
  5541. return
  5542. }
  5543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5544. userJSONBytes, _ := json.Marshal(respJSON)
  5545. fmt.Println("log")
  5546. fmt.Println(string(userJSONBytes))
  5547. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5548. utils.ErrorLog("解析失败:%v", err)
  5549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5550. return
  5551. }
  5552. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5553. data := make(map[string]interface{})
  5554. client := &http.Client{}
  5555. data["psn_no"] = his.PsnNo
  5556. data["mdtrt_id"] = his.Number
  5557. data["operator"] = roles.UserName
  5558. data["cert_no"] = his.IdCardNo
  5559. data["org_name"] = miConfig.OrgName
  5560. data["psn_name"] = his.Name
  5561. data["ipt_otp_no"] = his.IptOtpNo
  5562. data["ipt_psn_sp_flag_type"] = "0901"
  5563. data["ipt_psn_sp_flag"] = "1"
  5564. data["fixmedins_code"] = miConfig.Code
  5565. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5566. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5567. data["url"] = miConfig.Url
  5568. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5569. bytesData, _ := json.Marshal(data)
  5570. var req *http.Request
  5571. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5572. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5573. resp, _ := client.Do(req)
  5574. defer resp.Body.Close()
  5575. body, ioErr := ioutil.ReadAll(resp.Body)
  5576. if ioErr != nil {
  5577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5579. return
  5580. }
  5581. var respJSON map[string]interface{}
  5582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5585. return
  5586. }
  5587. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5588. if status == "0" {
  5589. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5590. c.ServeSuccessJSON(map[string]interface{}{
  5591. "failed_code": -10,
  5592. "msg": err_msg,
  5593. })
  5594. return
  5595. }
  5596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5597. userJSONBytes, _ := json.Marshal(respJSON)
  5598. fmt.Println("log")
  5599. fmt.Println(string(userJSONBytes))
  5600. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5601. utils.ErrorLog("解析失败:%v", err)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. }
  5606. if res2.Infcode != 0 {
  5607. adminUser := c.GetAdminUserInfo()
  5608. errlog := &models.HisOrderError{
  5609. UserOrgId: adminUser.CurrentOrgId,
  5610. Ctime: time.Now().Unix(),
  5611. Mtime: time.Now().Unix(),
  5612. ErrMsg: res2.ErrMsg,
  5613. Status: 1,
  5614. PatientId: id,
  5615. RecordTime: recordDateTime,
  5616. Stage: 3,
  5617. }
  5618. service.CreateErrMsgLog(errlog)
  5619. c.ServeSuccessJSON(map[string]interface{}{
  5620. "failed_code": -10,
  5621. "msg": res2.ErrMsg,
  5622. })
  5623. return
  5624. } else {
  5625. c.ServeSuccessJSON(map[string]interface{}{
  5626. "msg": "上传成功",
  5627. })
  5628. return
  5629. }
  5630. }
  5631. func (c *HisApiController) Get4105() {
  5632. }
  5633. func (c *HisApiController) Post5302() {
  5634. patient_id, _ := c.GetInt64("id")
  5635. admin_user_id, _ := c.GetInt64("admin_user_id")
  5636. p, _ := service.GetHisPatientById(patient_id)
  5637. adminUser := c.GetAdminUserInfo()
  5638. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5639. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5640. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5641. }
  5642. func (c *HisApiController) Get4104() {
  5643. }
  5644. type Output struct {
  5645. CertNo string `json:"certno"`
  5646. PsnName string `json:"psn_name"`
  5647. CardNo string `json:"card_no"`
  5648. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5649. CardSN string `json:"card_sn"`
  5650. PsnCertType string `json:"psn_cert_type"`
  5651. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5652. MdtrtCertType string `json:"mdtrt_cert_type"`
  5653. QRCode string `json:"qrCode"`
  5654. EcToken string `json:"ecToken"`
  5655. }
  5656. type AHResponse struct {
  5657. Body AHBody `json:"body"`
  5658. Code int `json:"code"`
  5659. CSBCode int `json:"csbCode"`
  5660. Message string `json:"message"`
  5661. RequestID string `json:"requestId"`
  5662. State struct{} `json:"state"`
  5663. }
  5664. type AHBody struct {
  5665. ErrMsg string `json:"err_msg"`
  5666. InfRefMsgID string `json:"inf_refmsgid"`
  5667. InfCode int `json:"infcode"`
  5668. Output struct {
  5669. Result []struct {
  5670. BasMednFlag string `json:"bas_medn_flag"`
  5671. ChldMedcFlag string `json:"chld_medc_flag"`
  5672. ChrgitmLv string `json:"chrgitm_lv"`
  5673. Cnt float64 `json:"cnt"`
  5674. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5675. DrtReimFlag string `json:"drt_reim_flag"`
  5676. FeedetlSn string `json:"feedetl_sn"`
  5677. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5678. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5680. ListSpItemFlag string `json:"list_sp_item_flag"`
  5681. LmtUsedFlag string `json:"lmt_used_flag"`
  5682. MedChrgitmType string `json:"med_chrgitm_type"`
  5683. Memo string `json:"memo"`
  5684. OverlmtAmt float64 `json:"overlmt_amt"`
  5685. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5686. Pric float64 `json:"pric"`
  5687. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5688. SelfpayProp float64 `json:"selfpay_prop"`
  5689. } `json:"result"`
  5690. } `json:"output"`
  5691. }
  5692. type Response struct {
  5693. Output Output `json:"output"`
  5694. Infcode int `json:"infcode"`
  5695. InfRefMsgID string `json:"inf_refmsgid"`
  5696. RefMsgTime string `json:"refmsg_time"`
  5697. RespondTime string `json:"respond_time"`
  5698. ErrMsg string `json:"err_msg"`
  5699. WarnMsg string `json:"warn_msg"`
  5700. SignType string `json:"signtype"`
  5701. CAInfo string `json:"cainfo"`
  5702. }
  5703. func (c *HisApiController) Getquerydata() {
  5704. query_type, _ := c.GetInt64("type")
  5705. refd_setl_flag := c.GetString("refd_setl_flag")
  5706. med_type := c.GetString("med_type")
  5707. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5708. cert_no := c.GetString("cert_no")
  5709. psn_no := c.GetString("psn_no")
  5710. start_time := c.GetString("start_time")
  5711. end_time := c.GetString("end_time")
  5712. page, _ := c.GetInt64("page")
  5713. limit, _ := c.GetInt64("limit")
  5714. var bp models.BusinessParams5262
  5715. bp.RefdSetlFlag = refd_setl_flag
  5716. bp.MedType = med_type
  5717. bp.Certno = cert_no
  5718. bp.Psnno = psn_no
  5719. bp.QBegntime = start_time
  5720. bp.QEndtime = end_time
  5721. if query_type == 1 { //本地
  5722. Post5262(c, bp, page, limit)
  5723. } else { //异地
  5724. Post5267(c, bp, page, limit)
  5725. }
  5726. }
  5727. func (c *HisApiController) Drugscheck() {
  5728. admin_user_id, _ := c.GetInt64("admin_user_id")
  5729. adminUser := c.GetAdminUserInfo()
  5730. var queryResult []QueryResult
  5731. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5732. for _, item := range drugs {
  5733. result := QueryResult{
  5734. ID: item.ID,
  5735. Name: item.DrugName,
  5736. Code: item.MedicalInsuranceNumber,
  5737. List_type_code: "101",
  5738. }
  5739. queryResult = append(queryResult, result)
  5740. }
  5741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5742. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5744. for _, item := range queryResult {
  5745. 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)
  5746. }
  5747. }
  5748. func (c *HisApiController) Goodcheck() {
  5749. admin_user_id, _ := c.GetInt64("admin_user_id")
  5750. adminUser := c.GetAdminUserInfo()
  5751. var queryResult []QueryResult
  5752. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5753. for _, item := range goods {
  5754. result := QueryResult{
  5755. ID: item.ID,
  5756. Name: item.GoodName,
  5757. Code: item.SocialSecurityDirectoryCode,
  5758. List_type_code: "301",
  5759. }
  5760. queryResult = append(queryResult, result)
  5761. }
  5762. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5763. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5764. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5765. for _, item := range queryResult {
  5766. 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)
  5767. //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)
  5768. }
  5769. }
  5770. func (c *HisApiController) Projectcheck() {
  5771. admin_user_id, _ := c.GetInt64("admin_user_id")
  5772. adminUser := c.GetAdminUserInfo()
  5773. var queryResult []QueryResult
  5774. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5775. for _, item := range projects {
  5776. result := QueryResult{
  5777. ID: item.ID,
  5778. Name: item.ProjectName,
  5779. Code: item.MedicalCode,
  5780. List_type_code: "201",
  5781. }
  5782. queryResult = append(queryResult, result)
  5783. }
  5784. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5785. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5786. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5787. for _, item := range queryResult {
  5788. 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)
  5789. }
  5790. }
  5791. //func (c *HisApiController)CancleDia(){
  5792. //
  5793. // id, _ := c.GetInt64("id")
  5794. // record_time := c.GetString("record_time")
  5795. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5796. //
  5797. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5798. //
  5799. // diagnosis_id := c.GetString("diagnosis")
  5800. // sick_type, _ := c.GetInt64("sick_type")
  5801. // reg_type, _ := c.GetInt64("p_type")
  5802. // begin_time := c.GetString("begin_time")
  5803. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5804. //
  5805. //
  5806. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5807. //
  5808. // fmt.Println(acct_used_flag)
  5809. //
  5810. //
  5811. // timeLayout := "2006-01-02"
  5812. // loc, _ := time.LoadLocation("Local")
  5813. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5814. // if err != nil {
  5815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5816. // return
  5817. // }
  5818. // recordDateTime := theTime.Unix()
  5819. // adminUser := c.GetAdminUserInfo()
  5820. //
  5821. //
  5822. //
  5823. //
  5824. //
  5825. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5826. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5827. // var patientPrescription models.HisPrescriptionInfo
  5828. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5829. // if patientPrescription.ID == 0 {
  5830. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5831. // }
  5832. // //if patientPrescription.Do
  5833. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5834. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5835. //
  5836. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5837. //
  5838. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5839. //
  5840. // var config []*models.HisXtDiagnoseConfig
  5841. // for _, item := range diagnosis_ids {
  5842. // id, _ := strconv.ParseInt(item, 10, 64)
  5843. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5844. // config = append(config, &diagnosisConfig)
  5845. // }
  5846. //
  5847. // sickConfig, _ := service.FindSickById(sick_type)
  5848. //
  5849. //
  5850. // data := make(map[string]interface{})
  5851. // client := &http.Client{}
  5852. // data["psn_no"] = his.PsnNo
  5853. // data["mdtrt_id"] = his.Number
  5854. // data["doctor"] = roles.UserName
  5855. // data["department"] = department.Name
  5856. // data["org_name"] = miConfig.OrgName
  5857. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5858. // data["doctor_id"] = doctor_info.DoctorNumber
  5859. // data["new_doctor_name"] = doctor_info.UserName
  5860. // data["fixmedins_code"] = miConfig.Code
  5861. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5862. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5863. // data["secret_key"] = miConfig.SecretKey
  5864. // data["sick_code"] = sickConfig.CountryCode
  5865. // data["sick_name"] = sickConfig.ClassName
  5866. // data["url"] = miConfig.Url
  5867. // data["ak"] = miConfig.AccessKey
  5868. // data["begin_time"] = begin_time
  5869. // data["cainfo"] = miConfig.Cainfo
  5870. // data["is_vaild"] = "0"
  5871. //
  5872. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5873. // data["config"] = config
  5874. // bytesData, _ := json.Marshal(data)
  5875. //
  5876. // var req *http.Request
  5877. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5878. // resp, _ := client.Do(req)
  5879. // defer resp.Body.Close()
  5880. // body, ioErr := ioutil.ReadAll(resp.Body)
  5881. // if ioErr != nil {
  5882. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. // return
  5885. // }
  5886. // var respJSON map[string]interface{}
  5887. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5888. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. // return
  5891. // }
  5892. //
  5893. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5894. // userJSONBytes, _ := json.Marshal(respJSON)
  5895. // fmt.Println("log")
  5896. // fmt.Println(string(userJSONBytes))
  5897. //
  5898. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5899. // utils.ErrorLog("解析失败:%v", err)
  5900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5901. // return
  5902. // }
  5903. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5904. // res2.Output = ressix10265.Output
  5905. // res2.ErrMsg = ressix10265.ErrMsg
  5906. // res2.Cainfo = ressix10265.Cainfo
  5907. // res2.WarnMsg = ressix10265.WarnMsg
  5908. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5909. // res2.Infcode = infocode
  5910. //
  5911. //}
  5912. func (c *HisApiController) Get4102() {
  5913. order_id, _ := c.GetInt64("order_id")
  5914. admin_user_id, _ := c.GetInt64("admin_user_id")
  5915. stas_type := c.GetString("stas_type")
  5916. order, _ := service.GetHisOrderByIDTwo(order_id)
  5917. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5918. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5919. var pp models.PublicParams
  5920. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5921. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5922. pp.FixmedinsName = miConfig.OrgName
  5923. pp.FixmedinsCode = miConfig.Code
  5924. pp.RequestUrl = miConfig.Url
  5925. pp.Cainfo = miConfig.Cainfo
  5926. pp.SecretKey = miConfig.SecretKey
  5927. pp.AccessKey = miConfig.AccessKey
  5928. pp.OpterName = curRoles.UserName
  5929. if miConfig.MdtrtareaAdmvs == "350500" {
  5930. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5931. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5932. saveLog(result, request, "4102", "清单确认")
  5933. var dat map[string]interface{}
  5934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5935. fmt.Println(dat)
  5936. } else {
  5937. fmt.Println(err)
  5938. }
  5939. var empty ResultFourteen
  5940. userJSONBytes, _ := json.Marshal(dat)
  5941. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5942. utils.ErrorLog("解析失败:%v", err)
  5943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5944. return
  5945. }
  5946. if empty.Infcode == 0 {
  5947. c.ServeSuccessJSON(map[string]interface{}{
  5948. "msg": "确认成功",
  5949. })
  5950. return
  5951. }
  5952. } else {
  5953. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5954. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5955. result3, request3 := service.Jxyb4105(pp)
  5956. saveLog(result, request, "4102", "清单确认")
  5957. saveLog(result2, request2, "4103", "清单确认")
  5958. saveLog(result3, request3, "4105", "清单统计")
  5959. var dat map[string]interface{}
  5960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5961. fmt.Println(dat)
  5962. } else {
  5963. fmt.Println(err)
  5964. }
  5965. var empty ResultFourteen
  5966. userJSONBytes, _ := json.Marshal(dat)
  5967. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5968. utils.ErrorLog("解析失败:%v", err)
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. return
  5971. }
  5972. if empty.Infcode == 0 {
  5973. c.ServeSuccessJSON(map[string]interface{}{
  5974. "msg": "确认成功",
  5975. })
  5976. return
  5977. }
  5978. }
  5979. }
  5980. // 对账权限查询
  5981. func (c *HisApiController) Get3260() {
  5982. admin_user_id, _ := c.GetInt64("admin_user_id")
  5983. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5984. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5985. var api string
  5986. var res models.JSResult3260
  5987. if miConfig.MdtrtareaAdmvs == "320921" {
  5988. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5989. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5990. } else {
  5991. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5992. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5993. }
  5994. resp, requestErr := http.Get(api)
  5995. if requestErr != nil {
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5997. return
  5998. }
  5999. body, ioErr := ioutil.ReadAll(resp.Body)
  6000. if ioErr != nil {
  6001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6003. return
  6004. }
  6005. var respJSON map[string]interface{}
  6006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return
  6010. }
  6011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6012. result, _ := json.Marshal(respJSON)
  6013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6014. utils.ErrorLog("解析失败:%v", err)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return
  6017. }
  6018. if res.Infcode == "0" {
  6019. c.ServeSuccessJSON(map[string]interface{}{
  6020. "result": res.Output.Data,
  6021. })
  6022. } else {
  6023. c.ServeSuccessJSON(map[string]interface{}{
  6024. "failed_code": -10,
  6025. "msg": res.ErrMsg,
  6026. })
  6027. return
  6028. }
  6029. }
  6030. func (c *HisApiController) Get3261() {
  6031. admin_user_id, _ := c.GetInt64("admin_user_id")
  6032. //month := c.GetString("month")
  6033. startTime := c.GetString("start_time")
  6034. //endTime, _ := c.GetString("end_time")
  6035. times := strings.Split(startTime, "-")
  6036. stmt_mon := times[0] + times[1]
  6037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6039. var api string
  6040. var res models.JSResult3261
  6041. //var res10265 Result5301For10265
  6042. if miConfig.MdtrtareaAdmvs == "320921" {
  6043. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6044. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6045. } else {
  6046. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6047. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6048. }
  6049. resp, requestErr := http.Get(api)
  6050. if requestErr != nil {
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. body, ioErr := ioutil.ReadAll(resp.Body)
  6055. if ioErr != nil {
  6056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6058. return
  6059. }
  6060. var respJSON map[string]interface{}
  6061. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6064. return
  6065. }
  6066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6067. result, _ := json.Marshal(respJSON)
  6068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6069. utils.ErrorLog("解析失败:%v", err)
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. return
  6072. }
  6073. if res.Infcode == "0" {
  6074. c.ServeSuccessJSON(map[string]interface{}{
  6075. "result": res.Output,
  6076. })
  6077. } else {
  6078. c.ServeSuccessJSON(map[string]interface{}{
  6079. "failed_code": -10,
  6080. "msg": res.ErrMsg,
  6081. })
  6082. return
  6083. }
  6084. }
  6085. type TempFun struct {
  6086. FundKey string
  6087. FundCode string
  6088. }
  6089. func (c *HisApiController) Get3262() {
  6090. admin_user_id, _ := c.GetInt64("admin_user_id")
  6091. startTime := c.GetString("start_time")
  6092. endTime := c.GetString("end_time")
  6093. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6094. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6095. //timeLayout := "2006-01-02"
  6096. //loc, _ := time.LoadLocation("Local")
  6097. //var theStartTIme int64
  6098. //if len(startTime) > 0 {
  6099. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6100. // if err != nil {
  6101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6102. // return
  6103. // }
  6104. // theStartTIme = theTime.Unix()
  6105. //}
  6106. //var theEndtTIme int64
  6107. //if len(endTime) > 0 {
  6108. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6109. // if err != nil {
  6110. // utils.ErrorLog(err.Error())
  6111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6112. // return
  6113. // }
  6114. // theEndtTIme = theTime.Unix()
  6115. //}
  6116. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6117. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6118. for _, team := range datas {
  6119. fmt.Println(team.PsnTime)
  6120. for _, team_two := range datas_two {
  6121. fmt.Println(team_two.PsnTime)
  6122. if team.FundKey == team_two.FundKey {
  6123. fmt.Println(team_two.PsnTime)
  6124. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6125. fmt.Println(team.PsnTime)
  6126. }
  6127. }
  6128. }
  6129. fmt.Println("1111")
  6130. fmt.Println(datas)
  6131. fmt.Println("1111")
  6132. var twos []models.FixMonRecDetailFileInTwo
  6133. for _, team := range datas {
  6134. var two models.FixMonRecDetailFileInTwo
  6135. two.MedType = team.MedType
  6136. two.Insutype = team.Insutype
  6137. two.PsnType = team.PsnType
  6138. two.MedType = team.MedType
  6139. two.FixBlngAdmdvs = "999999"
  6140. two.InsuAdmdvs = "555555"
  6141. two.PsnTime = team.PsnTime
  6142. two.PsnCnt = team.PsnCnt
  6143. two.FundKey = team.FundKey
  6144. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6145. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6146. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6147. two.MedfeeSumAmt = ms
  6148. two.InscpAmt = ia
  6149. two.FundPaySumAmt = fps
  6150. twos = append(twos, two)
  6151. }
  6152. //startTime := c.GetString("start_time")
  6153. //endTime, _ := c.GetString("end_time")
  6154. times := strings.Split(startTime, "-")
  6155. stmt_mon := times[0] + times[1]
  6156. var funs []models.FundDetail
  6157. for _, item := range datas {
  6158. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6159. funs = append(funs, fun...)
  6160. }
  6161. var funInfos []models.Fund
  6162. //for _, item := range funs {
  6163. // var rf []models.FundInfo
  6164. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6165. // for _, subitem := range rf {
  6166. // var fund models.Fund
  6167. // fund.FundCode = subitem.FundPayType
  6168. // fund.FundName = subitem.FundPayTypeName
  6169. // fund.FundAmt = subitem.FundPayAmt
  6170. // fund.FundKey = item.FundKey
  6171. // fund.InsuAdmdvs = "555555"
  6172. // fund.FixBlngAdmdvs = "999999"
  6173. // funInfos = append(funInfos, fund)
  6174. // }
  6175. //}
  6176. var tempFuns []TempFun
  6177. for _, funInfo := range funInfos {
  6178. var tempFun TempFun
  6179. tempFun.FundKey = funInfo.FundKey
  6180. tempFun.FundCode = funInfo.FundCode
  6181. tempFuns = append(tempFuns, tempFun)
  6182. }
  6183. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6184. fmt.Println(tempFuns)
  6185. var funInfosTwo []models.Fund
  6186. decimal.DivisionPrecision = 2
  6187. for _, item := range tempFuns {
  6188. var fund models.Fund
  6189. for _, subItem := range funInfos {
  6190. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6191. fund.FundKey = subItem.FundKey
  6192. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6193. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6194. fund.FundName = subItem.FundName
  6195. fund.FundCode = subItem.FundCode
  6196. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6197. }
  6198. }
  6199. funInfosTwo = append(funInfosTwo, fund)
  6200. }
  6201. fmt.Println("funInfosTwo")
  6202. fmt.Println(funInfosTwo)
  6203. var upld_btch string
  6204. var empty models.JSResultEmpty
  6205. data := make(map[string]interface{})
  6206. data["org_name"] = miConfig.OrgName
  6207. data["doctor"] = curRoles.UserName
  6208. data["doctor_name"] = curRoles.UserName
  6209. data["fixmedins_code"] = miConfig.Code
  6210. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6212. data["secret_key"] = miConfig.SecretKey
  6213. data["url"] = miConfig.Url
  6214. data["ak"] = miConfig.AccessKey
  6215. data["cainfo"] = miConfig.Cainfo
  6216. data["datas"] = twos
  6217. data["fund"] = funInfosTwo
  6218. fmt.Println(twos)
  6219. month := time.Unix(1557042972, 0).Format("1")
  6220. year := time.Now().Format("2006")
  6221. month = time.Now().Format("01")
  6222. day := time.Now().Format("02")
  6223. hour := time.Now().Format("15")
  6224. min := time.Now().Format("04")
  6225. sec := time.Now().Format("05")
  6226. fix_fill_date := year + month + day + hour + min + sec
  6227. data["fix_fill_dept"] = miConfig.OrgName
  6228. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6229. data["fix_fill_psn"] = curRoles.UserName
  6230. data["fix_fill_date"] = fix_fill_date
  6231. data["stmt_loc"] = "2"
  6232. data["setl_mon"] = stmt_mon
  6233. upld_btch = "0"
  6234. data["upld_btch"] = upld_btch
  6235. //fmt.Println(data)
  6236. client := &http.Client{}
  6237. bytesData, _ := json.Marshal(data)
  6238. var req *http.Request
  6239. if miConfig.MdtrtareaAdmvs == "320921" {
  6240. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6241. } else {
  6242. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6243. }
  6244. resp, _ := client.Do(req)
  6245. defer resp.Body.Close()
  6246. body, ioErr := ioutil.ReadAll(resp.Body)
  6247. if ioErr != nil {
  6248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6250. }
  6251. var respJSON map[string]interface{}
  6252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. }
  6256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6257. //fmt.Println(respJSON)
  6258. result, _ := json.Marshal(respJSON)
  6259. //fmt.Println(result)
  6260. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6261. utils.ErrorLog("解析失败:%v", err)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. }
  6264. if empty.Infcode != "0" {
  6265. c.ServeSuccessJSON(map[string]interface{}{
  6266. "failed_code": -10,
  6267. "msg": empty.ErrMsg,
  6268. })
  6269. return
  6270. } else {
  6271. c.ServeSuccessJSON(map[string]interface{}{
  6272. "msg": "上传成功",
  6273. })
  6274. return
  6275. }
  6276. }
  6277. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6278. newArr = make([]TempFun, 0)
  6279. for i := 0; i < len(arr); i++ {
  6280. repeat := false
  6281. for j := i + 1; j < len(arr); j++ {
  6282. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6283. repeat = true
  6284. break
  6285. }
  6286. }
  6287. if !repeat {
  6288. newArr = append(newArr, arr[i])
  6289. }
  6290. }
  6291. return
  6292. }
  6293. func (c *HisApiController) Get3263() {
  6294. admin_user_id, _ := c.GetInt64("admin_user_id")
  6295. startTime := c.GetString("start_time")
  6296. //endTime, _ := c.GetString("end_time")
  6297. times := strings.Split(startTime, "-")
  6298. setl_mon := times[0] + times[1]
  6299. upld_btch := "0"
  6300. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6302. var result3263 models.JSResult3263
  6303. data := make(map[string]interface{})
  6304. data["org_name"] = miConfig.OrgName
  6305. data["doctor"] = curRoles.UserName
  6306. data["doctor_name"] = curRoles.UserName
  6307. data["fixmedins_code"] = miConfig.Code
  6308. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6309. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6310. data["secret_key"] = miConfig.SecretKey
  6311. data["url"] = miConfig.Url
  6312. data["ak"] = miConfig.AccessKey
  6313. data["cainfo"] = miConfig.Cainfo
  6314. data["setl_mon"] = setl_mon
  6315. data["stmt_loc"] = "2"
  6316. data["upld_btch"] = upld_btch
  6317. client := &http.Client{}
  6318. bytesData, _ := json.Marshal(data)
  6319. var req *http.Request
  6320. if miConfig.MdtrtareaAdmvs == "320921" {
  6321. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6322. } else {
  6323. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6324. }
  6325. resp, _ := client.Do(req)
  6326. defer resp.Body.Close()
  6327. body, ioErr := ioutil.ReadAll(resp.Body)
  6328. if ioErr != nil {
  6329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6331. }
  6332. var respJSON map[string]interface{}
  6333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6336. }
  6337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6338. fmt.Println(respJSON)
  6339. result, _ := json.Marshal(respJSON)
  6340. fmt.Println(result)
  6341. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6342. utils.ErrorLog("解析失败:%v", err)
  6343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6344. }
  6345. if result3263.Infcode != "0" {
  6346. c.ServeSuccessJSON(map[string]interface{}{
  6347. "failed_code": -10,
  6348. "msg": result3263.ErrMsg,
  6349. })
  6350. return
  6351. } else {
  6352. c.ServeSuccessJSON(map[string]interface{}{
  6353. "list": result3263.Output,
  6354. })
  6355. return
  6356. }
  6357. }
  6358. func (c *HisApiController) Get3264() {
  6359. admin_user_id, _ := c.GetInt64("admin_user_id")
  6360. startTime := c.GetString("start_time")
  6361. //endTime, _ := c.GetString("end_time")
  6362. times := strings.Split(startTime, "-")
  6363. setl_mon := times[0] + times[1]
  6364. upld_btch := "0"
  6365. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6367. //solidify_id := []
  6368. var result3263 models.JSResult3263
  6369. data := make(map[string]interface{})
  6370. data["org_name"] = miConfig.OrgName
  6371. data["doctor"] = curRoles.UserName
  6372. data["doctor_name"] = curRoles.UserName
  6373. data["fixmedins_code"] = miConfig.Code
  6374. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6376. data["secret_key"] = miConfig.SecretKey
  6377. data["url"] = miConfig.Url
  6378. data["ak"] = miConfig.AccessKey
  6379. data["cainfo"] = miConfig.Cainfo
  6380. data["setl_mon"] = setl_mon
  6381. data["stmt_loc"] = "2"
  6382. data["upld_btch"] = upld_btch
  6383. client := &http.Client{}
  6384. bytesData, _ := json.Marshal(data)
  6385. var req3263 *http.Request
  6386. if miConfig.MdtrtareaAdmvs == "320921" {
  6387. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6388. } else {
  6389. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6390. }
  6391. resp, _ := client.Do(req3263)
  6392. defer resp.Body.Close()
  6393. body, ioErr := ioutil.ReadAll(resp.Body)
  6394. if ioErr != nil {
  6395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. }
  6398. var respJSON3263 map[string]interface{}
  6399. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6402. }
  6403. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6404. fmt.Println(respJSON3263)
  6405. result, _ := json.Marshal(respJSON3263)
  6406. fmt.Println(result)
  6407. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6408. utils.ErrorLog("解析失败:%v", err)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. }
  6411. var ids []string
  6412. for _, item := range result3263.Output {
  6413. ids = append(ids, item.SolidifyID)
  6414. }
  6415. var empty models.JSResultEmpty
  6416. data2 := make(map[string]interface{})
  6417. data2["org_name"] = miConfig.OrgName
  6418. data2["doctor"] = curRoles.UserName
  6419. data2["doctor_name"] = curRoles.UserName
  6420. data2["fixmedins_code"] = miConfig.Code
  6421. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6422. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6423. data2["secret_key"] = miConfig.SecretKey
  6424. data2["url"] = miConfig.Url
  6425. data2["ak"] = miConfig.AccessKey
  6426. data2["cainfo"] = miConfig.Cainfo
  6427. data2["setl_mon"] = setl_mon
  6428. data2["stmt_loc"] = "2"
  6429. data2["upld_btch"] = upld_btch
  6430. data2["solidify_id"] = ids
  6431. client2 := &http.Client{}
  6432. bytesData2, _ := json.Marshal(data2)
  6433. var req *http.Request
  6434. if miConfig.MdtrtareaAdmvs == "320921" {
  6435. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6436. } else {
  6437. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6438. }
  6439. resp2, _ := client2.Do(req)
  6440. defer resp.Body.Close()
  6441. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6442. if ioErr2 != nil {
  6443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6445. }
  6446. var respJSON map[string]interface{}
  6447. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6450. }
  6451. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6452. fmt.Println(respJSON)
  6453. result2, _ := json.Marshal(respJSON)
  6454. fmt.Println(result2)
  6455. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6456. utils.ErrorLog("解析失败:%v", err)
  6457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6458. }
  6459. if empty.Infcode != "0" {
  6460. c.ServeSuccessJSON(map[string]interface{}{
  6461. "failed_code": -10,
  6462. "msg": empty.ErrMsg,
  6463. })
  6464. return
  6465. } else {
  6466. c.ServeSuccessJSON(map[string]interface{}{
  6467. "msg": "",
  6468. })
  6469. return
  6470. }
  6471. }
  6472. func (c *HisApiController) Get3265() {
  6473. admin_user_id, _ := c.GetInt64("admin_user_id")
  6474. startTime := c.GetString("start_time")
  6475. //endTime, _ := c.GetString("end_time")
  6476. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6477. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6478. times := strings.Split(startTime, "-")
  6479. setl_mon := times[0] + times[1]
  6480. var upld_btch string
  6481. upld_btch = "0"
  6482. //var empty models.JSResultEmpty
  6483. var result3265 models.JSResult3264
  6484. var result3263 models.JSResult3263
  6485. data2 := make(map[string]interface{})
  6486. data2["org_name"] = miConfig.OrgName
  6487. data2["doctor"] = curRoles.UserName
  6488. data2["doctor_name"] = curRoles.UserName
  6489. data2["fixmedins_code"] = miConfig.Code
  6490. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6491. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6492. data2["secret_key"] = miConfig.SecretKey
  6493. data2["url"] = miConfig.Url
  6494. data2["ak"] = miConfig.AccessKey
  6495. data2["cainfo"] = miConfig.Cainfo
  6496. data2["setl_mon"] = setl_mon
  6497. data2["stmt_loc"] = "2"
  6498. data2["upld_btch"] = upld_btch
  6499. client2 := &http.Client{}
  6500. bytesData2, _ := json.Marshal(data2)
  6501. var req3263 *http.Request
  6502. if miConfig.MdtrtareaAdmvs == "320921" {
  6503. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6504. } else {
  6505. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6506. }
  6507. resp2, _ := client2.Do(req3263)
  6508. defer resp2.Body.Close()
  6509. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6510. if ioErr2 != nil {
  6511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6513. }
  6514. var respJSON3263 map[string]interface{}
  6515. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6518. }
  6519. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6520. fmt.Println(respJSON3263)
  6521. result2, _ := json.Marshal(respJSON3263)
  6522. fmt.Println(result2)
  6523. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6524. utils.ErrorLog("解析失败:%v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. }
  6527. var ids []string
  6528. for _, item := range result3263.Output {
  6529. ids = append(ids, item.SolidifyID)
  6530. }
  6531. data := make(map[string]interface{})
  6532. data["org_name"] = miConfig.OrgName
  6533. data["doctor"] = curRoles.UserName
  6534. data["doctor_name"] = curRoles.UserName
  6535. data["fixmedins_code"] = miConfig.Code
  6536. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6537. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6538. data["secret_key"] = miConfig.SecretKey
  6539. data["url"] = miConfig.Url
  6540. data["ak"] = miConfig.AccessKey
  6541. data["cainfo"] = miConfig.Cainfo
  6542. data["setl_mon"] = setl_mon
  6543. data["solidify_id"] = ids
  6544. month := time.Unix(1557042972, 0).Format("1")
  6545. year := time.Now().Format("2006")
  6546. month = time.Now().Format("01")
  6547. day := time.Now().Format("02")
  6548. hour := time.Now().Format("15")
  6549. min := time.Now().Format("04")
  6550. sec := time.Now().Format("05")
  6551. fix_fill_date := year + month + day + hour + min + sec
  6552. data["fix_fill_dept"] = miConfig.OrgName
  6553. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6554. data["fix_fill_psn"] = curRoles.UserName
  6555. data["fix_fill_date"] = fix_fill_date
  6556. data["stmt_loc"] = "2"
  6557. data["upld_btch"] = upld_btch
  6558. client := &http.Client{}
  6559. bytesData, _ := json.Marshal(data)
  6560. var req *http.Request
  6561. if miConfig.MdtrtareaAdmvs == "320921" {
  6562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6563. } else {
  6564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6565. }
  6566. resp, _ := client.Do(req)
  6567. defer resp.Body.Close()
  6568. body, ioErr := ioutil.ReadAll(resp.Body)
  6569. if ioErr != nil {
  6570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. }
  6573. var respJSON map[string]interface{}
  6574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. }
  6578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6579. fmt.Println(respJSON)
  6580. result, _ := json.Marshal(respJSON)
  6581. fmt.Println(result)
  6582. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6583. utils.ErrorLog("解析失败:%v", err)
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. }
  6586. if result3265.Infcode != "0" {
  6587. c.ServeSuccessJSON(map[string]interface{}{
  6588. "failed_code": -10,
  6589. "msg": result3265.ErrMsg,
  6590. })
  6591. return
  6592. } else {
  6593. c.ServeSuccessJSON(map[string]interface{}{
  6594. "info": result3265.Output,
  6595. })
  6596. return
  6597. }
  6598. }
  6599. func (c *HisApiController) Get3266() {
  6600. admin_user_id, _ := c.GetInt64("admin_user_id")
  6601. startTime := c.GetString("start_time")
  6602. //endTime, _ := c.GetString("end_time")
  6603. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6604. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6605. times := strings.Split(startTime, "-")
  6606. stmt_mon := times[0] + times[1]
  6607. var upld_btch string
  6608. //var empty models.JSResultEmpty
  6609. var result3265 models.JSResult3264
  6610. data := make(map[string]interface{})
  6611. data["org_name"] = miConfig.OrgName
  6612. data["doctor"] = curRoles.UserName
  6613. data["doctor_name"] = curRoles.UserName
  6614. data["fixmedins_code"] = miConfig.Code
  6615. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6616. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6617. data["secret_key"] = miConfig.SecretKey
  6618. data["url"] = miConfig.Url
  6619. data["ak"] = miConfig.AccessKey
  6620. data["cainfo"] = miConfig.Cainfo
  6621. data["setl_mon"] = stmt_mon
  6622. month := time.Unix(1557042972, 0).Format("1")
  6623. year := time.Now().Format("2006")
  6624. month = time.Now().Format("01")
  6625. day := time.Now().Format("02")
  6626. hour := time.Now().Format("15")
  6627. min := time.Now().Format("04")
  6628. sec := time.Now().Format("05")
  6629. fix_fill_date := year + month + day + hour + min + sec
  6630. data["fix_fill_dept"] = miConfig.OrgName
  6631. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6632. data["fix_fill_psn"] = curRoles.UserName
  6633. data["fix_fill_date"] = fix_fill_date
  6634. data["stmt_loc"] = "2"
  6635. upld_btch = "0"
  6636. data["upld_btch"] = upld_btch
  6637. client := &http.Client{}
  6638. bytesData, _ := json.Marshal(data)
  6639. var req *http.Request
  6640. if miConfig.MdtrtareaAdmvs == "320921" {
  6641. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6642. } else {
  6643. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6644. }
  6645. resp, _ := client.Do(req)
  6646. defer resp.Body.Close()
  6647. body, ioErr := ioutil.ReadAll(resp.Body)
  6648. if ioErr != nil {
  6649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. }
  6652. var respJSON map[string]interface{}
  6653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6656. }
  6657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6658. fmt.Println(respJSON)
  6659. result, _ := json.Marshal(respJSON)
  6660. fmt.Println(result)
  6661. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6662. utils.ErrorLog("解析失败:%v", err)
  6663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6664. }
  6665. if result3265.Infcode != "0" {
  6666. c.ServeSuccessJSON(map[string]interface{}{
  6667. "failed_code": -10,
  6668. "msg": result3265.ErrMsg,
  6669. })
  6670. return
  6671. } else {
  6672. c.ServeSuccessJSON(map[string]interface{}{
  6673. "info": result3265.Output,
  6674. })
  6675. return
  6676. }
  6677. }
  6678. func (c *HisApiController) Get3267() {
  6679. admin_user_id, _ := c.GetInt64("admin_user_id")
  6680. startTime := c.GetString("start_time")
  6681. //endTime, _ := c.GetString("end_time")
  6682. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6684. times := strings.Split(startTime, "-")
  6685. setl_mon := times[0] + times[1]
  6686. var upld_btch string
  6687. //var empty models.JSResultEmpty
  6688. var result3265 models.JSResult3264
  6689. upld_btch = "0"
  6690. data := make(map[string]interface{})
  6691. data["org_name"] = miConfig.OrgName
  6692. data["doctor"] = curRoles.UserName
  6693. data["doctor_name"] = curRoles.UserName
  6694. data["fixmedins_code"] = miConfig.Code
  6695. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6697. data["secret_key"] = miConfig.SecretKey
  6698. data["url"] = miConfig.Url
  6699. data["ak"] = miConfig.AccessKey
  6700. data["cainfo"] = miConfig.Cainfo
  6701. data["setl_mon"] = setl_mon
  6702. data["stmt_loc"] = "2"
  6703. data["upld_btch"] = upld_btch
  6704. client := &http.Client{}
  6705. bytesData, _ := json.Marshal(data)
  6706. var req *http.Request
  6707. if miConfig.MdtrtareaAdmvs == "320921" {
  6708. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6709. } else {
  6710. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6711. }
  6712. resp, _ := client.Do(req)
  6713. defer resp.Body.Close()
  6714. body, ioErr := ioutil.ReadAll(resp.Body)
  6715. if ioErr != nil {
  6716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. }
  6719. var respJSON map[string]interface{}
  6720. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. }
  6724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6725. fmt.Println(respJSON)
  6726. result, _ := json.Marshal(respJSON)
  6727. fmt.Println(result)
  6728. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6729. utils.ErrorLog("解析失败:%v", err)
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. }
  6732. if result3265.Infcode != "0" {
  6733. c.ServeSuccessJSON(map[string]interface{}{
  6734. "failed_code": -10,
  6735. "msg": result3265.ErrMsg,
  6736. })
  6737. return
  6738. } else {
  6739. c.ServeSuccessJSON(map[string]interface{}{
  6740. "info": result3265.Output.Data,
  6741. })
  6742. return
  6743. }
  6744. }
  6745. func (c *HisApiController) Get3268() {
  6746. admin_user_id, _ := c.GetInt64("admin_user_id")
  6747. startTime := c.GetString("start_time")
  6748. endTime := c.GetString("end_time")
  6749. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6751. times := strings.Split(startTime, "-")
  6752. setl_mon := times[0] + times[1]
  6753. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6754. var twos []models.FixMonRecDetailFileInTwo
  6755. var funs []models.FundDetail
  6756. for _, item := range datas {
  6757. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6758. funs = append(funs, fun...)
  6759. }
  6760. var funInfos []models.Fund
  6761. //for _, item := range funs {
  6762. // var rf []models.FundInfo
  6763. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6764. // for _, subitem := range rf {
  6765. // var fund models.Fund
  6766. // fund.FundCode = subitem.FundPayType
  6767. // fund.FundName = subitem.FundPayTypeName
  6768. // fund.FundAmt = subitem.FundPayAmt
  6769. // fund.FundKey = item.FundKey
  6770. // fund.InsuAdmdvs = "555555"
  6771. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6772. // funInfos = append(funInfos, fund)
  6773. // }
  6774. //}
  6775. for _, team := range datas {
  6776. var two models.FixMonRecDetailFileInTwo
  6777. two.SetlDate = time.Now().Format("2006-01-02")
  6778. two.MedType = team.MedType
  6779. two.Insutype = team.Insutype
  6780. two.PsnType = team.PsnType
  6781. two.MedType = team.MedType
  6782. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6783. two.InsuAdmdvs = team.InsuAdmdvs
  6784. two.PsnTime = team.PsnTime
  6785. two.PsnCnt = team.PsnCnt
  6786. two.FundKey = team.FundKey
  6787. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6788. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6789. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6790. two.MedfeeSumAmt = ms
  6791. two.InscpAmt = ia
  6792. two.FundPaySumAmt = fps
  6793. twos = append(twos, two)
  6794. }
  6795. var upld_btch string
  6796. upld_btch = "0"
  6797. var empty models.JSResultEmpty
  6798. data := make(map[string]interface{})
  6799. data["org_name"] = miConfig.OrgName
  6800. data["doctor"] = curRoles.UserName
  6801. data["doctor_name"] = curRoles.UserName
  6802. data["fixmedins_code"] = miConfig.Code
  6803. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6805. data["secret_key"] = miConfig.SecretKey
  6806. data["url"] = miConfig.Url
  6807. data["ak"] = miConfig.AccessKey
  6808. data["cainfo"] = miConfig.Cainfo
  6809. data["datas"] = twos
  6810. data["fund"] = funInfos
  6811. data["setl_mon"] = setl_mon
  6812. month := time.Unix(1557042972, 0).Format("1")
  6813. year := time.Now().Format("2006")
  6814. month = time.Now().Format("01")
  6815. day := time.Now().Format("02")
  6816. hour := time.Now().Format("15")
  6817. min := time.Now().Format("04")
  6818. sec := time.Now().Format("05")
  6819. fix_fill_date := year + month + day + hour + min + sec
  6820. data["fix_fill_dept"] = miConfig.OrgName
  6821. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6822. data["fix_fill_psn"] = curRoles.UserName
  6823. data["fix_fill_date"] = fix_fill_date
  6824. data["stmt_loc"] = "2"
  6825. data["upld_btch"] = upld_btch
  6826. client := &http.Client{}
  6827. bytesData, _ := json.Marshal(data)
  6828. var req *http.Request
  6829. if miConfig.MdtrtareaAdmvs == "320921" {
  6830. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6831. } else {
  6832. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6833. }
  6834. resp, _ := client.Do(req)
  6835. defer resp.Body.Close()
  6836. body, ioErr := ioutil.ReadAll(resp.Body)
  6837. if ioErr != nil {
  6838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. }
  6841. var respJSON map[string]interface{}
  6842. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6845. }
  6846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6847. fmt.Println(respJSON)
  6848. result, _ := json.Marshal(respJSON)
  6849. fmt.Println(result)
  6850. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6851. utils.ErrorLog("解析失败:%v", err)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. }
  6854. if empty.Infcode != "0" {
  6855. c.ServeSuccessJSON(map[string]interface{}{
  6856. "failed_code": -10,
  6857. "msg": empty.ErrMsg,
  6858. })
  6859. return
  6860. } else {
  6861. c.ServeSuccessJSON(map[string]interface{}{
  6862. "msg": "上传成功",
  6863. })
  6864. return
  6865. }
  6866. }
  6867. func (c *HisApiController) Get3269() {
  6868. admin_user_id, _ := c.GetInt64("admin_user_id")
  6869. startTime := c.GetString("start_time")
  6870. //endTime, _ := c.GetString("end_time")
  6871. times := strings.Split(startTime, "-")
  6872. setl_mon := times[0] + times[1]
  6873. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6875. var result3263 models.JSResult3263
  6876. data := make(map[string]interface{})
  6877. data["org_name"] = miConfig.OrgName
  6878. data["doctor"] = curRoles.UserName
  6879. data["doctor_name"] = curRoles.UserName
  6880. data["fixmedins_code"] = miConfig.Code
  6881. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6882. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6883. data["secret_key"] = miConfig.SecretKey
  6884. data["url"] = miConfig.Url
  6885. data["ak"] = miConfig.AccessKey
  6886. data["cainfo"] = miConfig.Cainfo
  6887. data["setl_mon"] = setl_mon
  6888. data["stmt_loc"] = "2"
  6889. client := &http.Client{}
  6890. bytesData, _ := json.Marshal(data)
  6891. var req *http.Request
  6892. if miConfig.MdtrtareaAdmvs == "320921" {
  6893. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6894. } else {
  6895. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6896. }
  6897. resp, _ := client.Do(req)
  6898. defer resp.Body.Close()
  6899. body, ioErr := ioutil.ReadAll(resp.Body)
  6900. if ioErr != nil {
  6901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. }
  6904. var respJSON map[string]interface{}
  6905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. }
  6909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6910. fmt.Println(respJSON)
  6911. result, _ := json.Marshal(respJSON)
  6912. fmt.Println(result)
  6913. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6914. utils.ErrorLog("解析失败:%v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. }
  6917. if result3263.Infcode != "0" {
  6918. c.ServeSuccessJSON(map[string]interface{}{
  6919. "failed_code": -10,
  6920. "msg": result3263.ErrMsg,
  6921. })
  6922. return
  6923. } else {
  6924. c.ServeSuccessJSON(map[string]interface{}{
  6925. "msg": "上传成功",
  6926. })
  6927. return
  6928. }
  6929. }
  6930. func (c *HisApiController) Get3270() {
  6931. admin_user_id, _ := c.GetInt64("admin_user_id")
  6932. startTime := c.GetString("start_time")
  6933. //endTime, _ := c.GetString("end_time")
  6934. times := strings.Split(startTime, "-")
  6935. setl_mon := times[0] + times[1]
  6936. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6938. var result3263 models.JSResult3263
  6939. data2 := make(map[string]interface{})
  6940. data2["org_name"] = miConfig.OrgName
  6941. data2["doctor"] = curRoles.UserName
  6942. data2["doctor_name"] = curRoles.UserName
  6943. data2["fixmedins_code"] = miConfig.Code
  6944. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6945. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6946. data2["secret_key"] = miConfig.SecretKey
  6947. data2["url"] = miConfig.Url
  6948. data2["ak"] = miConfig.AccessKey
  6949. data2["cainfo"] = miConfig.Cainfo
  6950. data2["setl_mon"] = setl_mon
  6951. data2["stmt_loc"] = "2"
  6952. client2 := &http.Client{}
  6953. bytesData2, _ := json.Marshal(data2)
  6954. var req3263 *http.Request
  6955. if miConfig.MdtrtareaAdmvs == "320921" {
  6956. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6957. } else {
  6958. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6959. }
  6960. resp2, _ := client2.Do(req3263)
  6961. defer resp2.Body.Close()
  6962. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6963. if ioErr2 != nil {
  6964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6966. }
  6967. var respJSON3263 map[string]interface{}
  6968. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. }
  6972. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6973. fmt.Println(respJSON3263)
  6974. result2, _ := json.Marshal(respJSON3263)
  6975. fmt.Println(result2)
  6976. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6977. utils.ErrorLog("解析失败:%v", err)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6979. }
  6980. var ids []string
  6981. for _, item := range result3263.Output {
  6982. ids = append(ids, item.SolidifyID)
  6983. }
  6984. var result3264 models.JSResult3264
  6985. data := make(map[string]interface{})
  6986. data["org_name"] = miConfig.OrgName
  6987. data["doctor"] = curRoles.UserName
  6988. data["doctor_name"] = curRoles.UserName
  6989. data["fixmedins_code"] = miConfig.Code
  6990. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6991. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6992. data["secret_key"] = miConfig.SecretKey
  6993. data["url"] = miConfig.Url
  6994. data["ak"] = miConfig.AccessKey
  6995. data["cainfo"] = miConfig.Cainfo
  6996. data["setl_mon"] = setl_mon
  6997. data["stmt_loc"] = "2"
  6998. data["solidify_id"] = ids
  6999. client := &http.Client{}
  7000. bytesData, _ := json.Marshal(data)
  7001. var req *http.Request
  7002. if miConfig.MdtrtareaAdmvs == "320921" {
  7003. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7004. } else {
  7005. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7006. }
  7007. resp, _ := client.Do(req)
  7008. defer resp.Body.Close()
  7009. body, ioErr := ioutil.ReadAll(resp.Body)
  7010. if ioErr != nil {
  7011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7013. }
  7014. var respJSON map[string]interface{}
  7015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. }
  7019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7020. fmt.Println(respJSON)
  7021. result, _ := json.Marshal(respJSON)
  7022. fmt.Println(result)
  7023. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7024. utils.ErrorLog("解析失败:%v", err)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. }
  7027. if result3264.Infcode != "0" {
  7028. c.ServeSuccessJSON(map[string]interface{}{
  7029. "failed_code": -10,
  7030. "msg": result3264.ErrMsg,
  7031. })
  7032. return
  7033. } else {
  7034. c.ServeSuccessJSON(map[string]interface{}{
  7035. "info": result3264.Output,
  7036. })
  7037. return
  7038. }
  7039. }
  7040. func (c *HisApiController) Get3271() {
  7041. admin_user_id, _ := c.GetInt64("admin_user_id")
  7042. startTime := c.GetString("start_time")
  7043. //endTime, _ := c.GetString("end_time")
  7044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7046. times := strings.Split(startTime, "-")
  7047. setl_mon := times[0] + times[1]
  7048. //var empty models.JSResultEmpty
  7049. var result3265 models.JSResult3264
  7050. var result3263 models.JSResult3263
  7051. data2 := make(map[string]interface{})
  7052. data2["org_name"] = miConfig.OrgName
  7053. data2["doctor"] = curRoles.UserName
  7054. data2["doctor_name"] = curRoles.UserName
  7055. data2["fixmedins_code"] = miConfig.Code
  7056. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7057. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7058. data2["secret_key"] = miConfig.SecretKey
  7059. data2["url"] = miConfig.Url
  7060. data2["ak"] = miConfig.AccessKey
  7061. data2["cainfo"] = miConfig.Cainfo
  7062. data2["setl_mon"] = setl_mon
  7063. data2["stmt_loc"] = "2"
  7064. client2 := &http.Client{}
  7065. bytesData2, _ := json.Marshal(data2)
  7066. var req3263 *http.Request
  7067. if miConfig.MdtrtareaAdmvs == "320921" {
  7068. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7069. } else {
  7070. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7071. }
  7072. resp2, _ := client2.Do(req3263)
  7073. defer resp2.Body.Close()
  7074. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7075. if ioErr2 != nil {
  7076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. }
  7079. var respJSON3263 map[string]interface{}
  7080. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7083. }
  7084. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7085. fmt.Println(respJSON3263)
  7086. result2, _ := json.Marshal(respJSON3263)
  7087. fmt.Println(result2)
  7088. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7089. utils.ErrorLog("解析失败:%v", err)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. }
  7092. var ids []string
  7093. for _, item := range result3263.Output {
  7094. ids = append(ids, item.SolidifyID)
  7095. }
  7096. data := make(map[string]interface{})
  7097. data["org_name"] = miConfig.OrgName
  7098. data["doctor"] = curRoles.UserName
  7099. data["doctor_name"] = curRoles.UserName
  7100. data["fixmedins_code"] = miConfig.Code
  7101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7103. data["secret_key"] = miConfig.SecretKey
  7104. data["url"] = miConfig.Url
  7105. data["ak"] = miConfig.AccessKey
  7106. data["cainfo"] = miConfig.Cainfo
  7107. data["setl_mon"] = setl_mon
  7108. data["solidify_id"] = ids
  7109. month := time.Unix(1557042972, 0).Format("1")
  7110. year := time.Now().Format("2006")
  7111. month = time.Now().Format("01")
  7112. day := time.Now().Format("02")
  7113. hour := time.Now().Format("15")
  7114. min := time.Now().Format("04")
  7115. sec := time.Now().Format("05")
  7116. fix_fill_date := year + month + day + hour + min + sec
  7117. data["fix_fill_dept"] = miConfig.OrgName
  7118. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7119. data["fix_fill_psn"] = curRoles.UserName
  7120. data["fix_fill_date"] = fix_fill_date
  7121. data["stmt_loc"] = "2"
  7122. client := &http.Client{}
  7123. bytesData, _ := json.Marshal(data)
  7124. var req *http.Request
  7125. if miConfig.MdtrtareaAdmvs == "320921" {
  7126. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7127. } else {
  7128. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7129. }
  7130. resp, _ := client.Do(req)
  7131. defer resp.Body.Close()
  7132. body, ioErr := ioutil.ReadAll(resp.Body)
  7133. if ioErr != nil {
  7134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. }
  7137. var respJSON map[string]interface{}
  7138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7141. }
  7142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7143. fmt.Println(respJSON)
  7144. result, _ := json.Marshal(respJSON)
  7145. fmt.Println(result)
  7146. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7147. utils.ErrorLog("解析失败:%v", err)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. }
  7150. if result3265.Infcode != "0" {
  7151. c.ServeSuccessJSON(map[string]interface{}{
  7152. "failed_code": -10,
  7153. "msg": result3265.ErrMsg,
  7154. })
  7155. return
  7156. } else {
  7157. c.ServeSuccessJSON(map[string]interface{}{
  7158. "info": result3265.Output.Data,
  7159. })
  7160. return
  7161. }
  7162. }
  7163. func (c *HisApiController) Get3272() {
  7164. admin_user_id, _ := c.GetInt64("admin_user_id")
  7165. startTime := c.GetString("start_time")
  7166. //endTime, _ := c.GetString("end_time")
  7167. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7169. times := strings.Split(startTime, "-")
  7170. setl_mon := times[0] + times[1]
  7171. var upld_btch string
  7172. //var empty models.JSResultEmpty
  7173. var result3265 models.JSResult3264
  7174. data := make(map[string]interface{})
  7175. data["org_name"] = miConfig.OrgName
  7176. data["doctor"] = curRoles.UserName
  7177. data["doctor_name"] = curRoles.UserName
  7178. data["fixmedins_code"] = miConfig.Code
  7179. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7180. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7181. data["secret_key"] = miConfig.SecretKey
  7182. data["url"] = miConfig.Url
  7183. data["ak"] = miConfig.AccessKey
  7184. data["cainfo"] = miConfig.Cainfo
  7185. data["setl_mon"] = setl_mon
  7186. month := time.Unix(1557042972, 0).Format("1")
  7187. year := time.Now().Format("2006")
  7188. month = time.Now().Format("01")
  7189. day := time.Now().Format("02")
  7190. hour := time.Now().Format("15")
  7191. min := time.Now().Format("04")
  7192. sec := time.Now().Format("05")
  7193. fix_fill_date := year + month + day + hour + min + sec
  7194. data["fix_fill_dept"] = miConfig.OrgName
  7195. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7196. data["fix_fill_psn"] = curRoles.UserName
  7197. data["fix_fill_date"] = fix_fill_date
  7198. data["stmt_loc"] = "2"
  7199. data["upld_btch"] = upld_btch
  7200. client := &http.Client{}
  7201. bytesData, _ := json.Marshal(data)
  7202. var req *http.Request
  7203. if miConfig.MdtrtareaAdmvs == "320921" {
  7204. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7205. } else {
  7206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7207. }
  7208. resp, _ := client.Do(req)
  7209. defer resp.Body.Close()
  7210. body, ioErr := ioutil.ReadAll(resp.Body)
  7211. if ioErr != nil {
  7212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. }
  7215. var respJSON map[string]interface{}
  7216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. }
  7220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7221. fmt.Println(respJSON)
  7222. result, _ := json.Marshal(respJSON)
  7223. fmt.Println(result)
  7224. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7225. utils.ErrorLog("解析失败:%v", err)
  7226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7227. }
  7228. if result3265.Infcode != "0" {
  7229. c.ServeSuccessJSON(map[string]interface{}{
  7230. "failed_code": -10,
  7231. "msg": result3265.ErrMsg,
  7232. })
  7233. return
  7234. } else {
  7235. c.ServeSuccessJSON(map[string]interface{}{
  7236. "info": result3265.Output,
  7237. })
  7238. return
  7239. }
  7240. }
  7241. func (c *HisApiController) Get3273() {
  7242. admin_user_id, _ := c.GetInt64("admin_user_id")
  7243. startTime := c.GetString("start_time")
  7244. //endTime, _ := c.GetString("end_time")
  7245. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7247. times := strings.Split(startTime, "-")
  7248. setl_mon := times[0] + times[1]
  7249. var result3265 models.JSResult3264
  7250. data := make(map[string]interface{})
  7251. data["org_name"] = miConfig.OrgName
  7252. data["doctor"] = curRoles.UserName
  7253. data["doctor_name"] = curRoles.UserName
  7254. data["fixmedins_code"] = miConfig.Code
  7255. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7256. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7257. data["secret_key"] = miConfig.SecretKey
  7258. data["url"] = miConfig.Url
  7259. data["ak"] = miConfig.AccessKey
  7260. data["cainfo"] = miConfig.Cainfo
  7261. data["setl_mon"] = setl_mon
  7262. data["stmt_loc"] = "2"
  7263. client := &http.Client{}
  7264. bytesData, _ := json.Marshal(data)
  7265. var req *http.Request
  7266. if miConfig.MdtrtareaAdmvs == "320921" {
  7267. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7268. } else {
  7269. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7270. }
  7271. resp, _ := client.Do(req)
  7272. defer resp.Body.Close()
  7273. body, ioErr := ioutil.ReadAll(resp.Body)
  7274. if ioErr != nil {
  7275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. }
  7278. var respJSON map[string]interface{}
  7279. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. }
  7283. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7284. fmt.Println(respJSON)
  7285. result, _ := json.Marshal(respJSON)
  7286. fmt.Println(result)
  7287. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7288. utils.ErrorLog("解析失败:%v", err)
  7289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7290. }
  7291. if result3265.Infcode != "0" {
  7292. c.ServeSuccessJSON(map[string]interface{}{
  7293. "failed_code": -10,
  7294. "msg": result3265.ErrMsg,
  7295. })
  7296. return
  7297. } else {
  7298. c.ServeSuccessJSON(map[string]interface{}{
  7299. "info": result3265.Output.Data,
  7300. })
  7301. return
  7302. }
  7303. }
  7304. func (c *HisApiController) Get3274() {
  7305. //if miConfig.MdtrtareaAdmvs == "320921" {
  7306. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7307. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7308. // "&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
  7309. //
  7310. //} else {
  7311. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7312. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7313. // "&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
  7314. //
  7315. //}
  7316. }
  7317. func (c *HisApiController) Get3275() {
  7318. //if miConfig.MdtrtareaAdmvs == "320921" {
  7319. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7320. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7321. // "&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
  7322. //
  7323. //} else {
  7324. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7325. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7326. // "&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
  7327. //
  7328. //}
  7329. }
  7330. func (c *HisApiController) Get3276() {
  7331. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7332. //month := c.GetString("month")
  7333. //
  7334. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7335. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7336. //var api string
  7337. //var res Result5301
  7338. //
  7339. //if miConfig.MdtrtareaAdmvs == "320921" {
  7340. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7341. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7342. //} else {
  7343. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7344. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7345. //}
  7346. //
  7347. //resp, requestErr := http.Get(api)
  7348. //if requestErr != nil {
  7349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. // return
  7351. //}
  7352. //
  7353. //body, ioErr := ioutil.ReadAll(resp.Body)
  7354. //if ioErr != nil {
  7355. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7357. // return
  7358. //}
  7359. //var respJSON map[string]interface{}
  7360. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7361. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. // return
  7364. //}
  7365. //
  7366. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7367. //result, _ := json.Marshal(respJSON)
  7368. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7369. // utils.ErrorLog("解析失败:%v", err)
  7370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. // return
  7372. //}
  7373. }
  7374. func (c *HisApiController) Get3277() {
  7375. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7376. //month := c.GetString("month")
  7377. //
  7378. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7379. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7380. //var api string
  7381. //var res Result5301
  7382. //
  7383. //if miConfig.MdtrtareaAdmvs == "320921" {
  7384. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7385. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7386. //} else {
  7387. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7388. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7389. //}
  7390. //
  7391. //resp, requestErr := http.Get(api)
  7392. //if requestErr != nil {
  7393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. // return
  7395. //}
  7396. //
  7397. //body, ioErr := ioutil.ReadAll(resp.Body)
  7398. //if ioErr != nil {
  7399. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. // return
  7402. //}
  7403. //var respJSON map[string]interface{}
  7404. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7405. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7407. // return
  7408. //}
  7409. //
  7410. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7411. //result, _ := json.Marshal(respJSON)
  7412. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7413. // utils.ErrorLog("解析失败:%v", err)
  7414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. // return
  7416. //}
  7417. }
  7418. //func (c *HisApiController) GetCFYLJG001() {
  7419. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7420. // patient_id, _ := c.GetInt64("patient_id")
  7421. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7422. // record_time := c.GetString("record_time")
  7423. // admin_user_id = 3626
  7424. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7425. // psn, _ := service.GetPsnByPatientId(patient_id)
  7426. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7427. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7428. // var cFYLJG001 models.CFYLJG001
  7429. //
  7430. // timeLayout := "2006-01-02"
  7431. // loc, _ := time.LoadLocation("Local")
  7432. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7433. // if err != nil {
  7434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7435. // return
  7436. // }
  7437. // recordDateTime := theTime.Unix()
  7438. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7439. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7440. //
  7441. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7442. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7443. //
  7444. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7445. //
  7446. // for _, item := range prescriptions {
  7447. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7448. // if his.IdCardType == 1 {
  7449. // bas := strings.Split(psn.CardInfo, "|")
  7450. // basNumber := bas[1]
  7451. // fmt.Println(basNumber)
  7452. // card_sn := bas[3]
  7453. // card_no := bas[2]
  7454. // cFYLJG001.MdtrtCertType = "03"
  7455. // cFYLJG001.CardSn = card_sn
  7456. // cFYLJG001.MdtrtCertNo = card_no
  7457. // cFYLJG001.EcToken = ""
  7458. // cFYLJG001.AuthNo = ""
  7459. // } else if his.IdCardType == 2 {
  7460. // cFYLJG001.MdtrtCertType = "02"
  7461. // cFYLJG001.CardSn = ""
  7462. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7463. // cFYLJG001.EcToken = ""
  7464. // cFYLJG001.AuthNo = ""
  7465. // } else if his.IdCardType == 4 {
  7466. // cFYLJG001.MdtrtCertType = "01"
  7467. // cFYLJG001.CardSn = ""
  7468. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7469. // cFYLJG001.EcToken = psn.VerifyNumber
  7470. // cFYLJG001.AuthNo = ""
  7471. // }
  7472. // cFYLJG001.BizTypeCode = "01"
  7473. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7474. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7475. // cFYLJG001.RxTypeCode = "1"
  7476. // tempTime := time.Unix(item.PreTime, 0)
  7477. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7478. // cFYLJG001.PrscTime = timeFormatOne
  7479. // var count float64
  7480. // if item.Type == 1 {
  7481. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7482. // count = count + sumItem.PrescribingNumber
  7483. // }
  7484. // }
  7485. // cFYLJG001.RxDrugCnt = count
  7486. // cFYLJG001.ValiDays = "5"
  7487. // ts := time.Unix(item.PreTime, 0)
  7488. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7489. // tempTime3 := time.Unix(record_time2, 0)
  7490. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7491. // cFYLJG001.ValiEndTime = timeFormat3
  7492. // cFYLJG001.RxCotnFlag = "0"
  7493. // for _, subItem := range item.HisDoctorAdviceInfo {
  7494. // var drug models.RxDrug
  7495. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7496. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7497. // drug.RxItemTypeCode = "11"
  7498. //
  7499. // drug.DrugDosform = "乳膏剂" //TODO
  7500. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7501. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7502. // }
  7503. //
  7504. // drug.MedcWayDscr = subItem.DeliveryWay
  7505. //
  7506. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7507. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7508. // drug.MedcBegntime = timeFormatTwo
  7509. // if subItem.Day > 0 {
  7510. // ts := time.Unix(subItem.StartTime, 0)
  7511. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7512. // tempTime4 := time.Unix(record_time, 0)
  7513. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7514. // drug.MedcEndtime = timeFormat5
  7515. // } else {
  7516. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7517. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7518. // drug.MedcEndtime = timeFormatTwo
  7519. // }
  7520. //
  7521. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7522. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7523. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7524. // drug.DrugCnt = subItem.PrescribingNumber
  7525. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7526. // drug.DrugGenname = subItem.AdviceName
  7527. // drug.MedcWayCodg = subItem.DeliveryWay
  7528. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7529. // drug.SinDoscnt = subItem.SingleDose
  7530. // drug.SinDosunt = subItem.SingleDoseUnit
  7531. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7532. // drug.UsedFrquName = subItem.ExecutionFrequency
  7533. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7534. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7535. // drug.HospApprFlag = "1"
  7536. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7537. // }
  7538. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7539. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7540. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7541. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7542. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7543. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7544. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7545. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7546. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7547. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7548. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7549. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7550. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7551. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7552. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7553. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7554. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7555. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7556. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7557. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7558. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7559. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7560. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7561. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7562. // tempTime2 := time.Now().Unix()
  7563. // tempTime6 := time.Unix(tempTime2, 0)
  7564. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7565. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7566. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7567. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7568. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7569. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7570. //
  7571. // //memo := make(map[string]interface{})
  7572. // //inputData := make(map[string]interface{}, 0)
  7573. //
  7574. // //type MyData struct {
  7575. // // Insutype string `json:"insutype"`
  7576. // //}
  7577. // //
  7578. // // data := MyData{
  7579. // // Insutype: his.Insutype,
  7580. // //}
  7581. // //
  7582. //
  7583. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7584. // var config []*models.HisXtDiagnoseConfig
  7585. // for _, item := range diagnosis_ids {
  7586. // id, _ := strconv.ParseInt(item, 10, 64)
  7587. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7588. // config = append(config, &diagnosisConfig)
  7589. // }
  7590. // for index, subitem := range config {
  7591. // if index == 0 {
  7592. // var dia models.DiseInfo
  7593. // dia.DiagType = "1"
  7594. // dia.MaindiagFlag = "1"
  7595. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7596. // dia.DiagCode = subitem.CountryCode
  7597. // dia.DiagName = subitem.ClassName
  7598. // dia.DiagDept = "肾内科"
  7599. // dia.DiagDrNo = doctor.DoctorNumber
  7600. // dia.DiagDrName = doctor.UserName
  7601. // tempTime3 := time.Unix(item.PreTime, 0)
  7602. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7603. // dia.DiagTime = timeFormatTwo
  7604. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7605. // } else {
  7606. // var dia models.DiseInfo
  7607. // dia.DiagType = "1"
  7608. // dia.MaindiagFlag = "0"
  7609. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7610. // dia.DiagCode = subitem.CountryCode
  7611. // dia.DiagName = subitem.ClassName
  7612. // dia.DiagDept = "肾内科"
  7613. // dia.DiagDrNo = doctor.DoctorNumber
  7614. // dia.DiagDrName = doctor.UserName
  7615. // tempTime3 := time.Unix(item.PreTime, 0)
  7616. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7617. // dia.DiagTime = timeFormatTwo
  7618. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7619. // }
  7620. // }
  7621. // if miConfig.MdtrtareaAdmvs == "340699" {
  7622. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7623. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7624. //
  7625. // } else {
  7626. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7627. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7628. //
  7629. // }
  7630. //
  7631. // var res ResultCFYLJG001
  7632. // var respJSON2 map[string]interface{}
  7633. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7634. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7636. // return
  7637. // }
  7638. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7639. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7640. // utils.ErrorLog("解析失败:%v", err)
  7641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. // return
  7643. // }
  7644. // if res.Infcode == -1 {
  7645. // c.ServeSuccessJSON(map[string]interface{}{
  7646. // "failed_code": -10,
  7647. // "msg": res.ErrMsg,
  7648. // })
  7649. // return
  7650. //
  7651. // } else {
  7652. // var flow models.HisPrescriptionFlow
  7653. // flow.Ctime = time.Now().Unix()
  7654. // flow.SignDigest = ""
  7655. // flow.RxTraceCode = res.Output.RxTraceCode
  7656. // flow.HiRxno = res.Output.HiRxno
  7657. // flow.MID = his.Number
  7658. // flow.Status = 1
  7659. // flow.DCode = doctor_info.DoctorNumber
  7660. // flow.OriginalRxFile = ""
  7661. // flow.OriginalValue = ""
  7662. // flow.SignCertDn = ""
  7663. // flow.UserOrgId = 10454
  7664. // flow.SignCertSn = ""
  7665. // flow.Mtime = time.Now().Unix()
  7666. //
  7667. // service.Createflow(&flow)
  7668. // c.ServeSuccessJSON(map[string]interface{}{
  7669. // "msg": "上传成功",
  7670. // })
  7671. // }
  7672. // }
  7673. //}
  7674. //func (c *HisApiController) GetCFYLJG002() {
  7675. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7676. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7677. // record_time := c.GetString("record_time")
  7678. // admin_user_id = 3626
  7679. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7680. // //id, _ := c.GetInt64("id")
  7681. // admin_user_id = 3626
  7682. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7683. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7684. //
  7685. // flow, _ := service.Getflowtwo(his.Number)
  7686. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7687. // //record_time := c.GetString("record_time")
  7688. // patient_id, _ := c.GetInt64("patient_id")
  7689. // //patient_id = 23834
  7690. // //record_time = "2023-09-18"
  7691. // timeLayout := "2006-01-02"
  7692. // loc, _ := time.LoadLocation("Local")
  7693. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7694. // if err != nil {
  7695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7696. // return
  7697. // }
  7698. // recordDateTime := theTime.Unix()
  7699. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7700. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7701. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7702. //
  7703. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7704. //
  7705. // inputData := make(map[string]interface{})
  7706. // inputData["rxTraceCode"] = flow.RxTraceCode
  7707. // inputData["hiRxno"] = flow.HiRxno
  7708. // inputData["mdtrtId"] = flow.MID
  7709. // inputData["patnName"] = his.PsnName
  7710. // inputData["psnCertType"] = his.PsnCertType
  7711. // inputData["certno"] = his.Certno
  7712. // inputData["fixmedinsName"] = miConfig.OrgName
  7713. // inputData["fixmedinsCode"] = miConfig.Code
  7714. // inputData["drCode"] = doctor_info.DoctorNumber
  7715. // inputData["prscDrName"] = doctor_info.UserName
  7716. // inputData["pharDeptName"] = dept.Name
  7717. // inputData["pharDeptCode"] = dept.Number
  7718. // inputData["pharProfttlCodg"] = dept.Name
  7719. // inputData["pharProfttlName"] = ""
  7720. // inputData["pharCode"] = "HY440309002107"
  7721. // inputData["pharCertType"] = "01"
  7722. // inputData["pharCertno"] = "430482199408260023"
  7723. // inputData["pharName"] = "彭斯遥"
  7724. // inputData["pharPracCertNo"] = ""
  7725. // tempTime2 := time.Unix(info.Ctime, 0)
  7726. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7727. // inputData["pharChkTime"] = timeFormatTwo
  7728. //
  7729. // bytesData, _ := json.Marshal(inputData)
  7730. // fmt.Println(string(bytesData))
  7731. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7732. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7733. // if err != nil {
  7734. // fmt.Println("Error reading PDF file:", err)
  7735. // return
  7736. // }
  7737. //
  7738. // // 将 PDF 文件内容进行 Base64 编码
  7739. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7740. //
  7741. // fmt.Println(err)
  7742. //
  7743. // if miConfig.MdtrtareaAdmvs == "340699" {
  7744. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7745. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7746. //
  7747. // } else {
  7748. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7749. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7750. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7751. //
  7752. // }
  7753. //
  7754. // var res2 Result002
  7755. // var respJSON2 map[string]interface{}
  7756. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7757. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7759. // return
  7760. // }
  7761. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7762. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7763. // utils.ErrorLog("解析失败:%v", err)
  7764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. // return
  7766. // }
  7767. // if res2.Infcode == 0 {
  7768. // flow.Ctime = time.Now().Unix()
  7769. // flow.SignDigest = res2.Output.SignDigest
  7770. // flow.RxFile = res2.Output.RxFile
  7771. // flow.MID = his.Number
  7772. // flow.Status = 1
  7773. // flow.DCode = doctor_info.DoctorNumber
  7774. // flow.OriginalRxFile = rx_encoded
  7775. // flow.OriginalValue = encoded
  7776. // flow.SignCertDn = res2.Output.SignCertDn
  7777. // flow.SignCertSn = res2.Output.SignCertSn
  7778. // flow.Mtime = time.Now().Unix()
  7779. // service.Saveflow(flow)
  7780. // c.ServeSuccessJSON(map[string]interface{}{
  7781. // "msg": "预签名成功",
  7782. // })
  7783. // } else {
  7784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. // return
  7786. // }
  7787. //}
  7788. //func (c *HisApiController) GetCFYLJG003() {
  7789. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7790. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7791. // record_time := c.GetString("record_time")
  7792. // admin_user_id = 3626
  7793. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7794. // //id, _ := c.GetInt64("id")
  7795. // admin_user_id = 3626
  7796. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7797. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7798. //
  7799. // flow, _ := service.Getflowtwo(his.Number)
  7800. // //id = 3
  7801. // patient_id, _ := c.GetInt64("patient_id")
  7802. // //patient_id = 23834
  7803. // //record_time = "2023-09-18"
  7804. // timeLayout := "2006-01-02"
  7805. // loc, _ := time.LoadLocation("Local")
  7806. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7807. // if err != nil {
  7808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7809. // return
  7810. // }
  7811. // recordDateTime := theTime.Unix()
  7812. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7813. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7814. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7815. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7816. //
  7817. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7818. //
  7819. // var cFYLJG003 models.CFYLJG003
  7820. //
  7821. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7822. // cFYLJG003.HiRxno = flow.HiRxno
  7823. // cFYLJG003.MdtrtID = flow.MID
  7824. // cFYLJG003.PatnName = his.Name
  7825. // cFYLJG003.Certno = his.Certno
  7826. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7827. // cFYLJG003.FixmedinsCode = miConfig.Code
  7828. //
  7829. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7830. // cFYLJG003.PrscDrName = doctor_info.UserName
  7831. // cFYLJG003.PharDeptName = dept.Name
  7832. // cFYLJG003.PharDeptCode = dept.Number
  7833. // cFYLJG003.PharCode = "HY440309002107"
  7834. // cFYLJG003.PharCertType = "01"
  7835. // cFYLJG003.PharCertno = "430482199408260023"
  7836. // cFYLJG003.PharName = "彭斯遥"
  7837. // cFYLJG003.PsnCertType = "01"
  7838. // cFYLJG003.RxFile = flow.RxFile
  7839. // cFYLJG003.SignDigest = flow.SignDigest
  7840. // cFYLJG003.FixmedinsCode = miConfig.Code
  7841. // cFYLJG003.PsnCertType = "01"
  7842. // cFYLJG003.PharProfttlCodg = dept.Name
  7843. // //inputData["pharProfttlCodg"] =dept.Name
  7844. //
  7845. // tempTime2 := time.Unix(info.Ctime, 0)
  7846. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7847. // cFYLJG003.PharChkTime = timeFormatTwo
  7848. //
  7849. // if miConfig.MdtrtareaAdmvs == "340699" {
  7850. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7851. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7852. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7853. // } else {
  7854. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7855. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7856. //
  7857. // }
  7858. //
  7859. // var res ResultCFYLJG003
  7860. // var respJSON2 map[string]interface{}
  7861. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7862. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7864. // return
  7865. // }
  7866. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7867. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7868. // utils.ErrorLog("解析失败:%v", err)
  7869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7870. // return
  7871. // }
  7872. // if res.Infcode == -1 {
  7873. // c.ServeSuccessJSON(map[string]interface{}{
  7874. // "failed_code": -10,
  7875. // "msg": res.ErrMsg,
  7876. // })
  7877. // return
  7878. // } else {
  7879. // c.ServeSuccessJSON(map[string]interface{}{
  7880. // "info": res.Output,
  7881. // })
  7882. // }
  7883. //
  7884. //}
  7885. //func (c *HisApiController) GetCFYLJG004() {
  7886. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7887. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7888. // record_time := c.GetString("record_time")
  7889. // admin_user_id = 3626
  7890. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7891. // //id, _ := c.GetInt64("id")
  7892. // admin_user_id = 3626
  7893. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7894. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7895. //
  7896. // flow, _ := service.Getflowtwo(his.Number)
  7897. // //id = 3
  7898. // patient_id, _ := c.GetInt64("patient_id")
  7899. // //patient_id = 23834
  7900. // //record_time = "2023-09-18"
  7901. // timeLayout := "2006-01-02"
  7902. // loc, _ := time.LoadLocation("Local")
  7903. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7904. // if err != nil {
  7905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7906. // return
  7907. // }
  7908. // recordDateTime := theTime.Unix()
  7909. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7910. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7911. // var cFYLJG004 models.CFYLJG004
  7912. // cFYLJG004.HiRxno = flow.HiRxno
  7913. // cFYLJG004.FixmedinsCode = miConfig.Code
  7914. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7915. // cFYLJG004.UndoDrCertType = "01"
  7916. // cFYLJG004.UndoRea = "撤销处方"
  7917. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7918. // cFYLJG004.UndoDrName = doctor_info.UserName
  7919. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7920. //
  7921. // if miConfig.MdtrtareaAdmvs == "340699" {
  7922. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7923. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7924. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7925. //
  7926. // } else {
  7927. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7928. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7929. //
  7930. // }
  7931. //
  7932. // var res ResultCFYLJG004
  7933. // var respJSON2 map[string]interface{}
  7934. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7937. // return
  7938. // }
  7939. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7940. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7941. // utils.ErrorLog("解析失败:%v", err)
  7942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. // return
  7944. // }
  7945. // if res.Infcode == -1 {
  7946. // c.ServeSuccessJSON(map[string]interface{}{
  7947. // "failed_code": -10,
  7948. // "msg": res.ErrMsg,
  7949. // })
  7950. // return
  7951. // } else {
  7952. // flow.Status = 0
  7953. // service.Saveflow(flow)
  7954. // c.ServeSuccessJSON(map[string]interface{}{
  7955. // "msg": "撤销成功",
  7956. // })
  7957. // return
  7958. //
  7959. // }
  7960. //}
  7961. //func (c *HisApiController) GetCFYLJG005() {
  7962. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7963. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7964. // //record_time := c.GetString("record_time")
  7965. // admin_user_id = 3626
  7966. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7967. // //id, _ := c.GetInt64("id")
  7968. // admin_user_id = 3626
  7969. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7970. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7971. //
  7972. // flow, _ := service.Getflowtwo(his.Number)
  7973. // //id = 3
  7974. // var cFYLJG005 models.CFYLJG005
  7975. //
  7976. // //patient_id, _ := c.GetInt64("patient_id")
  7977. // cFYLJG005.HiRxno = flow.HiRxno
  7978. // cFYLJG005.MdtrtID = flow.MID
  7979. // cFYLJG005.EcToken = ""
  7980. // cFYLJG005.PsnName = his.Name
  7981. // cFYLJG005.PsnCertType = "01"
  7982. // cFYLJG005.Certno = his.IdCardNo
  7983. //
  7984. // if miConfig.MdtrtareaAdmvs == "340699" {
  7985. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7986. //
  7987. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7988. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7989. //
  7990. // } else {
  7991. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7992. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7993. //
  7994. // }
  7995. //
  7996. // var res ResultCFYLJG005
  7997. // var respJSON2 map[string]interface{}
  7998. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7999. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. // return
  8002. // }
  8003. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8004. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8005. // utils.ErrorLog("解析失败:%v", err)
  8006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8007. // return
  8008. // }
  8009. // if res.Infcode == -1 {
  8010. // c.ServeSuccessJSON(map[string]interface{}{
  8011. // "failed_code": -10,
  8012. // "msg": res.ErrMsg,
  8013. // })
  8014. // return
  8015. // } else {
  8016. // c.ServeSuccessJSON(map[string]interface{}{
  8017. // "info": res.Output,
  8018. // })
  8019. // return
  8020. // }
  8021. //}
  8022. //func (c *HisApiController) GetCFYLJG006() {
  8023. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8024. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8025. // admin_user_id = 3626
  8026. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8027. // //id, _ := c.GetInt64("id")
  8028. // admin_user_id = 3626
  8029. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8030. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8031. //
  8032. // flow, _ := service.Getflowtwo(his.Number)
  8033. // //id = 3
  8034. // patient_id, _ := c.GetInt64("patient_id")
  8035. // var cFYLJG006 models.CFYLJG006
  8036. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8037. // cFYLJG006.HiRxno = flow.HiRxno
  8038. // cFYLJG006.MdtrtID = flow.MID
  8039. // cFYLJG006.PsnName = patient.Name
  8040. // cFYLJG006.PsnCertType = "01"
  8041. // cFYLJG006.Certno = patient.IdCardNo
  8042. //
  8043. // if miConfig.MdtrtareaAdmvs == "340699" {
  8044. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8045. //
  8046. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8047. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8048. // } else {
  8049. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8050. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8051. // }
  8052. //
  8053. // var res ResultCFYLJG006
  8054. // var respJSON2 map[string]interface{}
  8055. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8056. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. // return
  8059. // }
  8060. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8061. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8062. // utils.ErrorLog("解析失败:%v", err)
  8063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8064. // return
  8065. // }
  8066. // if res.Infcode == -1 {
  8067. // c.ServeSuccessJSON(map[string]interface{}{
  8068. // "failed_code": -10,
  8069. // "msg": res.ErrMsg,
  8070. // })
  8071. // return
  8072. // } else {
  8073. // c.ServeSuccessJSON(map[string]interface{}{
  8074. // "info": res.Output,
  8075. // })
  8076. // return
  8077. // }
  8078. //}
  8079. //func (c *HisApiController) GetCFYLJG007() {
  8080. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8081. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8082. // admin_user_id = 3626
  8083. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8084. // //id, _ := c.GetInt64("id")
  8085. // admin_user_id = 3626
  8086. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8087. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8088. //
  8089. // flow, _ := service.Getflowtwo(his.Number)
  8090. // //id = 3
  8091. // patient_id, _ := c.GetInt64("patient_id")
  8092. // var cFYLJG007 models.CFYLJG007
  8093. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8094. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8095. //
  8096. // cFYLJG007.HiRxno = flow.HiRxno
  8097. // cFYLJG007.MdtrtID = flow.MID
  8098. // cFYLJG007.PsnNo = his.PsnNo
  8099. // cFYLJG007.PsnCertType = "01"
  8100. // cFYLJG007.Certno = patient.IdCardNo
  8101. // cFYLJG007.PsnName = patient.Name
  8102. //
  8103. // if miConfig.MdtrtareaAdmvs == "340699" {
  8104. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8105. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8106. // } else {
  8107. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8108. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8109. // }
  8110. //
  8111. // var res ResultCFYLJG007
  8112. // var respJSON2 map[string]interface{}
  8113. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8114. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8116. // return
  8117. // }
  8118. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8119. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8120. // utils.ErrorLog("解析失败:%v", err)
  8121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. // return
  8123. // }
  8124. // if res.Infcode == -1 {
  8125. // c.ServeSuccessJSON(map[string]interface{}{
  8126. // "failed_code": -10,
  8127. // "msg": res.ErrMsg,
  8128. // })
  8129. // return
  8130. // } else {
  8131. // c.ServeSuccessJSON(map[string]interface{}{
  8132. // "info": res,
  8133. // })
  8134. // return
  8135. // }
  8136. //}
  8137. //
  8138. //func (c *HisApiController) GetCFYLJG008() {
  8139. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8140. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8141. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8142. // var cFYLJG008 models.CFYLJG008
  8143. // //id, _ := c.GetInt64("id")
  8144. // patient_id, _ := c.GetInt64("patient_id")
  8145. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8146. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8147. // //id = 3
  8148. // //flow, _ := service.Getflow(id)
  8149. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8150. //
  8151. // //
  8152. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8153. // //patient_id, _ := c.GetInt64("patient_id")
  8154. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8155. // record_time := c.GetString("record_time")
  8156. //
  8157. // admin_user_id = 3626
  8158. // patient_id = 19424
  8159. // //his_patient_id = 263947
  8160. // record_time = "2023-08-29"
  8161. //
  8162. // timeLayout := "2006-01-02"
  8163. // loc, _ := time.LoadLocation("Local")
  8164. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8165. // if err != nil {
  8166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8167. // return
  8168. // }
  8169. // recordDateTime := theTime.Unix()
  8170. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8171. //
  8172. // cFYLJG008.FixmedinsName = ""
  8173. // cFYLJG008.Lat = ""
  8174. // cFYLJG008.Lng = ""
  8175. // cFYLJG008.OrderType = "1"
  8176. // cFYLJG008.PoolareaNo = ""
  8177. // cFYLJG008.Lng = ""
  8178. // cFYLJG008.PageNum = 1
  8179. // cFYLJG008.PageSize = 10
  8180. // var MPI models.MedinsProdInvChgDDTO
  8181. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8182. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8183. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8184. //
  8185. // if miConfig.MdtrtareaAdmvs == "340699" {
  8186. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8187. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8188. //
  8189. // } else {
  8190. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8191. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8192. //
  8193. // var res ResultCFYLJG008
  8194. // var respJSON2 map[string]interface{}
  8195. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8196. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8198. // return
  8199. // }
  8200. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8201. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8202. // utils.ErrorLog("解析失败:%v", err)
  8203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8204. // return
  8205. // }
  8206. // if res.Infcode == -1 {
  8207. // c.ServeSuccessJSON(map[string]interface{}{
  8208. // "failed_code": -10,
  8209. // "msg": res.ErrMsg,
  8210. // })
  8211. // return
  8212. // } else {
  8213. // c.ServeSuccessJSON(map[string]interface{}{
  8214. // "info": res.Output,
  8215. // })
  8216. // return
  8217. // }
  8218. // }
  8219. //
  8220. //}
  8221. func (c *HisApiController) GetBL4201A() {
  8222. order_id, _ := c.GetInt64("order_id")
  8223. admin_user_id, _ := c.GetInt64("admin_user_id")
  8224. order, _ := service.GetHisOrderByIDTwo(order_id)
  8225. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8226. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8227. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8230. department, _ := service.GetDepartMentDetail(his.Departments)
  8231. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8232. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8233. if order.ID == 0 {
  8234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8235. return
  8236. }
  8237. var struct4201A models.Struct4201A
  8238. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8239. for _, items := range order_info {
  8240. memo := make(map[string]interface{})
  8241. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8242. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8243. fsiOPFLD.MedType = "14"
  8244. fsiOPFLD.BkkpSn = items.FeedetlSn
  8245. fsiOPFLD.FixmedinsCode = miConfig.Code
  8246. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8247. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8248. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8249. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8250. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8251. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8252. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8253. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8254. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8255. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8256. fsiOPFLD.BilgDeptName = department.Name
  8257. fsiOPFLD.BilgDeptCodg = department.Number
  8258. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8259. fsiOPFLD.BilgDrName = doctor.UserName
  8260. fsiOPFLD.MedChrgitmType = "09"
  8261. memo["hosp_appr_flag"] = "1"
  8262. memo["invoice_no"] = order.MdtrtId
  8263. memo["memo"] = "自费"
  8264. bytesData, _ := json.Marshal(memo)
  8265. fsiOPFLD.Memo = string(bytesData)
  8266. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8267. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8268. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8269. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8270. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8271. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8272. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8273. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8274. fsiOPFLD.BilgDeptName = department.Name
  8275. fsiOPFLD.BilgDeptCodg = department.Number
  8276. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8277. fsiOPFLD.BilgDrName = doctor.UserName
  8278. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8279. case 0:
  8280. break
  8281. case 1:
  8282. fsiOPFLD.MedChrgitmType = "14"
  8283. break
  8284. case 2:
  8285. fsiOPFLD.MedChrgitmType = "05"
  8286. break
  8287. case 3:
  8288. fsiOPFLD.MedChrgitmType = "03"
  8289. break
  8290. case 4:
  8291. fsiOPFLD.MedChrgitmType = "03"
  8292. break
  8293. case 5:
  8294. fsiOPFLD.MedChrgitmType = "08"
  8295. break
  8296. case 6:
  8297. fsiOPFLD.MedChrgitmType = "14"
  8298. break
  8299. case 7:
  8300. fsiOPFLD.MedChrgitmType = "14"
  8301. break
  8302. case 8:
  8303. fsiOPFLD.MedChrgitmType = "03"
  8304. break
  8305. case 9:
  8306. fsiOPFLD.MedChrgitmType = "14"
  8307. break
  8308. case 10:
  8309. fsiOPFLD.MedChrgitmType = "14"
  8310. break
  8311. case 11:
  8312. fsiOPFLD.MedChrgitmType = "06"
  8313. break
  8314. case 12:
  8315. fsiOPFLD.MedChrgitmType = "12"
  8316. break
  8317. case 13:
  8318. fsiOPFLD.MedChrgitmType = "01"
  8319. break
  8320. case 14:
  8321. fsiOPFLD.MedChrgitmType = "04"
  8322. break
  8323. case 15:
  8324. fsiOPFLD.MedChrgitmType = "14"
  8325. break
  8326. }
  8327. memo["hosp_appr_flag"] = "1"
  8328. memo["invoice_no"] = order.MdtrtId
  8329. memo["memo"] = "自费"
  8330. bytesData, _ := json.Marshal(memo)
  8331. fsiOPFLD.Memo = string(bytesData)
  8332. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8333. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8334. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8335. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8336. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8337. fsiOPFLD.BilgDeptName = department.Name
  8338. fsiOPFLD.BilgDeptCodg = department.Number
  8339. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8340. fsiOPFLD.BilgDrName = doctor.UserName
  8341. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8342. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8343. fsiOPFLD.MedChrgitmType = "08"
  8344. memo["hosp_appr_flag"] = "1"
  8345. memo["invoice_no"] = order.MdtrtId
  8346. memo["memo"] = "自费"
  8347. bytesData, _ := json.Marshal(memo)
  8348. fsiOPFLD.Memo = string(bytesData)
  8349. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8350. }
  8351. }
  8352. }
  8353. for _, items := range order_info_two {
  8354. memo := make(map[string]interface{})
  8355. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8356. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8357. fsiOPFLD.MedType = "14"
  8358. fsiOPFLD.BkkpSn = items.FeedetlSn
  8359. fsiOPFLD.FixmedinsCode = miConfig.Code
  8360. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8361. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8362. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8363. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8364. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8365. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8366. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8367. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8368. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8369. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8370. fsiOPFLD.BilgDeptName = department.Name
  8371. fsiOPFLD.BilgDeptCodg = department.Number
  8372. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8373. fsiOPFLD.BilgDrName = doctor.UserName
  8374. fsiOPFLD.MedChrgitmType = "09"
  8375. memo["hosp_appr_flag"] = "1"
  8376. memo["invoice_no"] = order.MdtrtId
  8377. memo["memo"] = "自费"
  8378. bytesData, _ := json.Marshal(memo)
  8379. fsiOPFLD.Memo = string(bytesData)
  8380. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8381. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8382. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8383. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8384. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8385. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8386. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8387. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8388. fsiOPFLD.BilgDeptName = department.Name
  8389. fsiOPFLD.BilgDeptCodg = department.Number
  8390. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8391. fsiOPFLD.BilgDrName = doctor.UserName
  8392. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8393. case 0:
  8394. break
  8395. case 1:
  8396. fsiOPFLD.MedChrgitmType = "14"
  8397. break
  8398. case 2:
  8399. fsiOPFLD.MedChrgitmType = "05"
  8400. break
  8401. case 3:
  8402. fsiOPFLD.MedChrgitmType = "03"
  8403. break
  8404. case 4:
  8405. fsiOPFLD.MedChrgitmType = "03"
  8406. break
  8407. case 5:
  8408. fsiOPFLD.MedChrgitmType = "08"
  8409. break
  8410. case 6:
  8411. fsiOPFLD.MedChrgitmType = "14"
  8412. break
  8413. case 7:
  8414. fsiOPFLD.MedChrgitmType = "14"
  8415. break
  8416. case 8:
  8417. fsiOPFLD.MedChrgitmType = "03"
  8418. break
  8419. case 9:
  8420. fsiOPFLD.MedChrgitmType = "14"
  8421. break
  8422. case 10:
  8423. fsiOPFLD.MedChrgitmType = "14"
  8424. break
  8425. case 11:
  8426. fsiOPFLD.MedChrgitmType = "06"
  8427. break
  8428. case 12:
  8429. fsiOPFLD.MedChrgitmType = "12"
  8430. break
  8431. case 13:
  8432. fsiOPFLD.MedChrgitmType = "01"
  8433. break
  8434. case 14:
  8435. fsiOPFLD.MedChrgitmType = "04"
  8436. break
  8437. case 15:
  8438. fsiOPFLD.MedChrgitmType = "14"
  8439. break
  8440. }
  8441. memo["hosp_appr_flag"] = "1"
  8442. memo["invoice_no"] = order.MdtrtId
  8443. memo["memo"] = "自费"
  8444. bytesData, _ := json.Marshal(memo)
  8445. fsiOPFLD.Memo = string(bytesData)
  8446. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8447. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8448. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8449. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8450. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8451. fsiOPFLD.BilgDeptName = department.Name
  8452. fsiOPFLD.BilgDeptCodg = department.Number
  8453. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8454. fsiOPFLD.BilgDrName = doctor.UserName
  8455. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8456. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8457. fsiOPFLD.MedChrgitmType = "08"
  8458. memo["hosp_appr_flag"] = "1"
  8459. memo["invoice_no"] = order.MdtrtId
  8460. memo["memo"] = "自费"
  8461. bytesData, _ := json.Marshal(memo)
  8462. fsiOPFLD.Memo = string(bytesData)
  8463. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8464. }
  8465. }
  8466. }
  8467. fmt.Println(fsiOPFLDs)
  8468. struct4201A.Fopfd = fsiOPFLDs
  8469. fmt.Println(struct4201A.Fopfd)
  8470. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8471. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8472. var res2 ResultSix
  8473. var respJSON2 map[string]interface{}
  8474. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8477. return
  8478. }
  8479. userJSONBytes2, _ := json.Marshal(respJSON2)
  8480. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8481. utils.ErrorLog("解析失败:%v", err)
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. if res2.Infcode != 0 {
  8486. c.ServeSuccessJSON(map[string]interface{}{
  8487. "failed_code": -10,
  8488. "msg": res2.ErrMsg,
  8489. })
  8490. return
  8491. } else {
  8492. order.IsUploadOrderInfo = 1
  8493. service.UpdateOrder(order)
  8494. c.ServeSuccessJSON(map[string]interface{}{
  8495. "msg": "上传成功",
  8496. })
  8497. }
  8498. }
  8499. func (c *HisApiController) Get3103() {
  8500. admin_user_id, _ := c.GetInt64("admin_user_id")
  8501. warm_type, _ := c.GetInt64("warm_type")
  8502. fk_state, _ := c.GetInt64("fk_state")
  8503. warm_ids := c.GetString("warm_ids")
  8504. desc := c.GetString("desc")
  8505. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8506. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8507. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  8508. saveLog(result, requestLog, "3103", "反馈")
  8509. var res2 ResultSix
  8510. var respJSON2 map[string]interface{}
  8511. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8514. return
  8515. }
  8516. userJSONBytes2, _ := json.Marshal(respJSON2)
  8517. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8518. utils.ErrorLog("解析失败:%v", err)
  8519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8520. return
  8521. }
  8522. if res2.Infcode != 0 {
  8523. c.ServeSuccessJSON(map[string]interface{}{
  8524. "failed_code": -10,
  8525. "msg": res2.ErrMsg,
  8526. })
  8527. return
  8528. } else {
  8529. c.ServeSuccessJSON(map[string]interface{}{
  8530. "msg": "反馈成功",
  8531. })
  8532. return
  8533. }
  8534. }
  8535. func (c *HisApiController) Get3103() {
  8536. admin_user_id, _ := c.GetInt64("admin_user_id")
  8537. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8538. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8539. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  8540. }
  8541. func (c *HisApiController) Get4201A() {
  8542. order_id, _ := c.GetInt64("order_id")
  8543. admin_user_id, _ := c.GetInt64("admin_user_id")
  8544. order, _ := service.GetHisOrderByIDTwo(order_id)
  8545. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8546. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8547. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8548. //order_info = append(order_info, order_info_two...)
  8549. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8550. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8551. department, _ := service.GetDepartMentDetail(his.Departments)
  8552. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8553. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8554. if order.ID == 0 {
  8555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8556. return
  8557. }
  8558. var struct4201A models.Struct4201A
  8559. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8560. for _, items := range order_info {
  8561. memo := make(map[string]interface{})
  8562. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8563. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8564. fsiOPFLD.MedType = "14"
  8565. fsiOPFLD.BkkpSn = items.FeedetlSn
  8566. fsiOPFLD.FixmedinsCode = miConfig.Code
  8567. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8568. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8569. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8570. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8571. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8572. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8573. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8574. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8575. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8576. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8577. fsiOPFLD.BilgDeptName = department.Name
  8578. fsiOPFLD.BilgDeptCodg = department.Number
  8579. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8580. fsiOPFLD.BilgDrName = doctor.UserName
  8581. fsiOPFLD.MedChrgitmType = "09"
  8582. memo["hosp_appr_flag"] = "1"
  8583. memo["invoice_no"] = order.MdtrtId
  8584. memo["memo"] = "自费"
  8585. bytesData, _ := json.Marshal(memo)
  8586. fsiOPFLD.Memo = string(bytesData)
  8587. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8588. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8589. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8590. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8591. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8592. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8593. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8594. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8595. fsiOPFLD.BilgDeptName = department.Name
  8596. fsiOPFLD.BilgDeptCodg = department.Number
  8597. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8598. fsiOPFLD.BilgDrName = doctor.UserName
  8599. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8600. case 0:
  8601. break
  8602. case 1:
  8603. fsiOPFLD.MedChrgitmType = "14"
  8604. break
  8605. case 2:
  8606. fsiOPFLD.MedChrgitmType = "05"
  8607. break
  8608. case 3:
  8609. fsiOPFLD.MedChrgitmType = "03"
  8610. break
  8611. case 4:
  8612. fsiOPFLD.MedChrgitmType = "03"
  8613. break
  8614. case 5:
  8615. fsiOPFLD.MedChrgitmType = "08"
  8616. break
  8617. case 6:
  8618. fsiOPFLD.MedChrgitmType = "14"
  8619. break
  8620. case 7:
  8621. fsiOPFLD.MedChrgitmType = "14"
  8622. break
  8623. case 8:
  8624. fsiOPFLD.MedChrgitmType = "03"
  8625. break
  8626. case 9:
  8627. fsiOPFLD.MedChrgitmType = "14"
  8628. break
  8629. case 10:
  8630. fsiOPFLD.MedChrgitmType = "14"
  8631. break
  8632. case 11:
  8633. fsiOPFLD.MedChrgitmType = "06"
  8634. break
  8635. case 12:
  8636. fsiOPFLD.MedChrgitmType = "12"
  8637. break
  8638. case 13:
  8639. fsiOPFLD.MedChrgitmType = "01"
  8640. break
  8641. case 14:
  8642. fsiOPFLD.MedChrgitmType = "04"
  8643. break
  8644. case 15:
  8645. fsiOPFLD.MedChrgitmType = "14"
  8646. break
  8647. }
  8648. memo["hosp_appr_flag"] = "1"
  8649. memo["invoice_no"] = order.MdtrtId
  8650. memo["memo"] = "自费"
  8651. bytesData, _ := json.Marshal(memo)
  8652. fsiOPFLD.Memo = string(bytesData)
  8653. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8654. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8655. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8656. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8657. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8658. fsiOPFLD.BilgDeptName = department.Name
  8659. fsiOPFLD.BilgDeptCodg = department.Number
  8660. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8661. fsiOPFLD.BilgDrName = doctor.UserName
  8662. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8663. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8664. fsiOPFLD.MedChrgitmType = "08"
  8665. memo["hosp_appr_flag"] = "1"
  8666. memo["invoice_no"] = order.MdtrtId
  8667. memo["memo"] = "自费"
  8668. bytesData, _ := json.Marshal(memo)
  8669. fsiOPFLD.Memo = string(bytesData)
  8670. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8671. }
  8672. }
  8673. }
  8674. for _, items := range order_info_two {
  8675. memo := make(map[string]interface{})
  8676. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8677. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8678. fsiOPFLD.MedType = "14"
  8679. fsiOPFLD.BkkpSn = items.FeedetlSn
  8680. fsiOPFLD.FixmedinsCode = miConfig.Code
  8681. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8682. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8683. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8684. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8685. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8686. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8687. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8688. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8689. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8690. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8691. fsiOPFLD.BilgDeptName = department.Name
  8692. fsiOPFLD.BilgDeptCodg = department.Number
  8693. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8694. fsiOPFLD.BilgDrName = doctor.UserName
  8695. fsiOPFLD.MedChrgitmType = "09"
  8696. memo["hosp_appr_flag"] = "1"
  8697. memo["invoice_no"] = order.MdtrtId
  8698. memo["memo"] = "自费"
  8699. bytesData, _ := json.Marshal(memo)
  8700. fsiOPFLD.Memo = string(bytesData)
  8701. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8702. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8703. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8704. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8705. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8706. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8707. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8708. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8709. fsiOPFLD.BilgDeptName = department.Name
  8710. fsiOPFLD.BilgDeptCodg = department.Number
  8711. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8712. fsiOPFLD.BilgDrName = doctor.UserName
  8713. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8714. case 0:
  8715. break
  8716. case 1:
  8717. fsiOPFLD.MedChrgitmType = "14"
  8718. break
  8719. case 2:
  8720. fsiOPFLD.MedChrgitmType = "05"
  8721. break
  8722. case 3:
  8723. fsiOPFLD.MedChrgitmType = "03"
  8724. break
  8725. case 4:
  8726. fsiOPFLD.MedChrgitmType = "03"
  8727. break
  8728. case 5:
  8729. fsiOPFLD.MedChrgitmType = "08"
  8730. break
  8731. case 6:
  8732. fsiOPFLD.MedChrgitmType = "14"
  8733. break
  8734. case 7:
  8735. fsiOPFLD.MedChrgitmType = "14"
  8736. break
  8737. case 8:
  8738. fsiOPFLD.MedChrgitmType = "03"
  8739. break
  8740. case 9:
  8741. fsiOPFLD.MedChrgitmType = "14"
  8742. break
  8743. case 10:
  8744. fsiOPFLD.MedChrgitmType = "14"
  8745. break
  8746. case 11:
  8747. fsiOPFLD.MedChrgitmType = "06"
  8748. break
  8749. case 12:
  8750. fsiOPFLD.MedChrgitmType = "12"
  8751. break
  8752. case 13:
  8753. fsiOPFLD.MedChrgitmType = "01"
  8754. break
  8755. case 14:
  8756. fsiOPFLD.MedChrgitmType = "04"
  8757. break
  8758. case 15:
  8759. fsiOPFLD.MedChrgitmType = "14"
  8760. break
  8761. }
  8762. memo["hosp_appr_flag"] = "1"
  8763. memo["invoice_no"] = order.MdtrtId
  8764. memo["memo"] = "自费"
  8765. bytesData, _ := json.Marshal(memo)
  8766. fsiOPFLD.Memo = string(bytesData)
  8767. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8768. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8769. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8770. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8771. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8772. fsiOPFLD.BilgDeptName = department.Name
  8773. fsiOPFLD.BilgDeptCodg = department.Number
  8774. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8775. fsiOPFLD.BilgDrName = doctor.UserName
  8776. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8777. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8778. fsiOPFLD.MedChrgitmType = "08"
  8779. memo["hosp_appr_flag"] = "1"
  8780. memo["invoice_no"] = order.MdtrtId
  8781. memo["memo"] = "自费"
  8782. bytesData, _ := json.Marshal(memo)
  8783. fsiOPFLD.Memo = string(bytesData)
  8784. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8785. }
  8786. }
  8787. }
  8788. fmt.Println(fsiOPFLDs)
  8789. struct4201A.Fopfd = fsiOPFLDs
  8790. fmt.Println(struct4201A.Fopfd)
  8791. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8792. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8793. var res2 ResultSix
  8794. var respJSON2 map[string]interface{}
  8795. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8798. return
  8799. }
  8800. userJSONBytes2, _ := json.Marshal(respJSON2)
  8801. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8802. utils.ErrorLog("解析失败:%v", err)
  8803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8804. return
  8805. }
  8806. if res2.Infcode != 0 {
  8807. c.ServeSuccessJSON(map[string]interface{}{
  8808. "failed_code": -10,
  8809. "msg": res2.ErrMsg,
  8810. })
  8811. return
  8812. } else {
  8813. order.IsUploadOrderInfo = 1
  8814. service.UpdateOrder(order)
  8815. c.ServeSuccessJSON(map[string]interface{}{
  8816. "msg": "上传成功",
  8817. })
  8818. }
  8819. }
  8820. func (c *HisApiController) Get4202() {
  8821. order_id, _ := c.GetInt64("order_id")
  8822. admin_user_id, _ := c.GetInt64("admin_user_id")
  8823. order, _ := service.GetHisOrderByIDTwo(order_id)
  8824. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8825. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8827. if order.ID == 0 {
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8829. return
  8830. }
  8831. var struct4202 models.Struct4202
  8832. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8833. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8834. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8835. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8836. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8837. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8838. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8839. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8840. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8841. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8842. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8843. var config []*models.HisXtDiagnoseConfig
  8844. for _, item := range diagnosis_ids {
  8845. id, _ := strconv.ParseInt(item, 10, 64)
  8846. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8847. config = append(config, &diagnosisConfig)
  8848. }
  8849. var tempDiaginfos []models.OwnPayPatnDiagListD
  8850. for index, item := range config {
  8851. if index == 0 {
  8852. var tempDiaginfo models.OwnPayPatnDiagListD
  8853. tempDiaginfo.InoutDiagType = "1"
  8854. tempDiaginfo.DiagCode = item.CountryCode
  8855. tempDiaginfo.DiagName = item.CountryContentName
  8856. tempDiaginfo.DiagType = "1"
  8857. tempDiaginfo.DiagSrtNo = "1"
  8858. tempDiaginfo.MaindiagFlag = "1"
  8859. tempDiaginfo.ValiFlag = "1"
  8860. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8861. } else {
  8862. var tempDiaginfo models.OwnPayPatnDiagListD
  8863. tempDiaginfo.DiagCode = item.CountryCode
  8864. tempDiaginfo.DiagName = item.CountryContentName
  8865. tempDiaginfo.DiagType = "2"
  8866. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8867. tempDiaginfo.MaindiagFlag = "0"
  8868. tempDiaginfo.ValiFlag = "1"
  8869. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8870. }
  8871. }
  8872. struct4202.ODiagListD = tempDiaginfos
  8873. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8874. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8875. var res2 ResultSix
  8876. var respJSON2 map[string]interface{}
  8877. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. userJSONBytes2, _ := json.Marshal(respJSON2)
  8883. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8884. utils.ErrorLog("解析失败:%v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. if res2.Infcode != 0 {
  8889. c.ServeSuccessJSON(map[string]interface{}{
  8890. "failed_code": -10,
  8891. "msg": res2.ErrMsg,
  8892. })
  8893. return
  8894. } else {
  8895. order.IsUploadDiagnose = 1
  8896. service.UpdateOrder(order)
  8897. c.ServeSuccessJSON(map[string]interface{}{
  8898. "msg": "上传成功",
  8899. })
  8900. }
  8901. }
  8902. func (c *HisApiController) Get4203() {
  8903. admin_user_id, _ := c.GetInt64("admin_user_id")
  8904. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8905. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8906. order_id, _ := c.GetInt64("order_id")
  8907. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8908. number := ""
  8909. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8910. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8911. if his.ID == 0 {
  8912. number = hospital.Number
  8913. } else {
  8914. number = his.Number
  8915. }
  8916. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8917. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8918. var res2 ResultSix
  8919. var respJSON2 map[string]interface{}
  8920. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. userJSONBytes2, _ := json.Marshal(respJSON2)
  8926. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8927. utils.ErrorLog("解析失败:%v", err)
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8929. return
  8930. }
  8931. if res2.Infcode != 0 {
  8932. c.ServeSuccessJSON(map[string]interface{}{
  8933. "failed_code": -10,
  8934. "msg": res2.ErrMsg,
  8935. })
  8936. return
  8937. } else {
  8938. order.IsUploadSuccess = 1
  8939. service.UpdateOrderTwo(order)
  8940. c.ServeSuccessJSON(map[string]interface{}{
  8941. "msg": "上传成功",
  8942. })
  8943. }
  8944. }
  8945. func (c *HisApiController) Get4205() {
  8946. order_id, _ := c.GetInt64("order_id")
  8947. admin_user_id, _ := c.GetInt64("admin_user_id")
  8948. fapiao_code := c.GetString("fapiao_code")
  8949. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8950. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8951. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8952. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8953. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8954. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8955. //order_info = append(order_info, order_info_two...)
  8956. department, _ := service.GetDepartMentDetail(his.Departments)
  8957. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8958. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8959. if order.ID == 0 {
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8961. return
  8962. }
  8963. var struct4201A models.Struct4201A
  8964. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8965. for _, items := range order_info {
  8966. memo := make(map[string]interface{})
  8967. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8968. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8969. fsiOPFLD.MedType = pre.MedType
  8970. fsiOPFLD.FixmedinsCode = miConfig.Code
  8971. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8972. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8973. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8974. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8975. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8976. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8977. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8978. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8979. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8980. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8981. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8982. fsiOPFLD.BilgDeptName = department.Name
  8983. fsiOPFLD.BilgDeptCodg = department.Number
  8984. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8985. fsiOPFLD.BilgDrName = doctor.UserName
  8986. fsiOPFLD.MedChrgitmType = "09"
  8987. memo["hosp_appr_flag"] = "1"
  8988. memo["invoice_no"] = fapiao_code
  8989. memo["memo"] = "自费"
  8990. bytesData, _ := json.Marshal(memo)
  8991. fsiOPFLD.Memo = string(bytesData)
  8992. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8993. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8994. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8995. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8996. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8997. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8998. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8999. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9000. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9001. fsiOPFLD.BilgDeptName = department.Name
  9002. fsiOPFLD.BilgDeptCodg = department.Number
  9003. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9004. fsiOPFLD.BilgDrName = doctor.UserName
  9005. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9006. case 0:
  9007. break
  9008. case 1:
  9009. fsiOPFLD.MedChrgitmType = "14"
  9010. break
  9011. case 2:
  9012. fsiOPFLD.MedChrgitmType = "05"
  9013. break
  9014. case 3:
  9015. fsiOPFLD.MedChrgitmType = "03"
  9016. break
  9017. case 4:
  9018. fsiOPFLD.MedChrgitmType = "03"
  9019. break
  9020. case 5:
  9021. fsiOPFLD.MedChrgitmType = "08"
  9022. break
  9023. case 6:
  9024. fsiOPFLD.MedChrgitmType = "14"
  9025. break
  9026. case 7:
  9027. fsiOPFLD.MedChrgitmType = "14"
  9028. break
  9029. case 8:
  9030. fsiOPFLD.MedChrgitmType = "03"
  9031. break
  9032. case 9:
  9033. fsiOPFLD.MedChrgitmType = "14"
  9034. break
  9035. case 10:
  9036. fsiOPFLD.MedChrgitmType = "14"
  9037. break
  9038. case 11:
  9039. fsiOPFLD.MedChrgitmType = "06"
  9040. break
  9041. case 12:
  9042. fsiOPFLD.MedChrgitmType = "12"
  9043. break
  9044. case 13:
  9045. fsiOPFLD.MedChrgitmType = "01"
  9046. break
  9047. case 14:
  9048. fsiOPFLD.MedChrgitmType = "04"
  9049. break
  9050. case 15:
  9051. fsiOPFLD.MedChrgitmType = "14"
  9052. break
  9053. }
  9054. memo["hosp_appr_flag"] = "1"
  9055. memo["invoice_no"] = fapiao_code
  9056. memo["memo"] = "自费"
  9057. bytesData, _ := json.Marshal(memo)
  9058. fsiOPFLD.Memo = string(bytesData)
  9059. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9060. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9061. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9062. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9063. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9064. fsiOPFLD.BilgDeptName = department.Name
  9065. fsiOPFLD.BilgDeptCodg = department.Number
  9066. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9067. fsiOPFLD.BilgDrName = doctor.UserName
  9068. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9069. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9070. fsiOPFLD.MedChrgitmType = "08"
  9071. memo["hosp_appr_flag"] = "1"
  9072. memo["invoice_no"] = fapiao_code
  9073. memo["memo"] = "自费"
  9074. bytesData, _ := json.Marshal(memo)
  9075. fsiOPFLD.Memo = string(bytesData)
  9076. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9077. }
  9078. }
  9079. }
  9080. for _, items := range order_info_two {
  9081. memo := make(map[string]interface{})
  9082. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9083. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9084. fsiOPFLD.MedType = pre.MedType
  9085. fsiOPFLD.BkkpSn = items.FeedetlSn
  9086. fsiOPFLD.FixmedinsCode = miConfig.Code
  9087. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9088. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9089. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9090. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9091. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9092. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9093. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9094. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9095. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9096. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9097. fsiOPFLD.BilgDeptName = department.Name
  9098. fsiOPFLD.BilgDeptCodg = department.Number
  9099. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9100. fsiOPFLD.BilgDrName = doctor.UserName
  9101. fsiOPFLD.MedChrgitmType = "09"
  9102. memo["hosp_appr_flag"] = "1"
  9103. memo["invoice_no"] = fapiao_code
  9104. memo["memo"] = "自费"
  9105. bytesData, _ := json.Marshal(memo)
  9106. fsiOPFLD.Memo = string(bytesData)
  9107. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9108. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9109. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9110. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9111. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9112. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9113. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9114. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9115. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9116. fsiOPFLD.BilgDeptName = department.Name
  9117. fsiOPFLD.BilgDeptCodg = department.Number
  9118. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9119. fsiOPFLD.BilgDrName = doctor.UserName
  9120. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9121. case 0:
  9122. break
  9123. case 1:
  9124. fsiOPFLD.MedChrgitmType = "14"
  9125. break
  9126. case 2:
  9127. fsiOPFLD.MedChrgitmType = "05"
  9128. break
  9129. case 3:
  9130. fsiOPFLD.MedChrgitmType = "03"
  9131. break
  9132. case 4:
  9133. fsiOPFLD.MedChrgitmType = "03"
  9134. break
  9135. case 5:
  9136. fsiOPFLD.MedChrgitmType = "08"
  9137. break
  9138. case 6:
  9139. fsiOPFLD.MedChrgitmType = "14"
  9140. break
  9141. case 7:
  9142. fsiOPFLD.MedChrgitmType = "14"
  9143. break
  9144. case 8:
  9145. fsiOPFLD.MedChrgitmType = "03"
  9146. break
  9147. case 9:
  9148. fsiOPFLD.MedChrgitmType = "14"
  9149. break
  9150. case 10:
  9151. fsiOPFLD.MedChrgitmType = "14"
  9152. break
  9153. case 11:
  9154. fsiOPFLD.MedChrgitmType = "06"
  9155. break
  9156. case 12:
  9157. fsiOPFLD.MedChrgitmType = "12"
  9158. break
  9159. case 13:
  9160. fsiOPFLD.MedChrgitmType = "01"
  9161. break
  9162. case 14:
  9163. fsiOPFLD.MedChrgitmType = "04"
  9164. break
  9165. case 15:
  9166. fsiOPFLD.MedChrgitmType = "14"
  9167. break
  9168. }
  9169. memo["hosp_appr_flag"] = "1"
  9170. memo["invoice_no"] = fapiao_code
  9171. memo["memo"] = "自费"
  9172. bytesData, _ := json.Marshal(memo)
  9173. fsiOPFLD.Memo = string(bytesData)
  9174. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9175. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9176. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9177. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9178. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9179. fsiOPFLD.BilgDeptName = department.Name
  9180. fsiOPFLD.BilgDeptCodg = department.Number
  9181. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9182. fsiOPFLD.BilgDrName = doctor.UserName
  9183. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9184. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9185. fsiOPFLD.MedChrgitmType = "08"
  9186. memo["hosp_appr_flag"] = "1"
  9187. memo["invoice_no"] = fapiao_code
  9188. memo["memo"] = "自费"
  9189. bytesData, _ := json.Marshal(memo)
  9190. fsiOPFLD.Memo = string(bytesData)
  9191. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9192. }
  9193. }
  9194. }
  9195. fmt.Println(fsiOPFLDs)
  9196. struct4201A.Fopfd = fsiOPFLDs
  9197. fmt.Println(struct4201A.Fopfd)
  9198. var struct4202 models.Struct4202
  9199. timeLayout := "2006-01-02 15:04:05"
  9200. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9201. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9202. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9203. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9204. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9205. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9206. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9207. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9208. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9209. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9210. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9211. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9212. var config []*models.HisXtDiagnoseConfig
  9213. for _, item := range diagnosis_ids {
  9214. id, _ := strconv.ParseInt(item, 10, 64)
  9215. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9216. config = append(config, &diagnosisConfig)
  9217. }
  9218. var tempDiaginfos []models.OwnPayPatnDiagListD
  9219. for index, item := range config {
  9220. if index == 0 {
  9221. var tempDiaginfo models.OwnPayPatnDiagListD
  9222. tempDiaginfo.InoutDiagType = "1"
  9223. tempDiaginfo.DiagCode = item.CountryCode
  9224. tempDiaginfo.DiagName = item.CountryContentName
  9225. tempDiaginfo.DiagType = "1"
  9226. tempDiaginfo.DiagSrtNo = "1"
  9227. tempDiaginfo.MaindiagFlag = "1"
  9228. tempDiaginfo.ValiFlag = "1"
  9229. tempDiaginfo.DiagDrName = doctor.UserName
  9230. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9231. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9232. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9233. } else {
  9234. var tempDiaginfo models.OwnPayPatnDiagListD
  9235. tempDiaginfo.DiagCode = item.CountryCode
  9236. tempDiaginfo.DiagName = item.CountryContentName
  9237. tempDiaginfo.DiagType = "2"
  9238. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9239. tempDiaginfo.MaindiagFlag = "0"
  9240. tempDiaginfo.ValiFlag = "1"
  9241. tempDiaginfo.DiagDrName = doctor.UserName
  9242. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9243. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9244. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9245. }
  9246. }
  9247. struct4202.ODiagListD = tempDiaginfos
  9248. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9249. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9250. var res2 ResultSix
  9251. var respJSON2 map[string]interface{}
  9252. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9255. return
  9256. }
  9257. userJSONBytes2, _ := json.Marshal(respJSON2)
  9258. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9259. utils.ErrorLog("解析失败:%v", err)
  9260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9261. return
  9262. }
  9263. if res2.Infcode != 0 {
  9264. c.ServeSuccessJSON(map[string]interface{}{
  9265. "failed_code": -10,
  9266. "msg": res2.ErrMsg,
  9267. })
  9268. return
  9269. } else {
  9270. order.IsUploadDiagnose = 1
  9271. order.IsUploadOrderInfo = 1
  9272. service.UpdateOrderTwo(order)
  9273. c.ServeSuccessJSON(map[string]interface{}{
  9274. "msg": "上传成功",
  9275. })
  9276. }
  9277. }
  9278. func (c *HisApiController) Get4207() {
  9279. admin_user_id, _ := c.GetInt64("admin_user_id")
  9280. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9281. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9282. order_id, _ := c.GetInt64("order_id")
  9283. order, _ := service.GetHisOrderByIDTwo(order_id)
  9284. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9285. var struct4207 models.Struct4207
  9286. struct4207.PageNum = "1"
  9287. struct4207.PageSize = "1000"
  9288. struct4207.FixmedinsCode = miConfig.Code
  9289. struct4207.FixmedinsMdtrtID = order.Number
  9290. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9291. saveLog(result, requestLog, "4207", "查询")
  9292. var res2 ResultSix
  9293. var respJSON2 map[string]interface{}
  9294. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9297. return
  9298. }
  9299. userJSONBytes2, _ := json.Marshal(respJSON2)
  9300. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9301. utils.ErrorLog("解析失败:%v", err)
  9302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9303. return
  9304. }
  9305. if res2.Infcode != 0 {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "failed_code": -10,
  9308. "msg": res2.ErrMsg,
  9309. })
  9310. return
  9311. } else {
  9312. c.ServeSuccessJSON(map[string]interface{}{
  9313. "msg": "查询成功",
  9314. })
  9315. }
  9316. }
  9317. func (c *HisApiController) Get4208() {
  9318. admin_user_id, _ := c.GetInt64("admin_user_id")
  9319. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9320. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9321. order_id, _ := c.GetInt64("order_id")
  9322. order, _ := service.GetHisOrderByIDTwo(order_id)
  9323. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9324. var struct4208 models.Struct4208
  9325. struct4208.PageNum = "1"
  9326. struct4208.PageSize = "1000"
  9327. struct4208.PsnCertType = "01"
  9328. struct4208.Certno = his.Certno
  9329. struct4208.MedType = order.MedType
  9330. struct4208.PsnName = his.Name
  9331. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9332. saveLog(result, requestLog, "4208", "查询")
  9333. var res2 ResultSix
  9334. var respJSON2 map[string]interface{}
  9335. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. return
  9339. }
  9340. userJSONBytes2, _ := json.Marshal(respJSON2)
  9341. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9342. utils.ErrorLog("解析失败:%v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. if res2.Infcode != 0 {
  9347. c.ServeSuccessJSON(map[string]interface{}{
  9348. "failed_code": -10,
  9349. "msg": res2.ErrMsg,
  9350. })
  9351. return
  9352. } else {
  9353. c.ServeSuccessJSON(map[string]interface{}{
  9354. "msg": "查询成功",
  9355. })
  9356. }
  9357. }
  9358. func (c *HisApiController) Get4209() {
  9359. admin_user_id, _ := c.GetInt64("admin_user_id")
  9360. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9361. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9362. order_id, _ := c.GetInt64("order_id")
  9363. order, _ := service.GetHisOrderByIDTwo(order_id)
  9364. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9365. var struct4209 models.Struct4209
  9366. struct4209.FixmedinsMdtrtID = order.Number
  9367. struct4209.FixmedinsCode = miConfig.Code
  9368. struct4209.PageSize = "1000"
  9369. struct4209.PageNum = "1"
  9370. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9371. saveLog(result, requestLog, "4209", "查询")
  9372. var res2 ResultSix
  9373. var respJSON2 map[string]interface{}
  9374. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9377. return
  9378. }
  9379. userJSONBytes2, _ := json.Marshal(respJSON2)
  9380. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9381. utils.ErrorLog("解析失败:%v", err)
  9382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9383. return
  9384. }
  9385. if res2.Infcode != 0 {
  9386. c.ServeSuccessJSON(map[string]interface{}{
  9387. "failed_code": -10,
  9388. "msg": res2.ErrMsg,
  9389. })
  9390. return
  9391. } else {
  9392. c.ServeSuccessJSON(map[string]interface{}{
  9393. "msg": "查询成功",
  9394. })
  9395. }
  9396. }
  9397. type Result3101 struct {
  9398. Infcode string `json:"infcode"`
  9399. InfRefmsgid string `json:"inf_refmsgid"`
  9400. RefmsgTime string `json:"refmsg_time"`
  9401. RespondTime string `json:"respond_time"`
  9402. Enctype string `json:"enctype"`
  9403. Signtype string `json:"signtype"`
  9404. ErrMsg string `json:"err_msg"`
  9405. Output struct {
  9406. Result []struct {
  9407. JudgeResultDetailDtos []struct {
  9408. VolaItemType string `json:"vola_item_type"`
  9409. MdtrtID string `json:"mdtrt_id"`
  9410. JrdID string `json:"jrd_id"`
  9411. PatnID string `json:"patn_id"`
  9412. RxID string `json:"rx_id"`
  9413. VolaAmt interface{} `json:"vola_amt"`
  9414. } `json:"judge_result_detail_dtos"`
  9415. RuleID string `json:"rule_id"`
  9416. VolaEvid string `json:"vola_evid"`
  9417. MdtrtID string `json:"mdtrt_id"`
  9418. RuleName string `json:"rule_name"`
  9419. VolaAmtStas string `json:"vola_amt_stas"`
  9420. JrID string `json:"jr_id"`
  9421. PatnID string `json:"patn_id"`
  9422. SevDeg string `json:"sev_deg"`
  9423. VolaAmt float64 `json:"vola_amt"`
  9424. VolaBhvrType string `json:"vola_bhvr_type"`
  9425. VolaCont string `json:"vola_cont"`
  9426. } `json:"result"`
  9427. } `json:"output"`
  9428. }
  9429. type Resultgd3101 struct {
  9430. Infcode int64 `json:"infcode"`
  9431. InfRefmsgid string `json:"inf_refmsgid"`
  9432. RefmsgTime string `json:"refmsg_time"`
  9433. RespondTime string `json:"respond_time"`
  9434. Enctype string `json:"enctype"`
  9435. Signtype string `json:"signtype"`
  9436. ErrMsg string `json:"err_msg"`
  9437. Output struct {
  9438. Result []struct {
  9439. JudgeResultDetailDtos []struct {
  9440. VolaItemType string `json:"vola_item_type"`
  9441. MdtrtID string `json:"mdtrt_id"`
  9442. JrdID string `json:"jrd_id"`
  9443. PatnID string `json:"patn_id"`
  9444. RxID string `json:"rx_id"`
  9445. VolaAmt interface{} `json:"vola_amt"`
  9446. } `json:"judge_result_detail_dtos"`
  9447. RuleID string `json:"rule_id"`
  9448. VolaEvid string `json:"vola_evid"`
  9449. MdtrtID string `json:"mdtrt_id"`
  9450. RuleName string `json:"rule_name"`
  9451. VolaAmtStas string `json:"vola_amt_stas"`
  9452. JrID string `json:"jr_id"`
  9453. PatnID string `json:"patn_id"`
  9454. SevDeg string `json:"sev_deg"`
  9455. VolaAmt float64 `json:"vola_amt"`
  9456. VolaBhvrType string `json:"vola_bhvr_type"`
  9457. VolaCont string `json:"vola_cont"`
  9458. } `json:"result"`
  9459. } `json:"output"`
  9460. }
  9461. func (c *HisApiController) ReadEleToken() {
  9462. admin_user_id, _ := c.GetInt64("admin_user_id")
  9463. his_patient_id, _ := c.GetInt64("his_patient_id")
  9464. adminUser := c.GetAdminUserInfo()
  9465. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9466. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9467. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9468. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9469. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9470. if len(tokens) > 0 {
  9471. c.ServeSuccessJSON(map[string]interface{}{
  9472. "msg": "读取成功",
  9473. })
  9474. } else {
  9475. c.ServeSuccessJSON(map[string]interface{}{
  9476. "failed_code": -10,
  9477. "msg": "读取失败",
  9478. })
  9479. }
  9480. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9481. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9482. if len(tokens) > 0 {
  9483. c.ServeSuccessJSON(map[string]interface{}{
  9484. "msg": "读取成功",
  9485. })
  9486. } else {
  9487. c.ServeSuccessJSON(map[string]interface{}{
  9488. "failed_code": -10,
  9489. "msg": "读取失败",
  9490. })
  9491. }
  9492. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9493. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9494. if len(tokens) > 0 {
  9495. c.ServeSuccessJSON(map[string]interface{}{
  9496. "msg": "读取成功",
  9497. })
  9498. } else {
  9499. c.ServeSuccessJSON(map[string]interface{}{
  9500. "failed_code": -10,
  9501. "msg": "读取失败",
  9502. })
  9503. }
  9504. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9505. var api string
  9506. 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 +
  9507. "&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"
  9508. resp, requestErr := http.Get(api)
  9509. if requestErr != nil {
  9510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. }
  9512. body, ioErr := ioutil.ReadAll(resp.Body)
  9513. if ioErr != nil {
  9514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. }
  9517. var respJSON map[string]interface{}
  9518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9521. return
  9522. }
  9523. var status string
  9524. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9525. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9526. var token string
  9527. var res ResultTwo //1101结果
  9528. var res10265 ResultTwo10265 //1101结果
  9529. if status == "0" { //读卡成功
  9530. var card_info string //卡信息
  9531. var busi_card_info string
  9532. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9533. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9534. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9535. fmt.Println(card_info)
  9536. fmt.Println(busi_card_info)
  9537. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9538. result, _ := json.Marshal(respJSON)
  9539. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9540. utils.ErrorLog("解析失败:%v", err)
  9541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9542. return
  9543. }
  9544. res.ErrMsg = res10265.ErrMsg
  9545. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9546. res.Infcode = infocode
  9547. res.Output = res10265.Output
  9548. res.InfRefmsgid = res10265.InfRefmsgid
  9549. if res.Infcode == 0 {
  9550. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9551. if err == gorm.ErrRecordNotFound {
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9553. return
  9554. } else if err != nil {
  9555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9556. return
  9557. } else {
  9558. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9559. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9560. infoStr := string(Iinfos)
  9561. idetinfoStr := string(Idetinfos)
  9562. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9563. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9564. psn := &models.HisPsn{
  9565. PsnNo: res.Output.Baseinfo.PsnNo,
  9566. PatientId: patient.ID,
  9567. Certno: res.Output.Baseinfo.Certno,
  9568. Gend: res.Output.Baseinfo.Gend,
  9569. Naty: res.Output.Baseinfo.Naty,
  9570. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9571. PsnName: res.Output.Baseinfo.PsnName,
  9572. Age: float64(age),
  9573. Brdy: b,
  9574. Idetinfo: idetinfoStr,
  9575. Insuinfo: infoStr,
  9576. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9577. CardInfo: card_info,
  9578. VerifyNumber: token,
  9579. IdCardType: 4,
  9580. }
  9581. var rf []*ResultFive
  9582. json.Unmarshal([]byte(infoStr), &rf)
  9583. var insutypes []*ResultFive
  9584. var insutype string
  9585. var is390 int = 0
  9586. var is310 int = 0
  9587. for _, item := range rf {
  9588. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9589. insutypes = append(insutypes, item)
  9590. }
  9591. }
  9592. if len(insutypes) == 1 {
  9593. insutype = insutypes[0].Insutype
  9594. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9595. } else {
  9596. for _, i := range insutypes {
  9597. if i.Insutype == "390" {
  9598. is390 = 1
  9599. }
  9600. if i.Insutype == "310" {
  9601. is310 = 1
  9602. }
  9603. }
  9604. }
  9605. if is390 == 1 {
  9606. insutype = "390"
  9607. }
  9608. if is310 == 1 {
  9609. insutype = "310"
  9610. }
  9611. if len(insutypes) == 0 {
  9612. insutype = "310"
  9613. }
  9614. service.CreateHisPsn(psn)
  9615. c.ServeSuccessJSON(map[string]interface{}{
  9616. "patient": patient,
  9617. "number": token,
  9618. "insutype": insutype,
  9619. })
  9620. }
  9621. } else {
  9622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9623. return
  9624. }
  9625. } else { //读卡失败
  9626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9627. return
  9628. }
  9629. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9630. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9631. if len(errMsg) == 0 {
  9632. type ELeData struct {
  9633. Data struct {
  9634. IdNo string `json:"idNo"`
  9635. IdType string `json:"idType"`
  9636. UserName string `json:"userName"`
  9637. EcToken string `json:"ecToken"`
  9638. InsuOrg string `json:"insuOrg"`
  9639. Gender string `json:"gender"`
  9640. Birthday string `json:"birthday"`
  9641. Nationality string `json:"nationality"`
  9642. Email string `json:"email"`
  9643. Extra string `json:"extra"`
  9644. } `json:"data"`
  9645. Code int `json:"code"`
  9646. Message string `json:"message"`
  9647. }
  9648. var ele ELeData
  9649. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9650. if err != nil {
  9651. utils.ErrorLog("解析失败:%v", err)
  9652. }
  9653. token := ele.Data.EcToken
  9654. if len(token) > 0 {
  9655. psn := &models.HisPsn{
  9656. PsnNo: his.PsnNo,
  9657. Age: 0,
  9658. PatientId: his.PatientId,
  9659. Certno: his.Certno,
  9660. Brdy: his.Brdy,
  9661. Gend: his.Gend,
  9662. Naty: his.Naty,
  9663. PsnCertType: his.PsnCertType,
  9664. PsnName: his.PsnName,
  9665. Idetinfo: his.Idetinfo,
  9666. Insuinfo: his.Iinfo,
  9667. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9668. CardInfo: outPutInfo,
  9669. VerifyNumber: token,
  9670. }
  9671. service.CreateHisPsn(psn)
  9672. }
  9673. if len(token) > 0 {
  9674. c.ServeSuccessJSON(map[string]interface{}{
  9675. "msg": "读取成功",
  9676. })
  9677. } else {
  9678. c.ServeSuccessJSON(map[string]interface{}{
  9679. "failed_code": -10,
  9680. "msg": "读取失败",
  9681. })
  9682. }
  9683. }
  9684. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9685. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9686. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9687. type ELeData struct {
  9688. Data struct {
  9689. IdNo string `json:"idNo"`
  9690. IdType string `json:"idType"`
  9691. UserName string `json:"userName"`
  9692. EcToken string `json:"ecToken"`
  9693. InsuOrg string `json:"insuOrg"`
  9694. Gender string `json:"gender"`
  9695. Birthday string `json:"birthday"`
  9696. Nationality string `json:"nationality"`
  9697. Email string `json:"email"`
  9698. Extra string `json:"extra"`
  9699. } `json:"data"`
  9700. Code int `json:"code"`
  9701. Message string `json:"message"`
  9702. }
  9703. var ele ELeData
  9704. err := json.Unmarshal([]byte(result), &ele)
  9705. if err != nil {
  9706. utils.ErrorLog("解析失败:%v", err)
  9707. }
  9708. token := ele.Data.EcToken
  9709. token = Remove0000(token)
  9710. fmt.Println(ele.Data.UserName)
  9711. 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)
  9712. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9713. var res ResultTwo
  9714. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9715. utils.ErrorLog("解析失败:%v", err)
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9717. return
  9718. }
  9719. if res.Infcode == 0 {
  9720. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9721. if err == gorm.ErrRecordNotFound {
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9723. return
  9724. } else if err != nil {
  9725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9726. return
  9727. } else {
  9728. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9729. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9730. infoStr := string(Iinfos)
  9731. idetinfoStr := string(Idetinfos)
  9732. psn := &models.HisPsn{
  9733. PsnNo: res.Output.Baseinfo.PsnNo,
  9734. PatientId: patient.ID,
  9735. Certno: res.Output.Baseinfo.Certno,
  9736. Gend: res.Output.Baseinfo.Gend,
  9737. Naty: res.Output.Baseinfo.Naty,
  9738. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9739. PsnName: res.Output.Baseinfo.PsnName,
  9740. Idetinfo: idetinfoStr,
  9741. Insuinfo: infoStr,
  9742. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9743. CardInfo: "",
  9744. VerifyNumber: token,
  9745. }
  9746. service.CreateHisPsn(psn)
  9747. c.ServeSuccessJSON(map[string]interface{}{
  9748. "patient": patient,
  9749. "number": token,
  9750. })
  9751. }
  9752. } else {
  9753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9754. return
  9755. }
  9756. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9757. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9758. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9759. type ELeData struct {
  9760. Data struct {
  9761. IdNo string `json:"idNo"`
  9762. IdType string `json:"idType"`
  9763. UserName string `json:"userName"`
  9764. EcToken string `json:"ecToken"`
  9765. InsuOrg string `json:"insuOrg"`
  9766. Gender string `json:"gender"`
  9767. Birthday string `json:"birthday"`
  9768. Nationality string `json:"nationality"`
  9769. Email string `json:"email"`
  9770. Extra string `json:"extra"`
  9771. } `json:"data"`
  9772. Code int `json:"code"`
  9773. Message string `json:"message"`
  9774. }
  9775. var ele ELeData
  9776. err := json.Unmarshal([]byte(result), &ele)
  9777. if err != nil {
  9778. utils.ErrorLog("解析失败:%v", err)
  9779. }
  9780. token := ele.Data.EcToken
  9781. token = Remove0000(token)
  9782. fmt.Println(ele.Data.UserName)
  9783. 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)
  9784. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9785. var res ResultTwo
  9786. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9787. utils.ErrorLog("解析失败:%v", err)
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9789. return
  9790. }
  9791. if res.Infcode == 0 {
  9792. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9793. if err == gorm.ErrRecordNotFound {
  9794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9795. return
  9796. } else if err != nil {
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9798. return
  9799. } else {
  9800. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9801. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9802. infoStr := string(Iinfos)
  9803. idetinfoStr := string(Idetinfos)
  9804. psn := &models.HisPsn{
  9805. PsnNo: res.Output.Baseinfo.PsnNo,
  9806. PatientId: patient.ID,
  9807. Certno: res.Output.Baseinfo.Certno,
  9808. Gend: res.Output.Baseinfo.Gend,
  9809. Naty: res.Output.Baseinfo.Naty,
  9810. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9811. PsnName: res.Output.Baseinfo.PsnName,
  9812. Idetinfo: idetinfoStr,
  9813. Insuinfo: infoStr,
  9814. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9815. CardInfo: "",
  9816. VerifyNumber: token,
  9817. }
  9818. service.CreateHisPsn(psn)
  9819. c.ServeSuccessJSON(map[string]interface{}{
  9820. "patient": patient,
  9821. "number": token,
  9822. })
  9823. }
  9824. } else {
  9825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9826. return
  9827. }
  9828. } else if miConfig.MdtrtareaAdmvs == "360100" {
  9829. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9830. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9831. type ELeData struct {
  9832. Data struct {
  9833. IdNo string `json:"idNo"`
  9834. IdType string `json:"idType"`
  9835. UserName string `json:"userName"`
  9836. EcToken string `json:"ecToken"`
  9837. InsuOrg string `json:"insuOrg"`
  9838. Gender string `json:"gender"`
  9839. Birthday string `json:"birthday"`
  9840. Nationality string `json:"nationality"`
  9841. Email string `json:"email"`
  9842. Extra string `json:"extra"`
  9843. } `json:"data"`
  9844. Code int `json:"code"`
  9845. Message string `json:"message"`
  9846. }
  9847. var ele ELeData
  9848. err := json.Unmarshal([]byte(result), &ele)
  9849. if err != nil {
  9850. utils.ErrorLog("解析失败:%v", err)
  9851. }
  9852. token := ele.Data.EcToken
  9853. token = Remove0000(token)
  9854. fmt.Println(ele.Data.UserName)
  9855. 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)
  9856. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9857. var res ResultTwo
  9858. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9859. utils.ErrorLog("解析失败:%v", err)
  9860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9861. return
  9862. }
  9863. if res.Infcode == 0 {
  9864. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9865. if err == gorm.ErrRecordNotFound {
  9866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9867. return
  9868. } else if err != nil {
  9869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9870. return
  9871. } else {
  9872. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9873. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9874. infoStr := string(Iinfos)
  9875. idetinfoStr := string(Idetinfos)
  9876. psn := &models.HisPsn{
  9877. PsnNo: res.Output.Baseinfo.PsnNo,
  9878. PatientId: patient.ID,
  9879. Certno: res.Output.Baseinfo.Certno,
  9880. Gend: res.Output.Baseinfo.Gend,
  9881. Naty: res.Output.Baseinfo.Naty,
  9882. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9883. PsnName: res.Output.Baseinfo.PsnName,
  9884. Idetinfo: idetinfoStr,
  9885. Insuinfo: infoStr,
  9886. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9887. CardInfo: "",
  9888. VerifyNumber: token,
  9889. }
  9890. service.CreateHisPsn(psn)
  9891. c.ServeSuccessJSON(map[string]interface{}{
  9892. "patient": patient,
  9893. "number": token,
  9894. })
  9895. }
  9896. } else {
  9897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9898. return
  9899. }
  9900. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9901. //if initFlag == 0 {
  9902. //c.TestGetJiangXiBasBaseInit()
  9903. //}
  9904. //if initEleFlag == 0 {
  9905. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9906. //}
  9907. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9908. utils.ErrorLog("解析失败:%v", json_result)
  9909. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9910. type ELeData struct {
  9911. Data struct {
  9912. IdNo string `json:"idNo"`
  9913. IdType string `json:"idType"`
  9914. UserName string `json:"userName"`
  9915. EcToken string `json:"ecToken"`
  9916. InsuOrg string `json:"insuOrg"`
  9917. Gender string `json:"gender"`
  9918. Birthday string `json:"birthday"`
  9919. Nationality string `json:"nationality"`
  9920. Email string `json:"email"`
  9921. Extra string `json:"extra"`
  9922. } `json:"data"`
  9923. Code int `json:"code"`
  9924. Message string `json:"message"`
  9925. }
  9926. var ele ELeData
  9927. err := json.Unmarshal([]byte(json_result), &ele)
  9928. if err != nil {
  9929. utils.ErrorLog("解析失败:%v", err)
  9930. }
  9931. token := ele.Data.EcToken
  9932. token = Remove0000(token)
  9933. //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)
  9934. 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)
  9935. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9936. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9937. var res ResultTwo
  9938. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9939. utils.ErrorLog("解析失败:%v", err)
  9940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9941. return
  9942. }
  9943. if res.Infcode == 0 {
  9944. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9945. if err == gorm.ErrRecordNotFound {
  9946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9947. return
  9948. } else if err != nil {
  9949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9950. return
  9951. } else {
  9952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9953. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9954. infoStr := string(Iinfos)
  9955. idetinfoStr := string(Idetinfos)
  9956. psn := &models.HisPsn{
  9957. PsnNo: res.Output.Baseinfo.PsnNo,
  9958. PatientId: patient.ID,
  9959. Certno: res.Output.Baseinfo.Certno,
  9960. Gend: res.Output.Baseinfo.Gend,
  9961. Naty: res.Output.Baseinfo.Naty,
  9962. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9963. PsnName: res.Output.Baseinfo.PsnName,
  9964. Idetinfo: idetinfoStr,
  9965. Insuinfo: infoStr,
  9966. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9967. CardInfo: "",
  9968. VerifyNumber: token,
  9969. InsuplcAdmdvs: ele.Data.InsuOrg,
  9970. }
  9971. service.CreateHisPsn(psn)
  9972. c.ServeSuccessJSON(map[string]interface{}{
  9973. "patient": patient,
  9974. "number": token,
  9975. })
  9976. }
  9977. } else {
  9978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9979. return
  9980. }
  9981. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9982. res := c.GetoleInfo()
  9983. if res.Infcode == 0 {
  9984. var result string
  9985. if res.Output.MdtrtCertType == "01" {
  9986. 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)
  9987. } else if res.Output.MdtrtCertType == "02" {
  9988. 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)
  9989. } else if res.Output.MdtrtCertType == "03" {
  9990. 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)
  9991. }
  9992. var dat map[string]interface{}
  9993. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9994. fmt.Println(dat)
  9995. } else {
  9996. fmt.Println(err)
  9997. }
  9998. userJSONBytes, _ := json.Marshal(dat)
  9999. var res2 ResultTwo
  10000. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10001. utils.ErrorLog("解析失败:%v", err)
  10002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10003. return
  10004. }
  10005. if res2.Infcode == 0 {
  10006. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10007. if err == gorm.ErrRecordNotFound {
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10009. return
  10010. } else if err != nil {
  10011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10012. return
  10013. } else {
  10014. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10015. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10016. infoStr := string(Iinfos)
  10017. idetinfoStr := string(Idetinfos)
  10018. var rf []*ResultFive
  10019. json.Unmarshal([]byte(infoStr), &rf)
  10020. var insutypes []*ResultFive
  10021. var insutype string
  10022. var is390 int = 0
  10023. var is310 int = 0
  10024. //var insuplc_admdvs string
  10025. for _, item := range rf {
  10026. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10027. insutypes = append(insutypes, item)
  10028. }
  10029. }
  10030. if len(insutypes) == 1 {
  10031. insutype = insutypes[0].Insutype
  10032. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10033. } else {
  10034. for _, i := range insutypes {
  10035. if i.Insutype == "390" {
  10036. is390 = 1
  10037. }
  10038. if i.Insutype == "310" {
  10039. is310 = 1
  10040. }
  10041. }
  10042. }
  10043. if is390 == 1 {
  10044. insutype = "390"
  10045. }
  10046. if is310 == 1 {
  10047. insutype = "310"
  10048. }
  10049. if len(insutypes) == 0 {
  10050. insutype = "310"
  10051. }
  10052. psn := &models.HisPsn{
  10053. PsnNo: res2.Output.Baseinfo.PsnNo,
  10054. PatientId: patient.ID,
  10055. Certno: res2.Output.Baseinfo.Certno,
  10056. Gend: res2.Output.Baseinfo.Gend,
  10057. Naty: res2.Output.Baseinfo.Naty,
  10058. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10059. PsnName: res2.Output.Baseinfo.PsnName,
  10060. Idetinfo: idetinfoStr,
  10061. Insuinfo: infoStr,
  10062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10063. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10064. VerifyNumber: res.Output.EcToken,
  10065. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10066. }
  10067. service.CreateHisPsn(psn)
  10068. c.ServeSuccessJSON(map[string]interface{}{
  10069. "patient": patient,
  10070. "number": res.Output.CardNo,
  10071. "insutype": insutype,
  10072. })
  10073. }
  10074. } else {
  10075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10076. return
  10077. }
  10078. } else {
  10079. c.ServeSuccessJSON(map[string]interface{}{
  10080. "failed_code": -10,
  10081. "msg": res.ErrMsg,
  10082. })
  10083. }
  10084. } else {
  10085. //if initFlag == 0 {
  10086. // c.TestGetBasBaseInit()
  10087. //}
  10088. //token := c.GetEleBaseInfo()
  10089. //token = Remove0000(token)
  10090. type ELeData struct {
  10091. Code string `json:"code"`
  10092. Data struct {
  10093. Aac002 string `json:"aac002"`
  10094. Aaz500 string `json:"aaz500"`
  10095. ActCardNo string `json:"actCardNo"`
  10096. Bab520 string `json:"bab520"`
  10097. Bkz543 string `json:"bkz543"`
  10098. BusinessType string `json:"businessType"`
  10099. CertfCodg string `json:"certfCodg"`
  10100. EcIndexNo string `json:"ecIndexNo"`
  10101. EcToken string `json:"ecToken"`
  10102. ID0000 string `json:"id0000"`
  10103. IDNo string `json:"idNo"`
  10104. IDType string `json:"idType"`
  10105. Idcode string `json:"idcode"`
  10106. IdentityToken string `json:"identity_token"`
  10107. InsuOrg string `json:"insuOrg"`
  10108. OfficeID string `json:"officeId"`
  10109. OfficeName string `json:"officeName"`
  10110. OperatorID string `json:"operatorId"`
  10111. OperatorName string `json:"operatorName"`
  10112. OrgID string `json:"orgId"`
  10113. UserName string `json:"userName"`
  10114. } `json:"data"`
  10115. Infno interface{} `json:"infno"`
  10116. Message string `json:"message"`
  10117. OrgID string `json:"orgId"`
  10118. TransType string `json:"transType"`
  10119. }
  10120. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10121. fmt.Println(result)
  10122. outPutInfo := Remove0000(result)
  10123. fmt.Println(outPutInfo)
  10124. var ele ELeData
  10125. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10126. if err != nil {
  10127. utils.ErrorLog("解析失败:%v", err)
  10128. }
  10129. token := ele.Data.EcToken
  10130. var result2 string
  10131. var requestLog2 string
  10132. if len(token) > 0 {
  10133. if strings.Contains(ele.Data.IDNo, "HKG") {
  10134. 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)
  10135. } else {
  10136. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10137. }
  10138. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10139. var res ResultTwo
  10140. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10141. utils.ErrorLog("解析失败:%v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. if res.Infcode == 0 {
  10146. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10147. if err == gorm.ErrRecordNotFound {
  10148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10149. return
  10150. } else if err != nil {
  10151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10152. return
  10153. } else {
  10154. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10155. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10156. infoStr := string(Iinfos)
  10157. idetinfoStr := string(Idetinfos)
  10158. psn := &models.HisPsn{
  10159. PsnNo: res.Output.Baseinfo.PsnNo,
  10160. PatientId: patient.ID,
  10161. Certno: res.Output.Baseinfo.Certno,
  10162. Gend: res.Output.Baseinfo.Gend,
  10163. Naty: res.Output.Baseinfo.Naty,
  10164. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10165. PsnName: res.Output.Baseinfo.PsnName,
  10166. Idetinfo: idetinfoStr,
  10167. Insuinfo: infoStr,
  10168. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10169. CardInfo: "",
  10170. VerifyNumber: token,
  10171. }
  10172. service.CreateHisPsn(psn)
  10173. c.ServeSuccessJSON(map[string]interface{}{
  10174. "msg": "读取成功",
  10175. })
  10176. }
  10177. } else {
  10178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10179. return
  10180. }
  10181. } else {
  10182. c.ServeSuccessJSON(map[string]interface{}{
  10183. "failed_code": -10,
  10184. "msg": "读取失败",
  10185. })
  10186. }
  10187. }
  10188. }
  10189. func (c *HisApiController) ReadEleFace() {
  10190. admin_user_id, _ := c.GetInt64("admin_user_id")
  10191. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10192. adminUser := c.GetAdminUserInfo()
  10193. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10194. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10195. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10196. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10197. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10198. if len(tokens) > 0 {
  10199. c.ServeSuccessJSON(map[string]interface{}{
  10200. "msg": "读取成功",
  10201. })
  10202. } else {
  10203. c.ServeSuccessJSON(map[string]interface{}{
  10204. "failed_code": -10,
  10205. "msg": "读取失败",
  10206. })
  10207. }
  10208. }
  10209. }
  10210. func (c *HisApiController) Get9001() {
  10211. adminUser := c.GetAdminUserInfo()
  10212. admin_user_id, _ := c.GetInt64("admin_user_id")
  10213. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10214. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10215. if miConfig.MdtrtareaAdmvs == "350500" {
  10216. service.GetFjAuthorizationInfo(miConfig.Code)
  10217. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10218. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10219. var dat map[string]interface{}
  10220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10221. fmt.Println(dat)
  10222. } else {
  10223. fmt.Println(err)
  10224. }
  10225. userJSONBytes, _ := json.Marshal(dat)
  10226. var res models.Result9001
  10227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10228. utils.ErrorLog("解析失败:%v", err)
  10229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10230. return
  10231. }
  10232. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10233. fmt.Println(miConfig.SecretKey)
  10234. var res models.Result9001Two
  10235. 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 +
  10236. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10237. resp, requestErr := http.Get(api)
  10238. if requestErr != nil {
  10239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10240. return
  10241. }
  10242. body, ioErr := ioutil.ReadAll(resp.Body)
  10243. if ioErr != nil {
  10244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10246. return
  10247. }
  10248. var respJSON map[string]interface{}
  10249. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10252. return
  10253. }
  10254. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10255. if status == "0" {
  10256. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10257. c.ServeSuccessJSON(map[string]interface{}{
  10258. "failed_code": -10,
  10259. "msg": err_msg,
  10260. })
  10261. return
  10262. }
  10263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10264. result, _ := json.Marshal(respJSON)
  10265. fmt.Println("log")
  10266. fmt.Println(string(result))
  10267. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10268. utils.ErrorLog("解析失败:%v", err)
  10269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10270. return
  10271. }
  10272. if res.Infcode == 0 {
  10273. sign := models.HisSignIn{
  10274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10275. SignNo: res.Output.Signinoutb.SignNo,
  10276. SignTime: "",
  10277. Ctime: time.Now().Unix(),
  10278. Mtime: time.Now().Unix(),
  10279. Status: 1,
  10280. InputLog: "",
  10281. OutputLog: "",
  10282. FixmedinsCode: miConfig.Code,
  10283. }
  10284. err := service.CreateSignIn(&sign)
  10285. if err == nil {
  10286. c.ServeSuccessJSON(map[string]interface{}{
  10287. "msg": "签到成功",
  10288. })
  10289. }
  10290. } else {
  10291. c.ServeSuccessJSON(map[string]interface{}{
  10292. "failed_code": -10,
  10293. "msg": res.ErrMsg,
  10294. })
  10295. return
  10296. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10297. //return
  10298. }
  10299. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10300. fmt.Println(miConfig.SecretKey)
  10301. var res models.Result9001Two
  10302. 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 +
  10303. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10304. resp, requestErr := http.Get(api)
  10305. if requestErr != nil {
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10307. return
  10308. }
  10309. body, ioErr := ioutil.ReadAll(resp.Body)
  10310. if ioErr != nil {
  10311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10313. return
  10314. }
  10315. var respJSON map[string]interface{}
  10316. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10319. return
  10320. }
  10321. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10322. if status == "0" {
  10323. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10324. c.ServeSuccessJSON(map[string]interface{}{
  10325. "failed_code": -10,
  10326. "msg": err_msg,
  10327. })
  10328. return
  10329. }
  10330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10331. result, _ := json.Marshal(respJSON)
  10332. fmt.Println("log")
  10333. fmt.Println(string(result))
  10334. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10335. utils.ErrorLog("解析失败:%v", err)
  10336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10337. return
  10338. }
  10339. if res.Infcode == 0 {
  10340. sign := models.HisSignIn{
  10341. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10342. SignNo: res.Output.Signinoutb.SignNo,
  10343. SignTime: "",
  10344. Ctime: time.Now().Unix(),
  10345. Mtime: time.Now().Unix(),
  10346. Status: 1,
  10347. InputLog: "",
  10348. OutputLog: "",
  10349. FixmedinsCode: miConfig.Code,
  10350. }
  10351. err := service.CreateSignIn(&sign)
  10352. if err == nil {
  10353. c.ServeSuccessJSON(map[string]interface{}{
  10354. "msg": "签到成功",
  10355. })
  10356. }
  10357. } else {
  10358. c.ServeSuccessJSON(map[string]interface{}{
  10359. "failed_code": -10,
  10360. "msg": res.ErrMsg,
  10361. })
  10362. return
  10363. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10364. //return
  10365. }
  10366. } else {
  10367. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10368. var dat map[string]interface{}
  10369. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10370. fmt.Println(dat)
  10371. } else {
  10372. fmt.Println(err)
  10373. }
  10374. userJSONBytes, _ := json.Marshal(dat)
  10375. var res models.Result9001
  10376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10377. utils.ErrorLog("解析失败:%v", err)
  10378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10379. return
  10380. }
  10381. if res.Infcode == 0 {
  10382. sign := models.HisSignIn{
  10383. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10384. SignNo: res.Output.Signinoutb.SignNo,
  10385. SignTime: res.Output.Signinoutb.SignTime,
  10386. Ctime: time.Now().Unix(),
  10387. Mtime: time.Now().Unix(),
  10388. Status: 1,
  10389. InputLog: "",
  10390. OutputLog: "",
  10391. FixmedinsCode: miConfig.Code,
  10392. }
  10393. err := service.CreateSignIn(&sign)
  10394. if err == nil {
  10395. c.ServeSuccessJSON(map[string]interface{}{
  10396. "msg": "签到成功",
  10397. })
  10398. }
  10399. }
  10400. }
  10401. }
  10402. 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) {
  10403. var res Result3101
  10404. adminUser := c.GetAdminUserInfo()
  10405. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10406. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10407. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10408. //record_time := c.GetString("record_time")
  10409. //trig_scen := c.GetString("trig_scen")
  10410. timeLayout := "2006-01-02"
  10411. loc, _ := time.LoadLocation("Local")
  10412. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10413. if err != nil {
  10414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10415. return res
  10416. }
  10417. recordDateTime := theTime.Unix()
  10418. var patientPrescription models.HisPrescriptionInfo
  10419. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10420. //if patientPrescription.ID == 0 {
  10421. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10422. //}
  10423. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10424. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10425. //
  10426. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10427. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10428. var pp models.PublicParams
  10429. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10430. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10431. pp.FixmedinsName = miConfig.OrgName
  10432. pp.FixmedinsCode = miConfig.Code
  10433. pp.RequestUrl = miConfig.Url
  10434. pp.Cainfo = miConfig.Cainfo
  10435. pp.SecretKey = miConfig.SecretKey
  10436. pp.AccessKey = miConfig.AccessKey
  10437. pp.OpterName = roles.UserName
  10438. var config []*models.HisXtDiagnoseConfig
  10439. for _, item := range diagnosis_ids {
  10440. id, _ := strconv.ParseInt(item, 10, 64)
  10441. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10442. config = append(config, &diagnosisConfig)
  10443. }
  10444. var pd models.PatientDtos
  10445. pd.PatnID = his.PsnNo
  10446. pd.PatnName = his.Name
  10447. pd.Gend = his.Gend
  10448. pd.Brdy = his.Brdy
  10449. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10450. pd.CurrMdtrtID = his.Number
  10451. var fed models.FsiEncounterDtos
  10452. fed.MdtrtID = his.Number
  10453. fed.MedinsID = miConfig.Code
  10454. fed.MedinsName = miConfig.OrgName
  10455. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10456. fed.MedMdtrtType = "1"
  10457. fed.MedinsType = "1"
  10458. fed.MedinsLv = "11"
  10459. tm := time.Unix(his.RecordDate, 0)
  10460. s_tm := tm.Format("2006-01-02 15:04:05")
  10461. fed.AdmDate = s_tm
  10462. fed.DscgDate = s_tm
  10463. fed.DscgMainDiseCodg = config[0].CountryCode
  10464. fed.DscgMainDiseName = config[0].CountryContentName
  10465. //诊断信息
  10466. var fdds []*models.FsiDiagnoseDtos
  10467. for index, item := range config {
  10468. if index == 0 {
  10469. var fdd models.FsiDiagnoseDtos
  10470. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10471. fdd.InoutDiseType = "1"
  10472. fdd.MaindiseFlag = "1"
  10473. fdd.DiseDate = s_tm
  10474. fdd.DiasSrtNo = "1"
  10475. fdd.DiseName = item.CountryContentName
  10476. fdd.DiseCodg = item.CountryCode
  10477. fdds = append(fdds, &fdd)
  10478. } else {
  10479. var fdd models.FsiDiagnoseDtos
  10480. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10481. fdd.InoutDiseType = "1"
  10482. fdd.MaindiseFlag = "1"
  10483. fdd.DiseDate = s_tm
  10484. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10485. fdd.DiseName = item.CountryContentName
  10486. fdd.DiseCodg = item.CountryCode
  10487. fdds = append(fdds, &fdd)
  10488. }
  10489. }
  10490. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10491. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10492. fed.AdmDeptName = de.Name
  10493. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10494. fed.DscgDeptName = de.Name
  10495. fed.MedMdtrtType = "1"
  10496. fed.MedType = "11"
  10497. //if his.Insutype == "390" {
  10498. // fed.MedType = "1402"
  10499. //} else {
  10500. // fed.MedType = "9933"
  10501. //}
  10502. var orders []*models.FsiOrderDtos
  10503. if trig_scen == "2" {
  10504. //处方医嘱信息
  10505. for _, item := range prescriptions {
  10506. for _, subItem := range item.HisDoctorAdviceInfo {
  10507. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10508. var order models.FsiOrderDtos
  10509. order.RxID = strconv.FormatInt(item.ID, 10)
  10510. order.Rxno = strconv.FormatInt(item.ID, 10)
  10511. order.LongDrordFlag = "0"
  10512. order.HilistType = "1"
  10513. order.ChrgType = "1"
  10514. order.DrordBhvr = "-"
  10515. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10516. order.HosplistName = subItem.BaseDrugLib.DrugName
  10517. order.HilistLv = "1"
  10518. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10519. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10520. order.HosplistName = subItem.BaseDrugLib.DrugName
  10521. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10522. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10523. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10524. order.OwnpayAmt = ""
  10525. order.SelfpayAmt = ""
  10526. order.Spec = ""
  10527. order.SpecUnt = ""
  10528. order.DrordBegnDate = s_tm
  10529. order.DrordStopDate = ""
  10530. order.DrordDrCodg = doctor_info.DoctorNumber
  10531. order.DrordDeptName = department.Name
  10532. order.DrordDeptCodg = department.Number
  10533. order.DrordDrName = doctor_info.UserName
  10534. order.DrordDrProfttl = "234"
  10535. order.CurrDrordFlag = "1"
  10536. orders = append(orders, &order)
  10537. }
  10538. }
  10539. for _, subItem := range item.HisPrescriptionProject {
  10540. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10541. var order models.FsiOrderDtos
  10542. order.RxID = strconv.FormatInt(item.ID, 10)
  10543. order.Rxno = strconv.FormatInt(item.ID, 10)
  10544. order.LongDrordFlag = "0"
  10545. order.HilistType = "1"
  10546. order.ChrgType = "1"
  10547. order.DrordBhvr = "-"
  10548. order.HilistCode = subItem.HisProject.MedicalCode
  10549. order.HosplistName = subItem.HisProject.ProjectName
  10550. order.HilistLv = "1"
  10551. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10552. order.HosplistCode = subItem.HisProject.MedicalCode
  10553. order.HosplistName = subItem.HisProject.ProjectName
  10554. order.Cnt = subItem.Count
  10555. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10556. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10557. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10558. order.OwnpayAmt = ""
  10559. order.SelfpayAmt = ""
  10560. order.Spec = ""
  10561. order.SpecUnt = ""
  10562. order.DrordBegnDate = s_tm
  10563. order.DrordStopDate = ""
  10564. order.DrordDrCodg = doctor_info.DoctorNumber
  10565. order.DrordDeptName = department.Name
  10566. order.DrordDeptCodg = department.Number
  10567. order.DrordDrName = doctor_info.UserName
  10568. order.DrordDrProfttl = "234"
  10569. order.CurrDrordFlag = "1"
  10570. orders = append(orders, &order)
  10571. }
  10572. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10573. var order models.FsiOrderDtos
  10574. order.RxID = strconv.FormatInt(item.ID, 10)
  10575. order.Rxno = strconv.FormatInt(item.ID, 10)
  10576. order.LongDrordFlag = "0"
  10577. order.HilistType = "1"
  10578. order.ChrgType = "1"
  10579. order.DrordBhvr = "-"
  10580. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10581. order.HosplistName = subItem.GoodInfo.GoodName
  10582. order.HilistLv = "1"
  10583. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10584. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10585. order.HosplistName = subItem.GoodInfo.GoodName
  10586. order.Cnt = subItem.Count
  10587. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10588. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10589. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10590. order.OwnpayAmt = ""
  10591. order.SelfpayAmt = ""
  10592. order.Spec = ""
  10593. order.SpecUnt = ""
  10594. order.DrordBegnDate = s_tm
  10595. order.DrordStopDate = ""
  10596. order.DrordDrCodg = doctor_info.DoctorNumber
  10597. order.DrordDeptName = department.Name
  10598. order.DrordDeptCodg = department.Number
  10599. order.DrordDrName = doctor_info.UserName
  10600. order.DrordDrProfttl = "234"
  10601. order.CurrDrordFlag = "1"
  10602. orders = append(orders, &order)
  10603. }
  10604. }
  10605. }
  10606. //处方医嘱信息
  10607. }
  10608. fed.MatnStas = "0"
  10609. fed.MedfeeSumamt = "0"
  10610. fed.OwnpayAmt = "0"
  10611. fed.SelfpayAmt = "0"
  10612. fed.AcctPayamt = "0"
  10613. fed.MaAmt = "0"
  10614. fed.HifpPayamt = "0"
  10615. fed.SetlTotlnum = "1"
  10616. fed.Insutype = his.Insutype
  10617. fed.ReimFlag = "0"
  10618. fed.OutSetlFlag = "0"
  10619. var fopd []*models.FsiOperationDtosData
  10620. data := make(map[string]interface{})
  10621. data["fed"] = fed
  10622. data["fdd"] = fdds
  10623. data["fod"] = orders
  10624. data["pd"] = pd
  10625. data["pp"] = pp
  10626. data["fopd"] = fopd
  10627. data["trig_scen"] = trig_scen
  10628. fmt.Println(data)
  10629. fmt.Println(fed)
  10630. fmt.Println(fdds)
  10631. fmt.Println(orders)
  10632. fmt.Println(pd)
  10633. fmt.Println(pp)
  10634. fmt.Println(fopd)
  10635. client := &http.Client{}
  10636. bytesData, _ := json.Marshal(data)
  10637. var req *http.Request
  10638. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10639. if miConfig.MdtrtareaAdmvs == "320921" {
  10640. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10641. } else {
  10642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10643. }
  10644. resp, _ := client.Do(req)
  10645. defer resp.Body.Close()
  10646. body, ioErr := ioutil.ReadAll(resp.Body)
  10647. if ioErr != nil {
  10648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10650. return res
  10651. }
  10652. var respJSON map[string]interface{}
  10653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10656. return res
  10657. }
  10658. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10659. fmt.Println(respJSON)
  10660. result, _ := json.Marshal(respJSON)
  10661. fmt.Println(result)
  10662. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10663. utils.ErrorLog("解析失败:%v", err)
  10664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10665. return res
  10666. }
  10667. return res
  10668. } else {
  10669. //if miConfig.MdtrtareaAdmvs == "441202" {
  10670. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10671. saveLog(output, input, "3101", "事前")
  10672. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10673. utils.ErrorLog("解析失败:%v", err)
  10674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10675. return
  10676. }
  10677. return res
  10678. //}
  10679. }
  10680. }
  10681. 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) {
  10682. adminUser := c.GetAdminUserInfo()
  10683. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10684. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10685. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10686. //record_time := c.GetString("record_time")
  10687. //trig_scen := c.GetString("trig_scen")
  10688. timeLayout := "2006-01-02"
  10689. loc, _ := time.LoadLocation("Local")
  10690. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10691. if err != nil {
  10692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10693. return res
  10694. }
  10695. recordDateTime := theTime.Unix()
  10696. var patientPrescription models.HisPrescriptionInfo
  10697. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10698. if patientPrescription.ID == 0 {
  10699. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10700. }
  10701. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10702. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10703. //
  10704. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10705. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10706. var pp models.PublicParams
  10707. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10708. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10709. pp.FixmedinsName = miConfig.OrgName
  10710. pp.FixmedinsCode = miConfig.Code
  10711. pp.RequestUrl = miConfig.Url
  10712. pp.Cainfo = miConfig.Cainfo
  10713. pp.SecretKey = miConfig.SecretKey
  10714. pp.AccessKey = miConfig.AccessKey
  10715. pp.OpterName = roles.UserName
  10716. var config []*models.HisXtDiagnoseConfig
  10717. for _, item := range diagnosis_ids {
  10718. id, _ := strconv.ParseInt(item, 10, 64)
  10719. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10720. config = append(config, &diagnosisConfig)
  10721. }
  10722. var pd models.PatientDtos
  10723. pd.PatnID = his.PsnNo
  10724. pd.PatnName = his.Name
  10725. pd.Gend = his.Gend
  10726. pd.Brdy = his.Brdy
  10727. pd.Poolarea = his.InsuplcAdmdvs
  10728. pd.CurrMdtrtID = his.Number
  10729. var fed models.FsiEncounterDtos
  10730. fed.MdtrtID = his.Number
  10731. fed.MedinsID = miConfig.Code
  10732. fed.MedinsName = miConfig.OrgName
  10733. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10734. fed.MedMdtrtType = "1"
  10735. fed.MedinsType = "1"
  10736. fed.MedinsLv = "11"
  10737. tm := time.Unix(his.RecordDate, 0)
  10738. s_tm := tm.Format("2006-01-02 15:04:05")
  10739. fed.AdmDate = s_tm
  10740. fed.DscgDate = s_tm
  10741. fed.DscgMainDiseCodg = config[0].CountryCode
  10742. fed.DscgMainDiseName = config[0].CountryContentName
  10743. //诊断信息
  10744. var fdds []*models.FsiDiagnoseDtos
  10745. for index, item := range config {
  10746. if index == 0 {
  10747. var fdd models.FsiDiagnoseDtos
  10748. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10749. fdd.InoutDiseType = "1"
  10750. fdd.MaindiseFlag = "1"
  10751. fdd.DiseDate = s_tm
  10752. fdd.DiasSrtNo = "1"
  10753. fdd.DiseName = item.CountryContentName
  10754. fdd.DiseCodg = item.CountryCode
  10755. fdds = append(fdds, &fdd)
  10756. } else {
  10757. var fdd models.FsiDiagnoseDtos
  10758. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10759. fdd.InoutDiseType = "1"
  10760. fdd.MaindiseFlag = "1"
  10761. fdd.DiseDate = s_tm
  10762. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10763. fdd.DiseName = item.CountryContentName
  10764. fdd.DiseCodg = item.CountryCode
  10765. fdds = append(fdds, &fdd)
  10766. }
  10767. }
  10768. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10769. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10770. fed.AdmDeptName = department.Name
  10771. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10772. fed.DscgDeptName = department.Name
  10773. fed.MedMdtrtType = "1"
  10774. fed.MedType = "11"
  10775. //if his.Insutype == "390" {
  10776. // fed.MedType = "1402"
  10777. //} else {
  10778. // fed.MedType = "9933"
  10779. //}
  10780. var orders []*models.FsiOrderDtos
  10781. if trig_scen == "2" {
  10782. //处方医嘱信息
  10783. for _, item := range prescriptions {
  10784. for _, subItem := range item.HisDoctorAdviceInfo {
  10785. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10786. var order models.FsiOrderDtos
  10787. order.RxID = strconv.FormatInt(item.ID, 10)
  10788. order.Rxno = strconv.FormatInt(item.ID, 10)
  10789. order.LongDrordFlag = "0"
  10790. order.HilistType = "1"
  10791. order.ChrgType = "1"
  10792. order.DrordBhvr = "-"
  10793. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10794. order.HosplistName = subItem.BaseDrugLib.DrugName
  10795. order.HilistLv = "1"
  10796. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10797. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10798. order.HosplistName = subItem.BaseDrugLib.DrugName
  10799. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10800. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10801. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10802. order.OwnpayAmt = ""
  10803. order.SelfpayAmt = ""
  10804. order.Spec = ""
  10805. order.SpecUnt = ""
  10806. order.DrordBegnDate = s_tm
  10807. order.DrordStopDate = ""
  10808. order.DrordDrCodg = doctor_info.DoctorNumber
  10809. order.DrordDeptName = department.Name
  10810. order.DrordDeptCodg = department.Number
  10811. order.DrordDrName = doctor_info.UserName
  10812. order.DrordDrProfttl = "234"
  10813. order.CurrDrordFlag = "1"
  10814. orders = append(orders, &order)
  10815. }
  10816. }
  10817. for _, subItem := range item.HisPrescriptionProject {
  10818. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10819. var order models.FsiOrderDtos
  10820. order.RxID = strconv.FormatInt(item.ID, 10)
  10821. order.Rxno = strconv.FormatInt(item.ID, 10)
  10822. order.LongDrordFlag = "0"
  10823. order.HilistType = "1"
  10824. order.ChrgType = "1"
  10825. order.DrordBhvr = "-"
  10826. order.HilistCode = subItem.HisProject.MedicalCode
  10827. order.HosplistName = subItem.HisProject.ProjectName
  10828. order.HilistLv = "1"
  10829. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10830. order.HosplistCode = subItem.HisProject.MedicalCode
  10831. order.HosplistName = subItem.HisProject.ProjectName
  10832. order.Cnt = subItem.Count
  10833. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10834. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10835. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10836. order.OwnpayAmt = ""
  10837. order.SelfpayAmt = ""
  10838. order.Spec = ""
  10839. order.SpecUnt = ""
  10840. order.DrordBegnDate = s_tm
  10841. order.DrordStopDate = ""
  10842. order.DrordDrCodg = doctor_info.DoctorNumber
  10843. order.DrordDeptName = department.Name
  10844. order.DrordDeptCodg = department.Number
  10845. order.DrordDrName = doctor_info.UserName
  10846. order.DrordDrProfttl = "234"
  10847. order.CurrDrordFlag = "1"
  10848. orders = append(orders, &order)
  10849. }
  10850. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10851. var order models.FsiOrderDtos
  10852. order.RxID = strconv.FormatInt(item.ID, 10)
  10853. order.Rxno = strconv.FormatInt(item.ID, 10)
  10854. order.LongDrordFlag = "0"
  10855. order.HilistType = "1"
  10856. order.ChrgType = "1"
  10857. order.DrordBhvr = "-"
  10858. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10859. order.HosplistName = subItem.GoodInfo.GoodName
  10860. order.HilistLv = "1"
  10861. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10862. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10863. order.HosplistName = subItem.GoodInfo.GoodName
  10864. order.Cnt = subItem.Count
  10865. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10866. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10867. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10868. order.OwnpayAmt = ""
  10869. order.SelfpayAmt = ""
  10870. order.Spec = ""
  10871. order.SpecUnt = ""
  10872. order.DrordBegnDate = s_tm
  10873. order.DrordStopDate = ""
  10874. order.DrordDrCodg = doctor_info.DoctorNumber
  10875. order.DrordDeptName = department.Name
  10876. order.DrordDeptCodg = department.Number
  10877. order.DrordDrName = doctor_info.UserName
  10878. order.DrordDrProfttl = "234"
  10879. order.CurrDrordFlag = "1"
  10880. orders = append(orders, &order)
  10881. }
  10882. }
  10883. }
  10884. //处方医嘱信息
  10885. }
  10886. fed.MatnStas = "0"
  10887. fed.MedfeeSumamt = "0"
  10888. fed.OwnpayAmt = "0"
  10889. fed.SelfpayAmt = "0"
  10890. fed.AcctPayamt = "0"
  10891. fed.MaAmt = "0"
  10892. fed.HifpPayamt = "0"
  10893. fed.SetlTotlnum = "1"
  10894. fed.Insutype = his.Insutype
  10895. fed.ReimFlag = "0"
  10896. fed.OutSetlFlag = "0"
  10897. var fopd []*models.FsiOperationDtosData
  10898. data := make(map[string]interface{})
  10899. data["fed"] = fed
  10900. data["fdd"] = fdds
  10901. data["fod"] = orders
  10902. data["pd"] = pd
  10903. data["pp"] = pp
  10904. data["fopd"] = fopd
  10905. data["trig_scen"] = trig_scen
  10906. fmt.Println(data)
  10907. fmt.Println(fed)
  10908. fmt.Println(fdds)
  10909. fmt.Println(orders)
  10910. fmt.Println(pd)
  10911. fmt.Println(pp)
  10912. fmt.Println(fopd)
  10913. client := &http.Client{}
  10914. bytesData, _ := json.Marshal(data)
  10915. var req *http.Request
  10916. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10917. if miConfig.MdtrtareaAdmvs == "320921" {
  10918. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10919. } else {
  10920. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10921. }
  10922. resp, _ := client.Do(req)
  10923. defer resp.Body.Close()
  10924. body, ioErr := ioutil.ReadAll(resp.Body)
  10925. if ioErr != nil {
  10926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10928. return res
  10929. }
  10930. var respJSON map[string]interface{}
  10931. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10934. return res
  10935. }
  10936. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10937. fmt.Println(respJSON)
  10938. result, _ := json.Marshal(respJSON)
  10939. fmt.Println(result)
  10940. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10941. utils.ErrorLog("解析失败:%v", err)
  10942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10943. return res
  10944. }
  10945. return res
  10946. } else {
  10947. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10948. saveLog(output, input, "3101", "事前")
  10949. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10950. utils.ErrorLog("解析失败:%v", err)
  10951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10952. return
  10953. }
  10954. return res
  10955. }
  10956. return res
  10957. }
  10958. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10959. ////patient_id, _ := c.GetInt64("patient_id")
  10960. //order_id, _ := c.GetInt64("order_id")
  10961. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10962. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10963. //trig_scen := c.GetString("trig_scen")
  10964. adminUser := c.GetAdminUserInfo()
  10965. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10966. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10968. record_time := c.GetString("record_time")
  10969. order, _ := service.GetHisOrderByID(order_id)
  10970. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10971. timeLayout := "2006-01-02"
  10972. loc, _ := time.LoadLocation("Local")
  10973. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10974. if err != nil {
  10975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10976. return
  10977. }
  10978. recordDateTime := theTime.Unix()
  10979. var patientPrescription models.HisPrescriptionInfo
  10980. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10981. if patientPrescription.ID == 0 {
  10982. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10983. }
  10984. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10985. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10986. //
  10987. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10988. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10989. var pp models.PublicParams
  10990. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10991. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10992. pp.FixmedinsName = miConfig.OrgName
  10993. pp.FixmedinsCode = miConfig.Code
  10994. pp.RequestUrl = miConfig.Url
  10995. pp.Cainfo = miConfig.Cainfo
  10996. pp.SecretKey = miConfig.SecretKey
  10997. pp.AccessKey = miConfig.AccessKey
  10998. pp.OpterName = roles.UserName
  10999. var config []*models.HisXtDiagnoseConfig
  11000. for _, item := range diagnosis_ids {
  11001. id, _ := strconv.ParseInt(item, 10, 64)
  11002. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11003. config = append(config, &diagnosisConfig)
  11004. }
  11005. var pd models.PatientDtos
  11006. pd.PatnID = his.PsnNo
  11007. pd.PatnName = his.Name
  11008. pd.Gend = his.Gend
  11009. pd.Brdy = psn_info.Brdy
  11010. pd.Poolarea = his.InsuplcAdmdvs
  11011. pd.CurrMdtrtID = his.Number
  11012. var fed models.FsiEncounterDtos
  11013. fed.MdtrtID = his.Number
  11014. fed.MedinsID = miConfig.Code
  11015. fed.MedinsName = miConfig.OrgName
  11016. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11017. fed.MedMdtrtType = "1"
  11018. fed.MedinsType = "1"
  11019. fed.MedinsLv = "11"
  11020. tm := time.Unix(his.RecordDate, 0)
  11021. s_tm := tm.Format("2006-01-02 15:04:05")
  11022. fed.AdmDate = s_tm
  11023. fed.DscgDate = s_tm
  11024. fed.DscgMainDiseCodg = config[0].CountryCode
  11025. fed.DscgMainDiseName = config[0].CountryContentName
  11026. //诊断信息
  11027. var fdds []*models.FsiDiagnoseDtos
  11028. for index, item := range config {
  11029. if index == 0 {
  11030. var fdd models.FsiDiagnoseDtos
  11031. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11032. fdd.InoutDiseType = "1"
  11033. fdd.MaindiseFlag = "1"
  11034. fdd.DiseDate = s_tm
  11035. fdd.DiasSrtNo = "1"
  11036. fdd.DiseName = item.CountryContentName
  11037. fdd.DiseCodg = item.CountryCode
  11038. fdds = append(fdds, &fdd)
  11039. } else {
  11040. var fdd models.FsiDiagnoseDtos
  11041. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11042. fdd.InoutDiseType = "1"
  11043. fdd.MaindiseFlag = "1"
  11044. fdd.DiseDate = s_tm
  11045. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11046. fdd.DiseName = item.CountryContentName
  11047. fdd.DiseCodg = item.CountryCode
  11048. fdds = append(fdds, &fdd)
  11049. }
  11050. }
  11051. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11052. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11053. fed.AdmDeptName = department.Name
  11054. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11055. fed.DscgDeptName = department.Name
  11056. fed.MedType = order.MedType
  11057. //处方医嘱信息
  11058. var orders []*models.FsiOrderDtos
  11059. //for _, item := range prescriptions {
  11060. // for _, subItem := range item.HisDoctorAdviceInfo {
  11061. // var order models.FsiOrderDtos
  11062. // order.RxID = strconv.FormatInt(item.ID, 10)
  11063. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11064. // order.LongDrordFlag = "0"
  11065. // order.HilistType = "1"
  11066. // order.ChrgType = "1"
  11067. // order.DrordBhvr = "-"
  11068. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11069. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11070. // order.HilistLv = "1"
  11071. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11072. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11073. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11074. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11075. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11076. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11077. // order.OwnpayAmt = ""
  11078. // order.SelfpayAmt = ""
  11079. // order.Spec = ""
  11080. // order.SpecUnt = ""
  11081. // order.DrordBegnDate = s_tm
  11082. // order.DrordStopDate = ""
  11083. // order.DrordDrCodg = "1"
  11084. // order.DrordDeptName = department.Name
  11085. // order.DrordDrCodg = "1"
  11086. // order.DrordDrName = doctor_info.UserName
  11087. // order.DrordDrProfttl = ""
  11088. // order.CurrDrordFlag = "1"
  11089. // orders = append(orders, &order)
  11090. // }
  11091. // for _, subItem := range item.HisPrescriptionProject {
  11092. // if subItem.Type == 2 {
  11093. // var order models.FsiOrderDtos
  11094. // order.RxID = strconv.FormatInt(item.ID, 10)
  11095. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11096. // order.LongDrordFlag = "0"
  11097. // order.HilistType = "1"
  11098. // order.ChrgType = "1"
  11099. // order.DrordBhvr = "-"
  11100. // order.HilistCode = subItem.HisProject.MedicalCode
  11101. // order.HosplistName = subItem.HisProject.ProjectName
  11102. // order.HilistLv = "1"
  11103. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11104. // order.HosplistCode = subItem.HisProject.MedicalCode
  11105. // order.HosplistName = subItem.HisProject.ProjectName
  11106. // order.Cnt = subItem.Count
  11107. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11108. //
  11109. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11110. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11111. // order.OwnpayAmt = ""
  11112. // order.SelfpayAmt = ""
  11113. // order.Spec = ""
  11114. // order.SpecUnt = ""
  11115. // order.DrordBegnDate = s_tm
  11116. // order.DrordStopDate = ""
  11117. // order.DrordDrCodg = "1"
  11118. // order.DrordDeptName = department.Name
  11119. // order.DrordDrCodg = "1"
  11120. // order.DrordDrName = doctor_info.UserName
  11121. // order.DrordDrProfttl = ""
  11122. // order.CurrDrordFlag = "1"
  11123. // orders = append(orders, &order)
  11124. //
  11125. // }
  11126. // if subItem.Type == 3 {
  11127. //
  11128. // var order models.FsiOrderDtos
  11129. // order.RxID = strconv.FormatInt(item.ID, 10)
  11130. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11131. // order.LongDrordFlag = "0"
  11132. // order.HilistType = "1"
  11133. // order.ChrgType = "1"
  11134. // order.DrordBhvr = "-"
  11135. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11136. // order.HosplistName = subItem.GoodInfo.GoodName
  11137. // order.HilistLv = "1"
  11138. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11139. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11140. // order.HosplistName = subItem.GoodInfo.GoodName
  11141. // order.Cnt = subItem.Count
  11142. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11143. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11144. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11145. // order.OwnpayAmt = ""
  11146. // order.SelfpayAmt = ""
  11147. // order.Spec = ""
  11148. // order.SpecUnt = ""
  11149. // order.DrordBegnDate = s_tm
  11150. // order.DrordStopDate = ""
  11151. // order.DrordDrCodg = "1"
  11152. // order.DrordDeptName = department.Name
  11153. // order.DrordDrCodg = "1"
  11154. // order.DrordDrName = doctor_info.UserName
  11155. // order.DrordDrProfttl = ""
  11156. // order.CurrDrordFlag = "1"
  11157. // orders = append(orders, &order)
  11158. //
  11159. // }
  11160. // }
  11161. //}
  11162. for _, item := range prescriptions {
  11163. for _, subItem := range item.HisDoctorAdviceInfo {
  11164. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11165. var order models.FsiOrderDtos
  11166. order.RxID = strconv.FormatInt(item.ID, 10)
  11167. order.Rxno = strconv.FormatInt(item.ID, 10)
  11168. order.LongDrordFlag = "0"
  11169. order.HilistType = "1"
  11170. order.ChrgType = "1"
  11171. order.DrordBhvr = "-"
  11172. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11173. order.HosplistName = subItem.BaseDrugLib.DrugName
  11174. order.HilistLv = "1"
  11175. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11176. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11177. order.HosplistName = subItem.BaseDrugLib.DrugName
  11178. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11179. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11180. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11181. order.OwnpayAmt = ""
  11182. order.SelfpayAmt = ""
  11183. order.Spec = ""
  11184. order.SpecUnt = ""
  11185. order.DrordBegnDate = s_tm
  11186. order.DrordStopDate = ""
  11187. order.DrordDrCodg = doctor_info.DoctorNumber
  11188. order.DrordDeptName = department.Name
  11189. order.DrordDeptCodg = department.Number
  11190. order.DrordDrName = doctor_info.UserName
  11191. order.DrordDrProfttl = "234"
  11192. order.CurrDrordFlag = "1"
  11193. orders = append(orders, &order)
  11194. }
  11195. }
  11196. for _, subItem := range item.HisPrescriptionProject {
  11197. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11198. var order models.FsiOrderDtos
  11199. order.RxID = strconv.FormatInt(item.ID, 10)
  11200. order.Rxno = strconv.FormatInt(item.ID, 10)
  11201. order.LongDrordFlag = "0"
  11202. order.HilistType = "1"
  11203. order.ChrgType = "1"
  11204. order.DrordBhvr = "-"
  11205. order.HilistCode = subItem.HisProject.MedicalCode
  11206. order.HosplistName = subItem.HisProject.ProjectName
  11207. order.HilistLv = "1"
  11208. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11209. order.HosplistCode = subItem.HisProject.MedicalCode
  11210. order.HosplistName = subItem.HisProject.ProjectName
  11211. order.Cnt = subItem.Count
  11212. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11213. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11214. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11215. order.OwnpayAmt = ""
  11216. order.SelfpayAmt = ""
  11217. order.Spec = ""
  11218. order.SpecUnt = ""
  11219. order.DrordBegnDate = s_tm
  11220. order.DrordStopDate = ""
  11221. order.DrordDrCodg = doctor_info.DoctorNumber
  11222. order.DrordDeptName = department.Name
  11223. order.DrordDeptCodg = department.Number
  11224. order.DrordDrName = doctor_info.UserName
  11225. order.DrordDrProfttl = "234"
  11226. order.CurrDrordFlag = "1"
  11227. orders = append(orders, &order)
  11228. }
  11229. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11230. var order models.FsiOrderDtos
  11231. order.RxID = strconv.FormatInt(item.ID, 10)
  11232. order.Rxno = strconv.FormatInt(item.ID, 10)
  11233. order.LongDrordFlag = "0"
  11234. order.HilistType = "1"
  11235. order.ChrgType = "1"
  11236. order.DrordBhvr = "0"
  11237. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11238. order.HosplistName = subItem.GoodInfo.GoodName
  11239. order.HilistLv = "1"
  11240. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11241. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11242. order.HosplistName = subItem.GoodInfo.GoodName
  11243. order.Cnt = subItem.Count
  11244. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11245. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11246. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11247. order.OwnpayAmt = ""
  11248. order.SelfpayAmt = ""
  11249. order.Spec = ""
  11250. order.SpecUnt = ""
  11251. order.DrordBegnDate = s_tm
  11252. order.DrordStopDate = ""
  11253. order.DrordDrCodg = doctor_info.DoctorNumber
  11254. order.DrordDeptName = department.Name
  11255. order.DrordDeptCodg = department.Number
  11256. order.DrordDrName = doctor_info.UserName
  11257. order.DrordDrProfttl = "234"
  11258. order.CurrDrordFlag = "1"
  11259. orders = append(orders, &order)
  11260. }
  11261. }
  11262. }
  11263. //处方医嘱信息
  11264. fed.MatnStas = "0"
  11265. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11266. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11267. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11268. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11269. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11270. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11271. fed.SetlTotlnum = "1"
  11272. fed.Insutype = his.Insutype
  11273. fed.ReimFlag = "0"
  11274. fed.OutSetlFlag = "0"
  11275. var fopd []*models.FsiOperationDtosData
  11276. data := make(map[string]interface{})
  11277. data["fed"] = fed
  11278. data["fdd"] = fdds
  11279. data["fod"] = orders
  11280. data["pd"] = pd
  11281. data["pp"] = pp
  11282. data["fopd"] = fopd
  11283. data["trig_scen"] = trig_scen
  11284. client := &http.Client{}
  11285. bytesData, _ := json.Marshal(data)
  11286. var req *http.Request
  11287. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11288. if miConfig.MdtrtareaAdmvs == "320921" {
  11289. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11290. } else {
  11291. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11292. }
  11293. resp, _ := client.Do(req)
  11294. defer resp.Body.Close()
  11295. body, ioErr := ioutil.ReadAll(resp.Body)
  11296. if ioErr != nil {
  11297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11299. return res
  11300. }
  11301. var respJSON map[string]interface{}
  11302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11305. return res
  11306. }
  11307. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11308. result, _ := json.Marshal(respJSON)
  11309. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11310. utils.ErrorLog("解析失败:%v", err)
  11311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11312. return res
  11313. }
  11314. return res
  11315. } else {
  11316. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11317. saveLog(output, input, "3102", "事中")
  11318. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11319. utils.ErrorLog("解析失败:%v", err)
  11320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11321. return
  11322. }
  11323. return res
  11324. }
  11325. return res
  11326. }
  11327. 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) {
  11328. var res Resultgd3101
  11329. adminUser := c.GetAdminUserInfo()
  11330. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11331. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11332. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11333. //record_time := c.GetString("record_time")
  11334. //trig_scen := c.GetString("trig_scen")
  11335. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11336. //psn_info, _ := service.GetPatientId(patient_id)
  11337. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11338. timeLayout := "2006-01-02"
  11339. loc, _ := time.LoadLocation("Local")
  11340. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11341. if err != nil {
  11342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11343. return res
  11344. }
  11345. recordDateTime := theTime.Unix()
  11346. var patientPrescription models.HisPrescriptionInfo
  11347. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11348. //if patientPrescription.ID == 0 {
  11349. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11350. //}
  11351. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11352. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11353. //
  11354. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11355. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11356. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11357. var pp models.PublicParams
  11358. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11359. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11360. pp.FixmedinsName = miConfig.OrgName
  11361. pp.FixmedinsCode = miConfig.Code
  11362. pp.RequestUrl = miConfig.Url
  11363. pp.Cainfo = miConfig.Cainfo
  11364. pp.SecretKey = miConfig.SecretKey
  11365. pp.AccessKey = miConfig.AccessKey
  11366. pp.OpterName = roles.UserName
  11367. var config []*models.HisXtDiagnoseConfig
  11368. for _, item := range diagnosis_ids {
  11369. id, _ := strconv.ParseInt(item, 10, 64)
  11370. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11371. config = append(config, &diagnosisConfig)
  11372. }
  11373. var pd models.PatientDtos
  11374. pd.PatnID = his.PsnNo
  11375. pd.PatnName = his.Name
  11376. pd.Gend = his.Gend
  11377. pd.Brdy = str
  11378. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11379. pd.CurrMdtrtID = his.Number
  11380. var fed models.FsiEncounterDtos
  11381. fed.MdtrtID = his.Number
  11382. fed.MedinsID = miConfig.Code
  11383. fed.MedinsName = miConfig.OrgName
  11384. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11385. fed.MedMdtrtType = "1"
  11386. fed.MedinsType = "1"
  11387. fed.MedinsLv = "11"
  11388. tm := time.Unix(his.RecordDate, 0)
  11389. s_tm := tm.Format("2006-01-02 15:04:05")
  11390. fed.AdmDate = s_tm
  11391. fed.DscgDate = s_tm
  11392. fed.DscgMainDiseCodg = config[0].CountryCode
  11393. fed.DscgMainDiseName = config[0].CountryContentName
  11394. //诊断信息
  11395. var fdds []*models.FsiDiagnoseDtos
  11396. for index, item := range config {
  11397. if index == 0 {
  11398. var fdd models.FsiDiagnoseDtos
  11399. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11400. fdd.InoutDiseType = "1"
  11401. fdd.MaindiseFlag = "1"
  11402. fdd.DiseDate = s_tm
  11403. fdd.DiasSrtNo = "1"
  11404. fdd.DiseName = item.CountryContentName
  11405. fdd.DiseCodg = item.CountryCode
  11406. fdds = append(fdds, &fdd)
  11407. } else {
  11408. var fdd models.FsiDiagnoseDtos
  11409. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11410. fdd.InoutDiseType = "1"
  11411. fdd.MaindiseFlag = "1"
  11412. fdd.DiseDate = s_tm
  11413. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11414. fdd.DiseName = item.CountryContentName
  11415. fdd.DiseCodg = item.CountryCode
  11416. fdds = append(fdds, &fdd)
  11417. }
  11418. }
  11419. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11420. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11421. fed.AdmDeptName = de.Name
  11422. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11423. fed.DscgDeptName = de.Name
  11424. fed.MedMdtrtType = "1"
  11425. fed.MedType = "11"
  11426. //if his.Insutype == "390" {
  11427. // fed.MedType = "1402"
  11428. //} else {
  11429. // fed.MedType = "9933"
  11430. //}
  11431. var orders []*models.FsiOrderDtos
  11432. if trig_scen == "2" {
  11433. //处方医嘱信息
  11434. for _, item := range prescriptions {
  11435. for _, subItem := range item.HisDoctorAdviceInfo {
  11436. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11437. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11438. var order models.FsiOrderDtos
  11439. order.RxID = strconv.FormatInt(item.ID, 10)
  11440. order.Rxno = strconv.FormatInt(item.ID, 10)
  11441. order.LongDrordFlag = "0"
  11442. order.HilistType = "1"
  11443. order.ChrgType = "1"
  11444. order.DrordBhvr = "0"
  11445. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11446. order.HosplistName = subItem.BaseDrugLib.DrugName
  11447. order.HilistLv = "1"
  11448. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11449. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11450. order.HosplistName = subItem.BaseDrugLib.DrugName
  11451. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11452. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11453. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11454. order.OwnpayAmt = ""
  11455. order.SelfpayAmt = ""
  11456. order.Spec = spec
  11457. order.SpecUnt = subItem.PrescribingNumberUnit
  11458. order.DrordBegnDate = s_tm
  11459. order.DrordStopDate = ""
  11460. order.DrordDrCodg = doctor_info.DoctorNumber
  11461. order.DrordDeptName = department.Name
  11462. order.DrordDeptCodg = department.Number
  11463. order.DrordDrName = doctor_info.UserName
  11464. order.DrordDrProfttl = "234"
  11465. order.CurrDrordFlag = "1"
  11466. orders = append(orders, &order)
  11467. }
  11468. }
  11469. for _, subItem := range item.HisPrescriptionProject {
  11470. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11471. var order models.FsiOrderDtos
  11472. order.RxID = strconv.FormatInt(item.ID, 10)
  11473. order.Rxno = strconv.FormatInt(item.ID, 10)
  11474. order.LongDrordFlag = "0"
  11475. order.HilistType = "1"
  11476. order.ChrgType = "1"
  11477. order.DrordBhvr = "0"
  11478. order.HilistCode = subItem.HisProject.MedicalCode
  11479. order.HosplistName = subItem.HisProject.ProjectName
  11480. order.HilistLv = "1"
  11481. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11482. order.HosplistCode = subItem.HisProject.MedicalCode
  11483. order.HosplistName = subItem.HisProject.ProjectName
  11484. order.Cnt = subItem.Count
  11485. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11486. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11487. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11488. order.OwnpayAmt = ""
  11489. order.SelfpayAmt = ""
  11490. order.Spec = subItem.Unit
  11491. order.SpecUnt = subItem.Unit
  11492. order.DrordBegnDate = s_tm
  11493. order.DrordStopDate = ""
  11494. order.DrordDrCodg = doctor_info.DoctorNumber
  11495. order.DrordDeptName = department.Name
  11496. order.DrordDeptCodg = department.Number
  11497. order.DrordDrName = doctor_info.UserName
  11498. order.DrordDrProfttl = "234"
  11499. order.CurrDrordFlag = "1"
  11500. orders = append(orders, &order)
  11501. }
  11502. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11503. var order models.FsiOrderDtos
  11504. order.RxID = strconv.FormatInt(item.ID, 10)
  11505. order.Rxno = strconv.FormatInt(item.ID, 10)
  11506. order.LongDrordFlag = "0"
  11507. order.HilistType = "1"
  11508. order.ChrgType = "1"
  11509. order.DrordBhvr = "0"
  11510. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11511. order.HosplistName = subItem.GoodInfo.GoodName
  11512. order.HilistLv = "1"
  11513. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11514. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11515. order.HosplistName = subItem.GoodInfo.GoodName
  11516. order.Cnt = subItem.Count
  11517. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11518. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11519. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11520. order.OwnpayAmt = ""
  11521. order.SelfpayAmt = ""
  11522. order.Spec = subItem.GoodInfo.SpecificationName
  11523. order.SpecUnt = subItem.Unit
  11524. order.DrordBegnDate = s_tm
  11525. order.DrordStopDate = ""
  11526. order.DrordDrCodg = doctor_info.DoctorNumber
  11527. order.DrordDeptName = department.Name
  11528. order.DrordDeptCodg = department.Number
  11529. order.DrordDrName = doctor_info.UserName
  11530. order.DrordDrProfttl = "234"
  11531. order.CurrDrordFlag = "1"
  11532. orders = append(orders, &order)
  11533. }
  11534. }
  11535. }
  11536. //处方医嘱信息
  11537. }
  11538. fed.MatnStas = "0"
  11539. fed.MedfeeSumamt = "0"
  11540. fed.OwnpayAmt = "0"
  11541. fed.SelfpayAmt = "0"
  11542. fed.AcctPayamt = "0"
  11543. fed.MaAmt = "0"
  11544. fed.HifpPayamt = "0"
  11545. fed.SetlTotlnum = "1"
  11546. fed.Insutype = his.Insutype
  11547. fed.ReimFlag = "0"
  11548. fed.OutSetlFlag = "0"
  11549. var fopd []*models.FsiOperationDtosData
  11550. data := make(map[string]interface{})
  11551. data["fed"] = fed
  11552. data["fdd"] = fdds
  11553. data["fod"] = orders
  11554. data["pd"] = pd
  11555. data["pp"] = pp
  11556. data["fopd"] = fopd
  11557. data["trig_scen"] = trig_scen
  11558. fmt.Println(data)
  11559. fmt.Println(fed)
  11560. fmt.Println(fdds)
  11561. fmt.Println(orders)
  11562. fmt.Println(pd)
  11563. fmt.Println(pp)
  11564. fmt.Println(fopd)
  11565. client := &http.Client{}
  11566. bytesData, _ := json.Marshal(data)
  11567. var req *http.Request
  11568. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11569. if miConfig.MdtrtareaAdmvs == "320921" {
  11570. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11571. } else {
  11572. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11573. }
  11574. resp, _ := client.Do(req)
  11575. defer resp.Body.Close()
  11576. body, ioErr := ioutil.ReadAll(resp.Body)
  11577. if ioErr != nil {
  11578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11580. return res
  11581. }
  11582. var respJSON map[string]interface{}
  11583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11586. return res
  11587. }
  11588. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11589. fmt.Println(respJSON)
  11590. result, _ := json.Marshal(respJSON)
  11591. fmt.Println(result)
  11592. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11593. utils.ErrorLog("解析失败:%v", err)
  11594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11595. return res
  11596. }
  11597. return res
  11598. } else {
  11599. //if miConfig.MdtrtareaAdmvs == "441202" {
  11600. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11601. saveLog(output, input, "3101", "事前")
  11602. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11603. utils.ErrorLog("解析失败:%v", err)
  11604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11605. return
  11606. }
  11607. return res
  11608. //}
  11609. }
  11610. }
  11611. 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) {
  11612. adminUser := c.GetAdminUserInfo()
  11613. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11614. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11615. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11616. //record_time := c.GetString("record_time")
  11617. //trig_scen := c.GetString("trig_scen")
  11618. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11619. timeLayout := "2006-01-02"
  11620. loc, _ := time.LoadLocation("Local")
  11621. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11622. if err != nil {
  11623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11624. return res
  11625. }
  11626. recordDateTime := theTime.Unix()
  11627. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11628. var patientPrescription models.HisPrescriptionInfo
  11629. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11630. if patientPrescription.ID == 0 {
  11631. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11632. }
  11633. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11634. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11635. //
  11636. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11637. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11638. var pp models.PublicParams
  11639. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11640. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11641. pp.FixmedinsName = miConfig.OrgName
  11642. pp.FixmedinsCode = miConfig.Code
  11643. pp.RequestUrl = miConfig.Url
  11644. pp.Cainfo = miConfig.Cainfo
  11645. pp.SecretKey = miConfig.SecretKey
  11646. pp.AccessKey = miConfig.AccessKey
  11647. pp.OpterName = roles.UserName
  11648. var config []*models.HisXtDiagnoseConfig
  11649. for _, item := range diagnosis_ids {
  11650. id, _ := strconv.ParseInt(item, 10, 64)
  11651. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11652. config = append(config, &diagnosisConfig)
  11653. }
  11654. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11655. var pd models.PatientDtos
  11656. pd.PatnID = his.PsnNo
  11657. pd.PatnName = his.Name
  11658. pd.Gend = his.Gend
  11659. pd.Brdy = str
  11660. pd.Poolarea = his.InsuplcAdmdvs
  11661. pd.CurrMdtrtID = his.Number
  11662. var fed models.FsiEncounterDtos
  11663. fed.MdtrtID = his.Number
  11664. fed.MedinsID = miConfig.Code
  11665. fed.MedinsName = miConfig.OrgName
  11666. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11667. fed.MedMdtrtType = "1"
  11668. fed.MedinsType = "1"
  11669. fed.MedinsLv = "11"
  11670. tm := time.Unix(his.RecordDate, 0)
  11671. s_tm := tm.Format("2006-01-02 15:04:05")
  11672. fed.AdmDate = s_tm
  11673. fed.DscgDate = s_tm
  11674. fed.DscgMainDiseCodg = config[0].CountryCode
  11675. fed.DscgMainDiseName = config[0].CountryContentName
  11676. //诊断信息
  11677. var fdds []*models.FsiDiagnoseDtos
  11678. for index, item := range config {
  11679. if index == 0 {
  11680. var fdd models.FsiDiagnoseDtos
  11681. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11682. fdd.InoutDiseType = "1"
  11683. fdd.MaindiseFlag = "1"
  11684. fdd.DiseDate = s_tm
  11685. fdd.DiasSrtNo = "1"
  11686. fdd.DiseName = item.CountryContentName
  11687. fdd.DiseCodg = item.CountryCode
  11688. fdds = append(fdds, &fdd)
  11689. } else {
  11690. var fdd models.FsiDiagnoseDtos
  11691. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11692. fdd.InoutDiseType = "1"
  11693. fdd.MaindiseFlag = "1"
  11694. fdd.DiseDate = s_tm
  11695. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11696. fdd.DiseName = item.CountryContentName
  11697. fdd.DiseCodg = item.CountryCode
  11698. fdds = append(fdds, &fdd)
  11699. }
  11700. }
  11701. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11702. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11703. fed.AdmDeptName = department.Name
  11704. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11705. fed.DscgDeptName = department.Name
  11706. fed.MedMdtrtType = "1"
  11707. fed.MedType = "11"
  11708. //if his.Insutype == "390" {
  11709. // fed.MedType = "1402"
  11710. //} else {
  11711. // fed.MedType = "9933"
  11712. //}
  11713. var orders []*models.FsiOrderDtos
  11714. if trig_scen == "2" {
  11715. //处方医嘱信息
  11716. for _, item := range prescriptions {
  11717. for _, subItem := range item.HisDoctorAdviceInfo {
  11718. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11719. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11720. var order models.FsiOrderDtos
  11721. order.RxID = strconv.FormatInt(item.ID, 10)
  11722. order.Rxno = strconv.FormatInt(item.ID, 10)
  11723. order.LongDrordFlag = "0"
  11724. order.HilistType = "1"
  11725. order.ChrgType = "1"
  11726. order.DrordBhvr = "0"
  11727. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11728. order.HosplistName = subItem.BaseDrugLib.DrugName
  11729. order.HilistLv = "1"
  11730. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11731. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11732. order.HosplistName = subItem.BaseDrugLib.DrugName
  11733. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11734. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11735. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11736. order.OwnpayAmt = ""
  11737. order.SelfpayAmt = ""
  11738. order.Spec = spec
  11739. order.SpecUnt = subItem.PrescribingNumberUnit
  11740. order.DrordBegnDate = s_tm
  11741. order.DrordStopDate = ""
  11742. order.DrordDrCodg = doctor_info.DoctorNumber
  11743. order.DrordDeptName = department.Name
  11744. order.DrordDeptCodg = department.Number
  11745. order.DrordDrName = doctor_info.UserName
  11746. order.DrordDrProfttl = "234"
  11747. order.CurrDrordFlag = "1"
  11748. orders = append(orders, &order)
  11749. }
  11750. }
  11751. for _, subItem := range item.HisPrescriptionProject {
  11752. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  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 = "0"
  11760. order.HilistCode = subItem.HisProject.MedicalCode
  11761. order.HosplistName = subItem.HisProject.ProjectName
  11762. order.HilistLv = "1"
  11763. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11764. order.HosplistCode = subItem.HisProject.MedicalCode
  11765. order.HosplistName = subItem.HisProject.ProjectName
  11766. order.Cnt = subItem.Count
  11767. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11768. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11769. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11770. order.OwnpayAmt = ""
  11771. order.SelfpayAmt = ""
  11772. order.Spec = subItem.Unit
  11773. order.SpecUnt = subItem.Unit
  11774. order.DrordBegnDate = s_tm
  11775. order.DrordStopDate = ""
  11776. order.DrordDrCodg = doctor_info.DoctorNumber
  11777. order.DrordDeptName = department.Name
  11778. order.DrordDeptCodg = department.Number
  11779. order.DrordDrName = doctor_info.UserName
  11780. order.DrordDrProfttl = "234"
  11781. order.CurrDrordFlag = "1"
  11782. orders = append(orders, &order)
  11783. }
  11784. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11785. var order models.FsiOrderDtos
  11786. order.RxID = strconv.FormatInt(item.ID, 10)
  11787. order.Rxno = strconv.FormatInt(item.ID, 10)
  11788. order.LongDrordFlag = "0"
  11789. order.HilistType = "1"
  11790. order.ChrgType = "1"
  11791. order.DrordBhvr = "0"
  11792. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11793. order.HosplistName = subItem.GoodInfo.GoodName
  11794. order.HilistLv = "1"
  11795. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11796. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11797. order.HosplistName = subItem.GoodInfo.GoodName
  11798. order.Cnt = subItem.Count
  11799. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11800. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11801. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11802. order.OwnpayAmt = ""
  11803. order.SelfpayAmt = ""
  11804. order.Spec = subItem.GoodInfo.SpecificationName
  11805. order.SpecUnt = subItem.Unit
  11806. order.DrordBegnDate = s_tm
  11807. order.DrordStopDate = ""
  11808. order.DrordDrCodg = doctor_info.DoctorNumber
  11809. order.DrordDeptName = department.Name
  11810. order.DrordDeptCodg = department.Number
  11811. order.DrordDrName = doctor_info.UserName
  11812. order.DrordDrProfttl = "234"
  11813. order.CurrDrordFlag = "1"
  11814. orders = append(orders, &order)
  11815. }
  11816. }
  11817. }
  11818. //处方医嘱信息
  11819. }
  11820. fed.MatnStas = "0"
  11821. fed.MedfeeSumamt = "0"
  11822. fed.OwnpayAmt = "0"
  11823. fed.SelfpayAmt = "0"
  11824. fed.AcctPayamt = "0"
  11825. fed.MaAmt = "0"
  11826. fed.HifpPayamt = "0"
  11827. fed.SetlTotlnum = "1"
  11828. fed.Insutype = his.Insutype
  11829. fed.ReimFlag = "0"
  11830. fed.OutSetlFlag = "0"
  11831. var fopd []*models.FsiOperationDtosData
  11832. data := make(map[string]interface{})
  11833. data["fed"] = fed
  11834. data["fdd"] = fdds
  11835. data["fod"] = orders
  11836. data["pd"] = pd
  11837. data["pp"] = pp
  11838. data["fopd"] = fopd
  11839. data["trig_scen"] = trig_scen
  11840. fmt.Println(data)
  11841. fmt.Println(fed)
  11842. fmt.Println(fdds)
  11843. fmt.Println(orders)
  11844. fmt.Println(pd)
  11845. fmt.Println(pp)
  11846. fmt.Println(fopd)
  11847. client := &http.Client{}
  11848. bytesData, _ := json.Marshal(data)
  11849. var req *http.Request
  11850. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11851. if miConfig.MdtrtareaAdmvs == "320921" {
  11852. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11853. } else {
  11854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11855. }
  11856. resp, _ := client.Do(req)
  11857. defer resp.Body.Close()
  11858. body, ioErr := ioutil.ReadAll(resp.Body)
  11859. if ioErr != nil {
  11860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11862. return res
  11863. }
  11864. var respJSON map[string]interface{}
  11865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11868. return res
  11869. }
  11870. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11871. fmt.Println(respJSON)
  11872. result, _ := json.Marshal(respJSON)
  11873. fmt.Println(result)
  11874. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11875. utils.ErrorLog("解析失败:%v", err)
  11876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11877. return res
  11878. }
  11879. return res
  11880. } else {
  11881. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11882. saveLog(output, input, "3101", "事前")
  11883. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11884. utils.ErrorLog("解析失败:%v", err)
  11885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11886. return
  11887. }
  11888. return res
  11889. }
  11890. return res
  11891. }
  11892. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11893. adminUser := c.GetAdminUserInfo()
  11894. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11895. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11896. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11897. record_time := c.GetString("record_time")
  11898. order, _ := service.GetHisOrderByID(order_id)
  11899. timeLayout := "2006-01-02"
  11900. loc, _ := time.LoadLocation("Local")
  11901. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11902. if err != nil {
  11903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11904. return
  11905. }
  11906. recordDateTime := theTime.Unix()
  11907. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11908. var patientPrescription models.HisPrescriptionInfo
  11909. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11910. if patientPrescription.ID == 0 {
  11911. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11912. }
  11913. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11914. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11915. //
  11916. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11917. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11918. var pp models.PublicParams
  11919. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11920. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11921. pp.FixmedinsName = miConfig.OrgName
  11922. pp.FixmedinsCode = miConfig.Code
  11923. pp.RequestUrl = miConfig.Url
  11924. pp.Cainfo = miConfig.Cainfo
  11925. pp.SecretKey = miConfig.SecretKey
  11926. pp.AccessKey = miConfig.AccessKey
  11927. pp.OpterName = roles.UserName
  11928. var config []*models.HisXtDiagnoseConfig
  11929. for _, item := range diagnosis_ids {
  11930. id, _ := strconv.ParseInt(item, 10, 64)
  11931. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11932. config = append(config, &diagnosisConfig)
  11933. }
  11934. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11935. var pd models.PatientDtos
  11936. pd.PatnID = his.PsnNo
  11937. pd.PatnName = his.Name
  11938. pd.Gend = his.Gend
  11939. pd.Brdy = str
  11940. pd.Poolarea = his.InsuplcAdmdvs
  11941. pd.CurrMdtrtID = his.Number
  11942. var fed models.FsiEncounterDtos
  11943. fed.MdtrtID = his.Number
  11944. fed.MedinsID = miConfig.Code
  11945. fed.MedinsName = miConfig.OrgName
  11946. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11947. fed.MedMdtrtType = "1"
  11948. fed.MedinsType = "1"
  11949. fed.MedinsLv = "11"
  11950. tm := time.Unix(his.RecordDate, 0)
  11951. s_tm := tm.Format("2006-01-02 15:04:05")
  11952. fed.AdmDate = s_tm
  11953. fed.DscgDate = s_tm
  11954. fed.DscgMainDiseCodg = config[0].CountryCode
  11955. fed.DscgMainDiseName = config[0].CountryContentName
  11956. //诊断信息
  11957. var fdds []*models.FsiDiagnoseDtos
  11958. for index, item := range config {
  11959. if index == 0 {
  11960. var fdd models.FsiDiagnoseDtos
  11961. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11962. fdd.InoutDiseType = "1"
  11963. fdd.MaindiseFlag = "1"
  11964. fdd.DiseDate = s_tm
  11965. fdd.DiasSrtNo = "1"
  11966. fdd.DiseName = item.CountryContentName
  11967. fdd.DiseCodg = item.CountryCode
  11968. fdds = append(fdds, &fdd)
  11969. } else {
  11970. var fdd models.FsiDiagnoseDtos
  11971. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11972. fdd.InoutDiseType = "1"
  11973. fdd.MaindiseFlag = "1"
  11974. fdd.DiseDate = s_tm
  11975. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11976. fdd.DiseName = item.CountryContentName
  11977. fdd.DiseCodg = item.CountryCode
  11978. fdds = append(fdds, &fdd)
  11979. }
  11980. }
  11981. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11982. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11983. fed.AdmDeptName = department.Name
  11984. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11985. fed.DscgDeptName = department.Name
  11986. fed.MedType = order.MedType
  11987. //处方医嘱信息
  11988. var orders []*models.FsiOrderDtos
  11989. //for _, item := range prescriptions {
  11990. // for _, subItem := range item.HisDoctorAdviceInfo {
  11991. // var order models.FsiOrderDtos
  11992. // order.RxID = strconv.FormatInt(item.ID, 10)
  11993. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11994. // order.LongDrordFlag = "0"
  11995. // order.HilistType = "1"
  11996. // order.ChrgType = "1"
  11997. // order.DrordBhvr = "-"
  11998. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11999. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12000. // order.HilistLv = "1"
  12001. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12002. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12003. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12004. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12005. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12006. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12007. // order.OwnpayAmt = ""
  12008. // order.SelfpayAmt = ""
  12009. // order.Spec = ""
  12010. // order.SpecUnt = ""
  12011. // order.DrordBegnDate = s_tm
  12012. // order.DrordStopDate = ""
  12013. // order.DrordDrCodg = "1"
  12014. // order.DrordDeptName = department.Name
  12015. // order.DrordDrCodg = "1"
  12016. // order.DrordDrName = doctor_info.UserName
  12017. // order.DrordDrProfttl = ""
  12018. // order.CurrDrordFlag = "1"
  12019. // orders = append(orders, &order)
  12020. // }
  12021. // for _, subItem := range item.HisPrescriptionProject {
  12022. // if subItem.Type == 2 {
  12023. // var order models.FsiOrderDtos
  12024. // order.RxID = strconv.FormatInt(item.ID, 10)
  12025. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12026. // order.LongDrordFlag = "0"
  12027. // order.HilistType = "1"
  12028. // order.ChrgType = "1"
  12029. // order.DrordBhvr = "-"
  12030. // order.HilistCode = subItem.HisProject.MedicalCode
  12031. // order.HosplistName = subItem.HisProject.ProjectName
  12032. // order.HilistLv = "1"
  12033. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12034. // order.HosplistCode = subItem.HisProject.MedicalCode
  12035. // order.HosplistName = subItem.HisProject.ProjectName
  12036. // order.Cnt = subItem.Count
  12037. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12038. //
  12039. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12040. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12041. // order.OwnpayAmt = ""
  12042. // order.SelfpayAmt = ""
  12043. // order.Spec = ""
  12044. // order.SpecUnt = ""
  12045. // order.DrordBegnDate = s_tm
  12046. // order.DrordStopDate = ""
  12047. // order.DrordDrCodg = "1"
  12048. // order.DrordDeptName = department.Name
  12049. // order.DrordDrCodg = "1"
  12050. // order.DrordDrName = doctor_info.UserName
  12051. // order.DrordDrProfttl = ""
  12052. // order.CurrDrordFlag = "1"
  12053. // orders = append(orders, &order)
  12054. //
  12055. // }
  12056. // if subItem.Type == 3 {
  12057. //
  12058. // var order models.FsiOrderDtos
  12059. // order.RxID = strconv.FormatInt(item.ID, 10)
  12060. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12061. // order.LongDrordFlag = "0"
  12062. // order.HilistType = "1"
  12063. // order.ChrgType = "1"
  12064. // order.DrordBhvr = "-"
  12065. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12066. // order.HosplistName = subItem.GoodInfo.GoodName
  12067. // order.HilistLv = "1"
  12068. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12069. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12070. // order.HosplistName = subItem.GoodInfo.GoodName
  12071. // order.Cnt = subItem.Count
  12072. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12073. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12074. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12075. // order.OwnpayAmt = ""
  12076. // order.SelfpayAmt = ""
  12077. // order.Spec = ""
  12078. // order.SpecUnt = ""
  12079. // order.DrordBegnDate = s_tm
  12080. // order.DrordStopDate = ""
  12081. // order.DrordDrCodg = "1"
  12082. // order.DrordDeptName = department.Name
  12083. // order.DrordDrCodg = "1"
  12084. // order.DrordDrName = doctor_info.UserName
  12085. // order.DrordDrProfttl = ""
  12086. // order.CurrDrordFlag = "1"
  12087. // orders = append(orders, &order)
  12088. //
  12089. // }
  12090. // }
  12091. //}
  12092. for _, item := range prescriptions {
  12093. for _, subItem := range item.HisDoctorAdviceInfo {
  12094. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12095. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12096. var order models.FsiOrderDtos
  12097. order.RxID = strconv.FormatInt(item.ID, 10)
  12098. order.Rxno = strconv.FormatInt(item.ID, 10)
  12099. order.LongDrordFlag = "0"
  12100. order.HilistType = "1"
  12101. order.ChrgType = "1"
  12102. order.DrordBhvr = "0"
  12103. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12104. order.HosplistName = subItem.BaseDrugLib.DrugName
  12105. order.HilistLv = "1"
  12106. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12107. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12108. order.HosplistName = subItem.BaseDrugLib.DrugName
  12109. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12110. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12111. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12112. order.OwnpayAmt = ""
  12113. order.SelfpayAmt = ""
  12114. order.Spec = spec
  12115. order.SpecUnt = subItem.PrescribingNumberUnit
  12116. order.DrordBegnDate = s_tm
  12117. order.DrordStopDate = ""
  12118. order.DrordDrCodg = doctor_info.DoctorNumber
  12119. order.DrordDeptName = department.Name
  12120. order.DrordDeptCodg = department.Number
  12121. order.DrordDrName = doctor_info.UserName
  12122. order.DrordDrProfttl = "234"
  12123. order.CurrDrordFlag = "1"
  12124. orders = append(orders, &order)
  12125. }
  12126. }
  12127. for _, subItem := range item.HisPrescriptionProject {
  12128. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12129. var order models.FsiOrderDtos
  12130. order.RxID = strconv.FormatInt(item.ID, 10)
  12131. order.Rxno = strconv.FormatInt(item.ID, 10)
  12132. order.LongDrordFlag = "0"
  12133. order.HilistType = "1"
  12134. order.ChrgType = "1"
  12135. order.DrordBhvr = "0"
  12136. order.HilistCode = subItem.HisProject.MedicalCode
  12137. order.HosplistName = subItem.HisProject.ProjectName
  12138. order.HilistLv = "1"
  12139. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12140. order.HosplistCode = subItem.HisProject.MedicalCode
  12141. order.HosplistName = subItem.HisProject.ProjectName
  12142. order.Cnt = subItem.Count
  12143. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12144. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12145. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12146. order.OwnpayAmt = ""
  12147. order.SelfpayAmt = ""
  12148. order.Spec = subItem.Unit
  12149. order.SpecUnt = subItem.Unit
  12150. order.DrordBegnDate = s_tm
  12151. order.DrordStopDate = ""
  12152. order.DrordDrCodg = doctor_info.DoctorNumber
  12153. order.DrordDeptName = department.Name
  12154. order.DrordDeptCodg = department.Number
  12155. order.DrordDrName = doctor_info.UserName
  12156. order.DrordDrProfttl = "234"
  12157. order.CurrDrordFlag = "1"
  12158. orders = append(orders, &order)
  12159. }
  12160. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12161. var order models.FsiOrderDtos
  12162. order.RxID = strconv.FormatInt(item.ID, 10)
  12163. order.Rxno = strconv.FormatInt(item.ID, 10)
  12164. order.LongDrordFlag = "0"
  12165. order.HilistType = "1"
  12166. order.ChrgType = "1"
  12167. order.DrordBhvr = "0"
  12168. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12169. order.HosplistName = subItem.GoodInfo.GoodName
  12170. order.HilistLv = "1"
  12171. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12172. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12173. order.HosplistName = subItem.GoodInfo.GoodName
  12174. order.Cnt = subItem.Count
  12175. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12176. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12177. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12178. order.OwnpayAmt = ""
  12179. order.SelfpayAmt = ""
  12180. order.Spec = subItem.GoodInfo.SpecificationName
  12181. order.SpecUnt = subItem.Unit
  12182. order.DrordBegnDate = s_tm
  12183. order.DrordStopDate = ""
  12184. order.DrordDrCodg = doctor_info.DoctorNumber
  12185. order.DrordDeptName = department.Name
  12186. order.DrordDeptCodg = department.Number
  12187. order.DrordDrName = doctor_info.UserName
  12188. order.DrordDrProfttl = "234"
  12189. order.CurrDrordFlag = "1"
  12190. orders = append(orders, &order)
  12191. }
  12192. }
  12193. }
  12194. //处方医嘱信息
  12195. fed.MatnStas = "0"
  12196. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12197. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12198. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12199. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12200. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12201. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12202. fed.SetlTotlnum = "1"
  12203. fed.Insutype = his.Insutype
  12204. fed.ReimFlag = "0"
  12205. fed.OutSetlFlag = "0"
  12206. var fopd []*models.FsiOperationDtosData
  12207. data := make(map[string]interface{})
  12208. data["fed"] = fed
  12209. data["fdd"] = fdds
  12210. data["fod"] = orders
  12211. data["pd"] = pd
  12212. data["pp"] = pp
  12213. data["fopd"] = fopd
  12214. data["trig_scen"] = trig_scen
  12215. client := &http.Client{}
  12216. bytesData, _ := json.Marshal(data)
  12217. var req *http.Request
  12218. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12219. if miConfig.MdtrtareaAdmvs == "320921" {
  12220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12221. } else {
  12222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12223. }
  12224. resp, _ := client.Do(req)
  12225. defer resp.Body.Close()
  12226. body, ioErr := ioutil.ReadAll(resp.Body)
  12227. if ioErr != nil {
  12228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12230. return res
  12231. }
  12232. var respJSON map[string]interface{}
  12233. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12236. return res
  12237. }
  12238. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12239. result, _ := json.Marshal(respJSON)
  12240. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12241. utils.ErrorLog("解析失败:%v", err)
  12242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12243. return res
  12244. }
  12245. return res
  12246. } else {
  12247. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12248. saveLog(output, input, "3102", "事中")
  12249. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12250. utils.ErrorLog("解析失败:%v", err)
  12251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12252. return
  12253. }
  12254. return res
  12255. }
  12256. return res
  12257. }
  12258. func (c *HisApiController) Check() {
  12259. psn_no := c.GetString("psn_no")
  12260. in := c.GetString("in")
  12261. mt := c.GetString("mt")
  12262. baseParams := models.BaseParams{
  12263. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12264. FixmedinsCode: "H15049901371",
  12265. InsuplcAdmdvs: "150499",
  12266. MdtrtareaAdmvs: "150499",
  12267. OrgName: "赤峰费森血液透析中心",
  12268. Doctor: "1111",
  12269. }
  12270. service.Gdyb2001(baseParams, psn_no, in, mt)
  12271. }
  12272. func (c *HisApiController) GetPsnNcdsInfo() {
  12273. admin_user_id, _ := c.GetInt64("admin_user_id")
  12274. patient_id, _ := c.GetInt64("patient_id")
  12275. //id, _ := c.GetInt64("id")
  12276. adminUser := c.GetAdminUserInfo()
  12277. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12278. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12279. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12280. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12281. //psn_record, _ := service.GetP(id)
  12282. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12283. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12284. //
  12285. //if psn_record.ID == 0 {
  12286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12287. // return
  12288. //}
  12289. var res Result5301
  12290. var res10265 Result5301For10265
  12291. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12292. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12293. var api string
  12294. if miConfig.MdtrtareaAdmvs == "320921" {
  12295. 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 +
  12296. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12297. } else {
  12298. 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 +
  12299. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12300. }
  12301. resp, requestErr := http.Get(api)
  12302. if requestErr != nil {
  12303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12304. return
  12305. }
  12306. body, ioErr := ioutil.ReadAll(resp.Body)
  12307. if ioErr != nil {
  12308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. var respJSON map[string]interface{}
  12313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12316. return
  12317. }
  12318. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12319. result, _ := json.Marshal(respJSON)
  12320. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12321. utils.ErrorLog("解析失败:%v", err)
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12323. return
  12324. }
  12325. res.ErrMsg = res10265.ErrMsg
  12326. res.Output = res10265.Output
  12327. res.InfRefmsgid = res10265.InfRefmsgid
  12328. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12329. res.Infcode = infocode
  12330. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12331. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12332. var api string
  12333. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12334. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12335. resp, requestErr := http.Get(api)
  12336. if requestErr != nil {
  12337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12338. return
  12339. }
  12340. body, ioErr := ioutil.ReadAll(resp.Body)
  12341. if ioErr != nil {
  12342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12344. return
  12345. }
  12346. var respJSON map[string]interface{}
  12347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12350. return
  12351. }
  12352. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12353. if status == "0" {
  12354. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12355. c.ServeSuccessJSON(map[string]interface{}{
  12356. "failed_code": -10,
  12357. "msg": err_msg,
  12358. })
  12359. return
  12360. }
  12361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12362. result, _ := json.Marshal(respJSON)
  12363. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12364. utils.ErrorLog("解析失败:%v", err)
  12365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12366. return
  12367. }
  12368. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12369. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12370. var api string
  12371. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12372. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12373. resp, requestErr := http.Get(api)
  12374. if requestErr != nil {
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. body, ioErr := ioutil.ReadAll(resp.Body)
  12379. if ioErr != nil {
  12380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12382. return
  12383. }
  12384. var respJSON map[string]interface{}
  12385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12388. return
  12389. }
  12390. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12391. if status == "0" {
  12392. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12393. c.ServeSuccessJSON(map[string]interface{}{
  12394. "failed_code": -10,
  12395. "msg": err_msg,
  12396. })
  12397. return
  12398. }
  12399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12400. result, _ := json.Marshal(respJSON)
  12401. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12402. utils.ErrorLog("解析失败:%v", err)
  12403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12404. return
  12405. }
  12406. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12407. p, _ := service.GetHisPatientById(patient_id)
  12408. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12409. var dat map[string]interface{}
  12410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12411. fmt.Println(dat)
  12412. } else {
  12413. fmt.Println(err)
  12414. }
  12415. userJSONBytes, _ := json.Marshal(dat)
  12416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12417. utils.ErrorLog("解析失败:%v", err)
  12418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12419. return
  12420. }
  12421. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12422. p, _ := service.GetHisPatientById(patient_id)
  12423. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12424. var dat map[string]interface{}
  12425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12426. fmt.Println(dat)
  12427. } else {
  12428. fmt.Println(err)
  12429. }
  12430. userJSONBytes, _ := json.Marshal(dat)
  12431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12432. utils.ErrorLog("解析失败:%v", err)
  12433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12434. return
  12435. }
  12436. } else if miConfig.MdtrtareaAdmvs == "360100" {
  12437. p, _ := service.GetHisPatientById(patient_id)
  12438. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12439. var dat map[string]interface{}
  12440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12441. fmt.Println(dat)
  12442. } else {
  12443. fmt.Println(err)
  12444. }
  12445. userJSONBytes, _ := json.Marshal(dat)
  12446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12447. utils.ErrorLog("解析失败:%v", err)
  12448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12449. return
  12450. }
  12451. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12452. p, _ := service.GetHisPatientById(patient_id)
  12453. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12454. var dat map[string]interface{}
  12455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12456. fmt.Println(dat)
  12457. } else {
  12458. fmt.Println(err)
  12459. }
  12460. userJSONBytes, _ := json.Marshal(dat)
  12461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12462. utils.ErrorLog("解析失败:%v", err)
  12463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12464. return
  12465. }
  12466. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12467. p, _ := service.GetHisPatientById(patient_id)
  12468. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12469. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12470. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12471. resp, requestErr := http.Get(api)
  12472. if requestErr != nil {
  12473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12474. return
  12475. }
  12476. body, ioErr := ioutil.ReadAll(resp.Body)
  12477. if ioErr != nil {
  12478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12480. return
  12481. }
  12482. var respJSON map[string]interface{}
  12483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12486. return
  12487. }
  12488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12489. result, _ := json.Marshal(respJSON)
  12490. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12491. utils.ErrorLog("解析失败:%v", err)
  12492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12493. return
  12494. }
  12495. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12496. p, _ := service.GetHisPatientById(patient_id)
  12497. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12498. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12499. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12500. resp, requestErr := http.Get(api)
  12501. if requestErr != nil {
  12502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12503. return
  12504. }
  12505. body, ioErr := ioutil.ReadAll(resp.Body)
  12506. if ioErr != nil {
  12507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12509. return
  12510. }
  12511. var respJSON map[string]interface{}
  12512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12515. return
  12516. }
  12517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12518. result, _ := json.Marshal(respJSON)
  12519. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12520. utils.ErrorLog("解析失败:%v", err)
  12521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12522. return
  12523. }
  12524. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12525. p, _ := service.GetHisPatientById(patient_id)
  12526. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12527. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12528. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12529. resp, requestErr := http.Get(api)
  12530. if requestErr != nil {
  12531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12532. return
  12533. }
  12534. body, ioErr := ioutil.ReadAll(resp.Body)
  12535. if ioErr != nil {
  12536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12538. return
  12539. }
  12540. var respJSON map[string]interface{}
  12541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12544. return
  12545. }
  12546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12547. result, _ := json.Marshal(respJSON)
  12548. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12549. utils.ErrorLog("解析失败:%v", err)
  12550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12551. return
  12552. }
  12553. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12554. p, _ := service.GetHisPatientById(patient_id)
  12555. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12556. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12557. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12558. resp, requestErr := http.Get(api)
  12559. if requestErr != nil {
  12560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12561. return
  12562. }
  12563. body, ioErr := ioutil.ReadAll(resp.Body)
  12564. if ioErr != nil {
  12565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12567. return
  12568. }
  12569. var respJSON map[string]interface{}
  12570. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12573. return
  12574. }
  12575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12576. result, _ := json.Marshal(respJSON)
  12577. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12578. utils.ErrorLog("解析失败:%v", err)
  12579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12580. return
  12581. }
  12582. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12583. p, _ := service.GetHisPatientById(patient_id)
  12584. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12585. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12586. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12587. resp, requestErr := http.Get(api)
  12588. if requestErr != nil {
  12589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12590. return
  12591. }
  12592. body, ioErr := ioutil.ReadAll(resp.Body)
  12593. if ioErr != nil {
  12594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12596. return
  12597. }
  12598. var respJSON map[string]interface{}
  12599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12602. return
  12603. }
  12604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12605. result, _ := json.Marshal(respJSON)
  12606. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12607. utils.ErrorLog("解析失败:%v", err)
  12608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12609. return
  12610. }
  12611. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12612. p, _ := service.GetHisPatientById(patient_id)
  12613. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12614. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12615. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12616. resp, requestErr := http.Get(api)
  12617. if requestErr != nil {
  12618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12619. return
  12620. }
  12621. body, ioErr := ioutil.ReadAll(resp.Body)
  12622. if ioErr != nil {
  12623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12625. return
  12626. }
  12627. var respJSON map[string]interface{}
  12628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12631. return
  12632. }
  12633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12634. result, _ := json.Marshal(respJSON)
  12635. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12636. utils.ErrorLog("解析失败:%v", err)
  12637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12638. return
  12639. }
  12640. } else {
  12641. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12642. var dat map[string]interface{}
  12643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12644. fmt.Println(dat)
  12645. } else {
  12646. fmt.Println(err)
  12647. }
  12648. userJSONBytes, _ := json.Marshal(dat)
  12649. if miConfig.Code == "H15049901371" {
  12650. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12651. utils.ErrorLog("解析失败:%v", err)
  12652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12653. return
  12654. }
  12655. res.InfRefmsgid = res10265.InfRefmsgid
  12656. res.Output = res10265.Output
  12657. res.ErrMsg = res10265.ErrMsg
  12658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12659. res.Infcode = infocode
  12660. } else {
  12661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12662. utils.ErrorLog("解析失败:%v", err)
  12663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. return
  12665. }
  12666. }
  12667. }
  12668. if res.Infcode == 0 {
  12669. c.ServeSuccessJSON(map[string]interface{}{
  12670. "result": res.Output.Result,
  12671. })
  12672. }
  12673. }
  12674. func (c *HisApiController) CheckInsutype() {
  12675. his_patient_id, _ := c.GetInt64("his_patient_id")
  12676. admin_user_id, _ := c.GetInt64("admin_user_id")
  12677. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12678. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12679. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12680. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12681. var dat map[string]interface{}
  12682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12683. fmt.Println(dat)
  12684. } else {
  12685. fmt.Println(err)
  12686. }
  12687. userJSONBytes, _ := json.Marshal(dat)
  12688. var res Result90100
  12689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12690. utils.ErrorLog("解析失败:%v", err)
  12691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12692. return
  12693. }
  12694. if res.Infcode != 0 {
  12695. c.ServeSuccessJSON(map[string]interface{}{
  12696. "failed_code": -10,
  12697. "msg": res.ErrMsg,
  12698. })
  12699. return
  12700. } else {
  12701. fmt.Println(res)
  12702. }
  12703. }
  12704. func (c *HisApiController) CheckCardPWD() {
  12705. card_pwd := c.GetString("card_pwd")
  12706. his_patient_id, _ := c.GetInt64("his_patient_id")
  12707. admin_user_id, _ := c.GetInt64("admin_user_id")
  12708. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12710. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12711. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12712. bas := strings.Split(psn.CardInfo, "|")
  12713. basNumber := bas[2]
  12714. if psn.InsuplcAdmdvs[:4] == "4403" {
  12715. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12716. var dat map[string]interface{}
  12717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12718. fmt.Println(dat)
  12719. } else {
  12720. fmt.Println(err)
  12721. }
  12722. userJSONBytes, _ := json.Marshal(dat)
  12723. var res Result90991
  12724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12725. utils.ErrorLog("解析失败:%v", err)
  12726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12727. return
  12728. }
  12729. if res.Infcode != 0 {
  12730. c.ServeSuccessJSON(map[string]interface{}{
  12731. "failed_code": -10,
  12732. "msg": res.ErrMsg,
  12733. })
  12734. return
  12735. } else {
  12736. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12737. var msg string
  12738. switch res.Output.Result.CardStat {
  12739. case "00":
  12740. msg = "未激活"
  12741. break
  12742. case "10":
  12743. msg = "激活"
  12744. break
  12745. case "20":
  12746. msg = "窗口挂失"
  12747. break
  12748. case "21":
  12749. msg = "电话挂失"
  12750. break
  12751. case "22":
  12752. msg = "单位网上申报挂失"
  12753. break
  12754. case "23":
  12755. msg = "保健办挂失"
  12756. break
  12757. case "24":
  12758. msg = "个人网上挂失"
  12759. break
  12760. case "25":
  12761. msg = "网上服务大厅挂失"
  12762. break
  12763. case "30":
  12764. msg = "注销"
  12765. break
  12766. case "40":
  12767. msg = "回收"
  12768. break
  12769. case "99":
  12770. msg = "制卡中(无效卡)"
  12771. break
  12772. }
  12773. c.ServeSuccessJSON(map[string]interface{}{
  12774. "failed_code": -10,
  12775. "msg": msg,
  12776. })
  12777. return
  12778. } else {
  12779. c.ServeSuccessJSON(map[string]interface{}{
  12780. "msg": "校验成功",
  12781. })
  12782. return
  12783. }
  12784. }
  12785. } else {
  12786. c.ServeSuccessJSON(map[string]interface{}{
  12787. "msg": "校验成功",
  12788. })
  12789. return
  12790. }
  12791. }
  12792. func (c *HisApiController) CheckCardPWDTwo() {
  12793. //card_pwd := c.GetString("card_pwd")
  12794. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12795. admin_user_id, _ := c.GetInt64("admin_user_id")
  12796. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12797. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12798. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12799. var dat map[string]interface{}
  12800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12801. fmt.Println(dat)
  12802. } else {
  12803. fmt.Println(err)
  12804. }
  12805. userJSONBytes, _ := json.Marshal(dat)
  12806. var res Result90991
  12807. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12808. utils.ErrorLog("解析失败:%v", err)
  12809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12810. return
  12811. }
  12812. if res.Infcode != 0 {
  12813. c.ServeSuccessJSON(map[string]interface{}{
  12814. "failed_code": -10,
  12815. "msg": res.ErrMsg,
  12816. })
  12817. return
  12818. } else {
  12819. if res.Output.Result.SscnoCheckStat == "0" {
  12820. var msg string
  12821. switch res.Output.Result.CardStat {
  12822. case "00":
  12823. msg = "未激活"
  12824. break
  12825. case "10":
  12826. msg = "激活"
  12827. break
  12828. case "20":
  12829. msg = "窗口挂失"
  12830. break
  12831. case "21":
  12832. msg = "电话挂失"
  12833. break
  12834. case "22":
  12835. msg = "单位网上申报挂失"
  12836. break
  12837. case "23":
  12838. msg = "保健办挂失"
  12839. break
  12840. case "24":
  12841. msg = "个人网上挂失"
  12842. break
  12843. case "25":
  12844. msg = "网上服务大厅挂失"
  12845. break
  12846. case "30":
  12847. msg = "注销"
  12848. break
  12849. case "40":
  12850. msg = "回收"
  12851. break
  12852. case "99":
  12853. msg = "制卡中(无效卡)"
  12854. break
  12855. }
  12856. c.ServeSuccessJSON(map[string]interface{}{
  12857. "failed_code": -10,
  12858. "msg": msg,
  12859. })
  12860. return
  12861. } else {
  12862. c.ServeSuccessJSON(map[string]interface{}{
  12863. "msg": "校验成功",
  12864. })
  12865. return
  12866. }
  12867. }
  12868. }
  12869. type ELeCertData struct {
  12870. Data struct {
  12871. Extra string `json:"extra"`
  12872. IDNo string `json:"idNo"`
  12873. IDType string `json:"idType"`
  12874. EcToken string `json:"ecToken"`
  12875. InsuOrg string `json:"insuOrg"`
  12876. UserName string `json:"userName"`
  12877. EcIndexNo string `json:"ecIndexNo"`
  12878. Gender string `json:"gender"`
  12879. Birthday string `json:"birthday"`
  12880. Nationality string `json:"nationality"`
  12881. Email string `json:"email"`
  12882. } `json:"OutData"`
  12883. }
  12884. func (c *HisApiController) ReadCard() {
  12885. id_card_type, _ := c.GetInt64("id_card_type")
  12886. admin_user_id, _ := c.GetInt64("admin_user_id")
  12887. certificates, _ := c.GetInt64("certificates")
  12888. //
  12889. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12890. id_card_no := c.GetString("id_card_no")
  12891. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12892. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12893. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12894. switch id_card_type {
  12895. case 1:
  12896. if miConfig.MdtrtareaAdmvs == "421300" {
  12897. var res ResultTwo
  12898. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12899. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12900. "&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)
  12901. resp, requestErr := http.Get(api)
  12902. if requestErr != nil {
  12903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12904. return
  12905. }
  12906. body, ioErr := ioutil.ReadAll(resp.Body)
  12907. if ioErr != nil {
  12908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12910. return
  12911. }
  12912. var respJSON map[string]interface{}
  12913. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12916. return
  12917. }
  12918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12919. result, _ := json.Marshal(respJSON)
  12920. fmt.Println("log")
  12921. fmt.Println(string(result))
  12922. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12923. utils.ErrorLog("解析失败:%v", err)
  12924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12925. return
  12926. }
  12927. if res.Infcode == 0 {
  12928. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12929. if err == gorm.ErrRecordNotFound {
  12930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12931. return
  12932. } else if err != nil {
  12933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12934. return
  12935. } else {
  12936. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12937. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12938. infoStr := string(Iinfos)
  12939. idetinfoStr := string(Idetinfos)
  12940. var rf []*ResultFive
  12941. json.Unmarshal([]byte(infoStr), &rf)
  12942. var insutypes []*ResultFive
  12943. var insutype string
  12944. var is390 int = 0
  12945. var is310 int = 0
  12946. for _, item := range rf {
  12947. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12948. insutypes = append(insutypes, item)
  12949. }
  12950. }
  12951. if len(insutypes) == 1 {
  12952. insutype = insutypes[0].Insutype
  12953. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12954. } else {
  12955. for _, i := range insutypes {
  12956. if i.Insutype == "390" {
  12957. is390 = 1
  12958. }
  12959. if i.Insutype == "310" {
  12960. is310 = 1
  12961. }
  12962. }
  12963. }
  12964. if is390 == 1 {
  12965. insutype = "390"
  12966. }
  12967. if is310 == 1 {
  12968. insutype = "310"
  12969. }
  12970. if len(insutypes) == 0 {
  12971. insutype = "390"
  12972. }
  12973. var insuplc_admdvs string
  12974. for _, item := range rf {
  12975. if item.Insutype == insutype {
  12976. insuplc_admdvs = item.InsuplcAdmdvs
  12977. }
  12978. }
  12979. if strings.Contains(insuplc_admdvs, "4213") {
  12980. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12981. }
  12982. psn := &models.HisPsn{
  12983. PsnNo: res.Output.Baseinfo.PsnNo,
  12984. PatientId: patient.ID,
  12985. Certno: res.Output.Baseinfo.Certno,
  12986. Gend: res.Output.Baseinfo.Gend,
  12987. Naty: res.Output.Baseinfo.Naty,
  12988. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12989. PsnName: res.Output.Baseinfo.PsnName,
  12990. Idetinfo: idetinfoStr,
  12991. Insuinfo: infoStr,
  12992. InsuplcAdmdvs: insuplc_admdvs,
  12993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12994. }
  12995. service.CreateHisPsn(psn)
  12996. c.ServeSuccessJSON(map[string]interface{}{
  12997. "patient": patient,
  12998. "number": res.Output.Baseinfo.Certno,
  12999. })
  13000. }
  13001. } else {
  13002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13003. return
  13004. }
  13005. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13006. var res ResultTwo
  13007. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13008. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13009. "&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)
  13010. resp, requestErr := http.Get(api)
  13011. if requestErr != nil {
  13012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13013. return
  13014. }
  13015. body, ioErr := ioutil.ReadAll(resp.Body)
  13016. if ioErr != nil {
  13017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13019. return
  13020. }
  13021. var respJSON map[string]interface{}
  13022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13025. return
  13026. }
  13027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13028. result, _ := json.Marshal(respJSON)
  13029. fmt.Println("log")
  13030. fmt.Println(string(result))
  13031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13032. utils.ErrorLog("解析失败:%v", err)
  13033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13034. return
  13035. }
  13036. if res.Infcode == 0 {
  13037. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13038. if err == gorm.ErrRecordNotFound {
  13039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13040. return
  13041. } else if err != nil {
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13043. return
  13044. } else {
  13045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13047. infoStr := string(Iinfos)
  13048. idetinfoStr := string(Idetinfos)
  13049. psn := &models.HisPsn{
  13050. PsnNo: res.Output.Baseinfo.PsnNo,
  13051. PatientId: patient.ID,
  13052. Certno: res.Output.Baseinfo.Certno,
  13053. Gend: res.Output.Baseinfo.Gend,
  13054. Naty: res.Output.Baseinfo.Naty,
  13055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13056. PsnName: res.Output.Baseinfo.PsnName,
  13057. Idetinfo: idetinfoStr,
  13058. Insuinfo: infoStr,
  13059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13060. }
  13061. service.CreateHisPsn(psn)
  13062. var rf []*ResultFive
  13063. json.Unmarshal([]byte(infoStr), &rf)
  13064. var insutypes []*ResultFive
  13065. var insutype string
  13066. var is390 int = 0
  13067. var is310 int = 0
  13068. for _, item := range rf {
  13069. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13070. insutypes = append(insutypes, item)
  13071. }
  13072. }
  13073. if len(insutypes) == 1 {
  13074. insutype = insutypes[0].Insutype
  13075. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13076. } else {
  13077. for _, i := range insutypes {
  13078. if i.Insutype == "390" {
  13079. is390 = 1
  13080. }
  13081. if i.Insutype == "310" {
  13082. is310 = 1
  13083. }
  13084. }
  13085. }
  13086. if is390 == 1 {
  13087. insutype = "390"
  13088. }
  13089. if is310 == 1 {
  13090. insutype = "310"
  13091. }
  13092. if len(insutypes) == 0 {
  13093. insutype = "310"
  13094. }
  13095. c.ServeSuccessJSON(map[string]interface{}{
  13096. "patient": patient,
  13097. "number": res.Output.Baseinfo.Certno,
  13098. "insutype": insutype,
  13099. })
  13100. }
  13101. } else {
  13102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13103. return
  13104. }
  13105. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13106. var res ResultTwo
  13107. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13108. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13109. "&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)
  13110. resp, requestErr := http.Get(api)
  13111. if requestErr != nil {
  13112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13113. return
  13114. }
  13115. body, ioErr := ioutil.ReadAll(resp.Body)
  13116. if ioErr != nil {
  13117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13119. return
  13120. }
  13121. var respJSON map[string]interface{}
  13122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13125. return
  13126. }
  13127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13128. result, _ := json.Marshal(respJSON)
  13129. fmt.Println("log")
  13130. fmt.Println(string(result))
  13131. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13132. utils.ErrorLog("解析失败:%v", err)
  13133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13134. return
  13135. }
  13136. if res.Infcode == 0 {
  13137. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13138. if err == gorm.ErrRecordNotFound {
  13139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13140. return
  13141. } else if err != nil {
  13142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13143. return
  13144. } else {
  13145. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13146. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13147. infoStr := string(Iinfos)
  13148. idetinfoStr := string(Idetinfos)
  13149. var rf []*ResultFive
  13150. json.Unmarshal([]byte(infoStr), &rf)
  13151. var insutypes []*ResultFive
  13152. var insutype string
  13153. var is390 int = 0
  13154. var is310 int = 0
  13155. for _, item := range rf {
  13156. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13157. insutypes = append(insutypes, item)
  13158. }
  13159. }
  13160. if len(insutypes) == 1 {
  13161. insutype = insutypes[0].Insutype
  13162. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13163. } else {
  13164. for _, i := range insutypes {
  13165. if i.Insutype == "390" {
  13166. is390 = 1
  13167. }
  13168. if i.Insutype == "310" {
  13169. is310 = 1
  13170. }
  13171. }
  13172. }
  13173. if is390 == 1 {
  13174. insutype = "390"
  13175. }
  13176. if is310 == 1 {
  13177. insutype = "310"
  13178. }
  13179. if len(insutypes) == 0 {
  13180. insutype = "390"
  13181. }
  13182. var insuplc_admdvs string
  13183. for _, item := range rf {
  13184. if item.Insutype == insutype {
  13185. insuplc_admdvs = item.InsuplcAdmdvs
  13186. }
  13187. }
  13188. psn := &models.HisPsn{
  13189. PsnNo: res.Output.Baseinfo.PsnNo,
  13190. PatientId: patient.ID,
  13191. Certno: res.Output.Baseinfo.Certno,
  13192. Gend: res.Output.Baseinfo.Gend,
  13193. Naty: res.Output.Baseinfo.Naty,
  13194. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13195. PsnName: res.Output.Baseinfo.PsnName,
  13196. Idetinfo: idetinfoStr,
  13197. Insuinfo: infoStr,
  13198. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13199. InsuplcAdmdvs: insuplc_admdvs,
  13200. }
  13201. service.CreateHisPsn(psn)
  13202. for _, item := range rf {
  13203. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13204. insutypes = append(insutypes, item)
  13205. }
  13206. }
  13207. if len(insutypes) == 1 {
  13208. insutype = insutypes[0].Insutype
  13209. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13210. } else {
  13211. for _, i := range insutypes {
  13212. if i.Insutype == "390" {
  13213. is390 = 1
  13214. }
  13215. if i.Insutype == "310" {
  13216. is310 = 1
  13217. }
  13218. }
  13219. }
  13220. if is390 == 1 {
  13221. insutype = "390"
  13222. }
  13223. if is310 == 1 {
  13224. insutype = "310"
  13225. }
  13226. if len(insutypes) == 0 {
  13227. insutype = "310"
  13228. }
  13229. c.ServeSuccessJSON(map[string]interface{}{
  13230. "patient": patient,
  13231. "number": res.Output.Baseinfo.Certno,
  13232. "insutype": insutype,
  13233. })
  13234. }
  13235. } else {
  13236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13237. return
  13238. }
  13239. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13240. var res ResultTwo
  13241. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13242. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13243. "&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)
  13244. resp, requestErr := http.Get(api)
  13245. if requestErr != nil {
  13246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13247. return
  13248. }
  13249. body, ioErr := ioutil.ReadAll(resp.Body)
  13250. if ioErr != nil {
  13251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13253. return
  13254. }
  13255. var respJSON map[string]interface{}
  13256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13259. return
  13260. }
  13261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13262. result, _ := json.Marshal(respJSON)
  13263. fmt.Println("log")
  13264. fmt.Println(string(result))
  13265. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13266. utils.ErrorLog("解析失败:%v", err)
  13267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13268. return
  13269. }
  13270. if res.Infcode == 0 {
  13271. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13272. if err == gorm.ErrRecordNotFound {
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13274. return
  13275. } else if err != nil {
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13277. return
  13278. } else {
  13279. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13280. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13281. infoStr := string(Iinfos)
  13282. idetinfoStr := string(Idetinfos)
  13283. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13284. psn := &models.HisPsn{
  13285. PsnNo: res.Output.Baseinfo.PsnNo,
  13286. PatientId: patient.ID,
  13287. Certno: res.Output.Baseinfo.Certno,
  13288. Brdy: b,
  13289. Age: float64(age),
  13290. Gend: res.Output.Baseinfo.Gend,
  13291. Naty: res.Output.Baseinfo.Naty,
  13292. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13293. PsnName: res.Output.Baseinfo.PsnName,
  13294. Idetinfo: idetinfoStr,
  13295. Insuinfo: infoStr,
  13296. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13297. }
  13298. service.CreateHisPsn(psn)
  13299. var rf []*ResultFive
  13300. json.Unmarshal([]byte(infoStr), &rf)
  13301. var insutypes []*ResultFive
  13302. var insutype string
  13303. var is390 int = 0
  13304. var is310 int = 0
  13305. for _, item := range rf {
  13306. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13307. insutypes = append(insutypes, item)
  13308. }
  13309. }
  13310. if len(insutypes) == 1 {
  13311. insutype = insutypes[0].Insutype
  13312. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13313. } else {
  13314. for _, i := range insutypes {
  13315. if i.Insutype == "390" {
  13316. is390 = 1
  13317. }
  13318. if i.Insutype == "310" {
  13319. is310 = 1
  13320. }
  13321. }
  13322. }
  13323. if is390 == 1 {
  13324. insutype = "390"
  13325. }
  13326. if is310 == 1 {
  13327. insutype = "310"
  13328. }
  13329. if len(insutypes) == 0 {
  13330. insutype = "310"
  13331. }
  13332. c.ServeSuccessJSON(map[string]interface{}{
  13333. "patient": patient,
  13334. "number": res.Output.Baseinfo.Certno,
  13335. "insutype": insutype,
  13336. })
  13337. }
  13338. } else {
  13339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13340. return
  13341. }
  13342. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13343. var api string
  13344. if miConfig.MdtrtareaAdmvs == "320921" {
  13345. 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 +
  13346. "&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
  13347. fmt.Println(api)
  13348. } else {
  13349. 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 +
  13350. "&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)
  13351. }
  13352. resp, requestErr := http.Get(api)
  13353. if requestErr != nil {
  13354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13355. return
  13356. }
  13357. body, ioErr := ioutil.ReadAll(resp.Body)
  13358. if ioErr != nil {
  13359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13361. return
  13362. }
  13363. var respJSON map[string]interface{}
  13364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13367. return
  13368. }
  13369. var status string
  13370. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13371. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13372. //console.log()
  13373. fmt.Println("type===")
  13374. fmt.Println(card_type)
  13375. var token string
  13376. var res ResultTwo //1101结果
  13377. var res10265 ResultTwo10265 //1101结果
  13378. var card_info string //卡信息
  13379. var busi_card_info string
  13380. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13381. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13382. if status == "0" { //读卡成功
  13383. if card_type == "1" {
  13384. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13385. result, _ := json.Marshal(respJSON)
  13386. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13387. utils.ErrorLog("解析失败:%v", err)
  13388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13389. return
  13390. }
  13391. res.ErrMsg = res10265.ErrMsg
  13392. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13393. res.Infcode = infocode
  13394. res.Output = res10265.Output
  13395. res.InfRefmsgid = res10265.InfRefmsgid
  13396. } else {
  13397. //var card_info string //卡信息
  13398. //var busi_card_info string
  13399. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13400. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13401. //fmt.Println(card_info)
  13402. //fmt.Println(busi_card_info)
  13403. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13404. result, _ := json.Marshal(respJSON)
  13405. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13406. utils.ErrorLog("解析失败:%v", err)
  13407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13408. return
  13409. }
  13410. res.ErrMsg = res10265.ErrMsg
  13411. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13412. res.Infcode = infocode
  13413. res.Output = res10265.Output
  13414. res.InfRefmsgid = res10265.InfRefmsgid
  13415. }
  13416. if res.Infcode == 0 {
  13417. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13418. if err == gorm.ErrRecordNotFound {
  13419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13420. return
  13421. } else if err != nil {
  13422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13423. return
  13424. } else {
  13425. if card_type == "1" {
  13426. bas := strings.Split(card_info, "|")
  13427. basNumber := bas[2]
  13428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13430. infoStr := string(Iinfos)
  13431. idetinfoStr := string(Idetinfos)
  13432. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13433. psn := &models.HisPsn{
  13434. PsnNo: res.Output.Baseinfo.PsnNo,
  13435. PatientId: patient.ID,
  13436. Certno: res.Output.Baseinfo.Certno,
  13437. Brdy: b,
  13438. Age: float64(age),
  13439. Gend: res.Output.Baseinfo.Gend,
  13440. Naty: res.Output.Baseinfo.Naty,
  13441. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13442. PsnName: res.Output.Baseinfo.PsnName,
  13443. Idetinfo: idetinfoStr,
  13444. Insuinfo: infoStr,
  13445. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13446. CardInfo: card_info,
  13447. VerifyNumber: busi_card_info,
  13448. }
  13449. service.CreateHisPsn(psn)
  13450. var rf []*ResultFive
  13451. json.Unmarshal([]byte(infoStr), &rf)
  13452. var insutypes []*ResultFive
  13453. var insutype string
  13454. var is390 int = 0
  13455. var is310 int = 0
  13456. for _, item := range rf {
  13457. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13458. insutypes = append(insutypes, item)
  13459. }
  13460. }
  13461. if len(insutypes) == 1 {
  13462. insutype = insutypes[0].Insutype
  13463. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13464. } else {
  13465. for _, i := range insutypes {
  13466. if i.Insutype == "390" {
  13467. is390 = 1
  13468. }
  13469. if i.Insutype == "310" {
  13470. is310 = 1
  13471. }
  13472. }
  13473. }
  13474. if is390 == 1 {
  13475. insutype = "390"
  13476. }
  13477. if is310 == 1 {
  13478. insutype = "310"
  13479. }
  13480. if len(insutypes) == 0 {
  13481. insutype = "310"
  13482. }
  13483. c.ServeSuccessJSON(map[string]interface{}{
  13484. "patient": patient,
  13485. "number": basNumber,
  13486. "insutype": insutype,
  13487. })
  13488. } else {
  13489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13491. infoStr := string(Iinfos)
  13492. idetinfoStr := string(Idetinfos)
  13493. psn := &models.HisPsn{
  13494. PsnNo: res.Output.Baseinfo.PsnNo,
  13495. PatientId: patient.ID,
  13496. Certno: res.Output.Baseinfo.Certno,
  13497. Gend: res.Output.Baseinfo.Gend,
  13498. Naty: res.Output.Baseinfo.Naty,
  13499. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13500. PsnName: res.Output.Baseinfo.PsnName,
  13501. Idetinfo: idetinfoStr,
  13502. Insuinfo: infoStr,
  13503. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13504. CardInfo: card_info,
  13505. VerifyNumber: token,
  13506. }
  13507. service.CreateHisPsn(psn)
  13508. c.ServeSuccessJSON(map[string]interface{}{
  13509. "patient": patient,
  13510. "number": token,
  13511. })
  13512. }
  13513. }
  13514. } else {
  13515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13516. return
  13517. }
  13518. } else { //读卡失败
  13519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13520. return
  13521. }
  13522. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13523. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13524. cardnum = DeleteExtraSpaceTwo(cardnum)
  13525. cardCode = DeleteExtraSpaceTwo(cardCode)
  13526. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13527. name = DeleteExtraSpaceTwo(name)
  13528. errmsg = DeleteExtraSpaceTwo(errmsg)
  13529. cardnum = Remove0000(cardnum)
  13530. cardCode = Remove0000(cardCode)
  13531. id_card_no = Remove0000(id_card_no)
  13532. name = Remove0000(name)
  13533. errmsg = Remove0000(errmsg)
  13534. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13535. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13536. //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)
  13537. //fmt.Println(result2)
  13538. //fmt.Println(requestLog2)
  13539. //fmt.Println(errMsgLog2)
  13540. 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)
  13541. saveLog(result, requestLog, "1101", "获取人员信息")
  13542. fmt.Println(errMsgLog)
  13543. if len(errMsgLog) > 0 {
  13544. } else {
  13545. var dat map[string]interface{}
  13546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13547. fmt.Println(dat)
  13548. } else {
  13549. fmt.Println(err)
  13550. }
  13551. userJSONBytes, _ := json.Marshal(dat)
  13552. var res ResultTwo
  13553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13554. utils.ErrorLog("解析失败:%v", err)
  13555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13556. return
  13557. }
  13558. res.ErrMsg = errMsgLog
  13559. if res.Infcode == 0 {
  13560. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13561. if err == gorm.ErrRecordNotFound {
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13563. return
  13564. } else if err != nil {
  13565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13566. return
  13567. } else {
  13568. fmt.Println(res)
  13569. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13570. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13571. infoStr := string(Iinfos)
  13572. idetinfoStr := string(Idetinfos)
  13573. var rf []*ResultFive
  13574. json.Unmarshal([]byte(infoStr), &rf)
  13575. var insutypes []*ResultFive
  13576. var insutype string
  13577. var is390 int = 0
  13578. var is310 int = 0
  13579. for _, item := range rf {
  13580. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13581. insutypes = append(insutypes, item)
  13582. }
  13583. }
  13584. if len(insutypes) == 1 {
  13585. insutype = insutypes[0].Insutype
  13586. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13587. } else {
  13588. for _, i := range insutypes {
  13589. if i.Insutype == "390" {
  13590. is390 = 1
  13591. }
  13592. if i.Insutype == "310" {
  13593. is310 = 1
  13594. }
  13595. }
  13596. }
  13597. if is390 == 1 {
  13598. insutype = "390"
  13599. }
  13600. if is310 == 1 {
  13601. insutype = "310"
  13602. }
  13603. if len(insutypes) == 0 {
  13604. insutype = "390"
  13605. }
  13606. var insuplc_admdvs string
  13607. for _, item := range rf {
  13608. if item.Insutype == insutype {
  13609. insuplc_admdvs = item.InsuplcAdmdvs
  13610. }
  13611. }
  13612. psn := &models.HisPsn{
  13613. PsnNo: res.Output.Baseinfo.PsnNo,
  13614. PatientId: patient.ID,
  13615. Certno: res.Output.Baseinfo.Certno,
  13616. Gend: res.Output.Baseinfo.Gend,
  13617. Naty: res.Output.Baseinfo.Naty,
  13618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13619. PsnName: res.Output.Baseinfo.PsnName,
  13620. Idetinfo: idetinfoStr,
  13621. Insuinfo: infoStr,
  13622. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13623. CardInfo: basStr,
  13624. VerifyNumber: "",
  13625. InsuplcAdmdvs: insuplc_admdvs,
  13626. }
  13627. service.CreateHisPsn(psn)
  13628. c.ServeSuccessJSON(map[string]interface{}{
  13629. "patient": patient,
  13630. "number": cardnum,
  13631. "insutype": insutype,
  13632. })
  13633. }
  13634. } else {
  13635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13636. return
  13637. }
  13638. }
  13639. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13640. fmt.Println(initFlag)
  13641. fmt.Println("initFlag")
  13642. if initFlag == 0 {
  13643. c.TestGetJiangXiBasBaseInit()
  13644. }
  13645. basStr := c.GetBasBaseInfo()
  13646. if len(basStr) == 0 {
  13647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13648. return
  13649. }
  13650. fmt.Println(basStr)
  13651. bas := strings.Split(basStr, "|")
  13652. basNumber := bas[1]
  13653. fmt.Println(basNumber)
  13654. card_sn := bas[3]
  13655. fmt.Println(card_sn)
  13656. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13657. 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)
  13658. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13659. var dat map[string]interface{}
  13660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13661. fmt.Println(dat)
  13662. } else {
  13663. fmt.Println(err)
  13664. }
  13665. userJSONBytes, _ := json.Marshal(dat)
  13666. var res ResultTwo
  13667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13668. utils.ErrorLog("解析失败:%v", err)
  13669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13670. return
  13671. }
  13672. if res.Infcode == 0 {
  13673. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13674. if err == gorm.ErrRecordNotFound {
  13675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13676. return
  13677. } else if err != nil {
  13678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13679. return
  13680. } else {
  13681. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13682. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13683. infoStr := string(Iinfos)
  13684. idetinfoStr := string(Idetinfos)
  13685. var rf []*ResultFive
  13686. json.Unmarshal([]byte(infoStr), &rf)
  13687. var insutypes []*ResultFive
  13688. var insutype string
  13689. var is390 int = 0
  13690. var is310 int = 0
  13691. var insuplc_admdvs string
  13692. for _, item := range rf {
  13693. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13694. insutypes = append(insutypes, item)
  13695. }
  13696. }
  13697. if len(insutypes) == 1 {
  13698. insutype = insutypes[0].Insutype
  13699. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13700. } else {
  13701. for _, i := range insutypes {
  13702. if i.Insutype == "390" {
  13703. is390 = 1
  13704. }
  13705. if i.Insutype == "310" {
  13706. is310 = 1
  13707. }
  13708. }
  13709. }
  13710. if is390 == 1 {
  13711. insutype = "390"
  13712. }
  13713. if is310 == 1 {
  13714. insutype = "310"
  13715. }
  13716. if len(insutypes) == 0 {
  13717. insutype = "310"
  13718. }
  13719. for _, item := range rf {
  13720. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13721. insuplc_admdvs = item.InsuplcAdmdvs
  13722. }
  13723. }
  13724. psn := &models.HisPsn{
  13725. PsnNo: res.Output.Baseinfo.PsnNo,
  13726. PatientId: patient.ID,
  13727. Certno: res.Output.Baseinfo.Certno,
  13728. Gend: res.Output.Baseinfo.Gend,
  13729. Naty: res.Output.Baseinfo.Naty,
  13730. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13731. PsnName: res.Output.Baseinfo.PsnName,
  13732. Idetinfo: idetinfoStr,
  13733. Insuinfo: infoStr,
  13734. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13735. CardInfo: basStr,
  13736. InsuplcAdmdvs: insuplc_admdvs,
  13737. VerifyNumber: "",
  13738. }
  13739. service.CreateHisPsn(psn)
  13740. c.ServeSuccessJSON(map[string]interface{}{
  13741. "patient": patient,
  13742. "number": basNumber,
  13743. "insutype": insutype,
  13744. })
  13745. }
  13746. } else {
  13747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13748. return
  13749. }
  13750. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13751. basStr := c.GetBasBaseInfo22222()
  13752. fmt.Println(basStr)
  13753. if len(basStr) == 0 {
  13754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13755. return
  13756. }
  13757. fmt.Println(basStr)
  13758. bas := strings.Split(basStr, "|")
  13759. basNumber := bas[2] //卡号
  13760. card_sn := bas[3] //
  13761. id_card_No := bas[1] //卡号
  13762. fmt.Println(basNumber)
  13763. fmt.Println(card_sn)
  13764. fmt.Println(id_card_No)
  13765. var patient service.Patients
  13766. if len(id_card_No) == 0 {
  13767. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13768. } else {
  13769. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13770. }
  13771. 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)
  13772. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13773. var dat map[string]interface{}
  13774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13775. fmt.Println(dat)
  13776. } else {
  13777. fmt.Println(err)
  13778. }
  13779. userJSONBytes, _ := json.Marshal(dat)
  13780. var res ResultTwo
  13781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13782. utils.ErrorLog("解析失败:%v", err)
  13783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13784. return
  13785. }
  13786. if res.Infcode == 0 {
  13787. var pateint2 service.Patients
  13788. var err error
  13789. if len(id_card_No) == 0 {
  13790. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13791. } else {
  13792. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13793. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13794. }
  13795. if err == gorm.ErrRecordNotFound {
  13796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13797. return
  13798. } else if err != nil {
  13799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13800. return
  13801. } else {
  13802. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13803. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13804. infoStr := string(Iinfos)
  13805. idetinfoStr := string(Idetinfos)
  13806. var rf []*ResultFive
  13807. json.Unmarshal([]byte(infoStr), &rf)
  13808. var insutypes []*ResultFive
  13809. var insutype string
  13810. var is390 int = 0
  13811. var is310 int = 0
  13812. var insuplc_admdvs string
  13813. for _, item := range rf {
  13814. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13815. insutypes = append(insutypes, item)
  13816. }
  13817. }
  13818. if len(insutypes) == 1 {
  13819. insutype = insutypes[0].Insutype
  13820. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13821. } else {
  13822. for _, i := range insutypes {
  13823. if i.Insutype == "390" {
  13824. is390 = 1
  13825. }
  13826. if i.Insutype == "310" {
  13827. is310 = 1
  13828. }
  13829. }
  13830. }
  13831. if is390 == 1 {
  13832. insutype = "390"
  13833. }
  13834. if is310 == 1 {
  13835. insutype = "310"
  13836. }
  13837. if len(insutypes) == 0 {
  13838. insutype = "310"
  13839. }
  13840. for _, item := range rf {
  13841. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13842. insuplc_admdvs = item.InsuplcAdmdvs
  13843. }
  13844. }
  13845. psn := &models.HisPsn{
  13846. PsnNo: res.Output.Baseinfo.PsnNo,
  13847. PatientId: pateint2.ID,
  13848. Certno: res.Output.Baseinfo.Certno,
  13849. Gend: res.Output.Baseinfo.Gend,
  13850. Naty: res.Output.Baseinfo.Naty,
  13851. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13852. PsnName: res.Output.Baseinfo.PsnName,
  13853. Idetinfo: idetinfoStr,
  13854. Insuinfo: infoStr,
  13855. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13856. CardInfo: basStr,
  13857. InsuplcAdmdvs: insuplc_admdvs,
  13858. VerifyNumber: "",
  13859. }
  13860. service.CreateHisPsn(psn)
  13861. c.ServeSuccessJSON(map[string]interface{}{
  13862. "patient": patient,
  13863. "number": basNumber,
  13864. "insutype": insutype,
  13865. })
  13866. }
  13867. } else {
  13868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13869. return
  13870. }
  13871. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13872. basStr := c.GetBasBaseInfo22222()
  13873. fmt.Println(basStr)
  13874. if len(basStr) == 0 {
  13875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13876. return
  13877. }
  13878. fmt.Println(basStr)
  13879. bas := strings.Split(basStr, "|")
  13880. basNumber := bas[2] //卡号
  13881. card_sn := bas[3] //
  13882. id_card_No := bas[1] //卡号
  13883. fmt.Println(basNumber)
  13884. fmt.Println(card_sn)
  13885. fmt.Println(id_card_No)
  13886. var patient service.Patients
  13887. if len(id_card_No) == 0 {
  13888. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13889. } else {
  13890. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13891. }
  13892. 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)
  13893. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13894. var dat map[string]interface{}
  13895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13896. fmt.Println(dat)
  13897. } else {
  13898. fmt.Println(err)
  13899. }
  13900. userJSONBytes, _ := json.Marshal(dat)
  13901. var res ResultTwo
  13902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13903. utils.ErrorLog("解析失败:%v", err)
  13904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13905. return
  13906. }
  13907. if res.Infcode == 0 {
  13908. var pateint2 service.Patients
  13909. var err error
  13910. if len(id_card_No) == 0 {
  13911. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13912. } else {
  13913. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13914. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13915. }
  13916. if err == gorm.ErrRecordNotFound {
  13917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13918. return
  13919. } else if err != nil {
  13920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13921. return
  13922. } else {
  13923. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13924. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13925. infoStr := string(Iinfos)
  13926. idetinfoStr := string(Idetinfos)
  13927. var rf []*ResultFive
  13928. json.Unmarshal([]byte(infoStr), &rf)
  13929. var insutypes []*ResultFive
  13930. var insutype string
  13931. var is390 int = 0
  13932. var is310 int = 0
  13933. var insuplc_admdvs string
  13934. for _, item := range rf {
  13935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13936. insutypes = append(insutypes, item)
  13937. }
  13938. }
  13939. if len(insutypes) == 1 {
  13940. insutype = insutypes[0].Insutype
  13941. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13942. } else {
  13943. for _, i := range insutypes {
  13944. if i.Insutype == "390" {
  13945. is390 = 1
  13946. }
  13947. if i.Insutype == "310" {
  13948. is310 = 1
  13949. }
  13950. }
  13951. }
  13952. if is390 == 1 {
  13953. insutype = "390"
  13954. }
  13955. if is310 == 1 {
  13956. insutype = "310"
  13957. }
  13958. if len(insutypes) == 0 {
  13959. insutype = "310"
  13960. }
  13961. for _, item := range rf {
  13962. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13963. insuplc_admdvs = item.InsuplcAdmdvs
  13964. }
  13965. }
  13966. psn := &models.HisPsn{
  13967. PsnNo: res.Output.Baseinfo.PsnNo,
  13968. PatientId: pateint2.ID,
  13969. Certno: res.Output.Baseinfo.Certno,
  13970. Gend: res.Output.Baseinfo.Gend,
  13971. Naty: res.Output.Baseinfo.Naty,
  13972. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13973. PsnName: res.Output.Baseinfo.PsnName,
  13974. Idetinfo: idetinfoStr,
  13975. Insuinfo: infoStr,
  13976. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13977. CardInfo: basStr,
  13978. InsuplcAdmdvs: insuplc_admdvs,
  13979. VerifyNumber: "",
  13980. }
  13981. service.CreateHisPsn(psn)
  13982. c.ServeSuccessJSON(map[string]interface{}{
  13983. "patient": patient,
  13984. "number": basNumber,
  13985. "insutype": insutype,
  13986. })
  13987. }
  13988. } else {
  13989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13990. return
  13991. }
  13992. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13993. fmt.Println(initFlag)
  13994. fmt.Println("initFlag")
  13995. if initFlag == 0 {
  13996. c.TestGetHnBasBaseInit()
  13997. }
  13998. basStr := c.GetBasBaseInfo()
  13999. if len(basStr) == 0 {
  14000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14001. return
  14002. }
  14003. fmt.Println(basStr)
  14004. bas := strings.Split(basStr, "|")
  14005. basNumber := bas[1]
  14006. fmt.Println(basNumber)
  14007. card_sn := bas[3]
  14008. card_no := bas[2]
  14009. fmt.Println(card_sn)
  14010. name := bas[4]
  14011. name = ConvertToString(name, "gbk", "utf-8")
  14012. 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)
  14013. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14014. var dat map[string]interface{}
  14015. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14016. fmt.Println(dat)
  14017. } else {
  14018. fmt.Println(err)
  14019. }
  14020. userJSONBytes, _ := json.Marshal(dat)
  14021. var res ResultTwo
  14022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14023. utils.ErrorLog("解析失败:%v", err)
  14024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14025. return
  14026. }
  14027. if res.Infcode == 0 {
  14028. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14029. if err == gorm.ErrRecordNotFound {
  14030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14031. return
  14032. } else if err != nil {
  14033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14034. return
  14035. } else {
  14036. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14037. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14038. infoStr := string(Iinfos)
  14039. idetinfoStr := string(Idetinfos)
  14040. psn := &models.HisPsn{
  14041. PsnNo: res.Output.Baseinfo.PsnNo,
  14042. PatientId: patient.ID,
  14043. Certno: res.Output.Baseinfo.Certno,
  14044. Gend: res.Output.Baseinfo.Gend,
  14045. Naty: res.Output.Baseinfo.Naty,
  14046. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14047. PsnName: res.Output.Baseinfo.PsnName,
  14048. Idetinfo: idetinfoStr,
  14049. Insuinfo: infoStr,
  14050. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14051. CardInfo: basStr,
  14052. VerifyNumber: "",
  14053. }
  14054. service.CreateHisPsn(psn)
  14055. var rf []*ResultFive
  14056. json.Unmarshal([]byte(infoStr), &rf)
  14057. var insutypes []*ResultFive
  14058. var insutype string
  14059. var is390 int = 0
  14060. var is310 int = 0
  14061. for _, item := range rf {
  14062. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14063. insutypes = append(insutypes, item)
  14064. }
  14065. }
  14066. if len(insutypes) == 1 {
  14067. insutype = insutypes[0].Insutype
  14068. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14069. } else {
  14070. for _, i := range insutypes {
  14071. if i.Insutype == "390" {
  14072. is390 = 1
  14073. }
  14074. if i.Insutype == "310" {
  14075. is310 = 1
  14076. }
  14077. }
  14078. }
  14079. if is390 == 1 {
  14080. insutype = "390"
  14081. }
  14082. if is310 == 1 {
  14083. insutype = "310"
  14084. }
  14085. if len(insutypes) == 0 {
  14086. insutype = "310"
  14087. }
  14088. c.ServeSuccessJSON(map[string]interface{}{
  14089. "patient": patient,
  14090. "number": basNumber,
  14091. "insutype": insutype,
  14092. })
  14093. }
  14094. } else {
  14095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14096. return
  14097. }
  14098. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14099. var api string
  14100. 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 +
  14101. "&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
  14102. fmt.Println(api)
  14103. resp, requestErr := http.Get(api)
  14104. if requestErr != nil {
  14105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14106. return
  14107. }
  14108. body, ioErr := ioutil.ReadAll(resp.Body)
  14109. if ioErr != nil {
  14110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14112. return
  14113. }
  14114. var respJSON map[string]interface{}
  14115. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14118. return
  14119. }
  14120. var res ResultTwo //1101结果
  14121. var res10265 ResultTwo10265 //1101结果
  14122. var card_info string //卡信息
  14123. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14124. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14125. result, _ := json.Marshal(respJSON)
  14126. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14127. utils.ErrorLog("解析失败:%v", err)
  14128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14129. return
  14130. }
  14131. res.ErrMsg = res10265.ErrMsg
  14132. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14133. res.Infcode = infocode
  14134. res.Output = res10265.Output
  14135. res.InfRefmsgid = res10265.InfRefmsgid
  14136. if res.Infcode == 0 {
  14137. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14138. if err == gorm.ErrRecordNotFound {
  14139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14140. return
  14141. } else if err != nil {
  14142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14143. return
  14144. } else {
  14145. bas := strings.Split(card_info, "|")
  14146. basNumber := bas[2]
  14147. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14148. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14149. infoStr := string(Iinfos)
  14150. idetinfoStr := string(Idetinfos)
  14151. psn := &models.HisPsn{
  14152. PsnNo: res.Output.Baseinfo.PsnNo,
  14153. PatientId: patient.ID,
  14154. Certno: res.Output.Baseinfo.Certno,
  14155. Gend: res.Output.Baseinfo.Gend,
  14156. Naty: res.Output.Baseinfo.Naty,
  14157. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14158. PsnName: res.Output.Baseinfo.PsnName,
  14159. Idetinfo: idetinfoStr,
  14160. Insuinfo: infoStr,
  14161. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14162. CardInfo: card_info,
  14163. VerifyNumber: token,
  14164. }
  14165. service.CreateHisPsn(psn)
  14166. var rf []*ResultFive
  14167. json.Unmarshal([]byte(infoStr), &rf)
  14168. var insutypes []*ResultFive
  14169. var insutype string
  14170. var is390 int = 0
  14171. var is310 int = 0
  14172. for _, item := range rf {
  14173. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14174. insutypes = append(insutypes, item)
  14175. }
  14176. }
  14177. if len(insutypes) == 1 {
  14178. insutype = insutypes[0].Insutype
  14179. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14180. } else {
  14181. for _, i := range insutypes {
  14182. if i.Insutype == "390" {
  14183. is390 = 1
  14184. }
  14185. if i.Insutype == "310" {
  14186. is310 = 1
  14187. }
  14188. }
  14189. }
  14190. if is390 == 1 {
  14191. insutype = "390"
  14192. }
  14193. if is310 == 1 {
  14194. insutype = "310"
  14195. }
  14196. if len(insutypes) == 0 {
  14197. insutype = "310"
  14198. }
  14199. c.ServeSuccessJSON(map[string]interface{}{
  14200. "patient": patient,
  14201. "number": basNumber,
  14202. "insutype": insutype,
  14203. })
  14204. }
  14205. } else {
  14206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14207. return
  14208. }
  14209. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14210. res := c.GetoleInfo()
  14211. if res.Infcode == 0 {
  14212. var result string
  14213. if res.Output.MdtrtCertType == "01" {
  14214. 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)
  14215. } else if res.Output.MdtrtCertType == "02" {
  14216. 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)
  14217. } else if res.Output.MdtrtCertType == "03" {
  14218. 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)
  14219. }
  14220. var dat map[string]interface{}
  14221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14222. fmt.Println(dat)
  14223. } else {
  14224. fmt.Println(err)
  14225. }
  14226. userJSONBytes, _ := json.Marshal(dat)
  14227. var res2 ResultTwo
  14228. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14229. utils.ErrorLog("解析失败:%v", err)
  14230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14231. return
  14232. }
  14233. if res2.Infcode == 0 {
  14234. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14235. if err == gorm.ErrRecordNotFound {
  14236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14237. return
  14238. } else if err != nil {
  14239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14240. return
  14241. } else {
  14242. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14243. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14244. infoStr := string(Iinfos)
  14245. idetinfoStr := string(Idetinfos)
  14246. var rf []*ResultFive
  14247. json.Unmarshal([]byte(infoStr), &rf)
  14248. var insutypes []*ResultFive
  14249. var insutype string
  14250. var is390 int = 0
  14251. var is310 int = 0
  14252. //var insuplc_admdvs string
  14253. for _, item := range rf {
  14254. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14255. insutypes = append(insutypes, item)
  14256. }
  14257. }
  14258. if len(insutypes) == 1 {
  14259. insutype = insutypes[0].Insutype
  14260. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14261. } else {
  14262. for _, i := range insutypes {
  14263. if i.Insutype == "390" {
  14264. is390 = 1
  14265. }
  14266. if i.Insutype == "310" {
  14267. is310 = 1
  14268. }
  14269. }
  14270. }
  14271. if is390 == 1 {
  14272. insutype = "390"
  14273. }
  14274. if is310 == 1 {
  14275. insutype = "310"
  14276. }
  14277. if len(insutypes) == 0 {
  14278. insutype = "310"
  14279. }
  14280. psn := &models.HisPsn{
  14281. PsnNo: res2.Output.Baseinfo.PsnNo,
  14282. PatientId: patient.ID,
  14283. Certno: res2.Output.Baseinfo.Certno,
  14284. Gend: res2.Output.Baseinfo.Gend,
  14285. Naty: res2.Output.Baseinfo.Naty,
  14286. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14287. PsnName: res2.Output.Baseinfo.PsnName,
  14288. Idetinfo: idetinfoStr,
  14289. Insuinfo: infoStr,
  14290. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14291. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14292. VerifyNumber: res.Output.EcToken,
  14293. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14294. }
  14295. if res.Output.MdtrtCertType == "01" {
  14296. psn.VerifyNumber = res.Output.EcToken
  14297. //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)
  14298. } else if res.Output.MdtrtCertType == "02" {
  14299. psn.VerifyNumber = res.Output.MdtrtCertNo
  14300. //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)
  14301. } else if res.Output.MdtrtCertType == "03" {
  14302. psn.VerifyNumber = res.Output.MdtrtCertNo
  14303. //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)
  14304. }
  14305. var balc float64
  14306. for _, item := range rf {
  14307. if item.Insutype == insutype {
  14308. balc = item.Balc
  14309. }
  14310. }
  14311. service.CreateHisPsn(psn)
  14312. c.ServeSuccessJSON(map[string]interface{}{
  14313. "patient": patient,
  14314. "number": res.Output.CardNo,
  14315. "insutype": insutype,
  14316. "blac": balc,
  14317. "desc": idetinfoStr,
  14318. })
  14319. }
  14320. } else {
  14321. c.ServeSuccessJSON(map[string]interface{}{
  14322. "failed_code": -10,
  14323. "msg": res2.ErrMsg,
  14324. })
  14325. }
  14326. } else {
  14327. c.ServeSuccessJSON(map[string]interface{}{
  14328. "failed_code": -10,
  14329. "msg": res.ErrMsg,
  14330. })
  14331. }
  14332. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14333. var api string
  14334. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14335. "&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
  14336. fmt.Println(api)
  14337. resp, requestErr := http.Get(api)
  14338. if requestErr != nil {
  14339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14340. return
  14341. }
  14342. body, ioErr := ioutil.ReadAll(resp.Body)
  14343. if ioErr != nil {
  14344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14346. return
  14347. }
  14348. var respJSON map[string]interface{}
  14349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14352. return
  14353. }
  14354. var status string
  14355. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14356. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14357. //console.log()
  14358. fmt.Println("type===")
  14359. fmt.Println(card_type)
  14360. var token string
  14361. var res ResultTwo //1101结果
  14362. //var res10265 ResultTwoesultTwo10265 //1101结果
  14363. var card_info string //卡信息
  14364. var busi_card_info string
  14365. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14366. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14367. if status == "0" { //读卡成功
  14368. if card_type == "1" {
  14369. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14370. result, _ := json.Marshal(respJSON)
  14371. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14372. utils.ErrorLog("解析失败:%v", err)
  14373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14374. return
  14375. }
  14376. } else {
  14377. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14378. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14379. result, _ := json.Marshal(respJSON)
  14380. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14381. utils.ErrorLog("解析失败:%v", err)
  14382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14383. return
  14384. }
  14385. }
  14386. if res.Infcode == 0 {
  14387. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14388. if err == gorm.ErrRecordNotFound {
  14389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14390. return
  14391. } else if err != nil {
  14392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14393. return
  14394. } else {
  14395. if card_type == "1" {
  14396. bas := strings.Split(card_info, "|")
  14397. basNumber := bas[2]
  14398. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14399. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14400. infoStr := string(Iinfos)
  14401. idetinfoStr := string(Idetinfos)
  14402. psn := &models.HisPsn{
  14403. PsnNo: res.Output.Baseinfo.PsnNo,
  14404. PatientId: patient.ID,
  14405. Certno: res.Output.Baseinfo.Certno,
  14406. Gend: res.Output.Baseinfo.Gend,
  14407. Naty: res.Output.Baseinfo.Naty,
  14408. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14409. PsnName: res.Output.Baseinfo.PsnName,
  14410. Idetinfo: idetinfoStr,
  14411. Insuinfo: infoStr,
  14412. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14413. CardInfo: card_info,
  14414. VerifyNumber: busi_card_info,
  14415. }
  14416. service.CreateHisPsn(psn)
  14417. var rf []*ResultFive
  14418. json.Unmarshal([]byte(infoStr), &rf)
  14419. var insutypes []*ResultFive
  14420. var insutype string
  14421. var is390 int = 0
  14422. var is310 int = 0
  14423. for _, item := range rf {
  14424. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14425. insutypes = append(insutypes, item)
  14426. }
  14427. }
  14428. if len(insutypes) == 1 {
  14429. insutype = insutypes[0].Insutype
  14430. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14431. } else {
  14432. for _, i := range insutypes {
  14433. if i.Insutype == "390" {
  14434. is390 = 1
  14435. }
  14436. if i.Insutype == "310" {
  14437. is310 = 1
  14438. }
  14439. }
  14440. }
  14441. if is390 == 1 {
  14442. insutype = "390"
  14443. }
  14444. if is310 == 1 {
  14445. insutype = "310"
  14446. }
  14447. if len(insutypes) == 0 {
  14448. insutype = "310"
  14449. }
  14450. c.ServeSuccessJSON(map[string]interface{}{
  14451. "patient": patient,
  14452. "number": basNumber,
  14453. "insutype": insutype,
  14454. })
  14455. } else {
  14456. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14457. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14458. infoStr := string(Iinfos)
  14459. idetinfoStr := string(Idetinfos)
  14460. psn := &models.HisPsn{
  14461. PsnNo: res.Output.Baseinfo.PsnNo,
  14462. PatientId: patient.ID,
  14463. Certno: res.Output.Baseinfo.Certno,
  14464. Gend: res.Output.Baseinfo.Gend,
  14465. Naty: res.Output.Baseinfo.Naty,
  14466. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14467. PsnName: res.Output.Baseinfo.PsnName,
  14468. Idetinfo: idetinfoStr,
  14469. Insuinfo: infoStr,
  14470. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14471. CardInfo: card_info,
  14472. VerifyNumber: token,
  14473. }
  14474. service.CreateHisPsn(psn)
  14475. c.ServeSuccessJSON(map[string]interface{}{
  14476. "patient": patient,
  14477. "number": token,
  14478. })
  14479. }
  14480. }
  14481. } else {
  14482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14483. return
  14484. }
  14485. } else { //读卡失败
  14486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14487. return
  14488. }
  14489. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14490. var api string
  14491. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14492. "&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
  14493. fmt.Println(api)
  14494. resp, requestErr := http.Get(api)
  14495. if requestErr != nil {
  14496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14497. return
  14498. }
  14499. body, ioErr := ioutil.ReadAll(resp.Body)
  14500. if ioErr != nil {
  14501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14503. return
  14504. }
  14505. var respJSON map[string]interface{}
  14506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14509. return
  14510. }
  14511. var status string
  14512. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14513. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14514. //console.log()
  14515. fmt.Println("type===")
  14516. fmt.Println(card_type)
  14517. var token string
  14518. var res ResultTwo //1101结果
  14519. //var res10265 ResultTwoesultTwo10265 //1101结果
  14520. var card_info string //卡信息
  14521. //var busi_card_info string
  14522. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14523. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14524. if status == "0" { //读卡成功
  14525. if card_type == "1" {
  14526. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14527. result, _ := json.Marshal(respJSON)
  14528. fmt.Println(result)
  14529. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14530. utils.ErrorLog("解析失败:%v", err)
  14531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14532. return
  14533. }
  14534. fmt.Println(res)
  14535. } else {
  14536. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14537. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14538. result, _ := json.Marshal(respJSON)
  14539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14540. utils.ErrorLog("解析失败:%v", err)
  14541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14542. return
  14543. }
  14544. }
  14545. if res.Infcode == 0 {
  14546. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14547. if err == gorm.ErrRecordNotFound {
  14548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14549. return
  14550. } else if err != nil {
  14551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14552. return
  14553. } else {
  14554. if card_type == "1" {
  14555. bas := strings.Split(card_info, "|")
  14556. basNumber := bas[2]
  14557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14558. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14559. infoStr := string(Iinfos)
  14560. idetinfoStr := string(Idetinfos)
  14561. psn := &models.HisPsn{
  14562. PsnNo: res.Output.Baseinfo.PsnNo,
  14563. PatientId: patient.ID,
  14564. Certno: res.Output.Baseinfo.Certno,
  14565. Gend: res.Output.Baseinfo.Gend,
  14566. Naty: res.Output.Baseinfo.Naty,
  14567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14568. PsnName: res.Output.Baseinfo.PsnName,
  14569. Idetinfo: idetinfoStr,
  14570. Insuinfo: infoStr,
  14571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14572. CardInfo: card_info,
  14573. //VerifyNumber: busi_card_info,
  14574. }
  14575. service.CreateHisPsn(psn)
  14576. var rf []*ResultFive
  14577. json.Unmarshal([]byte(infoStr), &rf)
  14578. var insutypes []*ResultFive
  14579. var insutype string
  14580. var is390 int = 0
  14581. var is310 int = 0
  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. c.ServeSuccessJSON(map[string]interface{}{
  14610. "patient": patient,
  14611. "number": basNumber,
  14612. "insutype": insutype,
  14613. })
  14614. } else {
  14615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14617. infoStr := string(Iinfos)
  14618. idetinfoStr := string(Idetinfos)
  14619. psn := &models.HisPsn{
  14620. PsnNo: res.Output.Baseinfo.PsnNo,
  14621. PatientId: patient.ID,
  14622. Certno: res.Output.Baseinfo.Certno,
  14623. Gend: res.Output.Baseinfo.Gend,
  14624. Naty: res.Output.Baseinfo.Naty,
  14625. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14626. PsnName: res.Output.Baseinfo.PsnName,
  14627. Idetinfo: idetinfoStr,
  14628. Insuinfo: infoStr,
  14629. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14630. CardInfo: card_info,
  14631. VerifyNumber: token,
  14632. }
  14633. service.CreateHisPsn(psn)
  14634. c.ServeSuccessJSON(map[string]interface{}{
  14635. "patient": patient,
  14636. "number": token,
  14637. })
  14638. }
  14639. }
  14640. } else {
  14641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14642. return
  14643. }
  14644. } else { //读卡失败
  14645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14646. return
  14647. }
  14648. } else {
  14649. if initFlag == 0 {
  14650. c.TestGetBasBaseInit()
  14651. }
  14652. basStr := c.GetBasBaseInfo()
  14653. if len(basStr) == 0 {
  14654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14655. return
  14656. }
  14657. fmt.Println(basStr)
  14658. bas := strings.Split(basStr, "|")
  14659. basNumber := bas[1]
  14660. fmt.Println(basNumber)
  14661. card_sn := bas[3]
  14662. fmt.Println(card_sn)
  14663. cardNumber := bas[2]
  14664. fmt.Println(cardNumber)
  14665. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14666. var result string
  14667. if bas[0][:2] == "44" {
  14668. 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)
  14669. } else {
  14670. 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)
  14671. }
  14672. var dat map[string]interface{}
  14673. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14674. fmt.Println(dat)
  14675. } else {
  14676. fmt.Println(err)
  14677. }
  14678. userJSONBytes, _ := json.Marshal(dat)
  14679. var res ResultTwo
  14680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14681. utils.ErrorLog("解析失败:%v", err)
  14682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14683. return
  14684. }
  14685. if res.Infcode == 0 {
  14686. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14687. if err == gorm.ErrRecordNotFound {
  14688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14689. return
  14690. } else if err != nil {
  14691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14692. return
  14693. } else {
  14694. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14695. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14696. infoStr := string(Iinfos)
  14697. idetinfoStr := string(Idetinfos)
  14698. var rf []*ResultFive
  14699. json.Unmarshal([]byte(infoStr), &rf)
  14700. var insutypes []*ResultFive
  14701. var insutype string
  14702. var is390 int = 0
  14703. var is310 int = 0
  14704. var insuplc_admdvs string
  14705. for _, item := range rf {
  14706. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14707. insutypes = append(insutypes, item)
  14708. }
  14709. }
  14710. if len(insutypes) == 1 {
  14711. insutype = insutypes[0].Insutype
  14712. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14713. } else {
  14714. for _, i := range insutypes {
  14715. if i.Insutype == "390" {
  14716. is390 = 1
  14717. }
  14718. if i.Insutype == "310" {
  14719. is310 = 1
  14720. }
  14721. }
  14722. }
  14723. if is390 == 1 {
  14724. insutype = "390"
  14725. }
  14726. if is310 == 1 {
  14727. insutype = "310"
  14728. }
  14729. if len(insutypes) == 0 {
  14730. insutype = "310"
  14731. }
  14732. for _, item := range rf {
  14733. if item.Insutype == insutype {
  14734. insuplc_admdvs = item.InsuplcAdmdvs
  14735. }
  14736. }
  14737. psn := &models.HisPsn{
  14738. PsnNo: res.Output.Baseinfo.PsnNo,
  14739. PatientId: patient.ID,
  14740. Certno: res.Output.Baseinfo.Certno,
  14741. Gend: res.Output.Baseinfo.Gend,
  14742. Naty: res.Output.Baseinfo.Naty,
  14743. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14744. PsnName: res.Output.Baseinfo.PsnName,
  14745. Idetinfo: idetinfoStr,
  14746. Insuinfo: infoStr,
  14747. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14748. CardInfo: basStr,
  14749. VerifyNumber: "",
  14750. InsuplcAdmdvs: insuplc_admdvs,
  14751. }
  14752. service.CreateHisPsn(psn)
  14753. c.ServeSuccessJSON(map[string]interface{}{
  14754. "patient": patient,
  14755. "number": basNumber,
  14756. })
  14757. }
  14758. } else {
  14759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14760. return
  14761. }
  14762. break
  14763. }
  14764. case 2:
  14765. if miConfig.MdtrtareaAdmvs == "430800" {
  14766. if initFlag == 0 {
  14767. c.TestGetHnBasBaseInit()
  14768. }
  14769. SFZStr := c.GetSFZBaseInfo()
  14770. if len(SFZStr) == 0 {
  14771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14772. return
  14773. }
  14774. fmt.Println(SFZStr)
  14775. id_card_str := strings.Split(SFZStr, "^")
  14776. card_no := id_card_str[0]
  14777. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14778. //name := id_card_str[1]
  14779. //name = ConvertToString(name, "gbk", "utf-8")
  14780. 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)
  14781. var dat map[string]interface{}
  14782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14783. fmt.Println(dat)
  14784. } else {
  14785. fmt.Println(err)
  14786. }
  14787. userJSONBytes, _ := json.Marshal(dat)
  14788. var res ResultTwo
  14789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14790. utils.ErrorLog("解析失败:%v", err)
  14791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14792. return
  14793. }
  14794. if res.Infcode == 0 {
  14795. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14796. if err == gorm.ErrRecordNotFound {
  14797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14798. return
  14799. } else if err != nil {
  14800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14801. return
  14802. } else {
  14803. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14804. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14805. infoStr := string(Iinfos)
  14806. idetinfoStr := string(Idetinfos)
  14807. var rf []*ResultFive
  14808. json.Unmarshal([]byte(infoStr), &rf)
  14809. var insutypes []*ResultFive
  14810. var insutype string
  14811. var is390 int = 0
  14812. var is310 int = 0
  14813. for _, item := range rf {
  14814. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14815. insutypes = append(insutypes, item)
  14816. }
  14817. }
  14818. if len(insutypes) == 1 {
  14819. insutype = insutypes[0].Insutype
  14820. } else {
  14821. for _, i := range insutypes {
  14822. if i.Insutype == "390" {
  14823. is390 = 1
  14824. }
  14825. if i.Insutype == "310" {
  14826. is310 = 1
  14827. }
  14828. }
  14829. }
  14830. if is390 == 1 {
  14831. insutype = "390"
  14832. }
  14833. if is310 == 1 {
  14834. insutype = "310"
  14835. }
  14836. if len(insutypes) == 0 {
  14837. insutype = "310"
  14838. }
  14839. var InsuplcAdmdvs string
  14840. for _, item := range rf {
  14841. if item.Insutype == insutype {
  14842. InsuplcAdmdvs = item.InsuplcAdmdvs
  14843. }
  14844. }
  14845. psn := &models.HisPsn{
  14846. PsnNo: res.Output.Baseinfo.PsnNo,
  14847. PatientId: patient.ID,
  14848. Certno: res.Output.Baseinfo.Certno,
  14849. Gend: res.Output.Baseinfo.Gend,
  14850. Naty: res.Output.Baseinfo.Naty,
  14851. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14852. PsnName: res.Output.Baseinfo.PsnName,
  14853. Idetinfo: idetinfoStr,
  14854. Insuinfo: infoStr,
  14855. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14856. CardInfo: SFZStr,
  14857. VerifyNumber: "",
  14858. InsuplcAdmdvs: InsuplcAdmdvs,
  14859. }
  14860. service.CreateHisPsn(psn)
  14861. c.ServeSuccessJSON(map[string]interface{}{
  14862. "patient": patient,
  14863. "number": card_no,
  14864. "insutype": insutype,
  14865. })
  14866. }
  14867. } else {
  14868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14869. return
  14870. }
  14871. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14872. var res ResultTwo
  14873. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14874. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14875. "&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)
  14876. resp, requestErr := http.Get(api)
  14877. if requestErr != nil {
  14878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14879. return
  14880. }
  14881. body, ioErr := ioutil.ReadAll(resp.Body)
  14882. if ioErr != nil {
  14883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14885. return
  14886. }
  14887. var respJSON map[string]interface{}
  14888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14891. return
  14892. }
  14893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14894. result, _ := json.Marshal(respJSON)
  14895. fmt.Println("log")
  14896. fmt.Println(string(result))
  14897. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14898. utils.ErrorLog("解析失败:%v", err)
  14899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14900. return
  14901. }
  14902. if res.Infcode == 0 {
  14903. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14904. if err == gorm.ErrRecordNotFound {
  14905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14906. return
  14907. } else if err != nil {
  14908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14909. return
  14910. } else {
  14911. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14912. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14913. infoStr := string(Iinfos)
  14914. idetinfoStr := string(Idetinfos)
  14915. psn := &models.HisPsn{
  14916. PsnNo: res.Output.Baseinfo.PsnNo,
  14917. PatientId: patient.ID,
  14918. Certno: res.Output.Baseinfo.Certno,
  14919. Gend: res.Output.Baseinfo.Gend,
  14920. Naty: res.Output.Baseinfo.Naty,
  14921. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14922. PsnName: res.Output.Baseinfo.PsnName,
  14923. Idetinfo: idetinfoStr,
  14924. Insuinfo: infoStr,
  14925. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14926. }
  14927. service.CreateHisPsn(psn)
  14928. c.ServeSuccessJSON(map[string]interface{}{
  14929. "patient": patient,
  14930. "number": res.Output.Baseinfo.Certno,
  14931. })
  14932. }
  14933. } else {
  14934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14935. return
  14936. }
  14937. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14938. var res ResultTwo
  14939. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14940. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14941. "&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)
  14942. resp, requestErr := http.Get(api)
  14943. if requestErr != nil {
  14944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14945. return
  14946. }
  14947. body, ioErr := ioutil.ReadAll(resp.Body)
  14948. if ioErr != nil {
  14949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14951. return
  14952. }
  14953. var respJSON map[string]interface{}
  14954. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14957. return
  14958. }
  14959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14960. result, _ := json.Marshal(respJSON)
  14961. fmt.Println("log")
  14962. fmt.Println(string(result))
  14963. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14964. utils.ErrorLog("解析失败:%v", err)
  14965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14966. return
  14967. }
  14968. if res.Infcode == 0 {
  14969. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14970. if err == gorm.ErrRecordNotFound {
  14971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14972. return
  14973. } else if err != nil {
  14974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14975. return
  14976. } else {
  14977. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14978. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14979. infoStr := string(Iinfos)
  14980. idetinfoStr := string(Idetinfos)
  14981. psn := &models.HisPsn{
  14982. PsnNo: res.Output.Baseinfo.PsnNo,
  14983. PatientId: patient.ID,
  14984. Certno: res.Output.Baseinfo.Certno,
  14985. Gend: res.Output.Baseinfo.Gend,
  14986. Naty: res.Output.Baseinfo.Naty,
  14987. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14988. PsnName: res.Output.Baseinfo.PsnName,
  14989. Idetinfo: idetinfoStr,
  14990. Insuinfo: infoStr,
  14991. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14992. }
  14993. service.CreateHisPsn(psn)
  14994. c.ServeSuccessJSON(map[string]interface{}{
  14995. "patient": patient,
  14996. "number": res.Output.Baseinfo.Certno,
  14997. })
  14998. }
  14999. } else {
  15000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15001. return
  15002. }
  15003. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15004. var res ResultTwo
  15005. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15006. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15007. "&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)
  15008. resp, requestErr := http.Get(api)
  15009. if requestErr != nil {
  15010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15011. return
  15012. }
  15013. body, ioErr := ioutil.ReadAll(resp.Body)
  15014. if ioErr != nil {
  15015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15017. return
  15018. }
  15019. var respJSON map[string]interface{}
  15020. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15023. return
  15024. }
  15025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15026. result, _ := json.Marshal(respJSON)
  15027. fmt.Println("log")
  15028. fmt.Println(string(result))
  15029. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15030. utils.ErrorLog("解析失败:%v", err)
  15031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15032. return
  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. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15044. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15045. infoStr := string(Iinfos)
  15046. idetinfoStr := string(Idetinfos)
  15047. var rf []*ResultFive
  15048. json.Unmarshal([]byte(infoStr), &rf)
  15049. var insutypes []*ResultFive
  15050. var insutype string
  15051. var is390 int = 0
  15052. var is310 int = 0
  15053. for _, item := range rf {
  15054. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15055. insutypes = append(insutypes, item)
  15056. }
  15057. }
  15058. if len(insutypes) == 1 {
  15059. insutype = insutypes[0].Insutype
  15060. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15061. } else {
  15062. for _, i := range insutypes {
  15063. if i.Insutype == "390" {
  15064. is390 = 1
  15065. }
  15066. if i.Insutype == "310" {
  15067. is310 = 1
  15068. }
  15069. }
  15070. }
  15071. if is390 == 1 {
  15072. insutype = "390"
  15073. }
  15074. if is310 == 1 {
  15075. insutype = "310"
  15076. }
  15077. if len(insutypes) == 0 {
  15078. insutype = "390"
  15079. }
  15080. var insuplc_admdvs string
  15081. for _, item := range rf {
  15082. if item.Insutype == insutype {
  15083. insuplc_admdvs = item.InsuplcAdmdvs
  15084. }
  15085. }
  15086. psn := &models.HisPsn{
  15087. PsnNo: res.Output.Baseinfo.PsnNo,
  15088. PatientId: patient.ID,
  15089. Certno: res.Output.Baseinfo.Certno,
  15090. Gend: res.Output.Baseinfo.Gend,
  15091. Naty: res.Output.Baseinfo.Naty,
  15092. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15093. PsnName: res.Output.Baseinfo.PsnName,
  15094. Idetinfo: idetinfoStr,
  15095. Insuinfo: infoStr,
  15096. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15097. InsuplcAdmdvs: insuplc_admdvs,
  15098. }
  15099. service.CreateHisPsn(psn)
  15100. c.ServeSuccessJSON(map[string]interface{}{
  15101. "patient": patient,
  15102. "number": res.Output.Baseinfo.Certno,
  15103. })
  15104. }
  15105. } else {
  15106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15107. return
  15108. }
  15109. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15110. res := c.GetoleInfo()
  15111. if res.Infcode == 0 {
  15112. var result string
  15113. if res.Output.MdtrtCertType == "01" {
  15114. 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)
  15115. } else if res.Output.MdtrtCertType == "02" {
  15116. 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)
  15117. } else if res.Output.MdtrtCertType == "03" {
  15118. 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)
  15119. }
  15120. var dat map[string]interface{}
  15121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15122. fmt.Println(dat)
  15123. } else {
  15124. fmt.Println(err)
  15125. }
  15126. userJSONBytes, _ := json.Marshal(dat)
  15127. var res2 ResultTwo
  15128. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15129. utils.ErrorLog("解析失败:%v", err)
  15130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15131. return
  15132. }
  15133. if res2.Infcode == 0 {
  15134. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15135. if err == gorm.ErrRecordNotFound {
  15136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15137. return
  15138. } else if err != nil {
  15139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15140. return
  15141. } else {
  15142. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15143. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15144. infoStr := string(Iinfos)
  15145. idetinfoStr := string(Idetinfos)
  15146. var rf []*ResultFive
  15147. json.Unmarshal([]byte(infoStr), &rf)
  15148. var insutypes []*ResultFive
  15149. var insutype string
  15150. var is390 int = 0
  15151. var is310 int = 0
  15152. //var insuplc_admdvs string
  15153. for _, item := range rf {
  15154. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15155. insutypes = append(insutypes, item)
  15156. }
  15157. }
  15158. if len(insutypes) == 1 {
  15159. insutype = insutypes[0].Insutype
  15160. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15161. } else {
  15162. for _, i := range insutypes {
  15163. if i.Insutype == "390" {
  15164. is390 = 1
  15165. }
  15166. if i.Insutype == "310" {
  15167. is310 = 1
  15168. }
  15169. }
  15170. }
  15171. if is390 == 1 {
  15172. insutype = "390"
  15173. }
  15174. if is310 == 1 {
  15175. insutype = "310"
  15176. }
  15177. if len(insutypes) == 0 {
  15178. insutype = "310"
  15179. }
  15180. psn := &models.HisPsn{
  15181. PsnNo: res2.Output.Baseinfo.PsnNo,
  15182. PatientId: patient.ID,
  15183. //Brdy: res2.Output.Baseinfo.Brdy,
  15184. Certno: res2.Output.Baseinfo.Certno,
  15185. Gend: res2.Output.Baseinfo.Gend,
  15186. Naty: res2.Output.Baseinfo.Naty,
  15187. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15188. PsnName: res2.Output.Baseinfo.PsnName,
  15189. Idetinfo: idetinfoStr,
  15190. Insuinfo: infoStr,
  15191. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15192. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15193. VerifyNumber: res.Output.EcToken,
  15194. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15195. }
  15196. service.CreateHisPsn(psn)
  15197. var balc float64
  15198. for _, item := range rf {
  15199. if item.Insutype == insutype {
  15200. balc = item.Balc
  15201. }
  15202. }
  15203. c.ServeSuccessJSON(map[string]interface{}{
  15204. "patient": patient,
  15205. "number": res.Output.CardNo,
  15206. "insutype": insutype,
  15207. "blac": balc,
  15208. "desc": idetinfoStr,
  15209. })
  15210. }
  15211. } else {
  15212. c.ServeSuccessJSON(map[string]interface{}{
  15213. "failed_code": -10,
  15214. "msg": res2.ErrMsg,
  15215. })
  15216. }
  15217. } else {
  15218. c.ServeSuccessJSON(map[string]interface{}{
  15219. "failed_code": -10,
  15220. "msg": res.ErrMsg,
  15221. })
  15222. }
  15223. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15224. var insuplc_admdvs string
  15225. if len(patient.InsuplcAdmdvs) > 0 {
  15226. insuplc_admdvs = patient.InsuplcAdmdvs
  15227. } else {
  15228. if len(insuplc_admdvs_str) > 0 {
  15229. insuplc_admdvs = insuplc_admdvs_str
  15230. } else {
  15231. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15232. }
  15233. }
  15234. //请求内网数据
  15235. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15236. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15237. "&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=" + ""
  15238. resp, requestErr := http.Get(api)
  15239. if requestErr != nil {
  15240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15241. return
  15242. }
  15243. body, ioErr := ioutil.ReadAll(resp.Body)
  15244. if ioErr != nil {
  15245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15247. return
  15248. }
  15249. var respJSON map[string]interface{}
  15250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15253. return
  15254. }
  15255. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15256. if status == "0" {
  15257. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15258. c.ServeSuccessJSON(map[string]interface{}{
  15259. "failed_code": -10,
  15260. "msg": err_msg,
  15261. })
  15262. return
  15263. }
  15264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15265. var res ResultTwo
  15266. result, _ := json.Marshal(respJSON)
  15267. fmt.Println("log")
  15268. fmt.Println(string(result))
  15269. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15270. utils.ErrorLog("解析失败:%v", err)
  15271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15272. return
  15273. }
  15274. if res.Infcode == 0 {
  15275. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15276. if err == gorm.ErrRecordNotFound {
  15277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15278. return
  15279. } else if err != nil {
  15280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15281. return
  15282. } else {
  15283. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15284. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15285. infoStr := string(Iinfos)
  15286. idetinfoStr := string(Idetinfos)
  15287. psn := &models.HisPsn{
  15288. PsnNo: res.Output.Baseinfo.PsnNo,
  15289. PatientId: patient.ID,
  15290. Certno: res.Output.Baseinfo.Certno,
  15291. Gend: res.Output.Baseinfo.Gend,
  15292. Naty: res.Output.Baseinfo.Naty,
  15293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15294. PsnName: res.Output.Baseinfo.PsnName,
  15295. Idetinfo: idetinfoStr,
  15296. Insuinfo: infoStr,
  15297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15298. }
  15299. service.CreateHisPsn(psn)
  15300. var rf []*ResultFive
  15301. json.Unmarshal([]byte(infoStr), &rf)
  15302. var insutypes []*ResultFive
  15303. var is390 int = 0
  15304. var is310 int = 0
  15305. var insutype string
  15306. for _, item := range rf {
  15307. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15308. insutypes = append(insutypes, item)
  15309. }
  15310. }
  15311. if len(insutypes) == 1 {
  15312. insutype = insutypes[0].Insutype
  15313. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15314. } else {
  15315. for _, i := range insutypes {
  15316. if i.Insutype == "390" {
  15317. is390 = 1
  15318. }
  15319. if i.Insutype == "310" {
  15320. is310 = 1
  15321. }
  15322. }
  15323. }
  15324. if is390 == 1 {
  15325. insutype = "390"
  15326. }
  15327. if is310 == 1 {
  15328. insutype = "310"
  15329. }
  15330. if len(insutypes) == 0 {
  15331. insutype = "390"
  15332. }
  15333. c.ServeSuccessJSON(map[string]interface{}{
  15334. "patient": patient,
  15335. "insutype": insutype,
  15336. "number": res.Output.Baseinfo.Certno,
  15337. "info": res,
  15338. })
  15339. }
  15340. } else {
  15341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15342. return
  15343. }
  15344. } else {
  15345. SFZStr := c.GetSFZBaseInfo()
  15346. id_card_str := strings.Split(SFZStr, "^")
  15347. id_card_number := id_card_str[0]
  15348. card_sn := ""
  15349. 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)
  15350. var dat map[string]interface{}
  15351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15352. fmt.Println(dat)
  15353. } else {
  15354. fmt.Println(err)
  15355. }
  15356. userJSONBytes, _ := json.Marshal(dat)
  15357. var res ResultTwo
  15358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15359. utils.ErrorLog("解析失败:%v", err)
  15360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15361. return
  15362. }
  15363. if res.Infcode == 0 {
  15364. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15365. if err == gorm.ErrRecordNotFound {
  15366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15367. return
  15368. } else if err != nil {
  15369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15370. return
  15371. } else {
  15372. c.ServeSuccessJSON(map[string]interface{}{
  15373. "patient": patient,
  15374. "number": id_card_number,
  15375. })
  15376. }
  15377. } else {
  15378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15379. return
  15380. }
  15381. }
  15382. break
  15383. case 3:
  15384. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15385. var api string
  15386. if miConfig.MdtrtareaAdmvs == "320921" {
  15387. 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 +
  15388. "&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
  15389. fmt.Println(api)
  15390. } else {
  15391. 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 +
  15392. "&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)
  15393. }
  15394. resp, requestErr := http.Get(api)
  15395. if requestErr != nil {
  15396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15397. return
  15398. }
  15399. body, ioErr := ioutil.ReadAll(resp.Body)
  15400. if ioErr != nil {
  15401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15403. return
  15404. }
  15405. var respJSON map[string]interface{}
  15406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15409. return
  15410. }
  15411. var status string
  15412. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15413. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15414. var token string
  15415. var res ResultTwo //1101结果
  15416. var res10265 ResultTwo10265 //1101结果
  15417. var card_info string //卡信息
  15418. var busi_card_info string
  15419. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15420. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15421. if status == "0" { //读卡成功
  15422. if card_type == "1" {
  15423. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15424. result, _ := json.Marshal(respJSON)
  15425. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15426. utils.ErrorLog("解析失败:%v", err)
  15427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15428. return
  15429. }
  15430. res.ErrMsg = res10265.ErrMsg
  15431. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15432. res.Infcode = infocode
  15433. res.Output = res10265.Output
  15434. res.InfRefmsgid = res10265.InfRefmsgid
  15435. } else {
  15436. //var card_info string //卡信息
  15437. //var busi_card_info string
  15438. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15439. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15440. //fmt.Println(card_info)
  15441. //fmt.Println(busi_card_info)
  15442. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15443. result, _ := json.Marshal(respJSON)
  15444. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15445. utils.ErrorLog("解析失败:%v", err)
  15446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15447. return
  15448. }
  15449. res.ErrMsg = res10265.ErrMsg
  15450. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15451. res.Infcode = infocode
  15452. res.Output = res10265.Output
  15453. res.InfRefmsgid = res10265.InfRefmsgid
  15454. }
  15455. if res.Infcode == 0 {
  15456. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15457. if err == gorm.ErrRecordNotFound {
  15458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15459. return
  15460. } else if err != nil {
  15461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15462. return
  15463. } else {
  15464. if card_type == "1" {
  15465. bas := strings.Split(card_info, "|")
  15466. basNumber := bas[2]
  15467. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15468. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15469. infoStr := string(Iinfos)
  15470. idetinfoStr := string(Idetinfos)
  15471. psn := &models.HisPsn{
  15472. PsnNo: res.Output.Baseinfo.PsnNo,
  15473. PatientId: patient.ID,
  15474. Certno: res.Output.Baseinfo.Certno,
  15475. //Brdy: res.Output.Baseinfo.Brdy,
  15476. Gend: res.Output.Baseinfo.Gend,
  15477. Naty: res.Output.Baseinfo.Naty,
  15478. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15479. PsnName: res.Output.Baseinfo.PsnName,
  15480. Idetinfo: idetinfoStr,
  15481. Insuinfo: infoStr,
  15482. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15483. CardInfo: card_info,
  15484. VerifyNumber: busi_card_info,
  15485. }
  15486. service.CreateHisPsn(psn)
  15487. c.ServeSuccessJSON(map[string]interface{}{
  15488. "patient": patient,
  15489. "number": basNumber,
  15490. })
  15491. } else {
  15492. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15493. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15494. infoStr := string(Iinfos)
  15495. idetinfoStr := string(Idetinfos)
  15496. psn := &models.HisPsn{
  15497. PsnNo: res.Output.Baseinfo.PsnNo,
  15498. PatientId: patient.ID,
  15499. Certno: res.Output.Baseinfo.Certno,
  15500. Gend: res.Output.Baseinfo.Gend,
  15501. Naty: res.Output.Baseinfo.Naty,
  15502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15503. PsnName: res.Output.Baseinfo.PsnName,
  15504. Idetinfo: idetinfoStr,
  15505. Insuinfo: infoStr,
  15506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15507. CardInfo: card_info,
  15508. VerifyNumber: token,
  15509. }
  15510. service.CreateHisPsn(psn)
  15511. var rf []*ResultFive
  15512. json.Unmarshal([]byte(infoStr), &rf)
  15513. var insutypes []*ResultFive
  15514. var insutype string
  15515. var is390 int = 0
  15516. var is310 int = 0
  15517. for _, item := range rf {
  15518. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15519. insutypes = append(insutypes, item)
  15520. }
  15521. }
  15522. if len(insutypes) == 1 {
  15523. insutype = insutypes[0].Insutype
  15524. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15525. } else {
  15526. for _, i := range insutypes {
  15527. if i.Insutype == "390" {
  15528. is390 = 1
  15529. }
  15530. if i.Insutype == "310" {
  15531. is310 = 1
  15532. }
  15533. }
  15534. }
  15535. if is390 == 1 {
  15536. insutype = "390"
  15537. }
  15538. if is310 == 1 {
  15539. insutype = "310"
  15540. }
  15541. if len(insutypes) == 0 {
  15542. insutype = "310"
  15543. }
  15544. c.ServeSuccessJSON(map[string]interface{}{
  15545. "patient": patient,
  15546. "number": token,
  15547. "insutype": insutype,
  15548. })
  15549. }
  15550. }
  15551. } else {
  15552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15553. return
  15554. }
  15555. } else { //读卡失败
  15556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15557. return
  15558. }
  15559. }
  15560. break
  15561. case 4:
  15562. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15563. var api string
  15564. if miConfig.MdtrtareaAdmvs == "320921" {
  15565. 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 +
  15566. "&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
  15567. fmt.Println(api)
  15568. } else {
  15569. 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 +
  15570. "&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)
  15571. }
  15572. resp, requestErr := http.Get(api)
  15573. if requestErr != nil {
  15574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15575. return
  15576. }
  15577. body, ioErr := ioutil.ReadAll(resp.Body)
  15578. if ioErr != nil {
  15579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15581. return
  15582. }
  15583. var respJSON map[string]interface{}
  15584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15587. return
  15588. }
  15589. var status string
  15590. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15591. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15592. var token string
  15593. var res ResultTwo //1101结果
  15594. var res10265 ResultTwo10265 //1101结果
  15595. if status == "0" { //读卡成功
  15596. var card_info string //卡信息
  15597. var busi_card_info string
  15598. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15599. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15600. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15601. fmt.Println(card_info)
  15602. fmt.Println(busi_card_info)
  15603. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15604. result, _ := json.Marshal(respJSON)
  15605. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15606. utils.ErrorLog("解析失败:%v", err)
  15607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15608. return
  15609. }
  15610. res.ErrMsg = res10265.ErrMsg
  15611. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15612. res.Infcode = infocode
  15613. res.Output = res10265.Output
  15614. res.InfRefmsgid = res10265.InfRefmsgid
  15615. if res.Infcode == 0 {
  15616. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15617. if err == gorm.ErrRecordNotFound {
  15618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15619. return
  15620. } else if err != nil {
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15622. return
  15623. } else {
  15624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15626. infoStr := string(Iinfos)
  15627. idetinfoStr := string(Idetinfos)
  15628. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15629. psn := &models.HisPsn{
  15630. PsnNo: res.Output.Baseinfo.PsnNo,
  15631. PatientId: patient.ID,
  15632. Certno: res.Output.Baseinfo.Certno,
  15633. Brdy: b,
  15634. Age: float64(age),
  15635. //Brdy: res.Output.Baseinfo.Brdy,
  15636. Gend: res.Output.Baseinfo.Gend,
  15637. Naty: res.Output.Baseinfo.Naty,
  15638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15639. PsnName: res.Output.Baseinfo.PsnName,
  15640. Idetinfo: idetinfoStr,
  15641. Insuinfo: infoStr,
  15642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15643. CardInfo: card_info,
  15644. VerifyNumber: token,
  15645. }
  15646. var rf []*ResultFive
  15647. json.Unmarshal([]byte(infoStr), &rf)
  15648. var insutypes []*ResultFive
  15649. var insutype string
  15650. var is390 int = 0
  15651. var is310 int = 0
  15652. for _, item := range rf {
  15653. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15654. insutypes = append(insutypes, item)
  15655. }
  15656. }
  15657. if len(insutypes) == 1 {
  15658. insutype = insutypes[0].Insutype
  15659. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15660. } else {
  15661. for _, i := range insutypes {
  15662. if i.Insutype == "390" {
  15663. is390 = 1
  15664. }
  15665. if i.Insutype == "310" {
  15666. is310 = 1
  15667. }
  15668. }
  15669. }
  15670. if is390 == 1 {
  15671. insutype = "390"
  15672. }
  15673. if is310 == 1 {
  15674. insutype = "310"
  15675. }
  15676. if len(insutypes) == 0 {
  15677. insutype = "310"
  15678. }
  15679. service.CreateHisPsn(psn)
  15680. c.ServeSuccessJSON(map[string]interface{}{
  15681. "patient": patient,
  15682. "number": token,
  15683. "insutype": insutype,
  15684. })
  15685. }
  15686. } else {
  15687. c.ServeSuccessJSON(map[string]interface{}{
  15688. "failed_code": -10,
  15689. "msg": res.ErrMsg,
  15690. })
  15691. }
  15692. } else { //读卡失败
  15693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15694. return
  15695. }
  15696. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15697. var api string
  15698. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15699. "&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
  15700. resp, requestErr := http.Get(api)
  15701. if requestErr != nil {
  15702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15703. return
  15704. }
  15705. body, ioErr := ioutil.ReadAll(resp.Body)
  15706. if ioErr != nil {
  15707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15709. return
  15710. }
  15711. var respJSON map[string]interface{}
  15712. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15715. return
  15716. }
  15717. var status string
  15718. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15719. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15720. var token string
  15721. var res ResultTwo //1101结果
  15722. if status == "1" { //读卡成功
  15723. var card_info string //卡信息
  15724. var busi_card_info string
  15725. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15726. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15727. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15728. fmt.Println(card_info)
  15729. fmt.Println(busi_card_info)
  15730. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15731. result, _ := json.Marshal(respJSON)
  15732. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15733. utils.ErrorLog("解析失败:%v", err)
  15734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15735. return
  15736. }
  15737. if res.Infcode == 0 {
  15738. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15739. if err == gorm.ErrRecordNotFound {
  15740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15741. return
  15742. } else if err != nil {
  15743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15744. return
  15745. } else {
  15746. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15747. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15748. infoStr := string(Iinfos)
  15749. idetinfoStr := string(Idetinfos)
  15750. psn := &models.HisPsn{
  15751. PsnNo: res.Output.Baseinfo.PsnNo,
  15752. PatientId: patient.ID,
  15753. Certno: res.Output.Baseinfo.Certno,
  15754. Gend: res.Output.Baseinfo.Gend,
  15755. Naty: res.Output.Baseinfo.Naty,
  15756. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15757. PsnName: res.Output.Baseinfo.PsnName,
  15758. Idetinfo: idetinfoStr,
  15759. Insuinfo: infoStr,
  15760. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15761. CardInfo: card_info,
  15762. VerifyNumber: token,
  15763. }
  15764. var rf []*ResultFive
  15765. json.Unmarshal([]byte(infoStr), &rf)
  15766. var insutypes []*ResultFive
  15767. var insutype string
  15768. var is390 int = 0
  15769. var is310 int = 0
  15770. for _, item := range rf {
  15771. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15772. insutypes = append(insutypes, item)
  15773. }
  15774. }
  15775. if len(insutypes) == 1 {
  15776. insutype = insutypes[0].Insutype
  15777. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15778. } else {
  15779. for _, i := range insutypes {
  15780. if i.Insutype == "390" {
  15781. is390 = 1
  15782. }
  15783. if i.Insutype == "310" {
  15784. is310 = 1
  15785. }
  15786. }
  15787. }
  15788. if is390 == 1 {
  15789. insutype = "390"
  15790. }
  15791. if is310 == 1 {
  15792. insutype = "310"
  15793. }
  15794. if len(insutypes) == 0 {
  15795. insutype = "310"
  15796. }
  15797. service.CreateHisPsn(psn)
  15798. c.ServeSuccessJSON(map[string]interface{}{
  15799. "patient": patient,
  15800. "number": token,
  15801. "insutype": insutype,
  15802. })
  15803. }
  15804. } else {
  15805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15806. return
  15807. }
  15808. } else { //读卡失败
  15809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15810. return
  15811. }
  15812. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15813. var api string
  15814. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15815. "&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
  15816. resp, requestErr := http.Get(api)
  15817. if requestErr != nil {
  15818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15819. return
  15820. }
  15821. body, ioErr := ioutil.ReadAll(resp.Body)
  15822. if ioErr != nil {
  15823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15825. return
  15826. }
  15827. var respJSON map[string]interface{}
  15828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15831. return
  15832. }
  15833. var status string
  15834. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15835. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15836. var token string
  15837. var res ResultTwo //1101结果
  15838. if status == "1" { //读卡成功
  15839. var card_info string //卡信息
  15840. var busi_card_info string
  15841. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15842. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15843. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15844. fmt.Println(card_info)
  15845. fmt.Println(busi_card_info)
  15846. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15847. result, _ := json.Marshal(respJSON)
  15848. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15849. utils.ErrorLog("解析失败:%v", err)
  15850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15851. return
  15852. }
  15853. if res.Infcode == 0 {
  15854. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15855. if err == gorm.ErrRecordNotFound {
  15856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15857. return
  15858. } else if err != nil {
  15859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15860. return
  15861. } else {
  15862. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15863. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15864. infoStr := string(Iinfos)
  15865. idetinfoStr := string(Idetinfos)
  15866. psn := &models.HisPsn{
  15867. PsnNo: res.Output.Baseinfo.PsnNo,
  15868. PatientId: patient.ID,
  15869. Certno: res.Output.Baseinfo.Certno,
  15870. Gend: res.Output.Baseinfo.Gend,
  15871. Naty: res.Output.Baseinfo.Naty,
  15872. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15873. PsnName: res.Output.Baseinfo.PsnName,
  15874. Idetinfo: idetinfoStr,
  15875. Insuinfo: infoStr,
  15876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15877. CardInfo: card_info,
  15878. VerifyNumber: token,
  15879. }
  15880. var rf []*ResultFive
  15881. json.Unmarshal([]byte(infoStr), &rf)
  15882. var insutypes []*ResultFive
  15883. var insutype string
  15884. var is390 int = 0
  15885. var is310 int = 0
  15886. for _, item := range rf {
  15887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15888. insutypes = append(insutypes, item)
  15889. }
  15890. }
  15891. if len(insutypes) == 1 {
  15892. insutype = insutypes[0].Insutype
  15893. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15894. } else {
  15895. for _, i := range insutypes {
  15896. if i.Insutype == "390" {
  15897. is390 = 1
  15898. }
  15899. if i.Insutype == "310" {
  15900. is310 = 1
  15901. }
  15902. }
  15903. }
  15904. if is390 == 1 {
  15905. insutype = "390"
  15906. }
  15907. if is310 == 1 {
  15908. insutype = "310"
  15909. }
  15910. if len(insutypes) == 0 {
  15911. insutype = "310"
  15912. }
  15913. service.CreateHisPsn(psn)
  15914. c.ServeSuccessJSON(map[string]interface{}{
  15915. "patient": patient,
  15916. "number": token,
  15917. "insutype": insutype,
  15918. })
  15919. }
  15920. } else {
  15921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15922. return
  15923. }
  15924. } else { //读卡失败
  15925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15926. return
  15927. }
  15928. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15929. //idNo := c.GetString("idNo")
  15930. //userName := c.GetString("userName")
  15931. //ecToken := c.GetString("ecToken")
  15932. //insuOrg := c.GetString("insuOrg")
  15933. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15934. utils.ErrorLog("解析失败:%v", json_result)
  15935. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15936. type ELeData struct {
  15937. Data struct {
  15938. IdNo string `json:"idNo"`
  15939. IdType string `json:"idType"`
  15940. UserName string `json:"userName"`
  15941. EcToken string `json:"ecToken"`
  15942. InsuOrg string `json:"insuOrg"`
  15943. Gender string `json:"gender"`
  15944. Birthday string `json:"birthday"`
  15945. Nationality string `json:"nationality"`
  15946. Email string `json:"email"`
  15947. Extra string `json:"extra"`
  15948. } `json:"data"`
  15949. Code int `json:"code"`
  15950. Message string `json:"message"`
  15951. }
  15952. var ele ELeData
  15953. err := json.Unmarshal([]byte(json_result), &ele)
  15954. if err != nil {
  15955. utils.ErrorLog("解析失败:%v", err)
  15956. }
  15957. token := ele.Data.EcToken
  15958. token = Remove0000(token)
  15959. 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)
  15960. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15961. var res ResultTwo
  15962. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15963. utils.ErrorLog("解析失败:%v", err)
  15964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15965. return
  15966. }
  15967. if res.Infcode == 0 {
  15968. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15969. if err == gorm.ErrRecordNotFound {
  15970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15971. return
  15972. } else if err != nil {
  15973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15974. return
  15975. } else {
  15976. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15977. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15978. infoStr := string(Iinfos)
  15979. idetinfoStr := string(Idetinfos)
  15980. psn := &models.HisPsn{
  15981. PsnNo: res.Output.Baseinfo.PsnNo,
  15982. PatientId: patient.ID,
  15983. Certno: res.Output.Baseinfo.Certno,
  15984. Gend: res.Output.Baseinfo.Gend,
  15985. Naty: res.Output.Baseinfo.Naty,
  15986. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15987. PsnName: res.Output.Baseinfo.PsnName,
  15988. Idetinfo: idetinfoStr,
  15989. Insuinfo: infoStr,
  15990. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15991. CardInfo: "",
  15992. Stage: "1",
  15993. VerifyNumber: token,
  15994. InsuplcAdmdvs: ele.Data.InsuOrg,
  15995. }
  15996. service.CreateHisPsn(psn)
  15997. var rf []*ResultFive
  15998. json.Unmarshal([]byte(infoStr), &rf)
  15999. var insutypes []*ResultFive
  16000. var insutype string
  16001. var is390 int = 0
  16002. var is310 int = 0
  16003. for _, item := range rf {
  16004. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16005. insutypes = append(insutypes, item)
  16006. }
  16007. }
  16008. if len(insutypes) == 1 {
  16009. insutype = insutypes[0].Insutype
  16010. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16011. } else {
  16012. for _, i := range insutypes {
  16013. if i.Insutype == "390" {
  16014. is390 = 1
  16015. }
  16016. if i.Insutype == "310" {
  16017. is310 = 1
  16018. }
  16019. }
  16020. }
  16021. if is390 == 1 {
  16022. insutype = "390"
  16023. }
  16024. if is310 == 1 {
  16025. insutype = "310"
  16026. }
  16027. if len(insutypes) == 0 {
  16028. insutype = "310"
  16029. }
  16030. c.ServeSuccessJSON(map[string]interface{}{
  16031. "patient": patient,
  16032. "number": token,
  16033. "insutype": insutype,
  16034. })
  16035. }
  16036. } else {
  16037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16038. return
  16039. }
  16040. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16041. //if initFlag == 0 {
  16042. //c.TestGetJiangXiBasBaseInit()
  16043. //}
  16044. //if initEleFlag == 0 {
  16045. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16046. //}
  16047. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16048. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16049. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16050. type ELeData struct {
  16051. Data struct {
  16052. IdNo string `json:"idNo"`
  16053. IdType string `json:"idType"`
  16054. UserName string `json:"userName"`
  16055. EcToken string `json:"ecToken"`
  16056. InsuOrg string `json:"insuOrg"`
  16057. Gender string `json:"gender"`
  16058. Birthday string `json:"birthday"`
  16059. Nationality string `json:"nationality"`
  16060. Email string `json:"email"`
  16061. Extra string `json:"extra"`
  16062. } `json:"data"`
  16063. Code int `json:"code"`
  16064. Message string `json:"message"`
  16065. }
  16066. var ele ELeData
  16067. err := json.Unmarshal([]byte(result), &ele)
  16068. if err != nil {
  16069. utils.ErrorLog("解析失败:%v", err)
  16070. }
  16071. token := ele.Data.EcToken
  16072. token = Remove0000(token)
  16073. 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)
  16074. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16075. var res ResultTwo
  16076. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16077. utils.ErrorLog("解析失败:%v", err)
  16078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16079. return
  16080. }
  16081. if res.Infcode == 0 {
  16082. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16083. if err == gorm.ErrRecordNotFound {
  16084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16085. return
  16086. } else if err != nil {
  16087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16088. return
  16089. } else {
  16090. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16091. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16092. infoStr := string(Iinfos)
  16093. idetinfoStr := string(Idetinfos)
  16094. psn := &models.HisPsn{
  16095. PsnNo: res.Output.Baseinfo.PsnNo,
  16096. PatientId: patient.ID,
  16097. Certno: res.Output.Baseinfo.Certno,
  16098. Gend: res.Output.Baseinfo.Gend,
  16099. Naty: res.Output.Baseinfo.Naty,
  16100. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16101. PsnName: res.Output.Baseinfo.PsnName,
  16102. Idetinfo: idetinfoStr,
  16103. Insuinfo: infoStr,
  16104. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16105. CardInfo: "",
  16106. VerifyNumber: token,
  16107. InsuplcAdmdvs: ele.Data.InsuOrg,
  16108. }
  16109. service.CreateHisPsn(psn)
  16110. var rf []*ResultFive
  16111. json.Unmarshal([]byte(infoStr), &rf)
  16112. var insutypes []*ResultFive
  16113. var insutype string
  16114. var is390 int = 0
  16115. var is310 int = 0
  16116. for _, item := range rf {
  16117. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16118. insutypes = append(insutypes, item)
  16119. }
  16120. }
  16121. if len(insutypes) == 1 {
  16122. insutype = insutypes[0].Insutype
  16123. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16124. } else {
  16125. for _, i := range insutypes {
  16126. if i.Insutype == "390" {
  16127. is390 = 1
  16128. }
  16129. if i.Insutype == "310" {
  16130. is310 = 1
  16131. }
  16132. }
  16133. }
  16134. if is390 == 1 {
  16135. insutype = "390"
  16136. }
  16137. if is310 == 1 {
  16138. insutype = "310"
  16139. }
  16140. if len(insutypes) == 0 {
  16141. insutype = "310"
  16142. }
  16143. c.ServeSuccessJSON(map[string]interface{}{
  16144. "patient": patient,
  16145. "number": token,
  16146. "insutype": insutype,
  16147. })
  16148. }
  16149. } else {
  16150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16151. return
  16152. }
  16153. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16154. //if initFlag == 0 {
  16155. //c.TestGetJiangXiBasBaseInit()
  16156. //}
  16157. //if initEleFlag == 0 {
  16158. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16159. //}
  16160. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16161. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16162. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16163. type ELeData struct {
  16164. Data struct {
  16165. IdNo string `json:"idNo"`
  16166. IdType string `json:"idType"`
  16167. UserName string `json:"userName"`
  16168. EcToken string `json:"ecToken"`
  16169. InsuOrg string `json:"insuOrg"`
  16170. Gender string `json:"gender"`
  16171. Birthday string `json:"birthday"`
  16172. Nationality string `json:"nationality"`
  16173. Email string `json:"email"`
  16174. Extra string `json:"extra"`
  16175. } `json:"data"`
  16176. Code int `json:"code"`
  16177. Message string `json:"message"`
  16178. }
  16179. var ele ELeData
  16180. err := json.Unmarshal([]byte(result), &ele)
  16181. if err != nil {
  16182. utils.ErrorLog("解析失败:%v", err)
  16183. }
  16184. token := ele.Data.EcToken
  16185. token = Remove0000(token)
  16186. 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)
  16187. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16188. var res ResultTwo
  16189. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16190. utils.ErrorLog("解析失败:%v", err)
  16191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16192. return
  16193. }
  16194. if res.Infcode == 0 {
  16195. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16196. if err == gorm.ErrRecordNotFound {
  16197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16198. return
  16199. } else if err != nil {
  16200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16201. return
  16202. } else {
  16203. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16204. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16205. infoStr := string(Iinfos)
  16206. idetinfoStr := string(Idetinfos)
  16207. psn := &models.HisPsn{
  16208. PsnNo: res.Output.Baseinfo.PsnNo,
  16209. PatientId: patient.ID,
  16210. Certno: res.Output.Baseinfo.Certno,
  16211. Gend: res.Output.Baseinfo.Gend,
  16212. Naty: res.Output.Baseinfo.Naty,
  16213. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16214. PsnName: res.Output.Baseinfo.PsnName,
  16215. Idetinfo: idetinfoStr,
  16216. Insuinfo: infoStr,
  16217. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16218. CardInfo: "",
  16219. VerifyNumber: token,
  16220. InsuplcAdmdvs: ele.Data.InsuOrg,
  16221. }
  16222. service.CreateHisPsn(psn)
  16223. var rf []*ResultFive
  16224. json.Unmarshal([]byte(infoStr), &rf)
  16225. var insutypes []*ResultFive
  16226. var insutype string
  16227. var is390 int = 0
  16228. var is310 int = 0
  16229. for _, item := range rf {
  16230. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16231. insutypes = append(insutypes, item)
  16232. }
  16233. }
  16234. if len(insutypes) == 1 {
  16235. insutype = insutypes[0].Insutype
  16236. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16237. } else {
  16238. for _, i := range insutypes {
  16239. if i.Insutype == "390" {
  16240. is390 = 1
  16241. }
  16242. if i.Insutype == "310" {
  16243. is310 = 1
  16244. }
  16245. }
  16246. }
  16247. if is390 == 1 {
  16248. insutype = "390"
  16249. }
  16250. if is310 == 1 {
  16251. insutype = "310"
  16252. }
  16253. if len(insutypes) == 0 {
  16254. insutype = "310"
  16255. }
  16256. c.ServeSuccessJSON(map[string]interface{}{
  16257. "patient": patient,
  16258. "number": token,
  16259. "insutype": insutype,
  16260. })
  16261. }
  16262. } else {
  16263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16264. return
  16265. }
  16266. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16267. //if initFlag == 0 {
  16268. //c.TestGetJiangXiBasBaseInit()
  16269. //}
  16270. //if initEleFlag == 0 {
  16271. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16272. //}
  16273. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16274. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16275. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16276. type ELeData struct {
  16277. Data struct {
  16278. IdNo string `json:"idNo"`
  16279. IdType string `json:"idType"`
  16280. UserName string `json:"userName"`
  16281. EcToken string `json:"ecToken"`
  16282. InsuOrg string `json:"insuOrg"`
  16283. Gender string `json:"gender"`
  16284. Birthday string `json:"birthday"`
  16285. Nationality string `json:"nationality"`
  16286. Email string `json:"email"`
  16287. Extra string `json:"extra"`
  16288. } `json:"data"`
  16289. Code int `json:"code"`
  16290. Message string `json:"message"`
  16291. }
  16292. var ele ELeData
  16293. err := json.Unmarshal([]byte(result), &ele)
  16294. if err != nil {
  16295. utils.ErrorLog("解析失败:%v", err)
  16296. }
  16297. token := ele.Data.EcToken
  16298. token = Remove0000(token)
  16299. 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)
  16300. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16301. var res ResultTwo
  16302. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16303. utils.ErrorLog("解析失败:%v", err)
  16304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16305. return
  16306. }
  16307. if res.Infcode == 0 {
  16308. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16309. if err == gorm.ErrRecordNotFound {
  16310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16311. return
  16312. } else if err != nil {
  16313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16314. return
  16315. } else {
  16316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16317. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16318. infoStr := string(Iinfos)
  16319. idetinfoStr := string(Idetinfos)
  16320. psn := &models.HisPsn{
  16321. PsnNo: res.Output.Baseinfo.PsnNo,
  16322. PatientId: patient.ID,
  16323. Certno: res.Output.Baseinfo.Certno,
  16324. Gend: res.Output.Baseinfo.Gend,
  16325. Naty: res.Output.Baseinfo.Naty,
  16326. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16327. PsnName: res.Output.Baseinfo.PsnName,
  16328. Idetinfo: idetinfoStr,
  16329. Insuinfo: infoStr,
  16330. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16331. CardInfo: "",
  16332. VerifyNumber: token,
  16333. InsuplcAdmdvs: ele.Data.InsuOrg,
  16334. }
  16335. service.CreateHisPsn(psn)
  16336. var rf []*ResultFive
  16337. json.Unmarshal([]byte(infoStr), &rf)
  16338. var insutypes []*ResultFive
  16339. var insutype string
  16340. var is390 int = 0
  16341. var is310 int = 0
  16342. for _, item := range rf {
  16343. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16344. insutypes = append(insutypes, item)
  16345. }
  16346. }
  16347. if len(insutypes) == 1 {
  16348. insutype = insutypes[0].Insutype
  16349. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16350. } else {
  16351. for _, i := range insutypes {
  16352. if i.Insutype == "390" {
  16353. is390 = 1
  16354. }
  16355. if i.Insutype == "310" {
  16356. is310 = 1
  16357. }
  16358. }
  16359. }
  16360. if is390 == 1 {
  16361. insutype = "390"
  16362. }
  16363. if is310 == 1 {
  16364. insutype = "310"
  16365. }
  16366. if len(insutypes) == 0 {
  16367. insutype = "310"
  16368. }
  16369. c.ServeSuccessJSON(map[string]interface{}{
  16370. "patient": patient,
  16371. "number": token,
  16372. "insutype": insutype,
  16373. })
  16374. }
  16375. } else {
  16376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16377. return
  16378. }
  16379. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16380. //if initFlag == 0 {
  16381. c.TestGetJiangXiBasBaseInit()
  16382. //}
  16383. //if initEleFlag == 0 {
  16384. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16385. //}
  16386. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16387. type ELeData struct {
  16388. Data struct {
  16389. IdNo string `json:"idNo"`
  16390. IdType string `json:"idType"`
  16391. UserName string `json:"userName"`
  16392. EcToken string `json:"ecToken"`
  16393. InsuOrg string `json:"insuOrg"`
  16394. Gender string `json:"gender"`
  16395. Birthday string `json:"birthday"`
  16396. Nationality string `json:"nationality"`
  16397. Email string `json:"email"`
  16398. Extra string `json:"extra"`
  16399. } `json:"data"`
  16400. Code int `json:"code"`
  16401. Message string `json:"message"`
  16402. }
  16403. var ele ELeData
  16404. err := json.Unmarshal([]byte(json_result), &ele)
  16405. if err != nil {
  16406. utils.ErrorLog("解析失败:%v", err)
  16407. }
  16408. token := ele.Data.EcToken
  16409. token = Remove0000(token)
  16410. 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)
  16411. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16412. var res ResultTwo
  16413. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16414. utils.ErrorLog("解析失败:%v", err)
  16415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16416. return
  16417. }
  16418. if res.Infcode == 0 {
  16419. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16420. if err == gorm.ErrRecordNotFound {
  16421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16422. return
  16423. } else if err != nil {
  16424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16425. return
  16426. } else {
  16427. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16428. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16429. infoStr := string(Iinfos)
  16430. idetinfoStr := string(Idetinfos)
  16431. psn := &models.HisPsn{
  16432. PsnNo: res.Output.Baseinfo.PsnNo,
  16433. PatientId: patient.ID,
  16434. Certno: res.Output.Baseinfo.Certno,
  16435. Gend: res.Output.Baseinfo.Gend,
  16436. Naty: res.Output.Baseinfo.Naty,
  16437. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16438. PsnName: res.Output.Baseinfo.PsnName,
  16439. Idetinfo: idetinfoStr,
  16440. Insuinfo: infoStr,
  16441. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16442. CardInfo: "",
  16443. VerifyNumber: token,
  16444. }
  16445. service.CreateHisPsn(psn)
  16446. var rf []*ResultFive
  16447. json.Unmarshal([]byte(infoStr), &rf)
  16448. var insutypes []*ResultFive
  16449. var insutype string
  16450. var is390 int = 0
  16451. var is310 int = 0
  16452. for _, item := range rf {
  16453. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16454. insutypes = append(insutypes, item)
  16455. }
  16456. }
  16457. if len(insutypes) == 1 {
  16458. insutype = insutypes[0].Insutype
  16459. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16460. } else {
  16461. for _, i := range insutypes {
  16462. if i.Insutype == "390" {
  16463. is390 = 1
  16464. }
  16465. if i.Insutype == "310" {
  16466. is310 = 1
  16467. }
  16468. }
  16469. }
  16470. if is390 == 1 {
  16471. insutype = "390"
  16472. }
  16473. if is310 == 1 {
  16474. insutype = "310"
  16475. }
  16476. if len(insutypes) == 0 {
  16477. insutype = "310"
  16478. }
  16479. c.ServeSuccessJSON(map[string]interface{}{
  16480. "patient": patient,
  16481. "number": token,
  16482. "insutype": insutype,
  16483. })
  16484. }
  16485. } else {
  16486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16487. return
  16488. }
  16489. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16490. type ELeData struct {
  16491. Code string `json:"code"`
  16492. Data struct {
  16493. Aac002 string `json:"aac002"`
  16494. Aaz500 string `json:"aaz500"`
  16495. ActCardNo string `json:"actCardNo"`
  16496. Bab520 string `json:"bab520"`
  16497. Bkz543 string `json:"bkz543"`
  16498. BusinessType string `json:"businessType"`
  16499. CertfCodg string `json:"certfCodg"`
  16500. EcIndexNo string `json:"ecIndexNo"`
  16501. EcToken string `json:"ecToken"`
  16502. ID0000 string `json:"id0000"`
  16503. IDNo string `json:"idNo"`
  16504. IDType string `json:"idType"`
  16505. Idcode string `json:"idcode"`
  16506. IdentityToken string `json:"identity_token"`
  16507. InsuOrg string `json:"insuOrg"`
  16508. OfficeID string `json:"officeId"`
  16509. OfficeName string `json:"officeName"`
  16510. OperatorID string `json:"operatorId"`
  16511. OperatorName string `json:"operatorName"`
  16512. OrgID string `json:"orgId"`
  16513. UserName string `json:"userName"`
  16514. } `json:"data"`
  16515. Infno interface{} `json:"infno"`
  16516. Message string `json:"message"`
  16517. OrgID string `json:"orgId"`
  16518. TransType string `json:"transType"`
  16519. }
  16520. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16521. outPutInfo = Remove0000(outPutInfo)
  16522. if len(outPutInfo) > 0 {
  16523. var ele ELeData
  16524. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16525. if err != nil {
  16526. utils.ErrorLog("解析失败:%v", err)
  16527. }
  16528. token := ele.Data.EcToken
  16529. fmt.Println(inputInfo)
  16530. fmt.Println(outPutInfo)
  16531. 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)
  16532. saveLog(result, requestLog, "1101", "获取人员信息")
  16533. var dat map[string]interface{}
  16534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16535. fmt.Println(dat)
  16536. } else {
  16537. fmt.Println(err)
  16538. }
  16539. userJSONBytes, _ := json.Marshal(dat)
  16540. var res ResultTwo
  16541. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16542. utils.ErrorLog("解析失败:%v", err)
  16543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16544. return
  16545. }
  16546. res.ErrMsg = errMsgLog
  16547. if res.Infcode == 0 {
  16548. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16549. if err == gorm.ErrRecordNotFound {
  16550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16551. return
  16552. } else if err != nil {
  16553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16554. return
  16555. } else {
  16556. fmt.Println(res)
  16557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16558. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16559. infoStr := string(Iinfos)
  16560. idetinfoStr := string(Idetinfos)
  16561. psn := &models.HisPsn{
  16562. PsnNo: res.Output.Baseinfo.PsnNo,
  16563. PatientId: patient.ID,
  16564. Certno: res.Output.Baseinfo.Certno,
  16565. Gend: res.Output.Baseinfo.Gend,
  16566. Naty: res.Output.Baseinfo.Naty,
  16567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16568. PsnName: res.Output.Baseinfo.PsnName,
  16569. Idetinfo: idetinfoStr,
  16570. Insuinfo: infoStr,
  16571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16572. CardInfo: outPutInfo,
  16573. VerifyNumber: token,
  16574. InsuplcAdmdvs: ele.Data.InsuOrg,
  16575. }
  16576. service.CreateHisPsn(psn)
  16577. var rf []*ResultFive
  16578. json.Unmarshal([]byte(infoStr), &rf)
  16579. var insutypes []*ResultFive
  16580. var insutype string
  16581. var is390 int = 0
  16582. var is310 int = 0
  16583. for _, item := range rf {
  16584. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16585. insutypes = append(insutypes, item)
  16586. }
  16587. }
  16588. if len(insutypes) == 1 {
  16589. insutype = insutypes[0].Insutype
  16590. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16591. } else {
  16592. for _, i := range insutypes {
  16593. if i.Insutype == "390" {
  16594. is390 = 1
  16595. }
  16596. if i.Insutype == "310" {
  16597. is310 = 1
  16598. }
  16599. }
  16600. }
  16601. if is390 == 1 {
  16602. insutype = "390"
  16603. }
  16604. if is310 == 1 {
  16605. insutype = "310"
  16606. }
  16607. if len(insutypes) == 0 {
  16608. insutype = "310"
  16609. }
  16610. c.ServeSuccessJSON(map[string]interface{}{
  16611. "patient": patient,
  16612. "number": token,
  16613. "insutype": insutype,
  16614. })
  16615. }
  16616. } else {
  16617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16618. return
  16619. }
  16620. }
  16621. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16622. var api string
  16623. 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 +
  16624. "&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
  16625. resp, requestErr := http.Get(api)
  16626. if requestErr != nil {
  16627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16628. return
  16629. }
  16630. body, ioErr := ioutil.ReadAll(resp.Body)
  16631. if ioErr != nil {
  16632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16634. return
  16635. }
  16636. var respJSON map[string]interface{}
  16637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16640. return
  16641. }
  16642. var status string
  16643. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16644. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16645. var token string
  16646. var res ResultTwo //1101结果
  16647. var res10265 ResultTwo10265 //1101结果
  16648. if status == "0" { //读卡成功
  16649. var card_info string //卡信息
  16650. var busi_card_info string
  16651. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16652. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16653. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16654. fmt.Println(card_info)
  16655. fmt.Println(busi_card_info)
  16656. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16657. result, _ := json.Marshal(respJSON)
  16658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16659. utils.ErrorLog("解析失败:%v", err)
  16660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16661. return
  16662. }
  16663. res.ErrMsg = res10265.ErrMsg
  16664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16665. res.Infcode = infocode
  16666. res.Output = res10265.Output
  16667. res.InfRefmsgid = res10265.InfRefmsgid
  16668. if res.Infcode == 0 {
  16669. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16670. if err == gorm.ErrRecordNotFound {
  16671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16672. return
  16673. } else if err != nil {
  16674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16675. return
  16676. } else {
  16677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16679. infoStr := string(Iinfos)
  16680. idetinfoStr := string(Idetinfos)
  16681. psn := &models.HisPsn{
  16682. PsnNo: res.Output.Baseinfo.PsnNo,
  16683. PatientId: patient.ID,
  16684. Certno: res.Output.Baseinfo.Certno,
  16685. Gend: res.Output.Baseinfo.Gend,
  16686. Naty: res.Output.Baseinfo.Naty,
  16687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16688. PsnName: res.Output.Baseinfo.PsnName,
  16689. Idetinfo: idetinfoStr,
  16690. Insuinfo: infoStr,
  16691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16692. CardInfo: card_info,
  16693. VerifyNumber: token,
  16694. }
  16695. var rf []*ResultFive
  16696. json.Unmarshal([]byte(infoStr), &rf)
  16697. var insutypes []*ResultFive
  16698. var insutype string
  16699. var is390 int = 0
  16700. var is310 int = 0
  16701. for _, item := range rf {
  16702. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16703. insutypes = append(insutypes, item)
  16704. }
  16705. }
  16706. if len(insutypes) == 1 {
  16707. insutype = insutypes[0].Insutype
  16708. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16709. } else {
  16710. for _, i := range insutypes {
  16711. if i.Insutype == "390" {
  16712. is390 = 1
  16713. }
  16714. if i.Insutype == "310" {
  16715. is310 = 1
  16716. }
  16717. }
  16718. }
  16719. if is390 == 1 {
  16720. insutype = "390"
  16721. }
  16722. if is310 == 1 {
  16723. insutype = "310"
  16724. }
  16725. if len(insutypes) == 0 {
  16726. insutype = "310"
  16727. }
  16728. service.CreateHisPsn(psn)
  16729. c.ServeSuccessJSON(map[string]interface{}{
  16730. "patient": patient,
  16731. "number": token,
  16732. "insutype": insutype,
  16733. })
  16734. }
  16735. } else {
  16736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16737. return
  16738. }
  16739. } else { //读卡失败
  16740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16741. return
  16742. }
  16743. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16744. res := c.GetoleInfo()
  16745. if res.Infcode == 0 {
  16746. var result string
  16747. if res.Output.MdtrtCertType == "01" {
  16748. 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)
  16749. } else if res.Output.MdtrtCertType == "02" {
  16750. 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)
  16751. } else if res.Output.MdtrtCertType == "03" {
  16752. 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)
  16753. }
  16754. var dat map[string]interface{}
  16755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16756. fmt.Println(dat)
  16757. } else {
  16758. fmt.Println(err)
  16759. }
  16760. userJSONBytes, _ := json.Marshal(dat)
  16761. var res2 ResultTwo
  16762. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16763. utils.ErrorLog("解析失败:%v", err)
  16764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16765. return
  16766. }
  16767. if res2.Infcode == 0 {
  16768. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16769. if err == gorm.ErrRecordNotFound {
  16770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16771. return
  16772. } else if err != nil {
  16773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16774. return
  16775. } else {
  16776. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16777. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16778. infoStr := string(Iinfos)
  16779. idetinfoStr := string(Idetinfos)
  16780. var rf []*ResultFive
  16781. json.Unmarshal([]byte(infoStr), &rf)
  16782. var insutypes []*ResultFive
  16783. var insutype string
  16784. var is390 int = 0
  16785. var is310 int = 0
  16786. //var insuplc_admdvs string
  16787. for _, item := range rf {
  16788. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16789. insutypes = append(insutypes, item)
  16790. }
  16791. }
  16792. if len(insutypes) == 1 {
  16793. insutype = insutypes[0].Insutype
  16794. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16795. } else {
  16796. for _, i := range insutypes {
  16797. if i.Insutype == "390" {
  16798. is390 = 1
  16799. }
  16800. if i.Insutype == "310" {
  16801. is310 = 1
  16802. }
  16803. }
  16804. }
  16805. if is390 == 1 {
  16806. insutype = "390"
  16807. }
  16808. if is310 == 1 {
  16809. insutype = "310"
  16810. }
  16811. if len(insutypes) == 0 {
  16812. insutype = "310"
  16813. }
  16814. psn := &models.HisPsn{
  16815. PsnNo: res2.Output.Baseinfo.PsnNo,
  16816. PatientId: patient.ID,
  16817. Certno: res2.Output.Baseinfo.Certno,
  16818. Gend: res2.Output.Baseinfo.Gend,
  16819. Naty: res2.Output.Baseinfo.Naty,
  16820. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16821. PsnName: res2.Output.Baseinfo.PsnName,
  16822. Idetinfo: idetinfoStr,
  16823. Insuinfo: infoStr,
  16824. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16825. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16826. VerifyNumber: res.Output.EcToken,
  16827. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16828. }
  16829. if res.Output.MdtrtCertType == "01" {
  16830. psn.VerifyNumber = res.Output.EcToken
  16831. //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)
  16832. } else if res.Output.MdtrtCertType == "02" {
  16833. psn.VerifyNumber = res.Output.CardNo
  16834. //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)
  16835. } else if res.Output.MdtrtCertType == "03" {
  16836. psn.VerifyNumber = res.Output.MdtrtCertNo
  16837. //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)
  16838. }
  16839. service.CreateHisPsn(psn)
  16840. var balc float64
  16841. for _, item := range rf {
  16842. if item.Insutype == insutype {
  16843. balc = item.Balc
  16844. }
  16845. }
  16846. c.ServeSuccessJSON(map[string]interface{}{
  16847. "patient": patient,
  16848. "number": res.Output.CardNo,
  16849. "insutype": insutype,
  16850. "blac": balc,
  16851. "desc": idetinfoStr,
  16852. })
  16853. }
  16854. } else {
  16855. c.ServeSuccessJSON(map[string]interface{}{
  16856. "failed_code": -10,
  16857. "msg": res2.ErrMsg,
  16858. })
  16859. }
  16860. } else {
  16861. c.ServeSuccessJSON(map[string]interface{}{
  16862. "failed_code": -10,
  16863. "msg": res.ErrMsg,
  16864. })
  16865. }
  16866. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16867. var res ResultTwo
  16868. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16869. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16870. "&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)
  16871. resp, requestErr := http.Get(api)
  16872. if requestErr != nil {
  16873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16874. return
  16875. }
  16876. body, ioErr := ioutil.ReadAll(resp.Body)
  16877. if ioErr != nil {
  16878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16880. return
  16881. }
  16882. var respJSON map[string]interface{}
  16883. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16886. return
  16887. }
  16888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16889. result, _ := json.Marshal(respJSON)
  16890. fmt.Println("log")
  16891. fmt.Println(string(result))
  16892. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16893. utils.ErrorLog("解析失败:%v", err)
  16894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16895. return
  16896. }
  16897. if res.Infcode == 0 {
  16898. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16899. if err == gorm.ErrRecordNotFound {
  16900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16901. return
  16902. } else if err != nil {
  16903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16904. return
  16905. } else {
  16906. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16907. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16908. infoStr := string(Iinfos)
  16909. idetinfoStr := string(Idetinfos)
  16910. var rf []*ResultFive
  16911. json.Unmarshal([]byte(infoStr), &rf)
  16912. var insutypes []*ResultFive
  16913. var insutype string
  16914. var is390 int = 0
  16915. var is310 int = 0
  16916. for _, item := range rf {
  16917. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16918. insutypes = append(insutypes, item)
  16919. }
  16920. }
  16921. if len(insutypes) == 1 {
  16922. insutype = insutypes[0].Insutype
  16923. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16924. } else {
  16925. for _, i := range insutypes {
  16926. if i.Insutype == "390" {
  16927. is390 = 1
  16928. }
  16929. if i.Insutype == "310" {
  16930. is310 = 1
  16931. }
  16932. }
  16933. }
  16934. if is390 == 1 {
  16935. insutype = "390"
  16936. }
  16937. if is310 == 1 {
  16938. insutype = "310"
  16939. }
  16940. if len(insutypes) == 0 {
  16941. insutype = "390"
  16942. }
  16943. var insuplc_admdvs string
  16944. for _, item := range rf {
  16945. if item.Insutype == insutype {
  16946. insuplc_admdvs = item.InsuplcAdmdvs
  16947. }
  16948. }
  16949. psn := &models.HisPsn{
  16950. PsnNo: res.Output.Baseinfo.PsnNo,
  16951. PatientId: patient.ID,
  16952. Certno: res.Output.Baseinfo.Certno,
  16953. Gend: res.Output.Baseinfo.Gend,
  16954. Naty: res.Output.Baseinfo.Naty,
  16955. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16956. PsnName: res.Output.Baseinfo.PsnName,
  16957. Idetinfo: idetinfoStr,
  16958. Insuinfo: infoStr,
  16959. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16960. InsuplcAdmdvs: insuplc_admdvs,
  16961. }
  16962. service.CreateHisPsn(psn)
  16963. c.ServeSuccessJSON(map[string]interface{}{
  16964. "patient": patient,
  16965. "number": res.Output.Baseinfo.Certno,
  16966. })
  16967. }
  16968. } else {
  16969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16970. return
  16971. }
  16972. } else {
  16973. type ELeData struct {
  16974. Code string `json:"code"`
  16975. Data struct {
  16976. Aac002 string `json:"aac002"`
  16977. Aaz500 string `json:"aaz500"`
  16978. ActCardNo string `json:"actCardNo"`
  16979. Bab520 string `json:"bab520"`
  16980. Bkz543 string `json:"bkz543"`
  16981. BusinessType string `json:"businessType"`
  16982. CertfCodg string `json:"certfCodg"`
  16983. EcIndexNo string `json:"ecIndexNo"`
  16984. EcToken string `json:"ecToken"`
  16985. ID0000 string `json:"id0000"`
  16986. IDNo string `json:"idNo"`
  16987. IDType string `json:"idType"`
  16988. Idcode string `json:"idcode"`
  16989. IdentityToken string `json:"identity_token"`
  16990. InsuOrg string `json:"insuOrg"`
  16991. OfficeID string `json:"officeId"`
  16992. OfficeName string `json:"officeName"`
  16993. OperatorID string `json:"operatorId"`
  16994. OperatorName string `json:"operatorName"`
  16995. OrgID string `json:"orgId"`
  16996. UserName string `json:"userName"`
  16997. } `json:"data"`
  16998. Infno interface{} `json:"infno"`
  16999. Message string `json:"message"`
  17000. OrgID string `json:"orgId"`
  17001. TransType string `json:"transType"`
  17002. }
  17003. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17004. fmt.Println(result)
  17005. outPutInfo := Remove0000(result)
  17006. fmt.Println(outPutInfo)
  17007. if len(outPutInfo) > 0 {
  17008. var ele ELeData
  17009. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17010. if err != nil {
  17011. utils.ErrorLog("解析失败:%v", err)
  17012. }
  17013. token := ele.Data.EcToken
  17014. fmt.Println(outPutInfo)
  17015. 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)
  17016. saveLog(result, requestLog, "1101", "获取人员信息")
  17017. var dat map[string]interface{}
  17018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17019. fmt.Println(dat)
  17020. } else {
  17021. fmt.Println(err)
  17022. }
  17023. userJSONBytes, _ := json.Marshal(dat)
  17024. var res ResultTwo
  17025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17026. utils.ErrorLog("解析失败:%v", err)
  17027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17028. return
  17029. }
  17030. if res.Infcode == 0 {
  17031. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17032. if err == gorm.ErrRecordNotFound {
  17033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17034. return
  17035. } else if err != nil {
  17036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17037. return
  17038. } else {
  17039. fmt.Println(res)
  17040. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17041. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17042. infoStr := string(Iinfos)
  17043. idetinfoStr := string(Idetinfos)
  17044. psn := &models.HisPsn{
  17045. PsnNo: res.Output.Baseinfo.PsnNo,
  17046. PatientId: patient.ID,
  17047. Certno: res.Output.Baseinfo.Certno,
  17048. Gend: res.Output.Baseinfo.Gend,
  17049. Naty: res.Output.Baseinfo.Naty,
  17050. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17051. PsnName: res.Output.Baseinfo.PsnName,
  17052. Idetinfo: idetinfoStr,
  17053. Insuinfo: infoStr,
  17054. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17055. CardInfo: outPutInfo,
  17056. VerifyNumber: token,
  17057. InsuplcAdmdvs: ele.Data.InsuOrg,
  17058. }
  17059. service.CreateHisPsn(psn)
  17060. var rf []*ResultFive
  17061. json.Unmarshal([]byte(infoStr), &rf)
  17062. var insutypes []*ResultFive
  17063. var insutype string
  17064. var is390 int = 0
  17065. var is310 int = 0
  17066. for _, item := range rf {
  17067. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17068. insutypes = append(insutypes, item)
  17069. }
  17070. }
  17071. if len(insutypes) == 1 {
  17072. insutype = insutypes[0].Insutype
  17073. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17074. } else {
  17075. for _, i := range insutypes {
  17076. if i.Insutype == "390" {
  17077. is390 = 1
  17078. }
  17079. if i.Insutype == "310" {
  17080. is310 = 1
  17081. }
  17082. }
  17083. }
  17084. if is390 == 1 {
  17085. insutype = "390"
  17086. }
  17087. if is310 == 1 {
  17088. insutype = "310"
  17089. }
  17090. if len(insutypes) == 0 {
  17091. insutype = "310"
  17092. }
  17093. c.ServeSuccessJSON(map[string]interface{}{
  17094. "patient": patient,
  17095. "number": token,
  17096. "insutype": insutype,
  17097. })
  17098. }
  17099. } else {
  17100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17101. return
  17102. }
  17103. }
  17104. //fmt.Println(result)
  17105. //
  17106. //if initFlag == 0 {
  17107. // c.TestGetBasBaseInit()
  17108. //}
  17109. //token := c.GetEleBaseInfo()
  17110. //
  17111. //token = Remove0000(token)
  17112. //
  17113. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17114. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17115. ////
  17116. //var res ResultTwo
  17117. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17118. // utils.ErrorLog("解析失败:%v", err)
  17119. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17120. // return
  17121. //}
  17122. //
  17123. //if res.Infcode == 0 {
  17124. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17125. // if err == gorm.ErrRecordNotFound {
  17126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17127. // return
  17128. // } else if err != nil {
  17129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17130. // return
  17131. //
  17132. // } else {
  17133. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17134. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17135. // infoStr := string(Iinfos)
  17136. // idetinfoStr := string(Idetinfos)
  17137. //
  17138. //
  17139. //
  17140. //
  17141. // var rf []*ResultFive
  17142. // json.Unmarshal([]byte(infoStr), &rf)
  17143. //
  17144. // var insutypes []*ResultFive
  17145. // var insutype string
  17146. // var is390 int = 0
  17147. // var is310 int = 0
  17148. // var insuplc_admdvs string
  17149. //
  17150. // for _, item := range rf {
  17151. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17152. // insutypes = append(insutypes, item)
  17153. // }
  17154. // }
  17155. //
  17156. // if len(insutypes) == 1 {
  17157. // insutype = insutypes[0].Insutype
  17158. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17159. // } else {
  17160. // for _, i := range insutypes {
  17161. // if i.Insutype == "390" {
  17162. // is390 = 1
  17163. // }
  17164. //
  17165. // if i.Insutype == "310" {
  17166. // is310 = 1
  17167. // }
  17168. // }
  17169. // }
  17170. // if is390 == 1 {
  17171. // insutype = "390"
  17172. // }
  17173. //
  17174. // if is310 == 1 {
  17175. // insutype = "310"
  17176. // }
  17177. // if len(insutypes) == 0 {
  17178. // insutype = "310"
  17179. // }
  17180. // for _, item := range rf {
  17181. // if item.Insutype == insutype {
  17182. // insuplc_admdvs = item.InsuplcAdmdvs
  17183. // }
  17184. // }
  17185. // psn := &models.HisPsn{
  17186. // PsnNo: res.Output.Baseinfo.PsnNo,
  17187. // Age: res.Output.Baseinfo.Age,
  17188. // PatientId: patient.ID,
  17189. // Certno: res.Output.Baseinfo.Certno,
  17190. // Brdy: res.Output.Baseinfo.Brdy,
  17191. // Gend: res.Output.Baseinfo.Gend,
  17192. // Naty: res.Output.Baseinfo.Naty,
  17193. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17194. // PsnName: res.Output.Baseinfo.PsnName,
  17195. // Idetinfo: idetinfoStr,
  17196. // Insuinfo: infoStr,
  17197. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17198. // CardInfo: "",
  17199. // VerifyNumber: token,
  17200. // InsuplcAdmdvs: insuplc_admdvs,
  17201. // }
  17202. // service.CreateHisPsn(psn)
  17203. //
  17204. // c.ServeSuccessJSON(map[string]interface{}{
  17205. // "patient": patient,
  17206. // "number": token,
  17207. // })
  17208. // }
  17209. //} else {
  17210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17211. // return
  17212. //}
  17213. }
  17214. break
  17215. case 5:
  17216. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17217. var api string
  17218. if miConfig.MdtrtareaAdmvs == "320921" {
  17219. 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 +
  17220. "&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
  17221. fmt.Println(api)
  17222. } else {
  17223. 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 +
  17224. "&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)
  17225. }
  17226. resp, requestErr := http.Get(api)
  17227. if requestErr != nil {
  17228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17229. return
  17230. }
  17231. body, ioErr := ioutil.ReadAll(resp.Body)
  17232. if ioErr != nil {
  17233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17235. return
  17236. }
  17237. var respJSON map[string]interface{}
  17238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17241. return
  17242. }
  17243. var status string
  17244. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17245. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17246. var token string
  17247. var res ResultTwo //1101结果
  17248. var res10265 ResultTwo10265 //1101结果
  17249. if status == "0" { //读卡成功
  17250. var card_info string //卡信息
  17251. //var busi_card_info string
  17252. var auth_info string
  17253. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17254. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17255. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17256. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17257. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17258. result, _ := json.Marshal(respJSON)
  17259. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17260. utils.ErrorLog("解析失败:%v", err)
  17261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17262. return
  17263. }
  17264. res.ErrMsg = res10265.ErrMsg
  17265. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17266. res.Infcode = infocode
  17267. res.Output = res10265.Output
  17268. res.InfRefmsgid = res10265.InfRefmsgid
  17269. if res.Infcode == 0 {
  17270. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17271. if err == gorm.ErrRecordNotFound {
  17272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17273. return
  17274. } else if err != nil {
  17275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17276. return
  17277. } else {
  17278. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17279. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17280. infoStr := string(Iinfos)
  17281. idetinfoStr := string(Idetinfos)
  17282. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17283. psn := &models.HisPsn{
  17284. PsnNo: res.Output.Baseinfo.PsnNo,
  17285. PatientId: patient.ID,
  17286. Certno: res.Output.Baseinfo.Certno,
  17287. Gend: res.Output.Baseinfo.Gend,
  17288. Brdy: b,
  17289. Age: float64(age),
  17290. Naty: res.Output.Baseinfo.Naty,
  17291. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17292. PsnName: res.Output.Baseinfo.PsnName,
  17293. Idetinfo: idetinfoStr,
  17294. Insuinfo: infoStr,
  17295. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17296. CardInfo: card_info,
  17297. VerifyNumber: token,
  17298. AuthInfo: auth_info,
  17299. }
  17300. var rf []*ResultFive
  17301. json.Unmarshal([]byte(infoStr), &rf)
  17302. var insutypes []*ResultFive
  17303. var insutype string
  17304. var is390 int = 0
  17305. var is310 int = 0
  17306. for _, item := range rf {
  17307. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17308. insutypes = append(insutypes, item)
  17309. }
  17310. }
  17311. if len(insutypes) == 1 {
  17312. insutype = insutypes[0].Insutype
  17313. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17314. } else {
  17315. for _, i := range insutypes {
  17316. if i.Insutype == "390" {
  17317. is390 = 1
  17318. }
  17319. if i.Insutype == "310" {
  17320. is310 = 1
  17321. }
  17322. }
  17323. }
  17324. if is390 == 1 {
  17325. insutype = "390"
  17326. }
  17327. if is310 == 1 {
  17328. insutype = "310"
  17329. }
  17330. if len(insutypes) == 0 {
  17331. insutype = "310"
  17332. }
  17333. service.CreateHisPsn(psn)
  17334. c.ServeSuccessJSON(map[string]interface{}{
  17335. "patient": patient,
  17336. "number": token,
  17337. "insutype": insutype,
  17338. })
  17339. }
  17340. } else {
  17341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17342. return
  17343. }
  17344. } else { //读卡失败
  17345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17346. return
  17347. }
  17348. }
  17349. break
  17350. }
  17351. }
  17352. var initFlag int64 = 0
  17353. var initEleFlag int64 = 0
  17354. func (c *HisApiController) TestGetBasBaseInit() {
  17355. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17356. Iinit := DllDef.MustFindProc("Init")
  17357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17358. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17359. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17360. if ret != 0 {
  17361. fmt.Println("SSCard的报错原因:", err)
  17362. fmt.Println("SSCard的运算结果为:", ret)
  17363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17364. return
  17365. }
  17366. result := int(ret)
  17367. fmt.Println("SSCard的运算结果为1:", result)
  17368. initFlag = 1
  17369. return
  17370. }
  17371. func (c *HisApiController) HandleJiangXiReadCard() {
  17372. fmt.Println("~~~~~~")
  17373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17374. admin_user_id, _ := c.GetInt64("admin_user_id")
  17375. id_card_type, _ := c.GetInt64("id_card_type")
  17376. //certificates, _ := c.GetInt64("certificates")
  17377. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17378. if initFlag == 0 {
  17379. c.TestGetJiangXiBasBaseInit()
  17380. }
  17381. basStr := c.GetBasBaseInfo()
  17382. if len(basStr) == 0 {
  17383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17384. return
  17385. }
  17386. fmt.Println(basStr)
  17387. bas := strings.Split(basStr, "|")
  17388. basNumber := bas[1]
  17389. fmt.Println(basNumber)
  17390. card_sn := bas[3]
  17391. fmt.Println(card_sn)
  17392. 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, "")
  17393. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17394. var dat map[string]interface{}
  17395. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17396. fmt.Println(dat)
  17397. } else {
  17398. fmt.Println(err)
  17399. }
  17400. userJSONBytes, _ := json.Marshal(dat)
  17401. var res ResultTwo
  17402. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17403. utils.ErrorLog("解析失败:%v", err)
  17404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17405. return
  17406. }
  17407. if res.Infcode == 0 {
  17408. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17409. if err == gorm.ErrRecordNotFound {
  17410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17411. return
  17412. } else if err != nil {
  17413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17414. return
  17415. } else {
  17416. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17417. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17418. infoStr := string(Iinfos)
  17419. idetinfoStr := string(Idetinfos)
  17420. psn := &models.HisPsn{
  17421. PsnNo: res.Output.Baseinfo.PsnNo,
  17422. PatientId: patient.ID,
  17423. Certno: res.Output.Baseinfo.Certno,
  17424. Gend: res.Output.Baseinfo.Gend,
  17425. Naty: res.Output.Baseinfo.Naty,
  17426. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17427. PsnName: res.Output.Baseinfo.PsnName,
  17428. Idetinfo: idetinfoStr,
  17429. Insuinfo: infoStr,
  17430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17431. CardInfo: basStr,
  17432. VerifyNumber: "",
  17433. }
  17434. service.CreateHisPsn(psn)
  17435. c.ServeSuccessJSON(map[string]interface{}{
  17436. "patient": patient,
  17437. "number": basNumber,
  17438. })
  17439. }
  17440. } else {
  17441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17442. return
  17443. }
  17444. }
  17445. func (c *HisApiController) TestGetHnBasBaseInit() {
  17446. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17447. Iinit := DllDef.MustFindProc("Init")
  17448. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17449. //http://10.77.211.236/CSB/hsa-fsi-1303
  17450. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17451. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17452. // 调用 Init 函数
  17453. 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"))))
  17454. //if ret != 0 {
  17455. fmt.Println("SSCard的报错原因:", err)
  17456. fmt.Println("SSCard的运算结果为:", ret)
  17457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17458. // return
  17459. //}
  17460. result := int(ret)
  17461. fmt.Println("SSCard的运算结果为1:", result)
  17462. initFlag = 1
  17463. return
  17464. }
  17465. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17466. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17467. Iinit := DllDef.MustFindProc("Init")
  17468. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17469. //http://10.77.211.236/CSB/hsa-fsi-1303
  17470. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17471. if ret != 0 {
  17472. fmt.Println("SSCard的报错原因:", err)
  17473. fmt.Println("SSCard的运算结果为:", ret)
  17474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17475. return
  17476. }
  17477. result := int(ret)
  17478. fmt.Println("SSCard的运算结果为1:", result)
  17479. initFlag = 1
  17480. return
  17481. }
  17482. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17483. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17484. Iinit := DllDef.MustFindProc("Init")
  17485. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17486. //http://10.77.211.236/CSB/hsa-fsi-1303
  17487. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17488. if ret != 0 {
  17489. fmt.Println("SSCard的报错原因:", err)
  17490. fmt.Println("SSCard的运算结果为:", ret)
  17491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17492. return
  17493. }
  17494. result := int(ret)
  17495. fmt.Println("SSCard的运算结果为1:", result)
  17496. initFlag = 1
  17497. return
  17498. }
  17499. func (c *HisApiController) GetSFZBaseInfo() string {
  17500. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17501. readCard := DllDef.MustFindProc("ReadSFZ")
  17502. if readCard == nil {
  17503. fmt.Println("readcard is nil")
  17504. readCard = DllDef.MustFindProc("ReadSFZ")
  17505. }
  17506. str := make([]byte, 8096)
  17507. str1 := make([]byte, 8096)
  17508. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17509. fmt.Println(r)
  17510. return Remove0000(string(str))
  17511. }
  17512. func (c *HisApiController) GetEleBaseInfo() string {
  17513. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17514. readCard := DllDef.MustFindProc("GetQRBase")
  17515. fmt.Println(readCard)
  17516. if readCard == nil {
  17517. fmt.Println("readcard is nil")
  17518. readCard = DllDef.MustFindProc("GetQRBase")
  17519. }
  17520. str := make([]byte, 1024)
  17521. str1 := make([]byte, 1024)
  17522. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17523. fmt.Println(ret2)
  17524. fmt.Println(string(str1))
  17525. fmt.Println(string(str))
  17526. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17527. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17528. if ret2 != 0 {
  17529. return ""
  17530. }
  17531. return string(str)
  17532. }
  17533. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17534. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17535. readCard := DllDef.MustFindProc("NationEcTrans")
  17536. fmt.Println(readCard)
  17537. fmt.Println("!!!!!")
  17538. pBusiCardInfo := make([]byte, 2048)
  17539. input := make(map[string]interface{})
  17540. inputData := make(map[string]interface{})
  17541. inputData["orgId"] = code
  17542. inputData["businessType"] = "01101"
  17543. inputData["operatorId"] = "1"
  17544. inputData["operatorName"] = "admin"
  17545. inputData["officeId"] = "001"
  17546. inputData["officeName"] = "血透室"
  17547. inputData["deviceType"] = ""
  17548. input["data"] = inputData
  17549. input["orgId"] = code
  17550. input["transType"] = "ec.query"
  17551. bytesData, _ := json.Marshal(input)
  17552. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17553. fmt.Println(ret2)
  17554. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17555. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17556. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17557. }
  17558. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17559. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17560. readCard := DllDef.MustFindProc("NationEcTrans")
  17561. fmt.Println(readCard)
  17562. fmt.Println("!!!!!")
  17563. pBusiCardInfo := make([]byte, 2048)
  17564. input := make(map[string]interface{})
  17565. inputData := make(map[string]interface{})
  17566. inputData["orgId"] = code
  17567. inputData["businessType"] = "01101"
  17568. inputData["operatorId"] = "9"
  17569. inputData["operatorName"] = "admin"
  17570. inputData["officeId"] = "001"
  17571. inputData["officeName"] = "血透室"
  17572. inputData["deviceType"] = ""
  17573. input["data"] = inputData
  17574. input["orgId"] = code
  17575. input["transType"] = "ec.query"
  17576. bytesData, _ := json.Marshal(input)
  17577. 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])))
  17578. fmt.Println(ret2)
  17579. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17580. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17581. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17582. }
  17583. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17584. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17585. readCard := DllDef.MustFindProc("NationEcTrans")
  17586. fmt.Println(readCard)
  17587. fmt.Println("!!!!!")
  17588. pBusiCardInfo := make([]byte, 2048)
  17589. input := make(map[string]interface{})
  17590. inputData := make(map[string]interface{})
  17591. inputData["orgId"] = code
  17592. inputData["businessType"] = "01301"
  17593. inputData["operatorId"] = "9"
  17594. inputData["operatorName"] = "admin"
  17595. inputData["officeId"] = "001"
  17596. inputData["officeName"] = "血透室"
  17597. inputData["deviceType"] = ""
  17598. input["data"] = inputData
  17599. input["orgId"] = code
  17600. input["transType"] = "ec.query"
  17601. bytesData, _ := json.Marshal(input)
  17602. 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])))
  17603. fmt.Println(ret2)
  17604. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17605. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17606. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17607. }
  17608. func GetJxEleBaseInfo(org_id int64) string {
  17609. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17610. readCard := DllDef.MustFindProc("NationEcTrans")
  17611. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17612. if readCard == nil {
  17613. fmt.Println("readcard is nil")
  17614. readCard = DllDef.MustFindProc("NationEcTrans")
  17615. }
  17616. str1 := make([]byte, 1024)
  17617. data := make(map[string]interface{})
  17618. inputData := make(map[string]interface{})
  17619. inputData["orgId"] = miConfig.Code
  17620. inputData["businessType"] = "01101"
  17621. inputData["operatorId"] = "test001"
  17622. inputData["operatorName"] = "cn"
  17623. inputData["officeId"] = "32760"
  17624. inputData["officeName"] = "waike"
  17625. inputData["deviceType"] = ""
  17626. data["data"] = inputData
  17627. data["transType"] = "ec.query"
  17628. data["extra "] = ""
  17629. data["orgId"] = miConfig.Code
  17630. bytesData, _ := json.Marshal(data)
  17631. //bytesData, _ := json.Marshal(data)
  17632. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17633. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17634. fmt.Println(ret2)
  17635. fmt.Println(string(str1))
  17636. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17637. if ret2 != 0 {
  17638. return ""
  17639. }
  17640. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17641. }
  17642. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17643. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17644. // readCard := DllDef.MustFindProc("NationEcTrans")
  17645. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17646. //
  17647. // if readCard == nil {
  17648. // fmt.Println("readcard is nil")
  17649. // readCard = DllDef.MustFindProc("NationEcTrans")
  17650. // }
  17651. // str1 := make([]byte, 1024)
  17652. //
  17653. // data := make(map[string]interface{})
  17654. //
  17655. // inputData := make(map[string]interface{})
  17656. // inputData["orgId"] = miConfig.Code
  17657. // inputData["businessType"] = "01101"
  17658. // inputData["operatorId"] = "test001"
  17659. // inputData["operatorName"] = "cn"
  17660. // inputData["officeId"] = "32760"
  17661. // inputData["officeName"] = "waike"
  17662. // inputData["deviceType"] = ""
  17663. //
  17664. // data["data"] = inputData
  17665. // data["transType"] = "ec.query"
  17666. // data["extra "] = ""
  17667. // data["orgId"] = miConfig.Code
  17668. // bytesData, _ := json.Marshal(data)
  17669. // //bytesData, _ := json.Marshal(data)
  17670. //
  17671. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17672. //
  17673. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17674. // fmt.Println(ret2)
  17675. // fmt.Println(string(str1))
  17676. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17677. //
  17678. // if ret2 != 0 {
  17679. // return ""
  17680. // }
  17681. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17682. //}
  17683. func GetJxEleBaseInitInfo(org_id int64) string {
  17684. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17685. readCard := DllDef.MustFindProc("NationEcTrans")
  17686. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17687. if readCard == nil {
  17688. fmt.Println("readcard is nil")
  17689. readCard = DllDef.MustFindProc("NationEcTrans")
  17690. }
  17691. str1 := make([]byte, 2048)
  17692. data := make(map[string]interface{})
  17693. inputData := make(map[string]interface{})
  17694. inputData["orgId"] = miConfig.Code
  17695. inputData["businessType"] = "01101"
  17696. inputData["operatorId"] = "1"
  17697. inputData["operatorName"] = "huangchuang"
  17698. inputData["officeId"] = "101"
  17699. inputData["officeName"] = "xuetou"
  17700. inputData["deviceType"] = ""
  17701. data["data"] = inputData
  17702. data["transType"] = "ec.query"
  17703. data["orgId"] = miConfig.Code
  17704. bytesData, _ := json.Marshal(data)
  17705. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17706. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17707. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17708. fmt.Println(ret2)
  17709. fmt.Println(string(str1))
  17710. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17711. if ret2 != 0 {
  17712. return ""
  17713. }
  17714. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17715. initEleFlag = 1
  17716. }
  17717. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17718. }
  17719. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17720. // // 构建命令
  17721. // cmd := exec.Command("python", "b.py")
  17722. //
  17723. // // 执行命令并等待完成
  17724. // output, err := cmd.CombinedOutput()
  17725. // if err != nil {
  17726. // fmt.Println("Error executing Python script:", err)
  17727. // return
  17728. // }
  17729. //
  17730. // // 打印Python脚本的输出
  17731. // fmt.Println(string(output))
  17732. //}
  17733. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17734. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17735. readCard := DllDef.MustFindProc("gxyb_call")
  17736. if readCard == nil {
  17737. fmt.Println("readcard is nil")
  17738. readCard = DllDef.MustFindProc("gxyb_call")
  17739. }
  17740. str := make([]byte, 1024)
  17741. str1 := make([]byte, 1024)
  17742. //data := make(map[string]interface{})
  17743. currentTime := time.Now()
  17744. // 格式化时间为 "YYYYMMDDHH24MISS"
  17745. formattedTime := currentTime.Format("20060102150405")
  17746. inputData := make(map[string]interface{})
  17747. inputData2 := make(map[string]interface{})
  17748. inputData["transNo"] = "1401"
  17749. inputData["transType"] = "passwordCheck"
  17750. inputData["timestamp"] = formattedTime
  17751. inputData2["fixmedinsCode"] = code
  17752. inputData2["psnNo"] = ""
  17753. inputData["data"] = inputData2
  17754. jsonBytes, err := json.Marshal(inputData)
  17755. if err != nil {
  17756. fmt.Println("Error encoding map to JSON:", err)
  17757. }
  17758. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17759. fmt.Println(string(str1))
  17760. fmt.Println(string(str))
  17761. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17762. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17763. if ret2 != 0 {
  17764. return ""
  17765. }
  17766. return string(str)
  17767. }
  17768. func (c *HisApiController) GetoleInfo() Response {
  17769. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17770. defer ole.CoUninitialize()
  17771. // Replace with the ProgID or CLSID of your COM object
  17772. progID := "YinHai.XJ.Actual.Interface.New"
  17773. // Create COM object
  17774. unknown, err := oleutil.CreateObject(progID)
  17775. if err != nil {
  17776. fmt.Println("Unable to create COM object:", err)
  17777. }
  17778. defer unknown.Release()
  17779. // Query for the IDispatch interface
  17780. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17781. if err != nil {
  17782. fmt.Println("Unable to get IDispatch interface:", err)
  17783. }
  17784. defer dispatch.Release()
  17785. // Prepare parameters
  17786. transNo := "1401"
  17787. transType := "passwordCheck"
  17788. timestamp := time.Now().Unix()
  17789. fixmedinsCode := "H45072101171"
  17790. psnNo := ""
  17791. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17792. result2 := ""
  17793. // Call COM object's method using the IDispatch interface
  17794. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17795. fmt.Println(resulr)
  17796. fmt.Println(result2)
  17797. if err != nil {
  17798. fmt.Println("调用COM对象方法失败:", err)
  17799. }
  17800. var response Response
  17801. err2 := json.Unmarshal([]byte(result2), &response)
  17802. if err2 != nil {
  17803. fmt.Println("解析JSON失败:", err)
  17804. }
  17805. return response
  17806. }
  17807. func (c *HisApiController) GetBasBaseInfo() string {
  17808. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17809. readCard := DllDef.MustFindProc("ReadCardBas")
  17810. if readCard == nil {
  17811. fmt.Println("readcard is nil")
  17812. readCard = DllDef.MustFindProc("ReadCardBas")
  17813. }
  17814. str := make([]byte, 1024)
  17815. str1 := make([]byte, 1024)
  17816. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17817. fmt.Println(string(str1))
  17818. fmt.Println(string(str))
  17819. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17820. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17821. if ret2 != 0 {
  17822. return ""
  17823. }
  17824. return string(str)
  17825. }
  17826. type Program struct {
  17827. FunctionID string `xml:"function_id"`
  17828. CardInfo string `xml:"cardinfo"`
  17829. User string `xml:"user"`
  17830. }
  17831. func (c *HisApiController) GetBasBaseInfo1111() string {
  17832. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17833. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17834. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17835. if readCard == nil {
  17836. fmt.Println("readcard is nil")
  17837. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17838. }
  17839. if readCard2 == nil {
  17840. fmt.Println("readcard is nil")
  17841. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17842. }
  17843. str := make([]byte, 1024)
  17844. str1 := make([]byte, 1024)
  17845. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17846. str3 := make([]byte, 1024)
  17847. str4 := make([]byte, 1024)
  17848. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17849. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17850. //if err != nil {
  17851. // fmt.Println("Error opening file:", err)
  17852. //}
  17853. //defer file.Close()
  17854. //
  17855. //var lastProgram Program
  17856. //scanner := bufio.NewScanner(file)
  17857. //inProgram := false
  17858. //
  17859. //for scanner.Scan() {
  17860. // line := scanner.Text()
  17861. // if strings.Contains(line, "<program>") {
  17862. // inProgram = true
  17863. // programXML := "<program>"
  17864. // for scanner.Scan() {
  17865. // line = scanner.Text()
  17866. // programXML += line
  17867. // if strings.Contains(line, "</program>") {
  17868. // programXML += "</program>"
  17869. // break
  17870. // }
  17871. // }
  17872. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17873. // // 解析成功,更新最后的 Program
  17874. // }
  17875. // inProgram = false
  17876. // }
  17877. //}
  17878. //
  17879. // fmt.Println("Error reading file:", inProgram)
  17880. //
  17881. //if err := scanner.Err(); err != nil {
  17882. // fmt.Println("Error reading file:", err)
  17883. //}
  17884. // 输出最后一次的 Program
  17885. //fmt.Printf("最后一次的 <program>:\n")
  17886. //fmt.Printf("<program>\n")
  17887. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17888. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17889. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17890. //fmt.Printf("</program>\n")
  17891. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17892. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17893. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17894. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17895. return ConvertToString(string(str), "gbk", "utf-8")
  17896. }
  17897. func (c *HisApiController) GetBasBaseInfo22222() string {
  17898. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17899. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17900. if readCard == nil {
  17901. fmt.Println("readcard is nil")
  17902. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17903. }
  17904. str := make([]byte, 1024)
  17905. str1 := make([]byte, 1024)
  17906. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17907. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17908. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17909. //if err != nil {
  17910. // fmt.Println("Error opening file:", err)
  17911. //}
  17912. //defer file.Close()
  17913. //
  17914. //var lastProgram Program
  17915. //scanner := bufio.NewScanner(file)
  17916. //inProgram := false
  17917. //
  17918. //for scanner.Scan() {
  17919. // line := scanner.Text()
  17920. // if strings.Contains(line, "<program>") {
  17921. // inProgram = true
  17922. // programXML := "<program>"
  17923. // for scanner.Scan() {
  17924. // line = scanner.Text()
  17925. // programXML += line
  17926. // if strings.Contains(line, "</program>") {
  17927. // programXML += "</program>"
  17928. // break
  17929. // }
  17930. // }
  17931. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17932. // // 解析成功,更新最后的 Program
  17933. // }
  17934. // inProgram = false
  17935. // }
  17936. //}
  17937. //
  17938. // fmt.Println("Error reading file:", inProgram)
  17939. //
  17940. //if err := scanner.Err(); err != nil {
  17941. // fmt.Println("Error reading file:", err)
  17942. //}
  17943. // 输出最后一次的 Program
  17944. //fmt.Printf("最后一次的 <program>:\n")
  17945. //fmt.Printf("<program>\n")
  17946. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17947. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17948. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17949. //fmt.Printf("</program>\n")
  17950. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17951. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17952. return ConvertToString(string(str1), "gbk", "utf-8")
  17953. }
  17954. func (c *HisApiController) GetahBasBaseInfo() string {
  17955. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17956. readCard := DllDef.MustFindProc("iReadCardBas")
  17957. if readCard == nil {
  17958. fmt.Println("readcard is nil")
  17959. readCard = DllDef.MustFindProc("iReadCardBas")
  17960. }
  17961. //str := make([]byte, 1024)
  17962. str1 := make([]byte, 1024)
  17963. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17964. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17965. //if err != nil {
  17966. // fmt.Println("Error opening file:", err)
  17967. //}
  17968. //defer file.Close()
  17969. //
  17970. //var lastProgram Program
  17971. //scanner := bufio.NewScanner(file)
  17972. //inProgram := false
  17973. //
  17974. //for scanner.Scan() {
  17975. // line := scanner.Text()
  17976. // if strings.Contains(line, "<program>") {
  17977. // inProgram = true
  17978. // programXML := "<program>"
  17979. // for scanner.Scan() {
  17980. // line = scanner.Text()
  17981. // programXML += line
  17982. // if strings.Contains(line, "</program>") {
  17983. // programXML += "</program>"
  17984. // break
  17985. // }
  17986. // }
  17987. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17988. // // 解析成功,更新最后的 Program
  17989. // }
  17990. // inProgram = false
  17991. // }
  17992. //}
  17993. //
  17994. // fmt.Println("Error reading file:", inProgram)
  17995. //
  17996. //if err := scanner.Err(); err != nil {
  17997. // fmt.Println("Error reading file:", err)
  17998. //}
  17999. // 输出最后一次的 Program
  18000. //fmt.Printf("最后一次的 <program>:\n")
  18001. //fmt.Printf("<program>\n")
  18002. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18003. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18004. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18005. //fmt.Printf("</program>\n")
  18006. fmt.Println(string(str1))
  18007. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18008. if ret2 != 0 {
  18009. return ""
  18010. }
  18011. return string(str1)
  18012. }
  18013. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18014. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18015. readCard := DllDef.MustFindProc("read_cardinfo")
  18016. if readCard == nil {
  18017. fmt.Println("readcard is nil")
  18018. readCard = DllDef.MustFindProc("read_cardinfo")
  18019. }
  18020. str := make([]byte, 1024) //卡号
  18021. str1 := make([]byte, 1024) //卡识别码
  18022. str2 := make([]byte, 1024) //身份证号
  18023. str3 := make([]byte, 1024) //姓名
  18024. str4 := make([]byte, 1024) //错误信息
  18025. 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])))
  18026. fmt.Println(string(str1))
  18027. fmt.Println(string(str))
  18028. fmt.Println(string(str2))
  18029. fmt.Println(string(str3))
  18030. fmt.Println(string(str4))
  18031. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18032. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18033. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18034. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18035. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18036. if ret2 != 0 {
  18037. return "", "", "", "", ""
  18038. }
  18039. return string(str), string(str1), string(str2), string(str3), string(str4)
  18040. }
  18041. type CustomFundPay struct {
  18042. FundPayType string `json:"fund_pay_type"`
  18043. FundPayamt float64 `json:"fund_payamt"`
  18044. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18045. }
  18046. //func (c *HisApiController) GetBatchSettleList() {
  18047. // start_time_str := c.GetString("start_time")
  18048. // //end_time_str := c.GetString("end_time")
  18049. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18050. //
  18051. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18052. //
  18053. // for _, item := range orders {
  18054. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18055. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18056. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18057. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18058. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18059. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18060. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18061. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18062. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18063. //
  18064. // if order.ID == 0 {
  18065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18066. // return
  18067. // }
  18068. //
  18069. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18070. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18071. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18072. // //fmt.Println(count)
  18073. // //var zero string
  18074. // //number := count + 1
  18075. // //if number >= 1000 {
  18076. // // zero = "0000" + strconv.FormatInt(number, 10)
  18077. // //} else if number >= 10000 {
  18078. // // zero = "000" + strconv.FormatInt(number, 10)
  18079. // //} else if number >= 100000 {
  18080. // // zero = "00" + strconv.FormatInt(number, 10)
  18081. // //} else if number >= 1000000 {
  18082. // // zero = "0" + strconv.FormatInt(number, 10)
  18083. // //} else {
  18084. // // zero = strconv.FormatInt(number, 10)
  18085. // //}
  18086. // //fmt.Println(zero)
  18087. //
  18088. // struct4101 := service.Struct4101{
  18089. // PsnNo: order.PsnNo,
  18090. // MdtrtId: order.MdtrtId,
  18091. // SetlId: order.SetlId,
  18092. // PsnName: order.PsnName,
  18093. // Gend: order.Gend,
  18094. // Brdy: his.Brdy,
  18095. // Age: his.Age,
  18096. // Naty: order.Naty,
  18097. // PatnCertType: "01",
  18098. // Certno: order.Certno,
  18099. // Prfs: "90",
  18100. // ConerName: roles[0].UserName,
  18101. // PatnRlts: "99",
  18102. // ConerAddr: miConfig.OrgName,
  18103. // ConerTel: admin.Mobile,
  18104. // HiType: order.Insutype,
  18105. // Insuplc: miConfig.InsuplcAdmdvs,
  18106. // MaindiagFlag: "1",
  18107. // BillCode: order.SetlId,
  18108. // BillNo: order.SetlId,
  18109. // BizSn: order.Number,
  18110. // PsnSelfPay: order.PsnPartAmt,
  18111. // PsnOwnPay: order.PsnPartAmt,
  18112. // AcctPay: order.AcctPay,
  18113. // PsnCashpay: order.PsnCashPay,
  18114. // HiPaymtd: "1",
  18115. // Hsorg: miConfig.InsuplcAdmdvs,
  18116. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18117. // MedinsFillPsn: curRoles.UserName,
  18118. // MedinsFillDept: miConfig.OrgName,
  18119. // IptMedType: "2",
  18120. // }
  18121. // struct4101.SetlBegnDate = order.SetlTime
  18122. // struct4101.SetlEndDate = order.SetlTime
  18123. // time_arr := strings.Split(order.SetlTime, " ")
  18124. // struct4101.AdmTime = time_arr[0]
  18125. // struct4101.AdmEndTime = time_arr[0]
  18126. //
  18127. // var rf []CustomFundPay
  18128. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18129. //
  18130. // var tempFunPays []service.CustomStruct
  18131. // for _, item := range rf {
  18132. // var tempFunPay service.CustomStruct
  18133. // tempFunPay.FundPayamt = item.FundPayamt
  18134. // tempFunPay.FundPayType = item.FundPayType
  18135. // tempFunPays = append(tempFunPays, tempFunPay)
  18136. // }
  18137. // struct4101.CustomStruct = tempFunPays
  18138. //
  18139. // var tempDiaginfos []service.DiaginfoStructTwo
  18140. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18141. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18142. //
  18143. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18144. // var config []*models.HisXtDiagnoseConfig
  18145. // for _, item := range diagnosis_ids {
  18146. // id, _ := strconv.ParseInt(item, 10, 64)
  18147. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18148. // config = append(config, &diagnosisConfig)
  18149. // }
  18150. //
  18151. // for index, item := range config {
  18152. // if index == 0 {
  18153. // var tempDiaginfo service.DiaginfoStructTwo
  18154. // tempDiaginfo.DiagCode = item.CountryCode
  18155. // tempDiaginfo.DiagName = item.CountryContentName
  18156. // tempDiaginfo.DiagType = "1"
  18157. // tempDiaginfo.MaindiagFlag = "1"
  18158. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18159. // } else {
  18160. // var tempDiaginfo service.DiaginfoStructTwo
  18161. // tempDiaginfo.DiagCode = item.CountryCode
  18162. // tempDiaginfo.DiagName = item.CountryContentName
  18163. // tempDiaginfo.DiagType = "1"
  18164. // tempDiaginfo.MaindiagFlag = "0"
  18165. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18166. // }
  18167. // }
  18168. // struct4101.Diseinfo = tempDiaginfos
  18169. //
  18170. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18171. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18172. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18173. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18174. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18175. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18176. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18177. //
  18178. // var iteminfo service.IteminfoStruct
  18179. //
  18180. // var bedCostTotal float64 = 0 //床位总费
  18181. // var bedCostSelfTotal float64 = 0 //床位自费
  18182. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18183. //
  18184. // var operationCostTotal float64 = 0 //手术费
  18185. // var operationCostSelfTotal float64 = 0 //手术费
  18186. // var operationCostPartSelfTotal float64 = 0 //手术费
  18187. //
  18188. // var otherCostTotal float64 = 0 //其他费用
  18189. // var otherCostSelfTotal float64 = 0 //其他费用
  18190. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18191. //
  18192. // var materialCostTotal float64 = 0 //材料费
  18193. // var materialCostSelfTotal float64 = 0 //材料费
  18194. // var materialCostPartSelfTotal float64 = 0 //材料费
  18195. //
  18196. // var westernMedicineCostTotal float64 = 0 //西药费
  18197. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18198. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18199. //
  18200. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18201. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18202. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18203. //
  18204. // var checkCostTotal float64 = 0 //检查费
  18205. // var checkCostSelfTotal float64 = 0 //检查费
  18206. // var checkCostPartSelfTotal float64 = 0 //检查费
  18207. //
  18208. // var laboratoryCostTotal float64 = 0 //化验费
  18209. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18210. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18211. //
  18212. // var treatCostTotal float64 = 0 //治疗费用
  18213. // var treatCostSelfTotal float64 = 0 //治疗费用
  18214. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18215. //
  18216. // decimal.DivisionPrecision = 2
  18217. //
  18218. // var bed_fulamt_ownpay_amt float64 = 0
  18219. // var operation_fulamt_ownpay_amt float64 = 0
  18220. // var other_fulamt_ownpay_amt float64 = 0
  18221. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18222. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18223. // var check_fulamt_ownpay_amt float64 = 0
  18224. // var material_fulamt_ownpay_amt float64 = 0
  18225. // var laboratory_fulamt_ownpay_amt float64 = 0
  18226. // var treat_fulamt_ownpay_amt float64 = 0
  18227. //
  18228. // var bed_claa_sunmfee float64 = 0
  18229. // var bed_clab_amt float64 = 0
  18230. // var bed_other_amt float64 = 0
  18231. //
  18232. // var operation_claa_sunmfee float64 = 0
  18233. // var operation_clab_amt float64 = 0
  18234. // var operation_other_amt float64 = 0
  18235. //
  18236. // var other_claa_sunmfee float64 = 0
  18237. // var other_clab_amt float64 = 0
  18238. // var other_other_amt float64 = 0
  18239. //
  18240. // var westernMedicine_claa_sunmfee float64 = 0
  18241. // var westernMedicine_clab_amt float64 = 0
  18242. // var westernMedicine_other_amt float64 = 0
  18243. //
  18244. // var chineseTraditional_claa_sunmfee float64 = 0
  18245. // var chineseTraditional_clab_amt float64 = 0
  18246. // var chineseTraditional_other_amt float64 = 0
  18247. //
  18248. // var check_claa_sunmfee float64 = 0
  18249. // var check_clab_amt float64 = 0
  18250. // var check_other_amt float64 = 0
  18251. //
  18252. // var material_claa_sunmfee float64 = 0
  18253. // var material_clab_amt float64 = 0
  18254. // var material_other_amt float64 = 0
  18255. //
  18256. // var laboratory_claa_sunmfee float64 = 0
  18257. // var laboratory_clab_amt float64 = 0
  18258. // var laboratory_other_amt float64 = 0
  18259. //
  18260. // var treat_claa_sunmfee float64 = 0
  18261. // var treat_clab_amt float64 = 0
  18262. // var treat_other_amt float64 = 0
  18263. //
  18264. // for _, item := range order.HisOrderInfo {
  18265. // if item.MedChrgitmType == "01" { //床位费
  18266. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18267. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18268. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18269. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18270. // if item.ChrgitmLv == "1" {
  18271. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18272. // }
  18273. // if item.ChrgitmLv == "2" {
  18274. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18275. //
  18276. // }
  18277. // if item.ChrgitmLv == "3" {
  18278. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18279. // }
  18280. //
  18281. // }
  18282. //
  18283. // if item.MedChrgitmType == "03" { //检查费
  18284. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18285. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18286. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18287. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18288. // if item.ChrgitmLv == "1" {
  18289. //
  18290. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18291. //
  18292. // }
  18293. // if item.ChrgitmLv == "2" {
  18294. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18295. //
  18296. // }
  18297. // if item.ChrgitmLv == "3" {
  18298. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18299. // }
  18300. // }
  18301. //
  18302. // if item.MedChrgitmType == "04" { //化验费
  18303. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18304. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18305. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18306. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18307. // if item.ChrgitmLv == "1" {
  18308. //
  18309. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18310. //
  18311. // }
  18312. // if item.ChrgitmLv == "2" {
  18313. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18314. //
  18315. // }
  18316. // if item.ChrgitmLv == "3" {
  18317. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18318. // }
  18319. // }
  18320. //
  18321. // if item.MedChrgitmType == "05" { //治疗费
  18322. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18323. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18324. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18325. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18326. // if item.ChrgitmLv == "1" {
  18327. //
  18328. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18329. //
  18330. // }
  18331. // if item.ChrgitmLv == "2" {
  18332. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18333. //
  18334. // }
  18335. // if item.ChrgitmLv == "3" {
  18336. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18337. // }
  18338. // }
  18339. //
  18340. // if item.MedChrgitmType == "06" { //手术费
  18341. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18342. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18343. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18344. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18345. //
  18346. // if item.ChrgitmLv == "1" {
  18347. //
  18348. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18349. //
  18350. // }
  18351. // if item.ChrgitmLv == "2" {
  18352. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18353. //
  18354. // }
  18355. // if item.ChrgitmLv == "3" {
  18356. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18357. // }
  18358. // }
  18359. //
  18360. // if item.MedChrgitmType == "08" { //材料费
  18361. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18362. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18363. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18364. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18365. // if item.ChrgitmLv == "1" {
  18366. //
  18367. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18368. //
  18369. // }
  18370. // if item.ChrgitmLv == "2" {
  18371. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18372. //
  18373. // }
  18374. // if item.ChrgitmLv == "3" {
  18375. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18376. // }
  18377. // }
  18378. //
  18379. // if item.MedChrgitmType == "09" { //西药费
  18380. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18381. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18382. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18383. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18384. // if item.ChrgitmLv == "1" {
  18385. //
  18386. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18387. //
  18388. // }
  18389. // if item.ChrgitmLv == "2" {
  18390. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18391. //
  18392. // }
  18393. // if item.ChrgitmLv == "3" {
  18394. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18395. // }
  18396. // }
  18397. //
  18398. // if item.MedChrgitmType == "11" { //中成费
  18399. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18400. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18401. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18402. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18403. // if item.ChrgitmLv == "1" {
  18404. //
  18405. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18406. //
  18407. // }
  18408. // if item.ChrgitmLv == "2" {
  18409. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18410. //
  18411. // }
  18412. // if item.ChrgitmLv == "3" {
  18413. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18414. // }
  18415. // }
  18416. //
  18417. // if item.MedChrgitmType == "14" { //其他费
  18418. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18419. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18420. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18421. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18422. // if item.ChrgitmLv == "1" {
  18423. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18424. //
  18425. // }
  18426. // if item.ChrgitmLv == "2" {
  18427. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18428. //
  18429. // }
  18430. // if item.ChrgitmLv == "3" {
  18431. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18432. // }
  18433. // }
  18434. //
  18435. // }
  18436. //
  18437. // var iteminfoStructs []service.IteminfoStruct
  18438. //
  18439. // if bedCostTotal != 0 {
  18440. // iteminfo.MedChrgitm = "01"
  18441. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18442. // iteminfo.Amt = bedCostTotal
  18443. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18444. // iteminfo.ClabAmt = bed_clab_amt
  18445. // iteminfo.OthAmt = bed_other_amt
  18446. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18447. // }
  18448. //
  18449. // if checkCostTotal != 0 {
  18450. // iteminfo.MedChrgitm = "03"
  18451. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18452. // iteminfo.Amt = checkCostTotal
  18453. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18454. // iteminfo.ClabAmt = check_clab_amt
  18455. // iteminfo.OthAmt = check_other_amt
  18456. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18457. //
  18458. // }
  18459. //
  18460. // if laboratoryCostTotal != 0 {
  18461. // iteminfo.MedChrgitm = "04"
  18462. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18463. // iteminfo.Amt = laboratoryCostTotal
  18464. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18465. // iteminfo.ClabAmt = laboratory_clab_amt
  18466. // iteminfo.OthAmt = laboratory_other_amt
  18467. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18468. //
  18469. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18470. //
  18471. // }
  18472. //
  18473. // if treatCostTotal != 0 {
  18474. // iteminfo.MedChrgitm = "05"
  18475. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18476. // iteminfo.Amt = treatCostTotal
  18477. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18478. // iteminfo.ClabAmt = treat_clab_amt
  18479. // iteminfo.OthAmt = treat_other_amt
  18480. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18481. // //(struct4101.IteminfoStruct, iteminfo)
  18482. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18483. // }
  18484. //
  18485. // if operationCostTotal != 0 {
  18486. // iteminfo.MedChrgitm = "06"
  18487. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18488. // iteminfo.Amt = operationCostTotal
  18489. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18490. // iteminfo.ClabAmt = operation_clab_amt
  18491. // iteminfo.OthAmt = operation_other_amt
  18492. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18493. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18494. // }
  18495. //
  18496. // if materialCostTotal != 0 {
  18497. // iteminfo.MedChrgitm = "08"
  18498. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18499. // iteminfo.Amt = materialCostTotal
  18500. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18501. // iteminfo.ClabAmt = material_clab_amt
  18502. // iteminfo.OthAmt = material_other_amt
  18503. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18504. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18505. // }
  18506. //
  18507. // if westernMedicineCostTotal != 0 {
  18508. // iteminfo.MedChrgitm = "09"
  18509. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18510. // iteminfo.Amt = westernMedicineCostTotal
  18511. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18512. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18513. // iteminfo.OthAmt = westernMedicine_other_amt
  18514. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18515. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18516. //
  18517. // }
  18518. // if chineseTraditionalMedicineCostTotal != 0 {
  18519. // iteminfo.MedChrgitm = "11"
  18520. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18521. // iteminfo.Amt = westernMedicineCostTotal
  18522. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18523. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18524. // iteminfo.OthAmt = westernMedicine_other_amt
  18525. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18526. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18527. //
  18528. // }
  18529. // if otherCostTotal != 0 {
  18530. // iteminfo.MedChrgitm = "14"
  18531. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18532. // iteminfo.Amt = otherCostTotal
  18533. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18534. // iteminfo.ClabAmt = other_clab_amt
  18535. // iteminfo.OthAmt = other_other_amt
  18536. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18537. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18538. //
  18539. // }
  18540. // struct4101.IteminfoStruct = iteminfoStructs
  18541. // struct4101.Ntly = "中国"
  18542. // struct4101.AdmCaty = "A03.06"
  18543. //
  18544. // struct4101.DoctorName = doctor.UserName
  18545. // struct4101.DoctorCode = doctor.DoctorNumber
  18546. //
  18547. // var res ResultSeventeen
  18548. //
  18549. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18550. // struct4101.BillCode = order.Number
  18551. // struct4101.BillNo = order.SetlId
  18552. // var resOther ResultSeventeenOther
  18553. // var pp models.PublicParams
  18554. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18555. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18556. // pp.FixmedinsName = miConfig.OrgName
  18557. // pp.FixmedinsCode = miConfig.Code
  18558. // pp.RequestUrl = miConfig.Url
  18559. // pp.Cainfo = miConfig.Cainfo
  18560. // pp.SecretKey = miConfig.SecretKey
  18561. // pp.AccessKey = miConfig.AccessKey
  18562. // pp.OpterName = curRoles.UserName
  18563. //
  18564. // client := &http.Client{}
  18565. // var req *http.Request
  18566. // data := make(map[string]interface{})
  18567. // data["struct4101"] = struct4101
  18568. // data["pp"] = pp
  18569. // bytesData, _ := json.Marshal(data)
  18570. // if miConfig.MdtrtareaAdmvs == "320921" {
  18571. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18572. // } else {
  18573. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18574. // }
  18575. // resp, _ := client.Do(req)
  18576. // defer resp.Body.Close()
  18577. // body, ioErr := ioutil.ReadAll(resp.Body)
  18578. // if ioErr != nil {
  18579. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18581. // return
  18582. // }
  18583. // var respJSON map[string]interface{}
  18584. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18585. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18587. // return
  18588. // }
  18589. //
  18590. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18591. // userJSONBytes, _ := json.Marshal(respJSON)
  18592. // fmt.Println("log")
  18593. // fmt.Println(string(userJSONBytes))
  18594. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18595. // utils.ErrorLog("解析失败:%v", err)
  18596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18597. // return
  18598. // }
  18599. // res.InfRefmsgid = resOther.InfRefmsgid
  18600. // res.Output = resOther.Output
  18601. // res.ErrMsg = resOther.ErrMsg
  18602. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18603. // res.Infcode = infocode
  18604. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18605. //
  18606. // var pp models.PublicParams
  18607. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18608. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18609. // pp.FixmedinsName = miConfig.OrgName
  18610. // pp.FixmedinsCode = miConfig.Code
  18611. // pp.RequestUrl = miConfig.Url
  18612. // pp.Cainfo = miConfig.Cainfo
  18613. // pp.SecretKey = miConfig.SecretKey
  18614. // pp.AccessKey = miConfig.AccessKey
  18615. // pp.OpterName = curRoles.UserName
  18616. // result, _ := service.Jxyb4101(struct4101, pp)
  18617. // var dat map[string]interface{}
  18618. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18619. // fmt.Println(dat)
  18620. // } else {
  18621. // fmt.Println(err)
  18622. // }
  18623. // userJSONBytes, _ := json.Marshal(dat)
  18624. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18625. // utils.ErrorLog("解析失败:%v", err)
  18626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18627. // return
  18628. // }
  18629. //
  18630. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18631. // var pp models.PublicParams
  18632. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18633. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18634. // pp.FixmedinsName = miConfig.OrgName
  18635. // pp.FixmedinsCode = miConfig.Code
  18636. // pp.RequestUrl = miConfig.Url
  18637. // pp.Cainfo = miConfig.Cainfo
  18638. // pp.SecretKey = miConfig.SecretKey
  18639. // pp.AccessKey = miConfig.AccessKey
  18640. // pp.OpterName = curRoles.UserName
  18641. // result, _ := service.Hnyb4101(struct4101, pp)
  18642. // var dat map[string]interface{}
  18643. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18644. // fmt.Println(dat)
  18645. // } else {
  18646. // fmt.Println(err)
  18647. // }
  18648. // userJSONBytes, _ := json.Marshal(dat)
  18649. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18650. // utils.ErrorLog("解析失败:%v", err)
  18651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18652. // return
  18653. // }
  18654. //
  18655. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18656. // var resOther ResultSeventeenOther
  18657. //
  18658. // var pp models.PublicParams
  18659. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18660. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18661. // pp.FixmedinsName = miConfig.OrgName
  18662. // pp.FixmedinsCode = miConfig.Code
  18663. // pp.RequestUrl = miConfig.Url
  18664. // pp.Cainfo = miConfig.Cainfo
  18665. // pp.SecretKey = miConfig.SecretKey
  18666. // pp.AccessKey = miConfig.AccessKey
  18667. // pp.OpterName = curRoles.UserName
  18668. // client := &http.Client{}
  18669. // var req *http.Request
  18670. // data := make(map[string]interface{})
  18671. // data["struct4101"] = struct4101
  18672. // data["pp"] = pp
  18673. // bytesData, _ := json.Marshal(data)
  18674. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18675. // resp, _ := client.Do(req)
  18676. // defer resp.Body.Close()
  18677. // body, ioErr := ioutil.ReadAll(resp.Body)
  18678. // if ioErr != nil {
  18679. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18681. // return
  18682. // }
  18683. // var respJSON map[string]interface{}
  18684. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18685. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18687. // return
  18688. // }
  18689. //
  18690. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18691. // userJSONBytes, _ := json.Marshal(respJSON)
  18692. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18693. // utils.ErrorLog("解析失败:%v", err)
  18694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18695. // return
  18696. // }
  18697. // res.InfRefmsgid = resOther.InfRefmsgid
  18698. // res.Output = resOther.Output
  18699. // res.ErrMsg = resOther.ErrMsg
  18700. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18701. // res.Infcode = infocode
  18702. //
  18703. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18704. // var pp models.PublicParams
  18705. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18706. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18707. // pp.FixmedinsName = miConfig.OrgName
  18708. // pp.FixmedinsCode = miConfig.Code
  18709. // pp.RequestUrl = miConfig.Url
  18710. // pp.Cainfo = miConfig.Cainfo
  18711. // pp.SecretKey = miConfig.SecretKey
  18712. // pp.AccessKey = miConfig.AccessKey
  18713. // pp.OpterName = curRoles.UserName
  18714. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18715. // fmt.Println(requestLog)
  18716. // fmt.Println(errMsgLog)
  18717. //
  18718. // saveLog(result, requestLog, "4101a", "上传清单")
  18719. //
  18720. // var dat map[string]interface{}
  18721. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18722. // fmt.Println(dat)
  18723. // } else {
  18724. // fmt.Println(err)
  18725. // }
  18726. // userJSONBytes, _ := json.Marshal(dat)
  18727. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18728. // utils.ErrorLog("解析失败:%v", err)
  18729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18730. // return
  18731. // }
  18732. //
  18733. // } else {
  18734. //
  18735. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18736. // var dat map[string]interface{}
  18737. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18738. // fmt.Println(dat)
  18739. // } else {
  18740. // fmt.Println(err)
  18741. // }
  18742. // userJSONBytes, _ := json.Marshal(dat)
  18743. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18744. // utils.ErrorLog("解析失败:%v", err)
  18745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18746. // return
  18747. // }
  18748. // }
  18749. //
  18750. // if res.Infcode != 0 {
  18751. // adminUser := c.GetAdminUserInfo()
  18752. // errlog := &models.HisOrderError{
  18753. // UserOrgId: adminUser.CurrentOrgId,
  18754. // Ctime: time.Now().Unix(),
  18755. // Mtime: time.Now().Unix(),
  18756. // ErrMsg: res.ErrMsg,
  18757. // Status: 1,
  18758. // PatientId: order.ID,
  18759. // Stage: 10265,
  18760. // }
  18761. // service.CreateErrMsgLog(errlog)
  18762. // continue
  18763. // } else {
  18764. // //order.FaPiaoNumber = zero
  18765. // //order.FaPiaoCode = last_order.FaPiaoCode
  18766. // //service.UpdateOrder(order)
  18767. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18768. // Number: res.Output.SetlListId,
  18769. // Status: 1,
  18770. // Ctime: time.Now().Unix(),
  18771. // Mtime: time.Now().Unix(),
  18772. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18773. // IsUpload: 1,
  18774. // OrderId: order.ID,
  18775. // }
  18776. // service.CreateUploadRecord(hisFundSettleListResult)
  18777. // c.ServeSuccessJSON(map[string]interface{}{
  18778. // "msg": "上传成功",
  18779. // "result": hisFundSettleListResult,
  18780. // })
  18781. // continue
  18782. // }
  18783. // }
  18784. //}
  18785. func (c *HisApiController) GetbatchSettleList() {
  18786. //order_id, _ := c.GetInt64("order_id")
  18787. admin_user_id, _ := c.GetInt64("admin_user_id")
  18788. orders, _ := service.GetAllHisOrderTwo10485()
  18789. for _, item := range orders {
  18790. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18791. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18792. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18793. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18794. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18795. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18796. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18797. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18798. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18799. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18800. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18801. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18802. //fmt.Println(count)
  18803. //var zero string
  18804. //number := count + 1
  18805. //if number >= 1000 {
  18806. // zero = "0000" + strconv.FormatInt(number, 10)
  18807. //} else if number >= 10000 {
  18808. // zero = "000" + strconv.FormatInt(number, 10)
  18809. //} else if number >= 100000 {
  18810. // zero = "00" + strconv.FormatInt(number, 10)
  18811. //} else if number >= 1000000 {
  18812. // zero = "0" + strconv.FormatInt(number, 10)
  18813. //} else {
  18814. // zero = strconv.FormatInt(number, 10)
  18815. //}
  18816. //fmt.Println(zero)
  18817. struct4101 := service.Struct4101{
  18818. PsnNo: order.PsnNo,
  18819. MdtrtId: order.MdtrtId,
  18820. SetlId: order.SetlId,
  18821. PsnName: order.PsnName,
  18822. Gend: order.Gend,
  18823. Brdy: his.Brdy,
  18824. Age: his.Age,
  18825. Naty: order.Naty,
  18826. PatnCertType: "01",
  18827. Certno: order.Certno,
  18828. Prfs: "90",
  18829. ConerName: roles[0].UserName,
  18830. PatnRlts: "99",
  18831. ConerAddr: miConfig.OrgName,
  18832. ConerTel: admin.Mobile,
  18833. HiType: order.Insutype,
  18834. Insuplc: miConfig.InsuplcAdmdvs,
  18835. MaindiagFlag: "1",
  18836. BillCode: order.SetlId,
  18837. BillNo: order.SetlId,
  18838. BizSn: order.Number,
  18839. PsnSelfPay: order.PsnPartAmt,
  18840. PsnOwnPay: order.PsnPartAmt,
  18841. AcctPay: order.AcctPay,
  18842. PsnCashpay: order.PsnCashPay,
  18843. HiPaymtd: "1",
  18844. Hsorg: miConfig.InsuplcAdmdvs,
  18845. HsorgOpter: miConfig.InsuplcAdmdvs,
  18846. MedinsFillPsn: curRoles.UserName,
  18847. MedinsFillDept: miConfig.OrgName,
  18848. IptMedType: "2",
  18849. }
  18850. struct4101.SetlBegnDate = order.SetlTime
  18851. struct4101.SetlEndDate = order.SetlTime
  18852. time_arr := strings.Split(order.SetlTime, " ")
  18853. struct4101.AdmTime = time_arr[0]
  18854. struct4101.AdmEndTime = time_arr[0]
  18855. //var rf []CustomFundPay
  18856. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18857. //
  18858. //var tempFunPays []service.CustomStruct
  18859. //for _, item := range rf {
  18860. // var tempFunPay service.CustomStruct
  18861. // tempFunPay.FundPayamt = item.FundPayamt
  18862. // tempFunPay.FundPayType = item.FundPayType
  18863. // tempFunPays = append(tempFunPays, tempFunPay)
  18864. //}
  18865. //struct4101.CustomStruct = tempFunPays
  18866. var tempDiaginfos []service.DiaginfoStructTwo
  18867. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18868. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18869. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18870. var config []*models.HisXtDiagnoseConfig
  18871. for _, item := range diagnosis_ids {
  18872. id, _ := strconv.ParseInt(item, 10, 64)
  18873. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18874. config = append(config, &diagnosisConfig)
  18875. }
  18876. for index, item := range config {
  18877. if index == 0 {
  18878. var tempDiaginfo service.DiaginfoStructTwo
  18879. tempDiaginfo.DiagCode = item.CountryCode
  18880. tempDiaginfo.DiagName = item.CountryContentName
  18881. tempDiaginfo.DiagType = "1"
  18882. tempDiaginfo.MaindiagFlag = "1"
  18883. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18884. } else {
  18885. var tempDiaginfo service.DiaginfoStructTwo
  18886. tempDiaginfo.DiagCode = item.CountryCode
  18887. tempDiaginfo.DiagName = item.CountryContentName
  18888. tempDiaginfo.DiagType = "1"
  18889. tempDiaginfo.MaindiagFlag = "0"
  18890. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18891. }
  18892. }
  18893. struct4101.Diseinfo = tempDiaginfos
  18894. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18895. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18896. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18897. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18898. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18899. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18900. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18901. var iteminfo service.IteminfoStruct
  18902. var bedCostTotal float64 = 0 //床位总费
  18903. var bedCostSelfTotal float64 = 0 //床位自费
  18904. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18905. var operationCostTotal float64 = 0 //手术费
  18906. var operationCostSelfTotal float64 = 0 //手术费
  18907. var operationCostPartSelfTotal float64 = 0 //手术费
  18908. var otherCostTotal float64 = 0 //其他费用
  18909. var otherCostSelfTotal float64 = 0 //其他费用
  18910. var otherCostPartSelfTotal float64 = 0 //其他费用
  18911. var materialCostTotal float64 = 0 //材料费
  18912. var materialCostSelfTotal float64 = 0 //材料费
  18913. var materialCostPartSelfTotal float64 = 0 //材料费
  18914. var westernMedicineCostTotal float64 = 0 //西药费
  18915. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18916. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18917. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18918. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18919. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18920. var checkCostTotal float64 = 0 //检查费
  18921. var checkCostSelfTotal float64 = 0 //检查费
  18922. var checkCostPartSelfTotal float64 = 0 //检查费
  18923. var laboratoryCostTotal float64 = 0 //化验费
  18924. var laboratoryCostSelfTotal float64 = 0 //化验费
  18925. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18926. var treatCostTotal float64 = 0 //治疗费用
  18927. var treatCostSelfTotal float64 = 0 //治疗费用
  18928. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18929. decimal.DivisionPrecision = 2
  18930. var bed_fulamt_ownpay_amt float64 = 0
  18931. var operation_fulamt_ownpay_amt float64 = 0
  18932. var other_fulamt_ownpay_amt float64 = 0
  18933. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18934. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18935. var check_fulamt_ownpay_amt float64 = 0
  18936. var material_fulamt_ownpay_amt float64 = 0
  18937. var laboratory_fulamt_ownpay_amt float64 = 0
  18938. var treat_fulamt_ownpay_amt float64 = 0
  18939. var bed_claa_sunmfee float64 = 0
  18940. var bed_clab_amt float64 = 0
  18941. var bed_other_amt float64 = 0
  18942. var operation_claa_sunmfee float64 = 0
  18943. var operation_clab_amt float64 = 0
  18944. var operation_other_amt float64 = 0
  18945. var other_claa_sunmfee float64 = 0
  18946. var other_clab_amt float64 = 0
  18947. var other_other_amt float64 = 0
  18948. var westernMedicine_claa_sunmfee float64 = 0
  18949. var westernMedicine_clab_amt float64 = 0
  18950. var westernMedicine_other_amt float64 = 0
  18951. var chineseTraditional_claa_sunmfee float64 = 0
  18952. var chineseTraditional_clab_amt float64 = 0
  18953. var chineseTraditional_other_amt float64 = 0
  18954. var check_claa_sunmfee float64 = 0
  18955. var check_clab_amt float64 = 0
  18956. var check_other_amt float64 = 0
  18957. var material_claa_sunmfee float64 = 0
  18958. var material_clab_amt float64 = 0
  18959. var material_other_amt float64 = 0
  18960. var laboratory_claa_sunmfee float64 = 0
  18961. var laboratory_clab_amt float64 = 0
  18962. var laboratory_other_amt float64 = 0
  18963. var treat_claa_sunmfee float64 = 0
  18964. var treat_clab_amt float64 = 0
  18965. var treat_other_amt float64 = 0
  18966. for _, item := range order.HisOrderInfo {
  18967. if item.MedChrgitmType == "01" { //床位费
  18968. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18969. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18970. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18971. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18972. if item.ChrgitmLv == "1" {
  18973. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18974. }
  18975. if item.ChrgitmLv == "2" {
  18976. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18977. }
  18978. if item.ChrgitmLv == "3" {
  18979. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18980. }
  18981. }
  18982. if item.MedChrgitmType == "03" { //检查费
  18983. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18984. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18985. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18986. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18987. if item.ChrgitmLv == "1" {
  18988. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18989. }
  18990. if item.ChrgitmLv == "2" {
  18991. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18992. }
  18993. if item.ChrgitmLv == "3" {
  18994. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18995. }
  18996. }
  18997. if item.MedChrgitmType == "04" { //化验费
  18998. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18999. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19000. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19001. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19002. if item.ChrgitmLv == "1" {
  19003. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19004. }
  19005. if item.ChrgitmLv == "2" {
  19006. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19007. }
  19008. if item.ChrgitmLv == "3" {
  19009. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19010. }
  19011. }
  19012. if item.MedChrgitmType == "05" { //治疗费
  19013. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19014. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19015. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19016. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19017. if item.ChrgitmLv == "1" {
  19018. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19019. }
  19020. if item.ChrgitmLv == "2" {
  19021. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19022. }
  19023. if item.ChrgitmLv == "3" {
  19024. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19025. }
  19026. }
  19027. if item.MedChrgitmType == "06" { //手术费
  19028. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19029. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19030. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19031. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19032. if item.ChrgitmLv == "1" {
  19033. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19034. }
  19035. if item.ChrgitmLv == "2" {
  19036. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19037. }
  19038. if item.ChrgitmLv == "3" {
  19039. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19040. }
  19041. }
  19042. if item.MedChrgitmType == "08" { //材料费
  19043. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19044. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19045. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19046. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19047. if item.ChrgitmLv == "1" {
  19048. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19049. }
  19050. if item.ChrgitmLv == "2" {
  19051. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19052. }
  19053. if item.ChrgitmLv == "3" {
  19054. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19055. }
  19056. }
  19057. if item.MedChrgitmType == "09" { //西药费
  19058. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19059. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19060. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19061. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19062. if item.ChrgitmLv == "1" {
  19063. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19064. }
  19065. if item.ChrgitmLv == "2" {
  19066. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19067. }
  19068. if item.ChrgitmLv == "3" {
  19069. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19070. }
  19071. }
  19072. if item.MedChrgitmType == "11" { //中成费
  19073. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19074. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19075. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19076. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19077. if item.ChrgitmLv == "1" {
  19078. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19079. }
  19080. if item.ChrgitmLv == "2" {
  19081. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19082. }
  19083. if item.ChrgitmLv == "3" {
  19084. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  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. if item.ChrgitmLv == "2" {
  19096. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19097. }
  19098. if item.ChrgitmLv == "3" {
  19099. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19100. }
  19101. }
  19102. }
  19103. var iteminfoStructs []service.IteminfoStruct
  19104. if bedCostTotal != 0 {
  19105. iteminfo.MedChrgitm = "01"
  19106. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19107. iteminfo.Amt = bedCostTotal
  19108. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19109. iteminfo.ClabAmt = bed_clab_amt
  19110. iteminfo.OthAmt = bed_other_amt
  19111. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19112. }
  19113. if checkCostTotal != 0 {
  19114. iteminfo.MedChrgitm = "03"
  19115. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19116. iteminfo.Amt = checkCostTotal
  19117. iteminfo.ClaaSumfee = check_claa_sunmfee
  19118. iteminfo.ClabAmt = check_clab_amt
  19119. iteminfo.OthAmt = check_other_amt
  19120. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19121. }
  19122. if laboratoryCostTotal != 0 {
  19123. iteminfo.MedChrgitm = "04"
  19124. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19125. iteminfo.Amt = laboratoryCostTotal
  19126. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19127. iteminfo.ClabAmt = laboratory_clab_amt
  19128. iteminfo.OthAmt = laboratory_other_amt
  19129. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19130. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19131. }
  19132. if treatCostTotal != 0 {
  19133. iteminfo.MedChrgitm = "05"
  19134. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19135. iteminfo.Amt = treatCostTotal
  19136. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19137. iteminfo.ClabAmt = treat_clab_amt
  19138. iteminfo.OthAmt = treat_other_amt
  19139. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19140. //(struct4101.IteminfoStruct, iteminfo)
  19141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19142. }
  19143. if operationCostTotal != 0 {
  19144. iteminfo.MedChrgitm = "06"
  19145. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19146. iteminfo.Amt = operationCostTotal
  19147. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19148. iteminfo.ClabAmt = operation_clab_amt
  19149. iteminfo.OthAmt = operation_other_amt
  19150. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19151. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19152. }
  19153. if materialCostTotal != 0 {
  19154. iteminfo.MedChrgitm = "08"
  19155. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19156. iteminfo.Amt = materialCostTotal
  19157. iteminfo.ClaaSumfee = material_claa_sunmfee
  19158. iteminfo.ClabAmt = material_clab_amt
  19159. iteminfo.OthAmt = material_other_amt
  19160. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19161. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19162. }
  19163. if westernMedicineCostTotal != 0 {
  19164. iteminfo.MedChrgitm = "09"
  19165. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19166. iteminfo.Amt = westernMedicineCostTotal
  19167. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19168. iteminfo.ClabAmt = westernMedicine_clab_amt
  19169. iteminfo.OthAmt = westernMedicine_other_amt
  19170. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19171. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19172. }
  19173. if chineseTraditionalMedicineCostTotal != 0 {
  19174. iteminfo.MedChrgitm = "11"
  19175. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19176. iteminfo.Amt = westernMedicineCostTotal
  19177. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19178. iteminfo.ClabAmt = westernMedicine_clab_amt
  19179. iteminfo.OthAmt = westernMedicine_other_amt
  19180. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19181. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19182. }
  19183. if otherCostTotal != 0 {
  19184. iteminfo.MedChrgitm = "14"
  19185. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19186. iteminfo.Amt = otherCostTotal
  19187. iteminfo.ClaaSumfee = other_claa_sunmfee
  19188. iteminfo.ClabAmt = other_clab_amt
  19189. iteminfo.OthAmt = other_other_amt
  19190. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19191. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19192. }
  19193. struct4101.IteminfoStruct = iteminfoStructs
  19194. struct4101.Ntly = "中国"
  19195. struct4101.AdmCaty = "A03.06"
  19196. struct4101.DoctorName = doctor.UserName
  19197. struct4101.DoctorCode = doctor.DoctorNumber
  19198. var res ResultSeventeen
  19199. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19200. struct4101.BillCode = order.Number
  19201. struct4101.BillNo = order.SetlId
  19202. var resOther ResultSeventeenOther
  19203. var pp models.PublicParams
  19204. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19205. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19206. pp.FixmedinsName = miConfig.OrgName
  19207. pp.FixmedinsCode = miConfig.Code
  19208. pp.RequestUrl = miConfig.Url
  19209. pp.Cainfo = miConfig.Cainfo
  19210. pp.SecretKey = miConfig.SecretKey
  19211. pp.AccessKey = miConfig.AccessKey
  19212. pp.OpterName = curRoles.UserName
  19213. client := &http.Client{}
  19214. var req *http.Request
  19215. data := make(map[string]interface{})
  19216. data["struct4101"] = struct4101
  19217. data["pp"] = pp
  19218. bytesData, _ := json.Marshal(data)
  19219. if miConfig.MdtrtareaAdmvs == "320921" {
  19220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19221. } else {
  19222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19223. }
  19224. resp, _ := client.Do(req)
  19225. defer resp.Body.Close()
  19226. body, ioErr := ioutil.ReadAll(resp.Body)
  19227. if ioErr != nil {
  19228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19230. return
  19231. }
  19232. var respJSON map[string]interface{}
  19233. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19236. return
  19237. }
  19238. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19239. userJSONBytes, _ := json.Marshal(respJSON)
  19240. fmt.Println("log")
  19241. fmt.Println(string(userJSONBytes))
  19242. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19243. utils.ErrorLog("解析失败:%v", err)
  19244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19245. return
  19246. }
  19247. res.InfRefmsgid = resOther.InfRefmsgid
  19248. res.Output = resOther.Output
  19249. res.ErrMsg = resOther.ErrMsg
  19250. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19251. res.Infcode = infocode
  19252. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19253. var pp models.PublicParams
  19254. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19255. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19256. pp.FixmedinsName = miConfig.OrgName
  19257. pp.FixmedinsCode = miConfig.Code
  19258. pp.RequestUrl = miConfig.Url
  19259. pp.Cainfo = miConfig.Cainfo
  19260. pp.SecretKey = miConfig.SecretKey
  19261. pp.AccessKey = miConfig.AccessKey
  19262. pp.OpterName = curRoles.UserName
  19263. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19264. result, _ := service.Jxyb4101(struct4101, pp)
  19265. var dat map[string]interface{}
  19266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19267. fmt.Println(dat)
  19268. } else {
  19269. fmt.Println(err)
  19270. }
  19271. userJSONBytes, _ := json.Marshal(dat)
  19272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19273. utils.ErrorLog("解析失败:%v", err)
  19274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19275. return
  19276. }
  19277. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19278. var pp models.PublicParams
  19279. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19280. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19281. pp.FixmedinsName = miConfig.OrgName
  19282. pp.FixmedinsCode = miConfig.Code
  19283. pp.RequestUrl = miConfig.Url
  19284. pp.Cainfo = miConfig.Cainfo
  19285. pp.SecretKey = miConfig.SecretKey
  19286. pp.AccessKey = miConfig.AccessKey
  19287. pp.OpterName = curRoles.UserName
  19288. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19289. result, _ := service.Jxyb4101(struct4101, pp)
  19290. var dat map[string]interface{}
  19291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19292. fmt.Println(dat)
  19293. } else {
  19294. fmt.Println(err)
  19295. }
  19296. userJSONBytes, _ := json.Marshal(dat)
  19297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19298. utils.ErrorLog("解析失败:%v", err)
  19299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19300. return
  19301. }
  19302. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19303. var pp models.PublicParams
  19304. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19305. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19306. pp.FixmedinsName = miConfig.OrgName
  19307. pp.FixmedinsCode = miConfig.Code
  19308. pp.RequestUrl = miConfig.Url
  19309. pp.Cainfo = miConfig.Cainfo
  19310. pp.SecretKey = miConfig.SecretKey
  19311. pp.AccessKey = miConfig.AccessKey
  19312. pp.OpterName = curRoles.UserName
  19313. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19314. result, _ := service.Jxyb4101(struct4101, pp)
  19315. var dat map[string]interface{}
  19316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19317. fmt.Println(dat)
  19318. } else {
  19319. fmt.Println(err)
  19320. }
  19321. userJSONBytes, _ := json.Marshal(dat)
  19322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19323. utils.ErrorLog("解析失败:%v", err)
  19324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19325. return
  19326. }
  19327. } else if miConfig.MdtrtareaAdmvs == "430800" {
  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. result, _ := service.Hnyb4101(struct4101, pp)
  19339. var dat map[string]interface{}
  19340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19341. fmt.Println(dat)
  19342. } else {
  19343. fmt.Println(err)
  19344. }
  19345. userJSONBytes, _ := json.Marshal(dat)
  19346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19347. utils.ErrorLog("解析失败:%v", err)
  19348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19349. return
  19350. }
  19351. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19352. var resOther ResultSeventeenOther
  19353. var pp models.PublicParams
  19354. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19355. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19356. pp.FixmedinsName = miConfig.OrgName
  19357. pp.FixmedinsCode = miConfig.Code
  19358. pp.RequestUrl = miConfig.Url
  19359. pp.Cainfo = miConfig.Cainfo
  19360. pp.SecretKey = miConfig.SecretKey
  19361. pp.AccessKey = miConfig.AccessKey
  19362. pp.OpterName = curRoles.UserName
  19363. client := &http.Client{}
  19364. var req *http.Request
  19365. data := make(map[string]interface{})
  19366. data["struct4101"] = struct4101
  19367. data["pp"] = pp
  19368. bytesData, _ := json.Marshal(data)
  19369. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19370. resp, _ := client.Do(req)
  19371. defer resp.Body.Close()
  19372. body, ioErr := ioutil.ReadAll(resp.Body)
  19373. if ioErr != nil {
  19374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19376. return
  19377. }
  19378. var respJSON map[string]interface{}
  19379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19382. return
  19383. }
  19384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19385. userJSONBytes, _ := json.Marshal(respJSON)
  19386. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19387. utils.ErrorLog("解析失败:%v", err)
  19388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19389. return
  19390. }
  19391. res.InfRefmsgid = resOther.InfRefmsgid
  19392. res.Output = resOther.Output
  19393. res.ErrMsg = resOther.ErrMsg
  19394. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19395. res.Infcode = infocode
  19396. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19397. var pp models.PublicParams
  19398. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19399. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19400. pp.FixmedinsName = miConfig.OrgName
  19401. pp.FixmedinsCode = miConfig.Code
  19402. pp.RequestUrl = miConfig.Url
  19403. pp.Cainfo = miConfig.Cainfo
  19404. pp.SecretKey = miConfig.SecretKey
  19405. pp.AccessKey = miConfig.AccessKey
  19406. pp.OpterName = curRoles.UserName
  19407. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19408. fmt.Println(requestLog)
  19409. fmt.Println(errMsgLog)
  19410. saveLog(result, requestLog, "4101a", "上传清单")
  19411. var dat map[string]interface{}
  19412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19413. fmt.Println(dat)
  19414. } else {
  19415. fmt.Println(err)
  19416. }
  19417. userJSONBytes, _ := json.Marshal(dat)
  19418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19419. utils.ErrorLog("解析失败:%v", err)
  19420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19421. return
  19422. }
  19423. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19424. var pp models.PublicParams
  19425. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19426. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19427. pp.FixmedinsName = miConfig.OrgName
  19428. pp.FixmedinsCode = miConfig.Code
  19429. pp.RequestUrl = miConfig.Url
  19430. pp.Cainfo = miConfig.Cainfo
  19431. pp.SecretKey = miConfig.SecretKey
  19432. pp.AccessKey = miConfig.AccessKey
  19433. pp.OpterName = curRoles.UserName
  19434. client := &http.Client{}
  19435. var req *http.Request
  19436. data := make(map[string]interface{})
  19437. data["struct4101"] = struct4101
  19438. data["pp"] = pp
  19439. bytesData, _ := json.Marshal(data)
  19440. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19441. resp, _ := client.Do(req)
  19442. defer resp.Body.Close()
  19443. body, ioErr := ioutil.ReadAll(resp.Body)
  19444. if ioErr != nil {
  19445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19447. return
  19448. }
  19449. var respJSON map[string]interface{}
  19450. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19453. return
  19454. }
  19455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19456. userJSONBytes, _ := json.Marshal(respJSON)
  19457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19458. utils.ErrorLog("解析失败:%v", err)
  19459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19460. return
  19461. }
  19462. } else {
  19463. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19464. var dat map[string]interface{}
  19465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19466. fmt.Println(dat)
  19467. } else {
  19468. fmt.Println(err)
  19469. }
  19470. userJSONBytes, _ := json.Marshal(dat)
  19471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19472. utils.ErrorLog("解析失败:%v", err)
  19473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19474. return
  19475. }
  19476. }
  19477. if res.Infcode != 0 {
  19478. errlog := &models.HisOrderError{
  19479. UserOrgId: order.UserOrgId,
  19480. Ctime: time.Now().Unix(),
  19481. Mtime: time.Now().Unix(),
  19482. ErrMsg: res.ErrMsg + "解析失败",
  19483. Status: 1,
  19484. PatientId: order.ID,
  19485. Stage: 10485,
  19486. }
  19487. service.CreateErrMsgLog(errlog)
  19488. continue
  19489. //c.ServeSuccessJSON(map[string]interface{}{
  19490. // "failed_code": -10,
  19491. // "msg": res.ErrMsg,
  19492. //})
  19493. } else {
  19494. //order.FaPiaoNumber = zero
  19495. //order.FaPiaoCode = last_order.FaPiaoCode
  19496. //service.UpdateOrder(order)
  19497. hisFundSettleListResult := &models.HisFundSettleListResult{
  19498. Number: res.Output.SetlListId,
  19499. Status: 1,
  19500. Ctime: time.Now().Unix(),
  19501. Mtime: time.Now().Unix(),
  19502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19503. IsUpload: 1,
  19504. OrderId: order.ID,
  19505. }
  19506. service.CreateUploadRecord(hisFundSettleListResult)
  19507. continue
  19508. }
  19509. }
  19510. }
  19511. func (c *HisApiController) GetSettleList() {
  19512. order_id, _ := c.GetInt64("order_id")
  19513. admin_user_id, _ := c.GetInt64("admin_user_id")
  19514. order, _ := service.GetHisOrderByIDTwo(order_id)
  19515. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19516. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19517. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19518. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19519. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19520. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19521. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19522. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19523. if order.ID == 0 {
  19524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19525. return
  19526. }
  19527. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19528. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19529. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19530. //fmt.Println(count)
  19531. //var zero string
  19532. //number := count + 1
  19533. //if number >= 1000 {
  19534. // zero = "0000" + strconv.FormatInt(number, 10)
  19535. //} else if number >= 10000 {
  19536. // zero = "000" + strconv.FormatInt(number, 10)
  19537. //} else if number >= 100000 {
  19538. // zero = "00" + strconv.FormatInt(number, 10)
  19539. //} else if number >= 1000000 {
  19540. // zero = "0" + strconv.FormatInt(number, 10)
  19541. //} else {
  19542. // zero = strconv.FormatInt(number, 10)
  19543. //}
  19544. //fmt.Println(zero)
  19545. struct4101 := service.Struct4101{
  19546. PsnNo: order.PsnNo,
  19547. MdtrtId: order.MdtrtId,
  19548. SetlId: order.SetlId,
  19549. PsnName: order.PsnName,
  19550. Gend: order.Gend,
  19551. Brdy: his.Brdy,
  19552. Age: his.Age,
  19553. Naty: order.Naty,
  19554. PatnCertType: "01",
  19555. Certno: order.Certno,
  19556. Prfs: "90",
  19557. ConerName: roles[0].UserName,
  19558. PatnRlts: "99",
  19559. ConerAddr: miConfig.OrgName,
  19560. ConerTel: admin.Mobile,
  19561. HiType: order.Insutype,
  19562. Insuplc: miConfig.InsuplcAdmdvs,
  19563. MaindiagFlag: "1",
  19564. BillCode: order.SetlId,
  19565. BillNo: order.SetlId,
  19566. BizSn: order.Number,
  19567. PsnSelfPay: order.PsnPartAmt,
  19568. PsnOwnPay: order.PsnPartAmt,
  19569. AcctPay: order.AcctPay,
  19570. PsnCashpay: order.PsnCashPay,
  19571. HiPaymtd: "1",
  19572. Hsorg: miConfig.InsuplcAdmdvs,
  19573. HsorgOpter: miConfig.InsuplcAdmdvs,
  19574. MedinsFillPsn: curRoles.UserName,
  19575. MedinsFillDept: miConfig.OrgName,
  19576. IptMedType: "2",
  19577. }
  19578. struct4101.SetlBegnDate = order.SetlTime
  19579. struct4101.SetlEndDate = order.SetlTime
  19580. time_arr := strings.Split(order.SetlTime, " ")
  19581. struct4101.AdmTime = time_arr[0]
  19582. struct4101.AdmEndTime = time_arr[0]
  19583. //
  19584. //var rf []CustomFundPay
  19585. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19586. //
  19587. //var tempFunPays []service.CustomStruct
  19588. //for _, item := range rf {
  19589. // var tempFunPay service.CustomStruct
  19590. // tempFunPay.FundPayamt = item.FundPayamt
  19591. // tempFunPay.FundPayType = item.FundPayType
  19592. // tempFunPays = append(tempFunPays, tempFunPay)
  19593. //}
  19594. //struct4101.CustomStruct = tempFunPays
  19595. var tempDiaginfos []service.DiaginfoStructTwo
  19596. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19597. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19598. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19599. var config []*models.HisXtDiagnoseConfig
  19600. for _, item := range diagnosis_ids {
  19601. id, _ := strconv.ParseInt(item, 10, 64)
  19602. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19603. config = append(config, &diagnosisConfig)
  19604. }
  19605. if miConfig.Code == "H15049901371" {
  19606. //for _, item := range config {
  19607. // if item.ID == 138 {
  19608. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19609. var tempDiaginfo service.DiaginfoStructTwo
  19610. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19611. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19612. tempDiaginfo.DiagType = "1"
  19613. tempDiaginfo.MaindiagFlag = "1"
  19614. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19615. //}
  19616. //}
  19617. for _, item := range config {
  19618. if item.ID != 138 {
  19619. var tempDiaginfo service.DiaginfoStructTwo
  19620. tempDiaginfo.DiagCode = item.CountryCode
  19621. tempDiaginfo.DiagName = item.CountryContentName
  19622. tempDiaginfo.DiagType = "1"
  19623. tempDiaginfo.MaindiagFlag = "0"
  19624. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19625. }
  19626. }
  19627. } else {
  19628. for index, item := range config {
  19629. if index == 0 {
  19630. var tempDiaginfo service.DiaginfoStructTwo
  19631. tempDiaginfo.DiagCode = item.CountryCode
  19632. tempDiaginfo.DiagName = item.CountryContentName
  19633. tempDiaginfo.DiagType = "1"
  19634. tempDiaginfo.MaindiagFlag = "1"
  19635. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19636. } else {
  19637. var tempDiaginfo service.DiaginfoStructTwo
  19638. tempDiaginfo.DiagCode = item.CountryCode
  19639. tempDiaginfo.DiagName = item.CountryContentName
  19640. tempDiaginfo.DiagType = "1"
  19641. tempDiaginfo.MaindiagFlag = "0"
  19642. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19643. }
  19644. }
  19645. }
  19646. struct4101.Diseinfo = tempDiaginfos
  19647. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19648. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19649. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19650. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19651. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19652. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19653. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19654. var iteminfo service.IteminfoStruct
  19655. var bedCostTotal float64 = 0 //床位总费
  19656. var bedCostSelfTotal float64 = 0 //床位自费
  19657. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19658. var operationCostTotal float64 = 0 //手术费
  19659. var operationCostSelfTotal float64 = 0 //手术费
  19660. var operationCostPartSelfTotal float64 = 0 //手术费
  19661. var otherCostTotal float64 = 0 //其他费用
  19662. var otherCostSelfTotal float64 = 0 //其他费用
  19663. var otherCostPartSelfTotal float64 = 0 //其他费用
  19664. var materialCostTotal float64 = 0 //材料费
  19665. var materialCostSelfTotal float64 = 0 //材料费
  19666. var materialCostPartSelfTotal float64 = 0 //材料费
  19667. var westernMedicineCostTotal float64 = 0 //西药费
  19668. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19669. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19670. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19671. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19672. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19673. var checkCostTotal float64 = 0 //检查费
  19674. var checkCostSelfTotal float64 = 0 //检查费
  19675. var checkCostPartSelfTotal float64 = 0 //检查费
  19676. var laboratoryCostTotal float64 = 0 //化验费
  19677. var laboratoryCostSelfTotal float64 = 0 //化验费
  19678. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19679. var treatCostTotal float64 = 0 //治疗费用
  19680. var treatCostSelfTotal float64 = 0 //治疗费用
  19681. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19682. decimal.DivisionPrecision = 2
  19683. var bed_fulamt_ownpay_amt float64 = 0
  19684. var operation_fulamt_ownpay_amt float64 = 0
  19685. var other_fulamt_ownpay_amt float64 = 0
  19686. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19687. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19688. var check_fulamt_ownpay_amt float64 = 0
  19689. var material_fulamt_ownpay_amt float64 = 0
  19690. var laboratory_fulamt_ownpay_amt float64 = 0
  19691. var treat_fulamt_ownpay_amt float64 = 0
  19692. var bed_claa_sunmfee float64 = 0
  19693. var bed_clab_amt float64 = 0
  19694. var bed_other_amt float64 = 0
  19695. var operation_claa_sunmfee float64 = 0
  19696. var operation_clab_amt float64 = 0
  19697. var operation_other_amt float64 = 0
  19698. var other_claa_sunmfee float64 = 0
  19699. var other_clab_amt float64 = 0
  19700. var other_other_amt float64 = 0
  19701. var westernMedicine_claa_sunmfee float64 = 0
  19702. var westernMedicine_clab_amt float64 = 0
  19703. var westernMedicine_other_amt float64 = 0
  19704. var chineseTraditional_claa_sunmfee float64 = 0
  19705. var chineseTraditional_clab_amt float64 = 0
  19706. var chineseTraditional_other_amt float64 = 0
  19707. var check_claa_sunmfee float64 = 0
  19708. var check_clab_amt float64 = 0
  19709. var check_other_amt float64 = 0
  19710. var material_claa_sunmfee float64 = 0
  19711. var material_clab_amt float64 = 0
  19712. var material_other_amt float64 = 0
  19713. var laboratory_claa_sunmfee float64 = 0
  19714. var laboratory_clab_amt float64 = 0
  19715. var laboratory_other_amt float64 = 0
  19716. var treat_claa_sunmfee float64 = 0
  19717. var treat_clab_amt float64 = 0
  19718. var treat_other_amt float64 = 0
  19719. for _, item := range order.HisOrderInfo {
  19720. if item.MedChrgitmType == "01" { //床位费
  19721. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19722. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19723. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19724. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19725. if item.ChrgitmLv == "1" {
  19726. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19727. }
  19728. if item.ChrgitmLv == "2" {
  19729. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19730. }
  19731. if item.ChrgitmLv == "3" {
  19732. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19733. }
  19734. }
  19735. if item.MedChrgitmType == "03" { //检查费
  19736. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19737. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19738. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19739. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19740. if item.ChrgitmLv == "1" {
  19741. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19742. }
  19743. if item.ChrgitmLv == "2" {
  19744. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19745. }
  19746. if item.ChrgitmLv == "3" {
  19747. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19748. }
  19749. }
  19750. if item.MedChrgitmType == "04" { //化验费
  19751. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19752. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19753. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19754. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19755. if item.ChrgitmLv == "1" {
  19756. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19757. }
  19758. if item.ChrgitmLv == "2" {
  19759. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19760. }
  19761. if item.ChrgitmLv == "3" {
  19762. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19763. }
  19764. }
  19765. if item.MedChrgitmType == "05" { //治疗费
  19766. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19767. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19768. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19769. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19770. if item.ChrgitmLv == "1" {
  19771. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19772. }
  19773. if item.ChrgitmLv == "2" {
  19774. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19775. }
  19776. if item.ChrgitmLv == "3" {
  19777. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19778. }
  19779. }
  19780. if item.MedChrgitmType == "06" { //手术费
  19781. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19782. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19783. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19784. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19785. if item.ChrgitmLv == "1" {
  19786. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19787. }
  19788. if item.ChrgitmLv == "2" {
  19789. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19790. }
  19791. if item.ChrgitmLv == "3" {
  19792. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19793. }
  19794. }
  19795. if item.MedChrgitmType == "08" { //材料费
  19796. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19797. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19798. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19799. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19800. if item.ChrgitmLv == "1" {
  19801. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19802. }
  19803. if item.ChrgitmLv == "2" {
  19804. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19805. }
  19806. if item.ChrgitmLv == "3" {
  19807. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19808. }
  19809. }
  19810. if item.MedChrgitmType == "09" { //西药费
  19811. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19812. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19813. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19814. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19815. if item.ChrgitmLv == "1" {
  19816. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19817. }
  19818. if item.ChrgitmLv == "2" {
  19819. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19820. }
  19821. if item.ChrgitmLv == "3" {
  19822. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19823. }
  19824. }
  19825. if item.MedChrgitmType == "11" { //中成费
  19826. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19827. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19828. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19829. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19830. if item.ChrgitmLv == "1" {
  19831. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19832. }
  19833. if item.ChrgitmLv == "2" {
  19834. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19835. }
  19836. if item.ChrgitmLv == "3" {
  19837. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19838. }
  19839. }
  19840. if item.MedChrgitmType == "14" { //其他费
  19841. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19842. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19843. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19844. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19845. if item.ChrgitmLv == "1" {
  19846. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19847. }
  19848. if item.ChrgitmLv == "2" {
  19849. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19850. }
  19851. if item.ChrgitmLv == "3" {
  19852. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19853. }
  19854. }
  19855. }
  19856. var iteminfoStructs []service.IteminfoStruct
  19857. if bedCostTotal != 0 {
  19858. iteminfo.MedChrgitm = "01"
  19859. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19860. iteminfo.Amt = bedCostTotal
  19861. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19862. iteminfo.ClabAmt = bed_clab_amt
  19863. iteminfo.OthAmt = bed_other_amt
  19864. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19865. }
  19866. if checkCostTotal != 0 {
  19867. iteminfo.MedChrgitm = "03"
  19868. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19869. iteminfo.Amt = checkCostTotal
  19870. iteminfo.ClaaSumfee = check_claa_sunmfee
  19871. iteminfo.ClabAmt = check_clab_amt
  19872. iteminfo.OthAmt = check_other_amt
  19873. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19874. }
  19875. if laboratoryCostTotal != 0 {
  19876. iteminfo.MedChrgitm = "04"
  19877. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19878. iteminfo.Amt = laboratoryCostTotal
  19879. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19880. iteminfo.ClabAmt = laboratory_clab_amt
  19881. iteminfo.OthAmt = laboratory_other_amt
  19882. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19883. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19884. }
  19885. if treatCostTotal != 0 {
  19886. iteminfo.MedChrgitm = "05"
  19887. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19888. iteminfo.Amt = treatCostTotal
  19889. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19890. iteminfo.ClabAmt = treat_clab_amt
  19891. iteminfo.OthAmt = treat_other_amt
  19892. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19893. //(struct4101.IteminfoStruct, iteminfo)
  19894. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19895. }
  19896. if operationCostTotal != 0 {
  19897. iteminfo.MedChrgitm = "06"
  19898. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19899. iteminfo.Amt = operationCostTotal
  19900. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19901. iteminfo.ClabAmt = operation_clab_amt
  19902. iteminfo.OthAmt = operation_other_amt
  19903. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19904. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19905. }
  19906. if materialCostTotal != 0 {
  19907. iteminfo.MedChrgitm = "08"
  19908. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19909. iteminfo.Amt = materialCostTotal
  19910. iteminfo.ClaaSumfee = material_claa_sunmfee
  19911. iteminfo.ClabAmt = material_clab_amt
  19912. iteminfo.OthAmt = material_other_amt
  19913. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19914. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19915. }
  19916. if westernMedicineCostTotal != 0 {
  19917. iteminfo.MedChrgitm = "09"
  19918. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19919. iteminfo.Amt = westernMedicineCostTotal
  19920. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19921. iteminfo.ClabAmt = westernMedicine_clab_amt
  19922. iteminfo.OthAmt = westernMedicine_other_amt
  19923. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19924. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19925. }
  19926. if chineseTraditionalMedicineCostTotal != 0 {
  19927. iteminfo.MedChrgitm = "11"
  19928. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19929. iteminfo.Amt = westernMedicineCostTotal
  19930. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19931. iteminfo.ClabAmt = westernMedicine_clab_amt
  19932. iteminfo.OthAmt = westernMedicine_other_amt
  19933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19934. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19935. }
  19936. if otherCostTotal != 0 {
  19937. iteminfo.MedChrgitm = "14"
  19938. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19939. iteminfo.Amt = otherCostTotal
  19940. iteminfo.ClaaSumfee = other_claa_sunmfee
  19941. iteminfo.ClabAmt = other_clab_amt
  19942. iteminfo.OthAmt = other_other_amt
  19943. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19944. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19945. }
  19946. struct4101.IteminfoStruct = iteminfoStructs
  19947. struct4101.Ntly = "中国"
  19948. struct4101.AdmCaty = "A03.06"
  19949. struct4101.DoctorName = doctor.UserName
  19950. struct4101.DoctorCode = doctor.DoctorNumber
  19951. var res ResultSeventeen
  19952. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19953. struct4101.BillCode = order.Number
  19954. struct4101.BillNo = order.SetlId
  19955. var resOther ResultSeventeenOther
  19956. var pp models.PublicParams
  19957. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19958. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19959. pp.FixmedinsName = miConfig.OrgName
  19960. pp.FixmedinsCode = miConfig.Code
  19961. pp.RequestUrl = miConfig.Url
  19962. pp.Cainfo = miConfig.Cainfo
  19963. pp.SecretKey = miConfig.SecretKey
  19964. pp.AccessKey = miConfig.AccessKey
  19965. pp.OpterName = curRoles.UserName
  19966. client := &http.Client{}
  19967. var req *http.Request
  19968. data := make(map[string]interface{})
  19969. data["struct4101"] = struct4101
  19970. data["pp"] = pp
  19971. bytesData, _ := json.Marshal(data)
  19972. if miConfig.MdtrtareaAdmvs == "320921" {
  19973. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19974. } else {
  19975. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19976. }
  19977. resp, _ := client.Do(req)
  19978. defer resp.Body.Close()
  19979. body, ioErr := ioutil.ReadAll(resp.Body)
  19980. if ioErr != nil {
  19981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19983. return
  19984. }
  19985. var respJSON map[string]interface{}
  19986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19989. return
  19990. }
  19991. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19992. userJSONBytes, _ := json.Marshal(respJSON)
  19993. fmt.Println("log")
  19994. fmt.Println(string(userJSONBytes))
  19995. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19996. utils.ErrorLog("解析失败:%v", err)
  19997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19998. return
  19999. }
  20000. res.InfRefmsgid = resOther.InfRefmsgid
  20001. res.Output = resOther.Output
  20002. res.ErrMsg = resOther.ErrMsg
  20003. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20004. res.Infcode = infocode
  20005. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20006. var pp models.PublicParams
  20007. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20008. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20009. pp.FixmedinsName = miConfig.OrgName
  20010. pp.FixmedinsCode = miConfig.Code
  20011. pp.RequestUrl = miConfig.Url
  20012. pp.Cainfo = miConfig.Cainfo
  20013. pp.SecretKey = miConfig.SecretKey
  20014. pp.AccessKey = miConfig.AccessKey
  20015. pp.OpterName = curRoles.UserName
  20016. result, _ := service.Jxyb4101(struct4101, pp)
  20017. var dat map[string]interface{}
  20018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20019. fmt.Println(dat)
  20020. } else {
  20021. fmt.Println(err)
  20022. }
  20023. userJSONBytes, _ := json.Marshal(dat)
  20024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20025. utils.ErrorLog("解析失败:%v", err)
  20026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20027. return
  20028. }
  20029. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20030. var pp models.PublicParams
  20031. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20032. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20033. pp.FixmedinsName = miConfig.OrgName
  20034. pp.FixmedinsCode = miConfig.Code
  20035. pp.RequestUrl = miConfig.Url
  20036. pp.Cainfo = miConfig.Cainfo
  20037. pp.SecretKey = miConfig.SecretKey
  20038. pp.AccessKey = miConfig.AccessKey
  20039. pp.OpterName = curRoles.UserName
  20040. result, _ := service.Jxyb4101(struct4101, pp)
  20041. var dat map[string]interface{}
  20042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20043. fmt.Println(dat)
  20044. } else {
  20045. fmt.Println(err)
  20046. }
  20047. userJSONBytes, _ := json.Marshal(dat)
  20048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20049. utils.ErrorLog("解析失败:%v", err)
  20050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20051. return
  20052. }
  20053. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20054. var pp models.PublicParams
  20055. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20056. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20057. pp.FixmedinsName = miConfig.OrgName
  20058. pp.FixmedinsCode = miConfig.Code
  20059. pp.RequestUrl = miConfig.Url
  20060. pp.Cainfo = miConfig.Cainfo
  20061. pp.SecretKey = miConfig.SecretKey
  20062. pp.AccessKey = miConfig.AccessKey
  20063. pp.OpterName = curRoles.UserName
  20064. result, _ := service.Jxyb4101(struct4101, pp)
  20065. var dat map[string]interface{}
  20066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20067. fmt.Println(dat)
  20068. } else {
  20069. fmt.Println(err)
  20070. }
  20071. userJSONBytes, _ := json.Marshal(dat)
  20072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20073. utils.ErrorLog("解析失败:%v", err)
  20074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20075. return
  20076. }
  20077. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20078. var pp models.PublicParams
  20079. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20080. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20081. pp.FixmedinsName = miConfig.OrgName
  20082. pp.FixmedinsCode = miConfig.Code
  20083. pp.RequestUrl = miConfig.Url
  20084. pp.Cainfo = miConfig.Cainfo
  20085. pp.SecretKey = miConfig.SecretKey
  20086. pp.AccessKey = miConfig.AccessKey
  20087. pp.OpterName = curRoles.UserName
  20088. result, _ := service.Hnyb4101(struct4101, pp)
  20089. var dat map[string]interface{}
  20090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20091. fmt.Println(dat)
  20092. } else {
  20093. fmt.Println(err)
  20094. }
  20095. userJSONBytes, _ := json.Marshal(dat)
  20096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20097. utils.ErrorLog("解析失败:%v", err)
  20098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20099. return
  20100. }
  20101. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20102. var resOther ResultSeventeenOther
  20103. var pp models.PublicParams
  20104. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20105. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20106. pp.FixmedinsName = miConfig.OrgName
  20107. pp.FixmedinsCode = miConfig.Code
  20108. pp.RequestUrl = miConfig.Url
  20109. pp.Cainfo = miConfig.Cainfo
  20110. pp.SecretKey = miConfig.SecretKey
  20111. pp.AccessKey = miConfig.AccessKey
  20112. pp.OpterName = curRoles.UserName
  20113. client := &http.Client{}
  20114. var req *http.Request
  20115. data := make(map[string]interface{})
  20116. data["struct4101"] = struct4101
  20117. data["pp"] = pp
  20118. bytesData, _ := json.Marshal(data)
  20119. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20120. resp, _ := client.Do(req)
  20121. defer resp.Body.Close()
  20122. body, ioErr := ioutil.ReadAll(resp.Body)
  20123. if ioErr != nil {
  20124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20126. return
  20127. }
  20128. var respJSON map[string]interface{}
  20129. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20132. return
  20133. }
  20134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20135. userJSONBytes, _ := json.Marshal(respJSON)
  20136. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20137. utils.ErrorLog("解析失败:%v", err)
  20138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20139. return
  20140. }
  20141. res.InfRefmsgid = resOther.InfRefmsgid
  20142. res.Output = resOther.Output
  20143. res.ErrMsg = resOther.ErrMsg
  20144. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20145. res.Infcode = infocode
  20146. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20147. var pp models.PublicParams
  20148. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20149. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20150. pp.FixmedinsName = miConfig.OrgName
  20151. pp.FixmedinsCode = miConfig.Code
  20152. pp.RequestUrl = miConfig.Url
  20153. pp.Cainfo = miConfig.Cainfo
  20154. pp.SecretKey = miConfig.SecretKey
  20155. pp.AccessKey = miConfig.AccessKey
  20156. pp.OpterName = curRoles.UserName
  20157. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20158. fmt.Println(requestLog)
  20159. fmt.Println(errMsgLog)
  20160. saveLog(result, requestLog, "4101a", "上传清单")
  20161. var dat map[string]interface{}
  20162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20163. fmt.Println(dat)
  20164. } else {
  20165. fmt.Println(err)
  20166. }
  20167. userJSONBytes, _ := json.Marshal(dat)
  20168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20169. utils.ErrorLog("解析失败:%v", err)
  20170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20171. return
  20172. }
  20173. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20174. var pp models.PublicParams
  20175. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20176. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20177. pp.FixmedinsName = miConfig.OrgName
  20178. pp.FixmedinsCode = miConfig.Code
  20179. pp.RequestUrl = miConfig.Url
  20180. pp.Cainfo = miConfig.Cainfo
  20181. pp.SecretKey = miConfig.SecretKey
  20182. pp.AccessKey = miConfig.AccessKey
  20183. pp.OpterName = curRoles.UserName
  20184. client := &http.Client{}
  20185. var req *http.Request
  20186. data := make(map[string]interface{})
  20187. data["struct4101"] = struct4101
  20188. data["pp"] = pp
  20189. bytesData, _ := json.Marshal(data)
  20190. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20191. resp, _ := client.Do(req)
  20192. defer resp.Body.Close()
  20193. body, ioErr := ioutil.ReadAll(resp.Body)
  20194. if ioErr != nil {
  20195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20197. return
  20198. }
  20199. var respJSON map[string]interface{}
  20200. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20203. return
  20204. }
  20205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20206. userJSONBytes, _ := json.Marshal(respJSON)
  20207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20208. utils.ErrorLog("解析失败:%v", err)
  20209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20210. return
  20211. }
  20212. } else {
  20213. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20214. var dat map[string]interface{}
  20215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20216. fmt.Println(dat)
  20217. } else {
  20218. fmt.Println(err)
  20219. }
  20220. userJSONBytes, _ := json.Marshal(dat)
  20221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20222. utils.ErrorLog("解析失败:%v", err)
  20223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20224. return
  20225. }
  20226. }
  20227. if res.Infcode != 0 {
  20228. c.ServeSuccessJSON(map[string]interface{}{
  20229. "failed_code": -10,
  20230. "msg": res.ErrMsg,
  20231. })
  20232. return
  20233. } else {
  20234. //order.FaPiaoNumber = zero
  20235. //order.FaPiaoCode = last_order.FaPiaoCode
  20236. //service.UpdateOrder(order)
  20237. hisFundSettleListResult := &models.HisFundSettleListResult{
  20238. Number: res.Output.SetlListId,
  20239. Status: 1,
  20240. Ctime: time.Now().Unix(),
  20241. Mtime: time.Now().Unix(),
  20242. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20243. IsUpload: 1,
  20244. OrderId: order_id,
  20245. }
  20246. service.CreateUploadRecord(hisFundSettleListResult)
  20247. c.ServeSuccessJSON(map[string]interface{}{
  20248. "msg": "上传成功",
  20249. "result": hisFundSettleListResult,
  20250. })
  20251. return
  20252. }
  20253. }
  20254. func (c *HisApiController) GetSettleListHospital() {
  20255. order_id, _ := c.GetInt64("order_id")
  20256. admin_user_id, _ := c.GetInt64("admin_user_id")
  20257. order, _ := service.GetHisOrderByIDTwo(order_id)
  20258. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20259. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20260. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20261. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20262. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20263. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20264. if order.ID == 0 {
  20265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20266. return
  20267. }
  20268. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20269. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20270. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20271. fmt.Println(count)
  20272. var zero string
  20273. number := count + 1
  20274. if number >= 1000 {
  20275. zero = "0000" + strconv.FormatInt(number, 10)
  20276. } else if number >= 10000 {
  20277. zero = "000" + strconv.FormatInt(number, 10)
  20278. } else if number >= 100000 {
  20279. zero = "00" + strconv.FormatInt(number, 10)
  20280. } else if number >= 1000000 {
  20281. zero = "0" + strconv.FormatInt(number, 10)
  20282. } else {
  20283. zero = strconv.FormatInt(number, 10)
  20284. }
  20285. fmt.Println(zero)
  20286. struct4101 := service.Struct4101{
  20287. PsnNo: order.PsnNo,
  20288. MdtrtId: order.MdtrtId,
  20289. SetlId: order.SetlId,
  20290. PsnName: order.PsnName,
  20291. Gend: order.Gend,
  20292. Brdy: his.Brdy,
  20293. Age: int64(order.Age),
  20294. Naty: order.Naty,
  20295. PatnCertType: "01",
  20296. Certno: order.Certno,
  20297. Prfs: "90",
  20298. ConerName: roles[0].UserName,
  20299. PatnRlts: "99",
  20300. ConerAddr: miConfig.OrgName,
  20301. ConerTel: admin.Mobile,
  20302. HiType: order.Insutype,
  20303. Insuplc: miConfig.InsuplcAdmdvs,
  20304. MaindiagFlag: "1",
  20305. BillCode: order.SetlId,
  20306. BillNo: order.SetlId,
  20307. BizSn: order.Number,
  20308. PsnSelfPay: order.PsnPartAmt,
  20309. PsnOwnPay: order.PsnPartAmt,
  20310. AcctPay: order.AcctPay,
  20311. PsnCashpay: order.PsnCashPay,
  20312. HiPaymtd: "1",
  20313. Hsorg: miConfig.InsuplcAdmdvs,
  20314. HsorgOpter: miConfig.InsuplcAdmdvs,
  20315. MedinsFillPsn: curRoles.UserName,
  20316. MedinsFillDept: depart.Name,
  20317. IptMedType: "2",
  20318. AdmTime: his.InHosptialTime,
  20319. AdmEndTime: his.OutHosptialTime,
  20320. }
  20321. struct4101.SetlBegnDate = order.SetlTime
  20322. struct4101.SetlEndDate = order.SetlTime
  20323. //var rf []CustomFundPay
  20324. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20325. //
  20326. //var tempFunPays []service.CustomStruct
  20327. //for _, item := range rf {
  20328. // var tempFunPay service.CustomStruct
  20329. // tempFunPay.FundPayamt = item.FundPayamt
  20330. // tempFunPay.FundPayType = item.FundPayType
  20331. // tempFunPays = append(tempFunPays, tempFunPay)
  20332. //}
  20333. //struct4101.CustomStruct = tempFunPays
  20334. var tempDiaginfos []service.DiaginfoStructTwo
  20335. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20336. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20337. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  20338. //for _, item := range infos {
  20339. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  20340. //}
  20341. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  20342. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  20343. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20344. fmt.Println(diagnosis_ids_arr)
  20345. if order.UserOrgId == 10210 {
  20346. var diagnosis_ids_arr_two []int64
  20347. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  20348. var config []*models.HisXtDiagnoseConfig
  20349. for _, id := range diagnosis_ids_arr_two {
  20350. //id, _ := strconv.ParseInt(item, 10, 64)
  20351. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20352. if diagnosisConfig.ID > 0 {
  20353. config = append(config, &diagnosisConfig)
  20354. }
  20355. }
  20356. for index, item := range config {
  20357. if item.ID > 0 {
  20358. if index == 0 {
  20359. var tempDiaginfo service.DiaginfoStructTwo
  20360. tempDiaginfo.DiagCode = item.CountryCode
  20361. tempDiaginfo.DiagName = item.CountryContentName
  20362. tempDiaginfo.DiagType = "1"
  20363. tempDiaginfo.MaindiagFlag = "1"
  20364. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20365. } else {
  20366. var tempDiaginfo service.DiaginfoStructTwo
  20367. tempDiaginfo.DiagCode = item.CountryCode
  20368. tempDiaginfo.DiagName = item.CountryContentName
  20369. tempDiaginfo.DiagType = "1"
  20370. tempDiaginfo.MaindiagFlag = "0"
  20371. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20372. }
  20373. }
  20374. }
  20375. struct4101.Diseinfo = tempDiaginfos
  20376. } else {
  20377. var config []*models.HisXtDiagnoseConfig
  20378. for _, item := range diagnosis_ids_arr {
  20379. id, _ := strconv.ParseInt(item, 10, 64)
  20380. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20381. if diagnosisConfig.ID > 0 {
  20382. config = append(config, &diagnosisConfig)
  20383. }
  20384. }
  20385. for index, item := range config {
  20386. if item.ID > 0 {
  20387. if index == 0 {
  20388. var tempDiaginfo service.DiaginfoStructTwo
  20389. tempDiaginfo.DiagCode = item.CountryCode
  20390. tempDiaginfo.DiagName = item.CountryContentName
  20391. tempDiaginfo.DiagType = "1"
  20392. tempDiaginfo.MaindiagFlag = "1"
  20393. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20394. } else {
  20395. var tempDiaginfo service.DiaginfoStructTwo
  20396. tempDiaginfo.DiagCode = item.CountryCode
  20397. tempDiaginfo.DiagName = item.CountryContentName
  20398. tempDiaginfo.DiagType = "1"
  20399. tempDiaginfo.MaindiagFlag = "0"
  20400. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20401. }
  20402. }
  20403. }
  20404. struct4101.Diseinfo = tempDiaginfos
  20405. }
  20406. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20407. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20408. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20409. tempOpspdiseinfo2.OprnOprtCode = ""
  20410. tempOpspdiseinfo2.OprnOprtName = ""
  20411. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20412. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20413. var iteminfo service.IteminfoStruct
  20414. var bedCostTotal float64 = 0 //床位总费
  20415. var bedCostSelfTotal float64 = 0 //床位自费
  20416. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20417. var operationCostTotal float64 = 0 //手术费
  20418. var operationCostSelfTotal float64 = 0 //手术费
  20419. var operationCostPartSelfTotal float64 = 0 //手术费
  20420. var otherCostTotal float64 = 0 //其他费用
  20421. var otherCostSelfTotal float64 = 0 //其他费用
  20422. var otherCostPartSelfTotal float64 = 0 //其他费用
  20423. var materialCostTotal float64 = 0 //材料费
  20424. var materialCostSelfTotal float64 = 0 //材料费
  20425. var materialCostPartSelfTotal float64 = 0 //材料费
  20426. var westernMedicineCostTotal float64 = 0 //西药费
  20427. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20428. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20429. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20430. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20431. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20432. var checkCostTotal float64 = 0 //检查费
  20433. var checkCostSelfTotal float64 = 0 //检查费
  20434. var checkCostPartSelfTotal float64 = 0 //检查费
  20435. var laboratoryCostTotal float64 = 0 //化验费
  20436. var laboratoryCostSelfTotal float64 = 0 //化验费
  20437. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20438. var treatCostTotal float64 = 0 //治疗费用
  20439. var treatCostSelfTotal float64 = 0 //治疗费用
  20440. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20441. decimal.DivisionPrecision = 2
  20442. var bed_fulamt_ownpay_amt float64 = 0
  20443. var operation_fulamt_ownpay_amt float64 = 0
  20444. var other_fulamt_ownpay_amt float64 = 0
  20445. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20446. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20447. var check_fulamt_ownpay_amt float64 = 0
  20448. var material_fulamt_ownpay_amt float64 = 0
  20449. var laboratory_fulamt_ownpay_amt float64 = 0
  20450. var treat_fulamt_ownpay_amt float64 = 0
  20451. var bed_claa_sunmfee float64 = 0
  20452. var bed_clab_amt float64 = 0
  20453. var bed_other_amt float64 = 0
  20454. var operation_claa_sunmfee float64 = 0
  20455. var operation_clab_amt float64 = 0
  20456. var operation_other_amt float64 = 0
  20457. var other_claa_sunmfee float64 = 0
  20458. var other_clab_amt float64 = 0
  20459. var other_other_amt float64 = 0
  20460. var westernMedicine_claa_sunmfee float64 = 0
  20461. var westernMedicine_clab_amt float64 = 0
  20462. var westernMedicine_other_amt float64 = 0
  20463. var chineseTraditional_claa_sunmfee float64 = 0
  20464. var chineseTraditional_clab_amt float64 = 0
  20465. var chineseTraditional_other_amt float64 = 0
  20466. var check_claa_sunmfee float64 = 0
  20467. var check_clab_amt float64 = 0
  20468. var check_other_amt float64 = 0
  20469. var material_claa_sunmfee float64 = 0
  20470. var material_clab_amt float64 = 0
  20471. var material_other_amt float64 = 0
  20472. var laboratory_claa_sunmfee float64 = 0
  20473. var laboratory_clab_amt float64 = 0
  20474. var laboratory_other_amt float64 = 0
  20475. var treat_claa_sunmfee float64 = 0
  20476. var treat_clab_amt float64 = 0
  20477. var treat_other_amt float64 = 0
  20478. for _, item := range order.HisOrderInfo {
  20479. if item.MedChrgitmType == "01" { //床位费
  20480. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20481. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20482. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20483. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20484. if item.ChrgitmLv == "1" {
  20485. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20486. }
  20487. if item.ChrgitmLv == "2" {
  20488. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20489. }
  20490. if item.ChrgitmLv == "3" {
  20491. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20492. }
  20493. }
  20494. if item.MedChrgitmType == "03" { //检查费
  20495. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20496. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20497. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20498. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20499. if item.ChrgitmLv == "1" {
  20500. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20501. }
  20502. if item.ChrgitmLv == "2" {
  20503. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20504. }
  20505. if item.ChrgitmLv == "3" {
  20506. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20507. }
  20508. }
  20509. if item.MedChrgitmType == "04" { //化验费
  20510. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20511. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20512. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20513. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20514. if item.ChrgitmLv == "1" {
  20515. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20516. }
  20517. if item.ChrgitmLv == "2" {
  20518. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20519. }
  20520. if item.ChrgitmLv == "3" {
  20521. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20522. }
  20523. }
  20524. if item.MedChrgitmType == "05" { //治疗费
  20525. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20526. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20527. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20528. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20529. if item.ChrgitmLv == "1" {
  20530. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20531. }
  20532. if item.ChrgitmLv == "2" {
  20533. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20534. }
  20535. if item.ChrgitmLv == "3" {
  20536. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20537. }
  20538. }
  20539. if item.MedChrgitmType == "06" { //手术费
  20540. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20541. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20542. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20543. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20544. if item.ChrgitmLv == "1" {
  20545. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20546. }
  20547. if item.ChrgitmLv == "2" {
  20548. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20549. }
  20550. if item.ChrgitmLv == "3" {
  20551. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20552. }
  20553. }
  20554. if item.MedChrgitmType == "08" { //材料费
  20555. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20556. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20557. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20558. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20559. if item.ChrgitmLv == "1" {
  20560. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20561. }
  20562. if item.ChrgitmLv == "2" {
  20563. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20564. }
  20565. if item.ChrgitmLv == "3" {
  20566. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20567. }
  20568. }
  20569. if item.MedChrgitmType == "09" { //西药费
  20570. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20571. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20572. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20573. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20574. if item.ChrgitmLv == "1" {
  20575. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20576. }
  20577. if item.ChrgitmLv == "2" {
  20578. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20579. }
  20580. if item.ChrgitmLv == "3" {
  20581. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20582. }
  20583. }
  20584. if item.MedChrgitmType == "11" { //中成费
  20585. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20586. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20587. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20588. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20589. if item.ChrgitmLv == "1" {
  20590. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20591. }
  20592. if item.ChrgitmLv == "2" {
  20593. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20594. }
  20595. if item.ChrgitmLv == "3" {
  20596. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20597. }
  20598. }
  20599. if item.MedChrgitmType == "14" { //其他费
  20600. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20601. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20602. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20603. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20604. if item.ChrgitmLv == "1" {
  20605. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20606. }
  20607. if item.ChrgitmLv == "2" {
  20608. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20609. }
  20610. if item.ChrgitmLv == "3" {
  20611. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20612. }
  20613. }
  20614. }
  20615. var iteminfoStructs []service.IteminfoStruct
  20616. if bedCostTotal != 0 {
  20617. iteminfo.MedChrgitm = "01"
  20618. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20619. iteminfo.Amt = bedCostTotal
  20620. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20621. iteminfo.ClabAmt = bed_clab_amt
  20622. iteminfo.OthAmt = bed_other_amt
  20623. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20624. }
  20625. if checkCostTotal != 0 {
  20626. iteminfo.MedChrgitm = "03"
  20627. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20628. iteminfo.Amt = checkCostTotal
  20629. iteminfo.ClaaSumfee = check_claa_sunmfee
  20630. iteminfo.ClabAmt = check_clab_amt
  20631. iteminfo.OthAmt = check_other_amt
  20632. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20633. }
  20634. if laboratoryCostTotal != 0 {
  20635. iteminfo.MedChrgitm = "04"
  20636. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20637. iteminfo.Amt = laboratoryCostTotal
  20638. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20639. iteminfo.ClabAmt = laboratory_clab_amt
  20640. iteminfo.OthAmt = laboratory_other_amt
  20641. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20642. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20643. }
  20644. if treatCostTotal != 0 {
  20645. iteminfo.MedChrgitm = "05"
  20646. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20647. iteminfo.Amt = treatCostTotal
  20648. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20649. iteminfo.ClabAmt = treat_clab_amt
  20650. iteminfo.OthAmt = treat_other_amt
  20651. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20652. //(struct4101.IteminfoStruct, iteminfo)
  20653. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20654. }
  20655. if operationCostTotal != 0 {
  20656. iteminfo.MedChrgitm = "06"
  20657. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20658. iteminfo.Amt = operationCostTotal
  20659. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20660. iteminfo.ClabAmt = operation_clab_amt
  20661. iteminfo.OthAmt = operation_other_amt
  20662. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20663. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20664. }
  20665. if materialCostTotal != 0 {
  20666. iteminfo.MedChrgitm = "08"
  20667. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20668. iteminfo.Amt = materialCostTotal
  20669. iteminfo.ClaaSumfee = material_claa_sunmfee
  20670. iteminfo.ClabAmt = material_clab_amt
  20671. iteminfo.OthAmt = material_other_amt
  20672. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20673. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20674. }
  20675. if westernMedicineCostTotal != 0 {
  20676. iteminfo.MedChrgitm = "09"
  20677. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20678. iteminfo.Amt = westernMedicineCostTotal
  20679. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20680. iteminfo.ClabAmt = westernMedicine_clab_amt
  20681. iteminfo.OthAmt = westernMedicine_other_amt
  20682. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20683. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20684. }
  20685. if chineseTraditionalMedicineCostTotal != 0 {
  20686. iteminfo.MedChrgitm = "11"
  20687. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20688. iteminfo.Amt = westernMedicineCostTotal
  20689. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20690. iteminfo.ClabAmt = westernMedicine_clab_amt
  20691. iteminfo.OthAmt = westernMedicine_other_amt
  20692. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20693. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20694. }
  20695. if otherCostTotal != 0 {
  20696. iteminfo.MedChrgitm = "14"
  20697. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20698. iteminfo.Amt = otherCostTotal
  20699. iteminfo.ClaaSumfee = other_claa_sunmfee
  20700. iteminfo.ClabAmt = other_clab_amt
  20701. iteminfo.OthAmt = other_other_amt
  20702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20703. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20704. }
  20705. struct4101.IteminfoStruct = iteminfoStructs
  20706. struct4101.Ntly = "中国"
  20707. struct4101.AdmCaty = "A03.06"
  20708. var resOther ResultSeventeenOther
  20709. var res ResultSeventeen
  20710. if miConfig.MdtrtareaAdmvs == "150499" {
  20711. var pp models.PublicParams
  20712. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20713. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20714. pp.FixmedinsName = miConfig.OrgName
  20715. pp.FixmedinsCode = miConfig.Code
  20716. pp.RequestUrl = miConfig.Url
  20717. pp.Cainfo = miConfig.Cainfo
  20718. pp.SecretKey = miConfig.SecretKey
  20719. pp.AccessKey = miConfig.AccessKey
  20720. pp.OpterName = curRoles.UserName
  20721. client := &http.Client{}
  20722. var req *http.Request
  20723. data := make(map[string]interface{})
  20724. data["struct4101"] = struct4101
  20725. data["pp"] = pp
  20726. bytesData, _ := json.Marshal(data)
  20727. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20728. resp, _ := client.Do(req)
  20729. defer resp.Body.Close()
  20730. body, ioErr := ioutil.ReadAll(resp.Body)
  20731. if ioErr != nil {
  20732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20734. return
  20735. }
  20736. var respJSON map[string]interface{}
  20737. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20740. return
  20741. }
  20742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20743. userJSONBytes, _ := json.Marshal(respJSON)
  20744. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20745. utils.ErrorLog("解析失败:%v", err)
  20746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20747. return
  20748. }
  20749. res.InfRefmsgid = resOther.InfRefmsgid
  20750. res.Output = resOther.Output
  20751. res.ErrMsg = resOther.ErrMsg
  20752. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20753. res.Infcode = infocode
  20754. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20755. var pp models.PublicParams
  20756. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20757. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20758. pp.FixmedinsName = miConfig.OrgName
  20759. pp.FixmedinsCode = miConfig.Code
  20760. pp.RequestUrl = miConfig.Url
  20761. pp.Cainfo = miConfig.Cainfo
  20762. pp.SecretKey = miConfig.SecretKey
  20763. pp.AccessKey = miConfig.AccessKey
  20764. pp.OpterName = curRoles.UserName
  20765. result, _ := service.Jxyb4101(struct4101, pp)
  20766. var dat map[string]interface{}
  20767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20768. fmt.Println(dat)
  20769. } else {
  20770. fmt.Println(err)
  20771. }
  20772. userJSONBytes, _ := json.Marshal(dat)
  20773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20774. utils.ErrorLog("解析失败:%v", err)
  20775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20776. return
  20777. }
  20778. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20779. var pp models.PublicParams
  20780. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20781. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20782. pp.FixmedinsName = miConfig.OrgName
  20783. pp.FixmedinsCode = miConfig.Code
  20784. pp.RequestUrl = miConfig.Url
  20785. pp.Cainfo = miConfig.Cainfo
  20786. pp.SecretKey = miConfig.SecretKey
  20787. pp.AccessKey = miConfig.AccessKey
  20788. pp.OpterName = curRoles.UserName
  20789. result, _ := service.Jxyb4101(struct4101, pp)
  20790. var dat map[string]interface{}
  20791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20792. fmt.Println(dat)
  20793. } else {
  20794. fmt.Println(err)
  20795. }
  20796. userJSONBytes, _ := json.Marshal(dat)
  20797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20798. utils.ErrorLog("解析失败:%v", err)
  20799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20800. return
  20801. }
  20802. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20803. var pp models.PublicParams
  20804. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20805. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20806. pp.FixmedinsName = miConfig.OrgName
  20807. pp.FixmedinsCode = miConfig.Code
  20808. pp.RequestUrl = miConfig.Url
  20809. pp.Cainfo = miConfig.Cainfo
  20810. pp.SecretKey = miConfig.SecretKey
  20811. pp.AccessKey = miConfig.AccessKey
  20812. pp.OpterName = curRoles.UserName
  20813. result, _ := service.Jxyb4101(struct4101, pp)
  20814. var dat map[string]interface{}
  20815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20816. fmt.Println(dat)
  20817. } else {
  20818. fmt.Println(err)
  20819. }
  20820. userJSONBytes, _ := json.Marshal(dat)
  20821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20822. utils.ErrorLog("解析失败:%v", err)
  20823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20824. return
  20825. }
  20826. } else {
  20827. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20828. var dat map[string]interface{}
  20829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20830. fmt.Println(dat)
  20831. } else {
  20832. fmt.Println(err)
  20833. }
  20834. userJSONBytes, _ := json.Marshal(dat)
  20835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20836. utils.ErrorLog("解析失败:%v", err)
  20837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20838. return
  20839. }
  20840. }
  20841. if res.Infcode != 0 {
  20842. c.ServeSuccessJSON(map[string]interface{}{
  20843. "failed_code": -10,
  20844. "msg": res.ErrMsg,
  20845. })
  20846. return
  20847. } else {
  20848. if miConfig.MdtrtareaAdmvs != "150499" {
  20849. order.FaPiaoNumber = zero
  20850. order.FaPiaoCode = last_order.FaPiaoCode
  20851. service.UpdateOrder(order)
  20852. }
  20853. hisFundSettleListResult := &models.HisFundSettleListResult{
  20854. Number: res.Output.SetlListId,
  20855. Status: 1,
  20856. Ctime: time.Now().Unix(),
  20857. Mtime: time.Now().Unix(),
  20858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20859. IsUpload: 1,
  20860. OrderId: order_id,
  20861. }
  20862. service.CreateUploadRecord(hisFundSettleListResult)
  20863. c.ServeSuccessJSON(map[string]interface{}{
  20864. "msg": "上传成功",
  20865. "result": hisFundSettleListResult,
  20866. })
  20867. return
  20868. }
  20869. }
  20870. //func (c *HisApiController) GetBatchSettleList() {
  20871. // orders, _ := service.GetAllHisOrder(10106)
  20872. // for _, item := range orders {
  20873. // order_id := item.ID
  20874. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20875. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20876. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20877. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20878. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20879. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20880. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20881. //
  20882. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20883. //
  20884. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20885. //
  20886. // if order.ID == 0 {
  20887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20888. // return
  20889. // }
  20890. // if his.BalanceAccountsType == 2 {
  20891. // continue
  20892. // }
  20893. // struct4101 := service.Struct4101{
  20894. // PsnNo: order.PsnNo,
  20895. // MdtrtId: order.MdtrtId,
  20896. // SetlId: order.SetlId,
  20897. // PsnName: order.PsnName,
  20898. // Gend: order.Gend,
  20899. // Brdy: his.Brdy,
  20900. // Age: his.Age,
  20901. // Naty: order.Naty,
  20902. // PatnCertType: "01",
  20903. // Certno: order.Certno,
  20904. // Prfs: "90",
  20905. // ConerName: roles[0].UserName,
  20906. // PatnRlts: "99",
  20907. // ConerAddr: miConfig.OrgName,
  20908. // ConerTel: admin.Mobile,
  20909. // HiType: order.Insutype,
  20910. // Insuplc: his.InsuplcAdmdvs,
  20911. // MaindiagFlag: "1",
  20912. // BillCode: order.SetlId,
  20913. // BillNo: order.SetlId,
  20914. // BizSn: order.Number,
  20915. // PsnSelfPay: order.PsnPartAmt,
  20916. // PsnOwnPay: order.PsnPartAmt,
  20917. // AcctPay: order.AcctPay,
  20918. // PsnCashpay: order.PsnCashPay,
  20919. // HiPaymtd: "1",
  20920. // Hsorg: his.InsuplcAdmdvs,
  20921. // HsorgOpter: his.InsuplcAdmdvs,
  20922. // MedinsFillPsn: curRoles.UserName,
  20923. // MedinsFillDept: depart.Name,
  20924. // IptMedType: "2",
  20925. // }
  20926. // struct4101.SetlBegnDate = order.SetlTime
  20927. // struct4101.SetlEndDate = order.SetlTime
  20928. // //if order.SettleType == 1 {
  20929. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20930. // // dateStr := t.Format("2006-01-02")
  20931. // // struct4101.SetlBegnDate = dateStr
  20932. // // struct4101.SetlEndDate = dateStr
  20933. // //} else {
  20934. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20935. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20936. // // dateStartStr := t.Format("2006-01-02")
  20937. // // dateEndStr := t2.Format("2006-01-02")
  20938. // // struct4101.SetlBegnDate = dateStartStr
  20939. // // struct4101.SetlEndDate = dateEndStr
  20940. // //}
  20941. //
  20942. // var rf []CustomFundPay
  20943. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20944. //
  20945. // var tempFunPays []service.CustomStruct
  20946. // var tempFunPay610100 service.CustomStruct
  20947. //
  20948. // for _, item := range rf {
  20949. // if item.FundPayType == "610100" {
  20950. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20951. // tempFunPay610100.FundPayType = item.FundPayType
  20952. // } else {
  20953. // var tempFunPay service.CustomStruct
  20954. // tempFunPay.FundPayamt = item.FundPayamt
  20955. // tempFunPay.FundPayType = item.FundPayType
  20956. // tempFunPays = append(tempFunPays, tempFunPay)
  20957. // }
  20958. // }
  20959. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20960. // struct4101.CustomStruct = tempFunPays
  20961. //
  20962. // var tempDiaginfos []service.DiaginfoStructTwo
  20963. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20964. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20965. //
  20966. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20967. // var config []*models.HisXtDiagnoseConfig
  20968. // for _, item := range diagnosis_ids {
  20969. // id, _ := strconv.ParseInt(item, 10, 64)
  20970. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20971. // config = append(config, &diagnosisConfig)
  20972. // }
  20973. //
  20974. // for index, item := range config {
  20975. // if index == 0 {
  20976. // var tempDiaginfo service.DiaginfoStructTwo
  20977. // tempDiaginfo.DiagCode = item.CountryCode
  20978. // tempDiaginfo.DiagName = item.CountryContentName
  20979. // tempDiaginfo.DiagType = "1"
  20980. // tempDiaginfo.MaindiagFlag = "1"
  20981. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20982. // } else {
  20983. //
  20984. // var tempDiaginfo service.DiaginfoStructTwo
  20985. // tempDiaginfo.DiagCode = item.CountryCode
  20986. // tempDiaginfo.DiagName = item.CountryContentName
  20987. // tempDiaginfo.DiagType = "2"
  20988. // tempDiaginfo.MaindiagFlag = "0"
  20989. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20990. // }
  20991. // }
  20992. // struct4101.Diseinfo = tempDiaginfos
  20993. //
  20994. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20995. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20996. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20997. // tempOpspdiseinfo2.OprnOprtCode = ""
  20998. // tempOpspdiseinfo2.OprnOprtName = ""
  20999. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21000. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21001. //
  21002. // var iteminfo service.IteminfoStruct
  21003. //
  21004. // var bedCostTotal float64 = 0 //床位总费
  21005. // var bedCostSelfTotal float64 = 0 //床位自费
  21006. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21007. //
  21008. // var examineCostTotal float64 = 0 //诊查总费
  21009. // var examineCostSelfTotal float64 = 0 //诊查自费
  21010. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21011. //
  21012. // var nursingCostTotal float64 = 0 //护理总费
  21013. // var nursingCostSelfTotal float64 = 0 //护理自费
  21014. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21015. //
  21016. // var chineseMedicineCostTotal float64 = 0 //中成药
  21017. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21018. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21019. //
  21020. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21021. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21022. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21023. //
  21024. // var registerCostTotal float64 = 0 //一般诊疗费
  21025. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21026. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21027. //
  21028. // var operationCostTotal float64 = 0 //手术费
  21029. // var operationCostSelfTotal float64 = 0 //手术费
  21030. // var operationCostPartSelfTotal float64 = 0 //手术费
  21031. //
  21032. // var otherCostTotal float64 = 0 //其他费用
  21033. // var otherCostSelfTotal float64 = 0 //其他费用
  21034. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21035. //
  21036. // var materialCostTotal float64 = 0 //材料费
  21037. // var materialCostSelfTotal float64 = 0 //材料费
  21038. // var materialCostPartSelfTotal float64 = 0 //材料费
  21039. //
  21040. // var westernMedicineCostTotal float64 = 0 //西药费
  21041. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21042. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21043. //
  21044. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21045. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21046. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21047. //
  21048. // var checkCostTotal float64 = 0 //检查费
  21049. // var checkCostSelfTotal float64 = 0 //检查费
  21050. // var checkCostPartSelfTotal float64 = 0 //检查费
  21051. //
  21052. // var laboratoryCostTotal float64 = 0 //化验费
  21053. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21054. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21055. //
  21056. // var treatCostTotal float64 = 0 //治疗费用
  21057. // var treatCostSelfTotal float64 = 0 //治疗费用
  21058. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21059. //
  21060. // decimal.DivisionPrecision = 2
  21061. //
  21062. // var bed_fulamt_ownpay_amt float64 = 0
  21063. //
  21064. // var examine_fulamt_ownpay_amt float64 = 0
  21065. //
  21066. // var nursing_fulamt_ownpay_amt float64 = 0
  21067. //
  21068. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21069. //
  21070. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21071. //
  21072. // var register_fulamt_ownpay_amt float64 = 0
  21073. //
  21074. // var operation_fulamt_ownpay_amt float64 = 0
  21075. // var other_fulamt_ownpay_amt float64 = 0
  21076. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21077. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21078. // var check_fulamt_ownpay_amt float64 = 0
  21079. // var material_fulamt_ownpay_amt float64 = 0
  21080. // var laboratory_fulamt_ownpay_amt float64 = 0
  21081. // var treat_fulamt_ownpay_amt float64 = 0
  21082. //
  21083. // var bed_claa_sunmfee float64 = 0
  21084. // var bed_clab_amt float64 = 0
  21085. // var bed_other_amt float64 = 0
  21086. //
  21087. // var examine_claa_sunmfee float64 = 0
  21088. // var examine_clab_amt float64 = 0
  21089. // var examine_other_amt float64 = 0
  21090. //
  21091. // var nursing_claa_sunmfee float64 = 0
  21092. // var nursing_clab_amt float64 = 0
  21093. // var nursing_other_amt float64 = 0
  21094. //
  21095. // var chinese_medicine_claa_sunmfee float64 = 0
  21096. // var chinese_medicine_clab_amt float64 = 0
  21097. // var chinese_medicine_other_amt float64 = 0
  21098. //
  21099. // var commonly_treatment_claa_sunmfee float64 = 0
  21100. // var commonly_treatment_clab_amt float64 = 0
  21101. // var commonly_treatment_other_amt float64 = 0
  21102. //
  21103. // var operation_claa_sunmfee float64 = 0
  21104. // var operation_clab_amt float64 = 0
  21105. // var operation_other_amt float64 = 0
  21106. //
  21107. // var other_claa_sunmfee float64 = 0
  21108. // var other_clab_amt float64 = 0
  21109. // var other_other_amt float64 = 0
  21110. //
  21111. // var westernMedicine_claa_sunmfee float64 = 0
  21112. // var westernMedicine_clab_amt float64 = 0
  21113. // var westernMedicine_other_amt float64 = 0
  21114. //
  21115. // var chineseTraditional_claa_sunmfee float64 = 0
  21116. // var chineseTraditional_clab_amt float64 = 0
  21117. // var chineseTraditional_other_amt float64 = 0
  21118. //
  21119. // var check_claa_sunmfee float64 = 0
  21120. // var check_clab_amt float64 = 0
  21121. // var check_other_amt float64 = 0
  21122. //
  21123. // var material_claa_sunmfee float64 = 0
  21124. // var material_clab_amt float64 = 0
  21125. // var material_other_amt float64 = 0
  21126. //
  21127. // var laboratory_claa_sunmfee float64 = 0
  21128. // var laboratory_clab_amt float64 = 0
  21129. // var laboratory_other_amt float64 = 0
  21130. //
  21131. // var treat_claa_sunmfee float64 = 0
  21132. // var treat_clab_amt float64 = 0
  21133. // var treat_other_amt float64 = 0
  21134. //
  21135. // var register_claa_sunmfee float64 = 0
  21136. // var register_clab_amt float64 = 0
  21137. // var register_other_amt float64 = 0
  21138. //
  21139. // for _, item := range order.HisOrderInfo {
  21140. // if item.MedChrgitmType == "01" { //床位费
  21141. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21142. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21143. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21144. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21145. // if item.ChrgitmLv == "1" {
  21146. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21147. // }
  21148. // if item.ChrgitmLv == "2" {
  21149. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21150. //
  21151. // }
  21152. // if item.ChrgitmLv == "3" {
  21153. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21154. // }
  21155. //
  21156. // }
  21157. //
  21158. // if item.MedChrgitmType == "02" { //诊查
  21159. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21160. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21161. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21162. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21163. // if item.ChrgitmLv == "1" {
  21164. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21165. // }
  21166. // if item.ChrgitmLv == "2" {
  21167. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21168. //
  21169. // }
  21170. // if item.ChrgitmLv == "3" {
  21171. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21172. // }
  21173. //
  21174. // }
  21175. //
  21176. // if item.MedChrgitmType == "03" { //检查费
  21177. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21178. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21179. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21180. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21181. // if item.ChrgitmLv == "1" {
  21182. //
  21183. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21184. //
  21185. // }
  21186. // if item.ChrgitmLv == "2" {
  21187. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21188. //
  21189. // }
  21190. // if item.ChrgitmLv == "3" {
  21191. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21192. // }
  21193. // }
  21194. //
  21195. // if item.MedChrgitmType == "04" { //化验费
  21196. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21197. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21198. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21199. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21200. // if item.ChrgitmLv == "1" {
  21201. //
  21202. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21203. //
  21204. // }
  21205. // if item.ChrgitmLv == "2" {
  21206. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21207. //
  21208. // }
  21209. // if item.ChrgitmLv == "3" {
  21210. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21211. // }
  21212. // }
  21213. //
  21214. // if item.MedChrgitmType == "05" { //治疗费
  21215. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21216. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21217. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21218. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21219. // if item.ChrgitmLv == "1" {
  21220. //
  21221. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21222. //
  21223. // }
  21224. // if item.ChrgitmLv == "2" {
  21225. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21226. //
  21227. // }
  21228. // if item.ChrgitmLv == "3" {
  21229. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21230. // }
  21231. // }
  21232. //
  21233. // if item.MedChrgitmType == "06" { //手术费
  21234. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21235. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21236. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21237. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21238. //
  21239. // if item.ChrgitmLv == "1" {
  21240. //
  21241. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21242. //
  21243. // }
  21244. // if item.ChrgitmLv == "2" {
  21245. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21246. //
  21247. // }
  21248. // if item.ChrgitmLv == "3" {
  21249. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21250. // }
  21251. // }
  21252. //
  21253. // if item.MedChrgitmType == "07" { //手术费
  21254. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21255. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21256. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21257. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21258. //
  21259. // if item.ChrgitmLv == "1" {
  21260. //
  21261. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21262. //
  21263. // }
  21264. // if item.ChrgitmLv == "2" {
  21265. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21266. //
  21267. // }
  21268. // if item.ChrgitmLv == "3" {
  21269. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21270. // }
  21271. // }
  21272. //
  21273. // if item.MedChrgitmType == "08" { //材料费
  21274. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21275. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21276. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21277. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21278. // if item.ChrgitmLv == "1" {
  21279. //
  21280. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21281. //
  21282. // }
  21283. // if item.ChrgitmLv == "2" {
  21284. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21285. //
  21286. // }
  21287. // if item.ChrgitmLv == "3" {
  21288. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21289. // }
  21290. // }
  21291. // if item.MedChrgitmType == "09" { //西药费
  21292. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21293. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21294. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21295. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21296. // if item.ChrgitmLv == "1" {
  21297. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21298. // }
  21299. // if item.ChrgitmLv == "2" {
  21300. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21301. // }
  21302. // if item.ChrgitmLv == "3" {
  21303. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21304. // }
  21305. // }
  21306. // if item.MedChrgitmType == "10" { //中药饮片
  21307. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21308. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21309. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21310. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21311. // if item.ChrgitmLv == "1" {
  21312. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21313. // }
  21314. // if item.ChrgitmLv == "2" {
  21315. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21316. // }
  21317. // if item.ChrgitmLv == "3" {
  21318. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21319. // }
  21320. // }
  21321. //
  21322. // if item.MedChrgitmType == "11" { //中成费
  21323. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21324. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21325. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21326. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21327. // if item.ChrgitmLv == "1" {
  21328. //
  21329. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21330. //
  21331. // }
  21332. // if item.ChrgitmLv == "2" {
  21333. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21334. //
  21335. // }
  21336. // if item.ChrgitmLv == "3" {
  21337. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21338. // }
  21339. // }
  21340. //
  21341. // if item.MedChrgitmType == "12" { //中成费
  21342. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21343. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21344. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21345. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21346. // if item.ChrgitmLv == "1" {
  21347. //
  21348. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21349. //
  21350. // }
  21351. // if item.ChrgitmLv == "2" {
  21352. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21353. //
  21354. // }
  21355. // if item.ChrgitmLv == "3" {
  21356. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21357. // }
  21358. // }
  21359. //
  21360. // if item.MedChrgitmType == "13" { //中成费
  21361. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21362. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21363. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21364. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21365. // if item.ChrgitmLv == "1" {
  21366. //
  21367. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21368. //
  21369. // }
  21370. // if item.ChrgitmLv == "2" {
  21371. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21372. //
  21373. // }
  21374. // if item.ChrgitmLv == "3" {
  21375. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21376. // }
  21377. // }
  21378. //
  21379. // if item.MedChrgitmType == "14" { //其他费
  21380. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21381. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21382. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21383. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21384. // if item.ChrgitmLv == "1" {
  21385. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21386. //
  21387. // }
  21388. // if item.ChrgitmLv == "2" {
  21389. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21390. //
  21391. // }
  21392. // if item.ChrgitmLv == "3" {
  21393. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21394. // }
  21395. // }
  21396. //
  21397. // }
  21398. //
  21399. // var iteminfoStructs []service.IteminfoStruct
  21400. //
  21401. // if bedCostTotal != 0 {
  21402. // iteminfo.MedChrgitm = "01"
  21403. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21404. // iteminfo.Amt = bedCostTotal
  21405. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21406. // iteminfo.ClabAmt = bed_clab_amt
  21407. // iteminfo.OthAmt = bed_other_amt
  21408. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21409. // }
  21410. //
  21411. // if examineCostTotal != 0 {
  21412. // iteminfo.MedChrgitm = "02"
  21413. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21414. // iteminfo.Amt = examineCostTotal
  21415. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21416. // iteminfo.ClabAmt = examine_clab_amt
  21417. // iteminfo.OthAmt = examine_other_amt
  21418. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21419. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21420. // }
  21421. //
  21422. // if checkCostTotal != 0 {
  21423. // iteminfo.MedChrgitm = "03"
  21424. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21425. // iteminfo.Amt = checkCostTotal
  21426. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21427. // iteminfo.ClabAmt = check_clab_amt
  21428. // iteminfo.OthAmt = check_other_amt
  21429. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21430. //
  21431. // }
  21432. //
  21433. // if laboratoryCostTotal != 0 {
  21434. // iteminfo.MedChrgitm = "04"
  21435. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21436. // iteminfo.Amt = laboratoryCostTotal
  21437. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21438. // iteminfo.ClabAmt = laboratory_clab_amt
  21439. // iteminfo.OthAmt = laboratory_other_amt
  21440. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21441. //
  21442. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21443. //
  21444. // }
  21445. //
  21446. // if treatCostTotal != 0 {
  21447. // iteminfo.MedChrgitm = "05"
  21448. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21449. // iteminfo.Amt = treatCostTotal
  21450. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21451. // iteminfo.ClabAmt = treat_clab_amt
  21452. // iteminfo.OthAmt = treat_other_amt
  21453. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21454. // //(struct4101.IteminfoStruct, iteminfo)
  21455. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21456. // }
  21457. //
  21458. // if operationCostTotal != 0 {
  21459. // iteminfo.MedChrgitm = "06"
  21460. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21461. // iteminfo.Amt = operationCostTotal
  21462. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21463. // iteminfo.ClabAmt = operation_clab_amt
  21464. // iteminfo.OthAmt = operation_other_amt
  21465. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21466. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21467. // }
  21468. //
  21469. // if nursingCostTotal != 0 {
  21470. // iteminfo.MedChrgitm = "07"
  21471. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21472. // iteminfo.Amt = nursingCostTotal
  21473. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21474. // iteminfo.ClabAmt = nursing_clab_amt
  21475. // iteminfo.OthAmt = nursing_other_amt
  21476. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21477. // }
  21478. //
  21479. // if materialCostTotal != 0 {
  21480. // iteminfo.MedChrgitm = "08"
  21481. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21482. // iteminfo.Amt = materialCostTotal
  21483. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21484. // iteminfo.ClabAmt = material_clab_amt
  21485. // iteminfo.OthAmt = material_other_amt
  21486. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21487. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21488. // }
  21489. //
  21490. // if westernMedicineCostTotal != 0 {
  21491. // iteminfo.MedChrgitm = "09"
  21492. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21493. // iteminfo.Amt = westernMedicineCostTotal
  21494. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21495. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21496. // iteminfo.OthAmt = westernMedicine_other_amt
  21497. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21498. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21499. //
  21500. // }
  21501. //
  21502. // if chineseMedicineCostTotal != 0 {
  21503. // iteminfo.MedChrgitm = "10"
  21504. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21505. // iteminfo.Amt = chineseMedicineCostTotal
  21506. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21507. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21508. // iteminfo.OthAmt = chinese_medicine_other_amt
  21509. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21510. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21511. //
  21512. // }
  21513. //
  21514. // if chineseTraditionalMedicineCostTotal != 0 {
  21515. // iteminfo.MedChrgitm = "11"
  21516. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21517. // iteminfo.Amt = westernMedicineCostTotal
  21518. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21519. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21520. // iteminfo.OthAmt = westernMedicine_other_amt
  21521. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21522. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21523. //
  21524. // }
  21525. //
  21526. // if commonlyTreatmentCostTotal != 0 {
  21527. // iteminfo.MedChrgitm = "12"
  21528. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21529. // iteminfo.Amt = commonlyTreatmentCostTotal
  21530. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21531. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21532. // iteminfo.OthAmt = commonly_treatment_other_amt
  21533. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21534. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21535. //
  21536. // }
  21537. //
  21538. // if registerCostTotal != 0 {
  21539. // iteminfo.MedChrgitm = "13"
  21540. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21541. // iteminfo.Amt = registerCostTotal
  21542. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21543. // iteminfo.ClabAmt = register_clab_amt
  21544. // iteminfo.OthAmt = register_other_amt
  21545. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21546. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21547. //
  21548. // }
  21549. //
  21550. // if otherCostTotal != 0 {
  21551. // iteminfo.MedChrgitm = "14"
  21552. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21553. // iteminfo.Amt = otherCostTotal
  21554. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21555. // iteminfo.ClabAmt = other_clab_amt
  21556. // iteminfo.OthAmt = other_other_amt
  21557. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21558. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21559. //
  21560. // }
  21561. // struct4101.IteminfoStruct = iteminfoStructs
  21562. // time_arr := strings.Split(order.SetlTime, " ")
  21563. // struct4101.AdmTime = time_arr[0]
  21564. // struct4101.AdmEndTime = time_arr[0]
  21565. //
  21566. // struct4101.DoctorName = doctor.UserName
  21567. // struct4101.DoctorCode = doctor.DoctorNumber
  21568. //
  21569. // struct4101.Ntly = "中国"
  21570. // struct4101.AdmCaty = "A03.06"
  21571. // var res ResultSeventeen
  21572. // if miConfig.MdtrtareaAdmvs == "421300" {
  21573. // data := make(map[string]interface{})
  21574. // data["struct4101"] = struct4101
  21575. // data["secret_key"] = miConfig.SecretKey
  21576. // data["org_name"] = miConfig.OrgName
  21577. // data["opera"] = curRoles.UserName
  21578. // data["code"] = miConfig.Code
  21579. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21580. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21581. //
  21582. // client := &http.Client{}
  21583. // bytesData, _ := json.Marshal(data)
  21584. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21585. // resp, _ := client.Do(req)
  21586. // defer resp.Body.Close()
  21587. // body, ioErr := ioutil.ReadAll(resp.Body)
  21588. // if ioErr != nil {
  21589. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21591. // return
  21592. // }
  21593. // var respJSON map[string]interface{}
  21594. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21595. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21597. // return
  21598. // }
  21599. //
  21600. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21601. // userJSONBytes, _ := json.Marshal(respJSON)
  21602. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21603. // utils.ErrorLog("解析失败:%v", err)
  21604. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21605. // adminUser := c.GetAdminUserInfo()
  21606. // errlog := &models.HisOrderError{
  21607. // UserOrgId: adminUser.CurrentOrgId,
  21608. // Ctime: time.Now().Unix(),
  21609. // Mtime: time.Now().Unix(),
  21610. // ErrMsg: res.ErrMsg + "解析失败",
  21611. // Status: 1,
  21612. // PatientId: order_id,
  21613. // Stage: 10088,
  21614. // }
  21615. // service.CreateErrMsgLog(errlog)
  21616. // continue
  21617. // }
  21618. //
  21619. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21620. // data := make(map[string]interface{})
  21621. // data["struct4101"] = struct4101
  21622. // data["secret_key"] = miConfig.SecretKey
  21623. // data["org_name"] = miConfig.OrgName
  21624. // data["opera"] = curRoles.UserName
  21625. // data["code"] = miConfig.Code
  21626. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21627. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21628. //
  21629. // client := &http.Client{}
  21630. // bytesData, _ := json.Marshal(data)
  21631. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21632. // resp, _ := client.Do(req)
  21633. // defer resp.Body.Close()
  21634. // body, ioErr := ioutil.ReadAll(resp.Body)
  21635. // if ioErr != nil {
  21636. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21638. // return
  21639. // }
  21640. // var respJSON map[string]interface{}
  21641. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21642. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21644. // return
  21645. // }
  21646. //
  21647. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21648. // userJSONBytes, _ := json.Marshal(respJSON)
  21649. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21650. // utils.ErrorLog("解析失败:%v", err)
  21651. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21652. // adminUser := c.GetAdminUserInfo()
  21653. // errlog := &models.HisOrderError{
  21654. // UserOrgId: adminUser.CurrentOrgId,
  21655. // Ctime: time.Now().Unix(),
  21656. // Mtime: time.Now().Unix(),
  21657. // ErrMsg: res.ErrMsg + "解析失败",
  21658. // Status: 1,
  21659. // PatientId: order_id,
  21660. // Stage: 10088,
  21661. // }
  21662. // service.CreateErrMsgLog(errlog)
  21663. // continue
  21664. // }
  21665. //
  21666. // } else {
  21667. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21668. // fmt.Println(result)
  21669. //
  21670. // var dat map[string]interface{}
  21671. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21672. // fmt.Println(dat)
  21673. // } else {
  21674. // fmt.Println(err)
  21675. // }
  21676. // userJSONBytes, _ := json.Marshal(dat)
  21677. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21678. // utils.ErrorLog("解析失败:%v", err)
  21679. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21680. // adminUser := c.GetAdminUserInfo()
  21681. // errlog := &models.HisOrderError{
  21682. // UserOrgId: adminUser.CurrentOrgId,
  21683. // Ctime: time.Now().Unix(),
  21684. // Mtime: time.Now().Unix(),
  21685. // ErrMsg: res.ErrMsg + "解析失败",
  21686. // Status: 1,
  21687. // PatientId: order_id,
  21688. // Stage: 10106,
  21689. // }
  21690. // service.CreateErrMsgLog(errlog)
  21691. // continue
  21692. // }
  21693. // }
  21694. //
  21695. // if res.Infcode != 0 {
  21696. // adminUser := c.GetAdminUserInfo()
  21697. // errlog := &models.HisOrderError{
  21698. // UserOrgId: adminUser.CurrentOrgId,
  21699. // Ctime: time.Now().Unix(),
  21700. // Mtime: time.Now().Unix(),
  21701. // ErrMsg: res.ErrMsg,
  21702. // Status: 1,
  21703. // PatientId: order_id,
  21704. // Stage: 10106,
  21705. // }
  21706. // service.CreateErrMsgLog(errlog)
  21707. // continue
  21708. // } else {
  21709. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21710. // Number: res.Output.SetlListId,
  21711. // Status: 1,
  21712. // Ctime: time.Now().Unix(),
  21713. // Mtime: time.Now().Unix(),
  21714. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21715. // IsUpload: 1,
  21716. // OrderId: order_id,
  21717. // }
  21718. // service.CreateUploadRecord(hisFundSettleListResult)
  21719. // continue
  21720. // }
  21721. // }
  21722. //}
  21723. func (c *HisApiController) GetOrgInfo() {
  21724. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21725. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21726. }
  21727. func (c *HisApiController) GetHisPatientInfo() {
  21728. medical_insurance_card := c.GetString("medical_insurance_card")
  21729. id_card_type, _ := c.GetInt64("id_card_type")
  21730. id_card := c.GetString("id_card")
  21731. adminInfo := c.GetAdminUserInfo()
  21732. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21733. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21734. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21735. IdCardNo := ""
  21736. if id_card_type == 1 {
  21737. IdCardNo = medical_insurance_card
  21738. } else if id_card_type == 2 {
  21739. IdCardNo = id_card
  21740. }
  21741. if config.IsOpen == 1 {
  21742. 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
  21743. resp, requestErr := http.Get(api)
  21744. if requestErr != nil {
  21745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21746. return
  21747. }
  21748. defer resp.Body.Close()
  21749. body, ioErr := ioutil.ReadAll(resp.Body)
  21750. if ioErr != nil {
  21751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21753. return
  21754. }
  21755. var respJSON map[string]interface{}
  21756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21759. return
  21760. }
  21761. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21762. userJSONBytes, _ := json.Marshal(userJSON)
  21763. var res ResultTwo
  21764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21765. utils.ErrorLog("解析失败:%v", err)
  21766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21767. return
  21768. }
  21769. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21770. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21771. infoStr := string(Iinfos)
  21772. idetinfoStr := string(Idetinfos)
  21773. if res.Infcode == 0 {
  21774. his := models.VMHisPatient{
  21775. Status: 1,
  21776. Ctime: time.Now().Unix(),
  21777. Mtime: time.Now().Unix(),
  21778. PsnNo: res.Output.Baseinfo.PsnNo,
  21779. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21780. Certno: res.Output.Baseinfo.Certno,
  21781. PsnName: res.Output.Baseinfo.PsnName,
  21782. Gend: res.Output.Baseinfo.Gend,
  21783. Naty: res.Output.Baseinfo.Naty,
  21784. Iinfo: infoStr,
  21785. Idetinfo: idetinfoStr,
  21786. UserOrgId: adminInfo.CurrentOrgId,
  21787. IsReturn: 1,
  21788. IdCardType: id_card_type,
  21789. }
  21790. c.ServeSuccessJSON(map[string]interface{}{
  21791. "info": his,
  21792. })
  21793. } else {
  21794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21795. return
  21796. }
  21797. }
  21798. }
  21799. //func GetBasBaseInfo() (jsonStr string, err error) {
  21800. //
  21801. // handle := syscall.NewLazyDLL("SSCard.dll")
  21802. // add := handle.NewProc("ReadCardBas")
  21803. // str := make([]byte, 1024)
  21804. // str1 := make([]byte, 1024)
  21805. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21806. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21807. //
  21808. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21809. //
  21810. // fmt.Println("> Add(4,5)的结果为:", ret)
  21811. // handle.Release()
  21812. //
  21813. // return "", nil
  21814. //
  21815. //}
  21816. //func GetQRBaseInfo() (jsonStr string, err error) {
  21817. // handle := syscall.LoadDLL("SSCard.dll")
  21818. // ReadCardBas := handle.FindProc("GetQRBase")
  21819. //
  21820. // str := make([]byte, 256)
  21821. // str1 := make([]byte, 256)
  21822. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21823. //
  21824. // fmt.Println(string(str))
  21825. // fmt.Println(r)
  21826. // return string(str), nil
  21827. //}
  21828. //func CardInit() int {
  21829. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21830. // add := DllTestDef.MustFindProc("Init")
  21831. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21832. // if err != nil {
  21833. // fmt.Println("SSCard的运算结果为:", ret)
  21834. // }
  21835. // result := int(ret)
  21836. // return result
  21837. //}
  21838. //func CardInit() int {
  21839. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21840. // if err != nil {
  21841. // fmt.Println("SSCard的运算结果为:", ret)
  21842. // }
  21843. // fmt.Println(err)
  21844. // result := int(ret)
  21845. // return result
  21846. //}
  21847. func IntPtr(n int) uintptr {
  21848. return uintptr(n)
  21849. }
  21850. func StrPtr(s string) uintptr {
  21851. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21852. }
  21853. type Result2001 struct {
  21854. Cainfo interface{} `json:"cainfo"`
  21855. ErrMsg string `json:"err_msg"`
  21856. InfRefmsgid string `json:"inf_refmsgid"`
  21857. Infcode int64 `json:"infcode"`
  21858. Output struct {
  21859. Trtinfo struct {
  21860. PsnNo string `json:"psn_no"`
  21861. TrtChkType string `json:"trt_chk_type"`
  21862. FundPayType string `json:"fund_pay_type"`
  21863. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21864. Begndate string `json:"begndate"`
  21865. Enddate string `json:"enddate"`
  21866. TrtChkRslt string `json:"trt_chk_rslt"`
  21867. } `json:"trtinfo"`
  21868. } `json:"output"`
  21869. RefmsgTime string `json:"refmsg_time"`
  21870. RespondTime string `json:"respond_time"`
  21871. Signtype interface{} `json:"signtype"`
  21872. WarnMsg interface{} `json:"warn_msg"`
  21873. }
  21874. type Result2001Org10265 struct {
  21875. Cainfo interface{} `json:"cainfo"`
  21876. ErrMsg string `json:"err_msg"`
  21877. InfRefmsgid string `json:"inf_refmsgid"`
  21878. Infcode string `json:"infcode"`
  21879. Output struct {
  21880. Trtinfo struct {
  21881. PsnNo string `json:"psn_no"`
  21882. TrtChkType string `json:"trt_chk_type"`
  21883. FundPayType string `json:"fund_pay_type"`
  21884. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21885. Begndate string `json:"begndate"`
  21886. Enddate string `json:"enddate"`
  21887. TrtChkRslt string `json:"trt_chk_rslt"`
  21888. } `json:"trtinfo"`
  21889. } `json:"output"`
  21890. RefmsgTime string `json:"refmsg_time"`
  21891. RespondTime string `json:"respond_time"`
  21892. Signtype interface{} `json:"signtype"`
  21893. WarnMsg interface{} `json:"warn_msg"`
  21894. }
  21895. type ResultTwo struct {
  21896. ErrMsg string `json:"err_msg"`
  21897. InfRefmsgid string `json:"inf_refmsgid"`
  21898. Infcode int64 `json:"infcode"`
  21899. Output struct {
  21900. Baseinfo struct {
  21901. //Brdy string `json:"brdy"`
  21902. Certno string `json:"certno"`
  21903. Gend string `json:"gend"`
  21904. Naty string `json:"naty"`
  21905. PsnCertType string `json:"psn_cert_type"`
  21906. PsnName string `json:"psn_name"`
  21907. PsnNo string `json:"psn_no"`
  21908. } `json:"baseinfo"`
  21909. Idetinfo []interface{} `json:"idetinfo"`
  21910. Iinfo []struct {
  21911. Balc float64 `json:"balc"`
  21912. CvlservFlag string `json:"cvlserv_flag"`
  21913. EmpName string `json:"emp_name"`
  21914. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21915. Insutype string `json:"insutype"`
  21916. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21917. //PausInsuDate string `json:"paus_insu_date"`
  21918. //PsnInsuDate string `json:"psn_insu_date"`
  21919. PsnInsuStas string `json:"psn_insu_stas"`
  21920. PsnType string `json:"psn_type"`
  21921. } `json:"insuinfo"`
  21922. } `json:"output"`
  21923. RefmsgTime string `json:"refmsg_time"`
  21924. RespondTime string `json:"respond_time"`
  21925. Signtype interface{} `json:"signtype"`
  21926. WarnInfo interface{} `json:"warn_info"`
  21927. }
  21928. type ResultTwo10265 struct {
  21929. ErrMsg string `json:"err_msg"`
  21930. InfRefmsgid string `json:"inf_refmsgid"`
  21931. Infcode string `json:"infcode"`
  21932. Output struct {
  21933. Baseinfo struct {
  21934. //Brdy string `json:"brdy"`
  21935. Certno string `json:"certno"`
  21936. Gend string `json:"gend"`
  21937. Naty string `json:"naty"`
  21938. PsnCertType string `json:"psn_cert_type"`
  21939. PsnName string `json:"psn_name"`
  21940. PsnNo string `json:"psn_no"`
  21941. } `json:"baseinfo"`
  21942. Idetinfo []interface{} `json:"idetinfo"`
  21943. Iinfo []struct {
  21944. Balc float64 `json:"balc"`
  21945. CvlservFlag string `json:"cvlserv_flag"`
  21946. EmpName string `json:"emp_name"`
  21947. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21948. Insutype string `json:"insutype"`
  21949. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21950. PsnInsuStas string `json:"psn_insu_stas"`
  21951. PsnType string `json:"psn_type"`
  21952. } `json:"insuinfo"`
  21953. } `json:"output"`
  21954. RefmsgTime string `json:"refmsg_time"`
  21955. RespondTime string `json:"respond_time"`
  21956. Signtype interface{} `json:"signtype"`
  21957. WarnInfo interface{} `json:"warn_info"`
  21958. }
  21959. type ResultThree struct {
  21960. Cainfo interface{} `json:"cainfo"`
  21961. ErrMsg string `json:"err_msg"`
  21962. InfRefmsgid string `json:"inf_refmsgid"`
  21963. Infcode int64 `json:"infcode"`
  21964. Output struct {
  21965. Data struct {
  21966. IptOtpNo string `json:"ipt_otp_no"`
  21967. MdtrtID string `json:"mdtrt_id"`
  21968. PsnNo string `json:"psn_no"`
  21969. } `json:"data"`
  21970. } `json:"output"`
  21971. RefmsgTime string `json:"refmsg_time"`
  21972. RespondTime string `json:"respond_time"`
  21973. Signtype interface{} `json:"signtype"`
  21974. WarnMsg interface{} `json:"warn_msg"`
  21975. }
  21976. type ResultThree10265 struct {
  21977. Cainfo interface{} `json:"cainfo"`
  21978. ErrMsg string `json:"err_msg"`
  21979. InfRefmsgid string `json:"inf_refmsgid"`
  21980. Infcode string `json:"infcode"`
  21981. Output struct {
  21982. Data struct {
  21983. IptOtpNo string `json:"ipt_otp_no"`
  21984. MdtrtID string `json:"mdtrt_id"`
  21985. PsnNo string `json:"psn_no"`
  21986. } `json:"data"`
  21987. } `json:"output"`
  21988. RefmsgTime string `json:"refmsg_time"`
  21989. RespondTime string `json:"respond_time"`
  21990. Signtype interface{} `json:"signtype"`
  21991. WarnMsg interface{} `json:"warn_msg"`
  21992. }
  21993. type ResultFour struct {
  21994. Cainfo string `json:"cainfo"`
  21995. ErrMsg string `json:"err_msg"`
  21996. InfRefmsgid string `json:"inf_refmsgid"`
  21997. Infcode int64 `json:"infcode"`
  21998. Output struct {
  21999. Result []struct {
  22000. BasMednFlag string `json:"bas_medn_flag"`
  22001. ChldMedcFlag string `json:"chld_medc_flag"`
  22002. ChrgitmLv string `json:"chrgitm_lv"`
  22003. Cnt float64 `json:"cnt"`
  22004. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22005. DrtReimFlag string `json:"drt_reim_flag"`
  22006. FeedetlSn string `json:"feedetl_sn"`
  22007. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22008. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22009. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22010. ListSpItemFlag string `json:"list_sp_item_flag"`
  22011. LmtUsedFlag string `json:"lmt_used_flag"`
  22012. MedChrgitmType string `json:"med_chrgitm_type"`
  22013. Memo string `json:"memo"`
  22014. OverlmtAmt float64 `json:"overlmt_amt"`
  22015. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22016. Pric float64 `json:"pric"`
  22017. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22018. SelfpayProp float64 `json:"selfpay_prop"`
  22019. } `json:"result"`
  22020. } `json:"output"`
  22021. RefmsgTime string `json:"refmsg_time"`
  22022. RespondTime string `json:"respond_time"`
  22023. Signtype string `json:"signtype"`
  22024. WarnMsg string `json:"warn_msg"`
  22025. }
  22026. type ResultFour10265 struct {
  22027. Cainfo string `json:"cainfo"`
  22028. ErrMsg string `json:"err_msg"`
  22029. InfRefmsgid string `json:"inf_refmsgid"`
  22030. Infcode string `json:"infcode"`
  22031. Output struct {
  22032. Result []struct {
  22033. BasMednFlag string `json:"bas_medn_flag"`
  22034. ChldMedcFlag string `json:"chld_medc_flag"`
  22035. ChrgitmLv string `json:"chrgitm_lv"`
  22036. Cnt float64 `json:"cnt"`
  22037. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22038. DrtReimFlag string `json:"drt_reim_flag"`
  22039. FeedetlSn string `json:"feedetl_sn"`
  22040. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22041. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22042. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22043. ListSpItemFlag string `json:"list_sp_item_flag"`
  22044. LmtUsedFlag string `json:"lmt_used_flag"`
  22045. MedChrgitmType string `json:"med_chrgitm_type"`
  22046. Memo string `json:"memo"`
  22047. OverlmtAmt float64 `json:"overlmt_amt"`
  22048. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22049. Pric float64 `json:"pric"`
  22050. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22051. SelfpayProp float64 `json:"selfpay_prop"`
  22052. } `json:"result"`
  22053. } `json:"output"`
  22054. RefmsgTime string `json:"refmsg_time"`
  22055. RespondTime string `json:"respond_time"`
  22056. Signtype string `json:"signtype"`
  22057. WarnMsg string `json:"warn_msg"`
  22058. }
  22059. type ResultMemo struct {
  22060. InsuAdmdvs string `json:"insuAdmdvs"`
  22061. }
  22062. // [{"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}]
  22063. type ResultIDInfo struct {
  22064. Begntime string `json:"begntime"`
  22065. Endtime string `json:"endtime"`
  22066. Memo string `json:"memo"`
  22067. }
  22068. type ResultFive struct {
  22069. Balc float64 `json:"balc"`
  22070. CvlservFlag string `json:"cvlserv_flag"`
  22071. EmpName string `json:"emp_name"`
  22072. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22073. Insutype string `json:"insutype"`
  22074. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22075. PausInsuDate string `json:"paus_insu_date"`
  22076. PsnInsuDate string `json:"psn_insu_date"`
  22077. PsnInsuStas string `json:"psn_insu_stas"`
  22078. PsnType string `json:"psn_type"`
  22079. }
  22080. type ResultSix struct {
  22081. Cainfo interface{} `json:"cainfo"`
  22082. ErrMsg string `json:"err_msg"`
  22083. InfRefmsgid string `json:"inf_refmsgid"`
  22084. Infcode int64 `json:"infcode"`
  22085. Output struct {
  22086. } `json:"output"`
  22087. RefmsgTime string `json:"refmsg_time"`
  22088. RespondTime string `json:"respond_time"`
  22089. Signtype interface{} `json:"signtype"`
  22090. WarnMsg interface{} `json:"warn_msg"`
  22091. }
  22092. type FJ3507Result struct {
  22093. Cainfo interface{} `json:"cainfo"`
  22094. ErrMsg string `json:"err_msg"`
  22095. InfRefmsgid string `json:"inf_refmsgid"`
  22096. Infcode int64 `json:"infcode"`
  22097. Output struct {
  22098. retRslt string `json:"retRslt"`
  22099. msgRslt string `json:"msgRslt"`
  22100. } `json:"output"`
  22101. RefmsgTime string `json:"refmsg_time"`
  22102. RespondTime string `json:"respond_time"`
  22103. Signtype interface{} `json:"signtype"`
  22104. WarnMsg interface{} `json:"warn_msg"`
  22105. }
  22106. type FJ3507ResultFor10188 struct {
  22107. Cainfo interface{} `json:"cainfo"`
  22108. ErrMsg string `json:"err_msg"`
  22109. InfRefmsgid string `json:"inf_refmsgid"`
  22110. Infcode string `json:"infcode"`
  22111. RefmsgTime string `json:"refmsg_time"`
  22112. RespondTime string `json:"respond_time"`
  22113. Signtype interface{} `json:"signtype"`
  22114. WarnMsg interface{} `json:"warn_msg"`
  22115. }
  22116. type Result2406 struct {
  22117. Cainfo interface{} `json:"cainfo"`
  22118. ErrMsg string `json:"err_msg"`
  22119. InfRefmsgid string `json:"inf_refmsgid"`
  22120. Infcode int64 `json:"infcode"`
  22121. Output struct {
  22122. Result struct {
  22123. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22124. } `json:"result"`
  22125. } `json:"output"`
  22126. RefmsgTime string `json:"refmsg_time"`
  22127. RespondTime string `json:"respond_time"`
  22128. Signtype interface{} `json:"signtype"`
  22129. WarnMsg interface{} `json:"warn_msg"`
  22130. }
  22131. type GZResultSix struct {
  22132. Cainfo interface{} `json:"cainfo"`
  22133. ErrMsg string `json:"err_msg"`
  22134. InfRefmsgid string `json:"inf_refmsgid"`
  22135. Infcode int64 `json:"infcode"`
  22136. Output string `json:"output"`
  22137. RefmsgTime string `json:"refmsg_time"`
  22138. RespondTime string `json:"respond_time"`
  22139. Signtype interface{} `json:"signtype"`
  22140. WarnMsg interface{} `json:"warn_msg"`
  22141. }
  22142. type ResultSix10265 struct {
  22143. Cainfo interface{} `json:"cainfo"`
  22144. ErrMsg string `json:"err_msg"`
  22145. InfRefmsgid string `json:"inf_refmsgid"`
  22146. Infcode string `json:"infcode"`
  22147. Output struct {
  22148. } `json:"output"`
  22149. RefmsgTime string `json:"refmsg_time"`
  22150. RespondTime string `json:"respond_time"`
  22151. Signtype interface{} `json:"signtype"`
  22152. WarnMsg interface{} `json:"warn_msg"`
  22153. }
  22154. type ResultSeven struct {
  22155. Cainfo string `json:"cainfo"`
  22156. ErrMsg string `json:"err_msg"`
  22157. InfRefmsgid string `json:"inf_refmsgid"`
  22158. Infcode int64 `json:"infcode"`
  22159. Output struct {
  22160. Setlinfo struct {
  22161. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22162. AcctPay float64 `json:"acct_pay"`
  22163. ActPayDedc float64 `json:"act_pay_dedc"`
  22164. Age float64 `json:"age"`
  22165. Balc float64 `json:"balc"`
  22166. Certno string `json:"certno"`
  22167. ClrOptins string `json:"clr_optins"`
  22168. ClrType string `json:"clr_type"`
  22169. ClrWay string `json:"clr_way"`
  22170. CvlservFlag string `json:"cvlserv_flag"`
  22171. CvlservPay float64 `json:"cvlserv_pay"`
  22172. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22173. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22174. Gend string `json:"gend"`
  22175. HifesPay float64 `json:"hifes_pay"`
  22176. HifmiPay float64 `json:"hifmi_pay"`
  22177. HifpPay float64 `json:"hifp_pay"`
  22178. HospPartAmt float64 `json:"hosp_part_amt"`
  22179. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22180. Insutype string `json:"insutype"`
  22181. MafPay float64 `json:"maf_pay"`
  22182. MdtrtCertType string `json:"mdtrt_cert_type"`
  22183. HifobPay float64 `json:"hifob_pay"`
  22184. MdtrtID string `json:"mdtrt_id"`
  22185. MedType string `json:"med_type"`
  22186. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22187. MedinsSetlID string `json:"medins_setl_id"`
  22188. Naty string `json:"naty"`
  22189. OthPay float64 `json:"oth_pay"`
  22190. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22191. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22192. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22193. PsnCashPay float64 `json:"psn_cash_pay"`
  22194. PsnCertType string `json:"psn_cert_type"`
  22195. PsnName string `json:"psn_name"`
  22196. PsnNo string `json:"psn_no"`
  22197. PsnPartAmt float64 `json:"psn_part_amt"`
  22198. PsnType string `json:"psn_type"`
  22199. SetlID string `json:"setl_id"`
  22200. SetlTime string `json:"setl_time"`
  22201. } `json:"setlinfo"`
  22202. Setldetail interface{} `json:"setldetail"`
  22203. } `json:"output"`
  22204. RefmsgTime string `json:"refmsg_time"`
  22205. RespondTime string `json:"respond_time"`
  22206. Signtype interface{} `json:"signtype"`
  22207. WarnMsg interface{} `json:"warn_msg"`
  22208. }
  22209. type ResultSevenAH struct {
  22210. Cainfo string `json:"cainfo"`
  22211. ErrMsg string `json:"err_msg"`
  22212. InfRefmsgid string `json:"inf_refmsgid"`
  22213. Infcode int64 `json:"infcode"`
  22214. Output struct {
  22215. Setlinfo struct {
  22216. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22217. AcctPay float64 `json:"acct_pay"`
  22218. ActPayDedc float64 `json:"act_pay_dedc"`
  22219. Age float64 `json:"age"`
  22220. Balc float64 `json:"balc"`
  22221. Certno string `json:"certno"`
  22222. ClrOptins string `json:"clr_optins"`
  22223. ClrType string `json:"clr_type"`
  22224. ClrWay string `json:"clr_way"`
  22225. CvlservFlag string `json:"cvlserv_flag"`
  22226. CvlservPay float64 `json:"cvlserv_pay"`
  22227. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22228. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22229. Gend string `json:"gend"`
  22230. HifesPay float64 `json:"hifes_pay"`
  22231. HifmiPay float64 `json:"hifmi_pay"`
  22232. HifpPay float64 `json:"hifp_pay"`
  22233. HospPartAmt float64 `json:"hosp_part_amt"`
  22234. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22235. Insutype string `json:"insutype"`
  22236. MafPay float64 `json:"maf_pay"`
  22237. MdtrtCertType string `json:"mdtrt_cert_type"`
  22238. HifobPay float64 `json:"hifob_pay"`
  22239. MdtrtID string `json:"mdtrt_id"`
  22240. MedType string `json:"med_type"`
  22241. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22242. MedinsSetlID string `json:"medins_setl_id"`
  22243. Naty string `json:"naty"`
  22244. OthPay float64 `json:"oth_pay"`
  22245. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22246. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22247. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22248. PsnCashPay float64 `json:"psn_cash_pay"`
  22249. PsnCertType string `json:"psn_cert_type"`
  22250. PsnName string `json:"psn_name"`
  22251. PsnNo string `json:"psn_no"`
  22252. PsnPartAmt float64 `json:"psn_part_amt"`
  22253. PsnType string `json:"psn_type"`
  22254. SetlID string `json:"setl_id"`
  22255. SetlTime int64 `json:"setl_time"`
  22256. } `json:"setlinfo"`
  22257. Setldetail interface{} `json:"setldetail"`
  22258. } `json:"output"`
  22259. RefmsgTime string `json:"refmsg_time"`
  22260. RespondTime string `json:"respond_time"`
  22261. Signtype interface{} `json:"signtype"`
  22262. WarnMsg interface{} `json:"warn_msg"`
  22263. }
  22264. type ResultSeven10265 struct {
  22265. Cainfo string `json:"cainfo"`
  22266. ErrMsg string `json:"err_msg"`
  22267. InfRefmsgid string `json:"inf_refmsgid"`
  22268. Infcode string `json:"infcode"`
  22269. Output struct {
  22270. Setlinfo struct {
  22271. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22272. AcctPay float64 `json:"acct_pay"`
  22273. ActPayDedc float64 `json:"act_pay_dedc"`
  22274. Age float64 `json:"age"`
  22275. Balc float64 `json:"balc"`
  22276. Certno string `json:"certno"`
  22277. ClrOptins string `json:"clr_optins"`
  22278. ClrType string `json:"clr_type"`
  22279. ClrWay string `json:"clr_way"`
  22280. CvlservFlag string `json:"cvlserv_flag"`
  22281. CvlservPay float64 `json:"cvlserv_pay"`
  22282. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22283. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22284. Gend string `json:"gend"`
  22285. HifesPay float64 `json:"hifes_pay"`
  22286. HifmiPay float64 `json:"hifmi_pay"`
  22287. HifpPay float64 `json:"hifp_pay"`
  22288. HospPartAmt float64 `json:"hosp_part_amt"`
  22289. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22290. Insutype string `json:"insutype"`
  22291. MafPay float64 `json:"maf_pay"`
  22292. MdtrtCertType string `json:"mdtrt_cert_type"`
  22293. HifobPay float64 `json:"hifob_pay"`
  22294. MdtrtID string `json:"mdtrt_id"`
  22295. MedType string `json:"med_type"`
  22296. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22297. MedinsSetlID string `json:"medins_setl_id"`
  22298. Naty string `json:"naty"`
  22299. OthPay float64 `json:"oth_pay"`
  22300. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22301. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22302. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22303. PsnCashPay float64 `json:"psn_cash_pay"`
  22304. PsnCertType string `json:"psn_cert_type"`
  22305. PsnName string `json:"psn_name"`
  22306. PsnNo string `json:"psn_no"`
  22307. PsnPartAmt float64 `json:"psn_part_amt"`
  22308. PsnType string `json:"psn_type"`
  22309. SetlID string `json:"setl_id"`
  22310. SetlTime string `json:"setl_time"`
  22311. } `json:"setlinfo"`
  22312. Setldetail interface{} `json:"setldetail"`
  22313. } `json:"output"`
  22314. RefmsgTime string `json:"refmsg_time"`
  22315. RespondTime string `json:"respond_time"`
  22316. Signtype interface{} `json:"signtype"`
  22317. WarnMsg interface{} `json:"warn_msg"`
  22318. }
  22319. type ResultSeven10265Two struct {
  22320. Cainfo string `json:"cainfo"`
  22321. ErrMsg string `json:"err_msg"`
  22322. InfRefmsgid string `json:"inf_refmsgid"`
  22323. Infcode string `json:"infcode"`
  22324. Output struct {
  22325. Setlinfo struct {
  22326. AcctMulaidPay string `json:"acct_mulaid_pay"`
  22327. AcctPay float64 `json:"acct_pay"`
  22328. ActPayDedc float64 `json:"act_pay_dedc"`
  22329. Age float64 `json:"age"`
  22330. Balc float64 `json:"balc"`
  22331. Certno string `json:"certno"`
  22332. ClrOptins string `json:"clr_optins"`
  22333. ClrType string `json:"clr_type"`
  22334. ClrWay string `json:"clr_way"`
  22335. CvlservFlag string `json:"cvlserv_flag"`
  22336. CvlservPay float64 `json:"cvlserv_pay"`
  22337. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22338. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22339. Gend string `json:"gend"`
  22340. HifesPay float64 `json:"hifes_pay"`
  22341. HifmiPay float64 `json:"hifmi_pay"`
  22342. HifpPay float64 `json:"hifp_pay"`
  22343. HospPartAmt string `json:"hosp_part_amt"`
  22344. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22345. Insutype string `json:"insutype"`
  22346. MafPay float64 `json:"maf_pay"`
  22347. MdtrtCertType string `json:"mdtrt_cert_type"`
  22348. HifobPay float64 `json:"hifob_pay"`
  22349. MdtrtID string `json:"mdtrt_id"`
  22350. MedType string `json:"med_type"`
  22351. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22352. MedinsSetlID string `json:"medins_setl_id"`
  22353. Naty string `json:"naty"`
  22354. OthPay float64 `json:"oth_pay"`
  22355. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22356. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22357. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22358. PsnCashPay float64 `json:"psn_cash_pay"`
  22359. PsnCertType string `json:"psn_cert_type"`
  22360. PsnName string `json:"psn_name"`
  22361. PsnNo string `json:"psn_no"`
  22362. PsnPartAmt float64 `json:"psn_part_amt"`
  22363. PsnType string `json:"psn_type"`
  22364. SetlID string `json:"setl_id"`
  22365. SetlTime string `json:"setl_time"`
  22366. } `json:"setlinfo"`
  22367. Setldetail interface{} `json:"setldetail"`
  22368. } `json:"output"`
  22369. RefmsgTime string `json:"refmsg_time"`
  22370. RespondTime string `json:"respond_time"`
  22371. Signtype interface{} `json:"signtype"`
  22372. WarnMsg interface{} `json:"warn_msg"`
  22373. }
  22374. type GZResultSeven10265Two struct {
  22375. Cainfo string `json:"cainfo"`
  22376. ErrMsg string `json:"err_msg"`
  22377. InfRefmsgid string `json:"inf_refmsgid"`
  22378. Infcode int64 `json:"infcode"`
  22379. Output struct {
  22380. Setlinfo struct {
  22381. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22382. AcctPay float64 `json:"acct_pay"`
  22383. ActPayDedc float64 `json:"act_pay_dedc"`
  22384. Age float64 `json:"age"`
  22385. Balc float64 `json:"balc"`
  22386. Certno string `json:"certno"`
  22387. ClrOptins string `json:"clr_optins"`
  22388. ClrType string `json:"clr_type"`
  22389. ClrWay string `json:"clr_way"`
  22390. CvlservFlag string `json:"cvlserv_flag"`
  22391. CvlservPay float64 `json:"cvlserv_pay"`
  22392. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22393. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22394. Gend string `json:"gend"`
  22395. HifesPay float64 `json:"hifes_pay"`
  22396. HifmiPay float64 `json:"hifmi_pay"`
  22397. HifpPay float64 `json:"hifp_pay"`
  22398. HospPartAmt float64 `json:"hosp_part_amt"`
  22399. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22400. Insutype string `json:"insutype"`
  22401. MafPay float64 `json:"maf_pay"`
  22402. MdtrtCertType string `json:"mdtrt_cert_type"`
  22403. HifobPay float64 `json:"hifob_pay"`
  22404. MdtrtID string `json:"mdtrt_id"`
  22405. MedType string `json:"med_type"`
  22406. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22407. MedinsSetlID string `json:"medins_setl_id"`
  22408. Naty string `json:"naty"`
  22409. OthPay float64 `json:"oth_pay"`
  22410. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22411. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22412. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22413. PsnCashPay float64 `json:"psn_cash_pay"`
  22414. PsnCertType string `json:"psn_cert_type"`
  22415. PsnName string `json:"psn_name"`
  22416. PsnNo string `json:"psn_no"`
  22417. PsnPartAmt float64 `json:"psn_part_amt"`
  22418. PsnType string `json:"psn_type"`
  22419. SetlID string `json:"setl_id"`
  22420. SetlTime string `json:"setl_time"`
  22421. } `json:"setlinfo"`
  22422. Setldetail interface{} `json:"setldetail"`
  22423. } `json:"output"`
  22424. RefmsgTime string `json:"refmsg_time"`
  22425. RespondTime string `json:"respond_time"`
  22426. Signtype interface{} `json:"signtype"`
  22427. WarnMsg interface{} `json:"warn_msg"`
  22428. }
  22429. type ResultEight struct {
  22430. Cainfo string `json:"cainfo"`
  22431. ErrMsg string `json:"err_msg"`
  22432. InfRefmsgid string `json:"inf_refmsgid"`
  22433. Infcode int64 `json:"infcode"`
  22434. Output struct {
  22435. Stmtinfo struct {
  22436. SetlOptins string `json:"setl_optins"`
  22437. StmtRslt string `json:"stmt_rslt"`
  22438. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22439. } `json:"stmtinfo"`
  22440. } `json:"output"`
  22441. RefmsgTime string `json:"refmsg_time"`
  22442. RespondTime string `json:"respond_time"`
  22443. Signtype interface{} `json:"signtype"`
  22444. WarnMsg interface{} `json:"warn_msg"`
  22445. }
  22446. type ResultEightFor10188 struct {
  22447. Cainfo string `json:"cainfo"`
  22448. ErrMsg string `json:"err_msg"`
  22449. InfRefmsgid string `json:"inf_refmsgid"`
  22450. Infcode string `json:"infcode"`
  22451. Output struct {
  22452. Stmtinfo struct {
  22453. SetlOptins string `json:"setl_optins"`
  22454. StmtRslt string `json:"stmt_rslt"`
  22455. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22456. } `json:"stmtinfo"`
  22457. } `json:"output"`
  22458. RefmsgTime string `json:"refmsg_time"`
  22459. RespondTime string `json:"respond_time"`
  22460. Signtype interface{} `json:"signtype"`
  22461. WarnMsg interface{} `json:"warn_msg"`
  22462. }
  22463. type ResultNine struct {
  22464. Cainfo string `json:"cainfo"`
  22465. ErrMsg string `json:"err_msg"`
  22466. InfRefmsgid string `json:"inf_refmsgid"`
  22467. Infcode int64 `json:"infcode"`
  22468. Output struct {
  22469. FileQuryNo string `json:"file_qury_no"`
  22470. } `json:"output"`
  22471. RefmsgTime string `json:"refmsg_time"`
  22472. RespondTime string `json:"respond_time"`
  22473. Signtype interface{} `json:"signtype"`
  22474. WarnMsg interface{} `json:"warn_msg"`
  22475. }
  22476. type ResultTen struct {
  22477. Cainfo string `json:"cainfo"`
  22478. ErrMsg string `json:"err_msg"`
  22479. InfRefmsgid string `json:"inf_refmsgid"`
  22480. Infcode int64 `json:"infcode"`
  22481. Output struct {
  22482. Fileinfo struct {
  22483. DldEndtime string `json:"dld_endtime"`
  22484. FileQuryNo string `json:"file_qury_no"`
  22485. Filename string `json:"filename"`
  22486. } `json:"fileinfo"`
  22487. } `json:"output"`
  22488. RefmsgTime string `json:"refmsg_time"`
  22489. RespondTime string `json:"respond_time"`
  22490. Signtype interface{} `json:"signtype"`
  22491. WarnMsg interface{} `json:"warn_msg"`
  22492. }
  22493. type Result5262 struct {
  22494. ErrMsg string `json:"err_msg"`
  22495. InfRefmsgid string `json:"inf_refmsgid"`
  22496. Infcode int64 `json:"infcode"`
  22497. Output struct {
  22498. PageInfo struct {
  22499. Size int `json:"size"`
  22500. RecordCounts int `json:"record_counts"`
  22501. } `json:"page_info"`
  22502. Idetinfo []interface{} `json:"idetinfo"`
  22503. Result []struct {
  22504. SetlID string `json:"setl_id"`
  22505. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22506. MdtrtID string `json:"mdtrt_id"`
  22507. InitSetlID string `json:"init_setl_id,omitempty"`
  22508. PsnNo string `json:"psn_no"`
  22509. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22510. PsnName string `json:"psn_name"`
  22511. PsnCertType string `json:"psn_cert_type"`
  22512. Certno string `json:"certno"`
  22513. Gend string `json:"gend,omitempty"`
  22514. Naty string `json:"naty,omitempty"`
  22515. Brdy string `json:"brdy,omitempty"`
  22516. Age float64 `json:"age,omitempty"`
  22517. Insutype string `json:"insutype,omitempty"`
  22518. PsnType string `json:"psn_type"`
  22519. CvlservFlag string `json:"cvlserv_flag"`
  22520. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22521. SpPsnType string `json:"sp_psn_type,omitempty"`
  22522. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22523. ClctGrde string `json:"clct_grde,omitempty"`
  22524. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22525. NwbFlag string `json:"nwb_flag,omitempty"`
  22526. InsuAdmdvs string `json:"insu_admdvs"`
  22527. EmpNo string `json:"emp_no,omitempty"`
  22528. EmpName string `json:"emp_name,omitempty"`
  22529. EmpType string `json:"emp_type,omitempty"`
  22530. EconType string `json:"econ_type,omitempty"`
  22531. AfilIndu string `json:"afil_indu,omitempty"`
  22532. AfilRlts string `json:"afil_rlts,omitempty"`
  22533. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22534. PayLoc string `json:"pay_loc,omitempty"`
  22535. FixmedinsCode string `json:"fixmedins_code"`
  22536. FixmedinsName string `json:"fixmedins_name"`
  22537. HospLv string `json:"hosp_lv,omitempty"`
  22538. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22539. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22540. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22541. Begndate string `json:"begndate"`
  22542. Enddate string `json:"enddate"`
  22543. SetlTime string `json:"setl_time"`
  22544. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22545. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22546. MedType string `json:"med_type"`
  22547. SetlType string `json:"setl_type,omitempty"`
  22548. ClrType string `json:"clr_type,omitempty"`
  22549. ClrWay string `json:"clr_way,omitempty"`
  22550. PsnSetlway string `json:"psn_setlway,omitempty"`
  22551. ClrOptins string `json:"clr_optins,omitempty"`
  22552. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22553. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22554. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22555. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22556. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22557. DedcStd float64 `json:"dedc_std,omitempty"`
  22558. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22559. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22560. HifpPay float64 `json:"hifp_pay,omitempty"`
  22561. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22562. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22563. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22564. HifesPay float64 `json:"hifes_pay,omitempty"`
  22565. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22566. HifobPay float64 `json:"hifob_pay,omitempty"`
  22567. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22568. MafPay float64 `json:"maf_pay,omitempty"`
  22569. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22570. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22571. PsnPay float64 `json:"psn_pay,omitempty"`
  22572. AcctPay float64 `json:"acct_pay,omitempty"`
  22573. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22574. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22575. Balc float64 `json:"balc,omitempty"`
  22576. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22577. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22578. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22579. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22580. Year string `json:"year,omitempty"`
  22581. DiseNo string `json:"dise_no,omitempty"`
  22582. DiseName string `json:"dise_name,omitempty"`
  22583. Invono string `json:"invono,omitempty"`
  22584. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22585. ValiFlag string `json:"vali_flag,omitempty"`
  22586. Memo string `json:"memo,omitempty"`
  22587. Rid string `json:"rid"`
  22588. UpdtTime string `json:"updt_time,omitempty"`
  22589. CrterID string `json:"crter_id,omitempty"`
  22590. CrterName string `json:"crter_name,omitempty"`
  22591. CrteTime string `json:"crte_time,omitempty"`
  22592. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22593. OpterID string `json:"opter_id,omitempty"`
  22594. OpterName string `json:"opter_name,omitempty"`
  22595. OptTime string `json:"opt_time,omitempty"`
  22596. OptinsNo string `json:"optins_no,omitempty"`
  22597. PoolareaNo string `json:"poolarea_no,omitempty"`
  22598. } `json:"result"`
  22599. } `json:"output"`
  22600. RefmsgTime string `json:"refmsg_time"`
  22601. RespondTime string `json:"respond_time"`
  22602. Signtype interface{} `json:"signtype"`
  22603. WarnInfo interface{} `json:"warn_info"`
  22604. }
  22605. type Result5267 struct {
  22606. ErrMsg string `json:"err_msg"`
  22607. InfRefmsgid string `json:"inf_refmsgid"`
  22608. Infcode int64 `json:"infcode"`
  22609. Output struct {
  22610. PageInfo struct {
  22611. Size int `json:"size"`
  22612. RecordCounts int `json:"record_counts"`
  22613. } `json:"pageinfo"`
  22614. Result []struct {
  22615. SetlID string `json:"setl_id"`
  22616. ClrOptins string `json:"clr_optins"`
  22617. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22618. MdtrtID string `json:"mdtrt_id"`
  22619. InitSetlID string `json:"init_setl_id,omitempty"`
  22620. PsnNo string `json:"psn_no"`
  22621. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22622. PsnName string `json:"psn_name"`
  22623. PsnCertType string `json:"psn_cert_type"`
  22624. Certno string `json:"certno"`
  22625. Gend string `json:"gend,omitempty"`
  22626. Naty string `json:"naty,omitempty"`
  22627. Brdy string `json:"brdy,omitempty"`
  22628. Age float64 `json:"age,omitempty"`
  22629. Insutype string `json:"insutype,omitempty"`
  22630. PsnType string `json:"psn_type"`
  22631. CvlservFlag string `json:"cvlserv_flag"`
  22632. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22633. SpPsnType string `json:"sp_psn_type,omitempty"`
  22634. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22635. ClctGrde string `json:"clct_grde,omitempty"`
  22636. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22637. NwbFlag string `json:"nwb_flag,omitempty"`
  22638. InsuAdmdvs string `json:"insu_admdvs"`
  22639. EmpNo string `json:"emp_no,omitempty"`
  22640. EmpName string `json:"emp_name,omitempty"`
  22641. EmpType string `json:"emp_type,omitempty"`
  22642. EconType string `json:"econ_type,omitempty"`
  22643. AfilIndu string `json:"afil_indu,omitempty"`
  22644. AfilRlts string `json:"afil_rlts,omitempty"`
  22645. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22646. PayLoc string `json:"pay_loc,omitempty"`
  22647. FixmedinsCode string `json:"fixmedins_code"`
  22648. FixmedinsName string `json:"fixmedins_name"`
  22649. HospLv string `json:"hosp_lv,omitempty"`
  22650. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22651. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22652. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22653. Begndate string `json:"begndate,omitempty"`
  22654. Enddate string `json:"enddate,omitempty"`
  22655. SetlTime string `json:"setl_time,omitempty"`
  22656. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22657. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22658. MedType string `json:"med_type"`
  22659. SetlType string `json:"setl_type,omitempty"`
  22660. ClrType string `json:"clr_type,omitempty"`
  22661. ClrWay string `json:"clr_way,omitempty"`
  22662. PsnSetlway string `json:"psn_setlway,omitempty"`
  22663. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22664. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22665. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22666. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22667. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22668. DedcStd float64 `json:"dedc_std,omitempty"`
  22669. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22670. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22671. HifpPay float64 `json:"hifp_pay,omitempty"`
  22672. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22673. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22674. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22675. HifesPay float64 `json:"hifes_pay,omitempty"`
  22676. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22677. HifobPay float64 `json:"hifob_pay,omitempty"`
  22678. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22679. MafPay float64 `json:"maf_pay,omitempty"`
  22680. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22681. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22682. PsnPay float64 `json:"psn_pay,omitempty"`
  22683. AcctPay float64 `json:"acct_pay,omitempty"`
  22684. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22685. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22686. Balc float64 `json:"balc,omitempty"`
  22687. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22688. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22689. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22690. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22691. Year string `json:"year,omitempty"`
  22692. DiseNo string `json:"dise_no,omitempty"`
  22693. DiseName string `json:"dise_name,omitempty"`
  22694. Invono string `json:"invono,omitempty"`
  22695. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22696. Memo string `json:"memo,omitempty"`
  22697. UpdtTime string `json:"updt_time,omitempty"`
  22698. OpterID string `json:"opter_id,omitempty"`
  22699. OpterName string `json:"opter_name,omitempty"`
  22700. OptTime string `json:"opt_time,omitempty"`
  22701. OptinsNo string `json:"optins_no,omitempty"`
  22702. PoolareaNo string `json:"poolarea_no,omitempty"`
  22703. } `json:"result"`
  22704. } `json:"output"`
  22705. RefmsgTime string `json:"refmsg_time"`
  22706. RespondTime string `json:"respond_time"`
  22707. Signtype interface{} `json:"signtype"`
  22708. WarnInfo interface{} `json:"warn_info"`
  22709. }
  22710. // type Autogenerated struct {
  22711. // Output struct {
  22712. // Setlinfo struct {
  22713. // SetlTime string `json:"setl_time"`
  22714. // CvlservPay float64 `json:"cvlserv_pay"`
  22715. // Year string `json:"year"`
  22716. // MedType string `json:"med_type"`
  22717. // PsnPay float64 `json:"psn_pay"`
  22718. // OpterID string `json:"opter_id"`
  22719. // Begndate string `json:"begndate"`
  22720. // FlxempeFlag string `json:"flxempe_flag"`
  22721. // HifmiPay float64 `json:"hifmi_pay"`
  22722. // PsnNo string `json:"psn_no"`
  22723. // ActPayDedc float64 `json:"act_pay_dedc"`
  22724. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22725. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22726. // ClrWay string `json:"clr_way"`
  22727. // OthPay float64 `json:"oth_pay"`
  22728. // Gend string `json:"gend"`
  22729. // MdtrtID string `json:"mdtrt_id"`
  22730. // AcctPay float64 `json:"acct_pay"`
  22731. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22732. // Insutype string `json:"insutype"`
  22733. // Invono interface{} `json:"invono"`
  22734. // Enddate string `json:"enddate"`
  22735. // CashPayamt float64 `json:"cash_payamt"`
  22736. // PsnType string `json:"psn_type"`
  22737. // FixmedinsName string `json:"fixmedins_name"`
  22738. // HifpPay float64 `json:"hifp_pay"`
  22739. // NewFlag interface{} `json:"new_flag"`
  22740. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22741. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22742. // PayLoc string `json:"pay_loc"`
  22743. // ClrType string `json:"clr_type"`
  22744. // RefdSetlFlag string `json:"refd_setl_flag"`
  22745. // CvlservFlag string `json:"cvlserv_flag"`
  22746. // EmpName string `json:"emp_name"`
  22747. // Brdy string `json:"brdy"`
  22748. // Naty string `json:"naty"`
  22749. // Certno string `json:"certno"`
  22750. // DiseCode string `json:"dise_code"`
  22751. // FixmedinsCode string `json:"fixmedins_code"`
  22752. // DedcHospLv string `json:"dedc_hosp_lv"`
  22753. // OpterName string `json:"opter_name"`
  22754. // Balc float64 `json:"balc"`
  22755. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22756. // PsnCertType string `json:"psn_cert_type"`
  22757. // HifobPay float64 `json:"hifob_pay"`
  22758. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22759. // HifesPay float64 `json:"hifes_pay"`
  22760. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22761. // OptTime string `json:"opt_time"`
  22762. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22763. // SetlID string `json:"setl_id"`
  22764. // MafPay float64 `json:"maf_pay"`
  22765. // PsnName string `json:"psn_name"`
  22766. // InsuOptins interface{} `json:"insu_optins"`
  22767. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22768. // ClrOptins string `json:"clr_optins"`
  22769. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22770. // DiseName string `json:"dise_name"`
  22771. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22772. // Age float64 `json:"age"`
  22773. // DtrtCertType string `json:"dtrt_cert_type"`
  22774. // HospLv string `json:"hosp_lv"`
  22775. // } `json:"setlinfo"`
  22776. // Setldetail []struct {
  22777. // FundPayType string `json:"fund_pay_type"`
  22778. // FundPayamt float64 `json:"fund_payamt"`
  22779. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22780. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22781. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22782. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22783. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22784. // } `json:"setldetail"`
  22785. // } `json:"output"`
  22786. // Infcode int `json:"infcode"`
  22787. // WarnMsg interface{} `json:"warn_msg"`
  22788. // Cainfo interface{} `json:"cainfo"`
  22789. // ErrMsg interface{} `json:"err_msg"`
  22790. // RefmsgTime string `json:"refmsg_time"`
  22791. // Signtype interface{} `json:"signtype"`
  22792. // RespondTime string `json:"respond_time"`
  22793. // InfRefmsgid string `json:"inf_refmsgid"`
  22794. // }
  22795. type Result002 struct {
  22796. Cainfo interface{} `json:"cainfo"`
  22797. ErrMsg string `json:"err_msg"`
  22798. InfRefmsgid string `json:"inf_refmsgid"`
  22799. Infcode int64 `json:"infcode"`
  22800. Output struct {
  22801. RxFile string `json:"rx_file"`
  22802. SignDigest string `json:"sign_digest"`
  22803. SignCertSn string `json:"sign_cert_sn"`
  22804. SignCertDn string `json:"sign_cert_dn"`
  22805. } `json:"output"`
  22806. RefmsgTime string `json:"refmsg_time"`
  22807. RespondTime string `json:"respond_time"`
  22808. Signtype interface{} `json:"signtype"`
  22809. WarnMsg interface{} `json:"warn_msg"`
  22810. }
  22811. type Result003 struct {
  22812. Cainfo interface{} `json:"cainfo"`
  22813. ErrMsg string `json:"err_msg"`
  22814. InfRefmsgid string `json:"inf_refmsgid"`
  22815. Infcode int64 `json:"infcode"`
  22816. Output struct {
  22817. HiRxno string `json:"hi_rxno"`
  22818. RxStasCodg string `json:"rx_stas_codg"`
  22819. RxStasName string `json:"rx_stas_name"`
  22820. } `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 ResultEleven struct {
  22827. Cainfo string `json:"cainfo"`
  22828. ErrMsg string `json:"err_msg"`
  22829. InfRefmsgid string `json:"inf_refmsgid"`
  22830. Infcode int64 `json:"infcode"`
  22831. Output struct {
  22832. Setlinfo struct {
  22833. SetlTime string `json:"setl_time"`
  22834. CvlservPay float64 `json:"cvlserv_pay"`
  22835. Year string `json:"year"`
  22836. MedType string `json:"med_type"`
  22837. PsnPay float64 `json:"psn_pay"`
  22838. OpterID string `json:"opter_id"`
  22839. Begndate string `json:"begndate"`
  22840. FlxempeFlag string `json:"flxempe_flag"`
  22841. HifmiPay float64 `json:"hifmi_pay"`
  22842. PsnNo string `json:"psn_no"`
  22843. ActPayDedc float64 `json:"act_pay_dedc"`
  22844. MedinsSetlID interface{} `json:"medins_setl_id"`
  22845. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22846. ClrWay string `json:"clr_way"`
  22847. OthPay float64 `json:"oth_pay"`
  22848. Gend string `json:"gend"`
  22849. MdtrtID string `json:"mdtrt_id"`
  22850. AcctPay float64 `json:"acct_pay"`
  22851. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22852. Insutype string `json:"insutype"`
  22853. Invono interface{} `json:"invono"`
  22854. Enddate string `json:"enddate"`
  22855. CashPayamt float64 `json:"cash_payamt"`
  22856. PsnType string `json:"psn_type"`
  22857. FixmedinsName string `json:"fixmedins_name"`
  22858. HifpPay float64 `json:"hifp_pay"`
  22859. NewFlag interface{} `json:"new_flag"`
  22860. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22861. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22862. PayLoc string `json:"pay_loc"`
  22863. ClrType string `json:"clr_type"`
  22864. RefdSetlFlag string `json:"refd_setl_flag"`
  22865. CvlservFlag string `json:"cvlserv_flag"`
  22866. EmpName string `json:"emp_name"`
  22867. Brdy string `json:"brdy"`
  22868. Naty string `json:"naty"`
  22869. Certno string `json:"certno"`
  22870. DiseCode string `json:"dise_code"`
  22871. FixmedinsCode string `json:"fixmedins_code"`
  22872. DedcHospLv string `json:"dedc_hosp_lv"`
  22873. OpterName string `json:"opter_name"`
  22874. Balc float64 `json:"balc"`
  22875. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22876. PsnCertType string `json:"psn_cert_type"`
  22877. HifobPay float64 `json:"hifob_pay"`
  22878. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22879. HifesPay float64 `json:"hifes_pay"`
  22880. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22881. OptTime string `json:"opt_time"`
  22882. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22883. SetlID string `json:"setl_id"`
  22884. MafPay float64 `json:"maf_pay"`
  22885. PsnName string `json:"psn_name"`
  22886. InsuOptins interface{} `json:"insu_optins"`
  22887. PrefFundPay interface{} `json:"pref_fund_pay"`
  22888. ClrOptins string `json:"clr_optins"`
  22889. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22890. DiseName string `json:"dise_name"`
  22891. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22892. Age float64 `json:"age"`
  22893. DtrtCertType string `json:"dtrt_cert_type"`
  22894. HospLv string `json:"hosp_lv"`
  22895. PsnCashPay float64 `json:"psn_cash_pay"`
  22896. } `json:"setlinfo"`
  22897. } `json:"output"`
  22898. RefmsgTime string `json:"refmsg_time"`
  22899. RespondTime string `json:"respond_time"`
  22900. Signtype interface{} `json:"signtype"`
  22901. WarnMsg interface{} `json:"warn_msg"`
  22902. }
  22903. type ResultElevenah struct {
  22904. Cainfo string `json:"cainfo"`
  22905. ErrMsg string `json:"err_msg"`
  22906. InfRefmsgid string `json:"inf_refmsgid"`
  22907. Infcode int64 `json:"infcode"`
  22908. Output struct {
  22909. Setlinfo struct {
  22910. SetlTime int64 `json:"setl_time"`
  22911. CvlservPay float64 `json:"cvlserv_pay"`
  22912. Year string `json:"year"`
  22913. MedType string `json:"med_type"`
  22914. PsnPay float64 `json:"psn_pay"`
  22915. OpterID string `json:"opter_id"`
  22916. Begndate int64 `json:"begndate"`
  22917. FlxempeFlag string `json:"flxempe_flag"`
  22918. HifmiPay float64 `json:"hifmi_pay"`
  22919. PsnNo string `json:"psn_no"`
  22920. ActPayDedc float64 `json:"act_pay_dedc"`
  22921. MedinsSetlID interface{} `json:"medins_setl_id"`
  22922. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22923. ClrWay string `json:"clr_way"`
  22924. OthPay float64 `json:"oth_pay"`
  22925. Gend string `json:"gend"`
  22926. MdtrtID string `json:"mdtrt_id"`
  22927. AcctPay float64 `json:"acct_pay"`
  22928. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22929. Insutype string `json:"insutype"`
  22930. Invono interface{} `json:"invono"`
  22931. Enddate int64 `json:"enddate"`
  22932. CashPayamt float64 `json:"cash_payamt"`
  22933. PsnType string `json:"psn_type"`
  22934. FixmedinsName string `json:"fixmedins_name"`
  22935. HifpPay float64 `json:"hifp_pay"`
  22936. NewFlag interface{} `json:"new_flag"`
  22937. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22938. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22939. PayLoc string `json:"pay_loc"`
  22940. ClrType string `json:"clr_type"`
  22941. RefdSetlFlag string `json:"refd_setl_flag"`
  22942. CvlservFlag string `json:"cvlserv_flag"`
  22943. EmpName string `json:"emp_name"`
  22944. Brdy int64 `json:"brdy"`
  22945. Naty string `json:"naty"`
  22946. Certno string `json:"certno"`
  22947. DiseCode string `json:"dise_code"`
  22948. FixmedinsCode string `json:"fixmedins_code"`
  22949. DedcHospLv string `json:"dedc_hosp_lv"`
  22950. OpterName string `json:"opter_name"`
  22951. Balc float64 `json:"balc"`
  22952. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22953. PsnCertType string `json:"psn_cert_type"`
  22954. HifobPay float64 `json:"hifob_pay"`
  22955. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22956. HifesPay float64 `json:"hifes_pay"`
  22957. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22958. OptTime int64 `json:"opt_time"`
  22959. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22960. SetlID string `json:"setl_id"`
  22961. MafPay float64 `json:"maf_pay"`
  22962. PsnName string `json:"psn_name"`
  22963. InsuOptins interface{} `json:"insu_optins"`
  22964. PrefFundPay interface{} `json:"pref_fund_pay"`
  22965. ClrOptins string `json:"clr_optins"`
  22966. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22967. DiseName string `json:"dise_name"`
  22968. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22969. Age float64 `json:"age"`
  22970. DtrtCertType string `json:"dtrt_cert_type"`
  22971. HospLv string `json:"hosp_lv"`
  22972. PsnCashPay float64 `json:"psn_cash_pay"`
  22973. } `json:"setlinfo"`
  22974. } `json:"output"`
  22975. RefmsgTime string `json:"refmsg_time"`
  22976. RespondTime string `json:"respond_time"`
  22977. Signtype interface{} `json:"signtype"`
  22978. WarnMsg interface{} `json:"warn_msg"`
  22979. }
  22980. type ResultEleven10265 struct {
  22981. Cainfo string `json:"cainfo"`
  22982. ErrMsg string `json:"err_msg"`
  22983. InfRefmsgid string `json:"inf_refmsgid"`
  22984. Infcode string `json:"infcode"`
  22985. Output struct {
  22986. Setlinfo struct {
  22987. SetlTime string `json:"setl_time"`
  22988. CvlservPay float64 `json:"cvlserv_pay"`
  22989. Year string `json:"year"`
  22990. MedType string `json:"med_type"`
  22991. PsnPay float64 `json:"psn_pay"`
  22992. OpterID string `json:"opter_id"`
  22993. Begndate string `json:"begndate"`
  22994. FlxempeFlag string `json:"flxempe_flag"`
  22995. HifmiPay float64 `json:"hifmi_pay"`
  22996. PsnNo string `json:"psn_no"`
  22997. ActPayDedc float64 `json:"act_pay_dedc"`
  22998. MedinsSetlID interface{} `json:"medins_setl_id"`
  22999. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23000. ClrWay string `json:"clr_way"`
  23001. OthPay float64 `json:"oth_pay"`
  23002. Gend string `json:"gend"`
  23003. MdtrtID string `json:"mdtrt_id"`
  23004. AcctPay float64 `json:"acct_pay"`
  23005. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23006. Insutype string `json:"insutype"`
  23007. Invono interface{} `json:"invono"`
  23008. Enddate string `json:"enddate"`
  23009. CashPayamt float64 `json:"cash_payamt"`
  23010. PsnType string `json:"psn_type"`
  23011. FixmedinsName string `json:"fixmedins_name"`
  23012. HifpPay float64 `json:"hifp_pay"`
  23013. NewFlag interface{} `json:"new_flag"`
  23014. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23015. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23016. PayLoc string `json:"pay_loc"`
  23017. ClrType string `json:"clr_type"`
  23018. RefdSetlFlag string `json:"refd_setl_flag"`
  23019. CvlservFlag string `json:"cvlserv_flag"`
  23020. EmpName string `json:"emp_name"`
  23021. Brdy string `json:"brdy"`
  23022. Naty string `json:"naty"`
  23023. Certno string `json:"certno"`
  23024. DiseCode string `json:"dise_code"`
  23025. FixmedinsCode string `json:"fixmedins_code"`
  23026. DedcHospLv string `json:"dedc_hosp_lv"`
  23027. OpterName string `json:"opter_name"`
  23028. Balc float64 `json:"balc"`
  23029. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23030. PsnCertType string `json:"psn_cert_type"`
  23031. HifobPay float64 `json:"hifob_pay"`
  23032. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23033. HifesPay float64 `json:"hifes_pay"`
  23034. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23035. OptTime string `json:"opt_time"`
  23036. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23037. SetlID string `json:"setl_id"`
  23038. MafPay float64 `json:"maf_pay"`
  23039. PsnName string `json:"psn_name"`
  23040. InsuOptins interface{} `json:"insu_optins"`
  23041. PrefFundPay interface{} `json:"pref_fund_pay"`
  23042. ClrOptins string `json:"clr_optins"`
  23043. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23044. DiseName string `json:"dise_name"`
  23045. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23046. Age float64 `json:"age"`
  23047. DtrtCertType string `json:"dtrt_cert_type"`
  23048. HospLv string `json:"hosp_lv"`
  23049. PsnCashPay float64 `json:"psn_cash_pay"`
  23050. } `json:"setlinfo"`
  23051. } `json:"output"`
  23052. RefmsgTime string `json:"refmsg_time"`
  23053. RespondTime string `json:"respond_time"`
  23054. Signtype interface{} `json:"signtype"`
  23055. WarnMsg interface{} `json:"warn_msg"`
  23056. }
  23057. type ResultTwelve struct {
  23058. Cainfo string `json:"cainfo"`
  23059. ErrMsg string `json:"err_msg"`
  23060. InfRefmsgid string `json:"inf_refmsgid"`
  23061. Infcode int64 `json:"infcode"`
  23062. Output struct {
  23063. MdtrtId string `json:"mdtrt_id"`
  23064. ChrgBchno string `json:"chrg_bchno"`
  23065. PsnNo string `json:"psn_no"`
  23066. } `json:"output"`
  23067. RefmsgTime string `json:"refmsg_time"`
  23068. RespondTime string `json:"respond_time"`
  23069. Signtype interface{} `json:"signtype"`
  23070. WarnMsg interface{} `json:"warn_msg"`
  23071. }
  23072. type ResultThirteen struct {
  23073. ErrMsg string `json:"err_msg"`
  23074. InfRefmsgid string `json:"inf_refmsgid"`
  23075. Infcode int64 `json:"infcode"`
  23076. Output struct {
  23077. Result struct {
  23078. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23079. } `json:"result"`
  23080. } `json:"output"`
  23081. RefmsgTime string `json:"refmsg_time"`
  23082. RespondTime string `json:"respond_time"`
  23083. Signtype interface{} `json:"signtype"`
  23084. WarnInfo interface{} `json:"warn_info"`
  23085. }
  23086. type ResultThirteen10265 struct {
  23087. ErrMsg string `json:"err_msg"`
  23088. InfRefmsgid string `json:"inf_refmsgid"`
  23089. Infcode string `json:"infcode"`
  23090. Output struct {
  23091. Result struct {
  23092. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23093. } `json:"result"`
  23094. } `json:"output"`
  23095. RefmsgTime string `json:"refmsg_time"`
  23096. RespondTime string `json:"respond_time"`
  23097. Signtype interface{} `json:"signtype"`
  23098. WarnInfo interface{} `json:"warn_info"`
  23099. }
  23100. type ResultFourteen struct {
  23101. ErrMsg string `json:"err_msg"`
  23102. InfRefmsgid string `json:"inf_refmsgid"`
  23103. Infcode int64 `json:"infcode"`
  23104. Output struct {
  23105. } `json:"output"`
  23106. RefmsgTime string `json:"refmsg_time"`
  23107. RespondTime string `json:"respond_time"`
  23108. Signtype interface{} `json:"signtype"`
  23109. WarnInfo interface{} `json:"warn_info"`
  23110. }
  23111. type ResultCFYLJG001 struct {
  23112. ErrMsg string `json:"err_msg"`
  23113. InfRefmsgid string `json:"inf_refmsgid"`
  23114. Infcode int64 `json:"infcode"`
  23115. Output struct {
  23116. RxTraceCode string `json:"rx_trace_code"`
  23117. HiRxno string `json:"hi_rxno"`
  23118. } `json:"output"`
  23119. RefmsgTime string `json:"refmsg_time"`
  23120. RespondTime string `json:"respond_time"`
  23121. Signtype interface{} `json:"signtype"`
  23122. WarnInfo interface{} `json:"warn_info"`
  23123. }
  23124. type ResultCFYLJG007 struct {
  23125. ErrMsg string `json:"err_msg"`
  23126. InfRefmsgid string `json:"inf_refmsgid"`
  23127. Infcode int64 `json:"infcode"`
  23128. Output struct {
  23129. HiRxno string `json:"hi_rxno"`
  23130. RxStasName string `json:"rx_stas_name"`
  23131. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23132. Seltdelts []interface{} `json:"seltdelts"`
  23133. RxUsedStasName string `json:"rx_used_stas_name"`
  23134. RxStasCodg string `json:"rx_stas_codg"`
  23135. } `json:"output"`
  23136. RefmsgTime string `json:"refmsg_time"`
  23137. RespondTime string `json:"respond_time"`
  23138. Signtype interface{} `json:"signtype"`
  23139. WarnInfo interface{} `json:"warn_info"`
  23140. }
  23141. type ResultCFYLJG002 struct {
  23142. ErrMsg string `json:"err_msg"`
  23143. InfRefmsgid string `json:"inf_refmsgid"`
  23144. Infcode int64 `json:"infcode"`
  23145. Output struct {
  23146. RxFile string `json:"rx_file"`
  23147. SignDigest string `json:"sign_digest"`
  23148. SignCertSn string `json:"sign_cert_sn"`
  23149. SignCertDn string `json:"sign_cert_dn"`
  23150. } `json:"output"`
  23151. RefmsgTime string `json:"refmsg_time"`
  23152. RespondTime string `json:"respond_time"`
  23153. Signtype interface{} `json:"signtype"`
  23154. WarnInfo interface{} `json:"warn_info"`
  23155. }
  23156. type ResultCFYLJG003 struct {
  23157. ErrMsg string `json:"err_msg"`
  23158. InfRefmsgid string `json:"inf_refmsgid"`
  23159. Infcode int64 `json:"infcode"`
  23160. Output struct {
  23161. HiRxno string `json:"hi_rxno"`
  23162. RxStasCodg string `json:"rx_stas_codg"`
  23163. RxStasName string `json:"rx_stas_name"`
  23164. } `json:"output"`
  23165. RefmsgTime string `json:"refmsg_time"`
  23166. RespondTime string `json:"respond_time"`
  23167. Signtype interface{} `json:"signtype"`
  23168. WarnInfo interface{} `json:"warn_info"`
  23169. }
  23170. type ResultCFYLJG004 struct {
  23171. ErrMsg string `json:"err_msg"`
  23172. InfRefmsgid string `json:"inf_refmsgid"`
  23173. Infcode int64 `json:"infcode"`
  23174. Output struct {
  23175. HiRxno string `json:"hi_rxno"`
  23176. RxStasCodg string `json:"rx_stas_codg"`
  23177. RxStasName string `json:"rx_stas_name"`
  23178. } `json:"output"`
  23179. RefmsgTime string `json:"refmsg_time"`
  23180. RespondTime string `json:"respond_time"`
  23181. Signtype interface{} `json:"signtype"`
  23182. WarnInfo interface{} `json:"warn_info"`
  23183. }
  23184. type ResultCFYLJG008 struct {
  23185. ErrMsg string `json:"err_msg"`
  23186. InfRefmsgid string `json:"inf_refmsgid"`
  23187. Infcode int64 `json:"infcode"`
  23188. Output struct {
  23189. PoolareaNo string `json:"poolareaNo"`
  23190. AdmdvsName string `json:"admdvsName"`
  23191. Count string `json:"count"`
  23192. } `json:"output"`
  23193. RefmsgTime string `json:"refmsg_time"`
  23194. RespondTime string `json:"respond_time"`
  23195. Signtype interface{} `json:"signtype"`
  23196. WarnInfo interface{} `json:"warn_info"`
  23197. }
  23198. type ResultCFYLJG005 struct {
  23199. ErrMsg string `json:"err_msg"`
  23200. InfRefmsgid string `json:"inf_refmsgid"`
  23201. Infcode int64 `json:"infcode"`
  23202. Output struct {
  23203. HiRxNo string `json:"hi_rxno"`
  23204. FixMedinsCode string `json:"fixmedins_code"`
  23205. FixMedinsName string `json:"fixmedins_name"`
  23206. RxStasCodg string `json:"rx_stas_codg"`
  23207. RxStasName string `json:"rx_stas_name"`
  23208. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23209. RxUserdStasName string `json:"rx_userd_stas_name"`
  23210. PrscTime string `json:"prsc_time"`
  23211. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23212. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23213. RxUsedWayName string `json:"rx_used_way_name"`
  23214. RxFrquCodg string `json:"rx_frqu_codg"`
  23215. RxFrquName string `json:"rx_frqu_name"`
  23216. RxDosunt string `json:"rx_dosunt"`
  23217. RxDoscnt float64 `json:"rx_doscnt"`
  23218. RxDrordDscr string `json:"rx_drord_dscr"`
  23219. ValiDays int64 `json:"vali_days"`
  23220. ValiEndTime string `json:"vali_end_time"`
  23221. ReptFlag string `json:"rept_flag"`
  23222. MaxReptCnt int64 `json:"max_rept_cnt"`
  23223. ReptdCnt int64 `json:"reptd_cnt"`
  23224. MinInrvDays int64 `json:"min_inrv_days"`
  23225. RxTypeCode string `json:"rx_type_code"`
  23226. RxTypeName string `json:"rx_type_name"`
  23227. LongRxFlag string `json:"long_rx_flag"`
  23228. RxDetlList []struct {
  23229. MedListCodg string `json:"med_list_codg"`
  23230. MedinsListCodg string `json:"medins_list_codg"`
  23231. HospPrepFlag string `json:"hosp_prep_flag"`
  23232. RxItemTypeCode string `json:"rx_item_type_code"`
  23233. RxItemTypeName string `json:"rx_item_type_name"`
  23234. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23235. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23236. TcmHerbFoote string `json:"tcmherb_foote"`
  23237. MednTypeCode string `json:"medn_type_code"`
  23238. MednTypeName string `json:"medn_type_name"`
  23239. MainMedcFlag string `json:"main_medc_flag"`
  23240. UrgtFlag string `json:"urgt_flag"`
  23241. BasMednFlag string `json:"bas_medn_flag"`
  23242. ImpDrugFlag string `json:"imp_drug_flag"`
  23243. ProdBarc string `json:"prod_barc"`
  23244. DrugProdname string `json:"drug_prodname"`
  23245. GennameCodg string `json:"genname_codg"`
  23246. DrugGenname string `json:"drug_genname"`
  23247. DrugDosform string `json:"drug_dosform"`
  23248. DrugSpec string `json:"drug_spec"`
  23249. PrdrName string `json:"prdr_name"`
  23250. MedcWayCodg string `json:"medc_way_codg"`
  23251. MedcWayDscr string `json:"medc_way_dscr"`
  23252. MedcBegntime string `json:"medc_begntime"`
  23253. MedcEndtime string `json:"medc_endtime"`
  23254. MedcDays float64 `json:"medc_days"`
  23255. DrugPric float64 `json:"drug_pric"`
  23256. DrugSumamt float64 `json:"drug_sumamt"`
  23257. DrugCnt float64 `json:"drug_cnt"`
  23258. DrugDosunt string `json:"drug_dosunt"`
  23259. SinDoscnt float64 `json:"sin_doscnt"`
  23260. SinDosunt string `json:"sin_dosunt"`
  23261. UsedFrquCodg string `json:"used_frqu_codg"`
  23262. UsedFrquName string `json:"used_frqu_name"`
  23263. DrugTotlcnt string `json:"drug_totlcnt"`
  23264. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  23265. DiseCodg string `json:"dise_codg"`
  23266. HospApprFlag string `json:"hosp_appr_flag"`
  23267. } `json:"rx_detl_list"`
  23268. RxOtpinfo struct {
  23269. MedType string `json:"med_type"`
  23270. IptOtpNo string `json:"ipt_otp_no"`
  23271. OtpIptFlag string `json:"otp_ipt_flag"`
  23272. PatnName string `json:"patn_name"`
  23273. PatnAge float64 `json:"patn_age"`
  23274. PatnHgt float64 `json:"patn_hgt"`
  23275. PatnWt float64 `json:"patn_wt"`
  23276. Gend string `json:"gend"`
  23277. GesoVal float64 `json:"geso_val"`
  23278. NwbFlag string `json:"nwb_flag"`
  23279. NwbAge string `json:"nwb_age"`
  23280. SuckPrdFlag string `json:"suck_prd_flag"`
  23281. AlgsHis string `json:"algs_his"`
  23282. Insutype string `json:"insutype"`
  23283. PrscDeptName string `json:"prsc_dept_name"`
  23284. PrscDrName string `json:"prsc_dr_name"`
  23285. PharName string `json:"phar_name"`
  23286. PharChkTime string `json:"phar_chk_time"`
  23287. MdtrtTime string `json:"mdtrt_time"`
  23288. DiseCodg string `json:"dise_codg"`
  23289. DiseName string `json:"dise_name"`
  23290. SpDiseFlag string `json:"sp_dise_flag"`
  23291. MaindiagCode string `json:"maindiag_code"`
  23292. MaindiagName string `json:"maindiag_name"`
  23293. DiseCondDscr string `json:"dise_cond_dscr"`
  23294. FstdiagFlag string `json:"fstdiag_flag"`
  23295. } `json:"rx_otpinfo"`
  23296. RxDiseList []struct {
  23297. DiagType string `json:"diag_type"`
  23298. MaindiagFlag string `json:"maindiag_flag"`
  23299. DiagSrtNo string `json:"diag_srt_no"`
  23300. DiagCode string `json:"diag_code"`
  23301. DiagName string `json:"diag_name"`
  23302. DiagDept string `json:"diag_dept"`
  23303. DiagDrNo string `json:"diag_dr_no"`
  23304. DiagDrName string `json:"diag_dr_name"`
  23305. DiagTime string `json:"diag_time"`
  23306. TcmDiseCode string `json:"tcm_dise_code"`
  23307. TcmDiseName string `json:"tcm_dise_name"`
  23308. TcmSympCode string `json:"tcmsymp_code"`
  23309. TcmSymp string `json:"tcmsymp"`
  23310. } `json:"rx_dise_list"`
  23311. } `json:"output"`
  23312. RefmsgTime string `json:"refmsg_time"`
  23313. RespondTime string `json:"respond_time"`
  23314. Signtype interface{} `json:"signtype"`
  23315. WarnInfo interface{} `json:"warn_info"`
  23316. }
  23317. type ResultCFYLJG006 struct {
  23318. ErrMsg string `json:"err_msg"`
  23319. InfRefmsgid string `json:"inf_refmsgid"`
  23320. Infcode int64 `json:"infcode"`
  23321. Output struct {
  23322. HiRxNo string `json:"hi_rxno"`
  23323. PharCode string `json:"phar_code"`
  23324. PharName string `json:"phar_name"`
  23325. RxChkOpnn string `json:"rx_chk_opnn"`
  23326. RxChkTime string `json:"rx_chk_time"`
  23327. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  23328. RxChkStasName string `json:"rx_chk_stas_name"`
  23329. RxStasCodg string `json:"rx_stas_codg"`
  23330. RxStasName string `json:"rx_stas_name"`
  23331. } `json:"output"`
  23332. RefmsgTime string `json:"refmsg_time"`
  23333. RespondTime string `json:"respond_time"`
  23334. Signtype interface{} `json:"signtype"`
  23335. WarnInfo interface{} `json:"warn_info"`
  23336. }
  23337. type ResultFourteen10265 struct {
  23338. ErrMsg string `json:"err_msg"`
  23339. InfRefmsgid string `json:"inf_refmsgid"`
  23340. Infcode string `json:"infcode"`
  23341. Output struct {
  23342. } `json:"output"`
  23343. RefmsgTime string `json:"refmsg_time"`
  23344. RespondTime string `json:"respond_time"`
  23345. Signtype interface{} `json:"signtype"`
  23346. WarnInfo interface{} `json:"warn_info"`
  23347. }
  23348. type ResultSixteen struct {
  23349. Cainfo string `json:"cainfo"`
  23350. ErrMsg string `json:"err_msg"`
  23351. InfRefmsgid string `json:"inf_refmsgid"`
  23352. Infcode int64 `json:"infcode"`
  23353. Output struct {
  23354. Setlinfo struct {
  23355. MdtrtID string `json:"mdtrt_id"`
  23356. SetlID string `json:"setl_id"`
  23357. ClrOptins string `json:"clr_optins"`
  23358. SetlTime string `json:"setl_time"`
  23359. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23360. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23361. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23362. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23363. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23364. ActPayDedc float64 `json:"act_pay_dedc"`
  23365. HifpPay float64 `json:"hifp_pay"`
  23366. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23367. Lfpay float64 `json:"selfpay"`
  23368. CvlservPay float64 `json:"cvlserv_pay"`
  23369. HifesPay float64 `json:"hifes_pay"`
  23370. HifmiPay float64 `json:"hifmi_pay"`
  23371. HifobPay float64 `json:"hifob_pay"`
  23372. MafPay float64 `json:"maf_pay"`
  23373. OthPay float64 `json:"oth_pay"`
  23374. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23375. PsnPartAmt float64 `json:"psn_part_amt"`
  23376. AcctPay float64 `json:"acct_pay"`
  23377. Balc float64 `json:"balc"`
  23378. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23379. HospPartAmt float64 `json:"hosp_part_amt"`
  23380. MedinsSetlID string `json:"medins_setl_id"`
  23381. PdnCashPay string `json:"pdn_cash_pay"`
  23382. } `json:"setlinfo"`
  23383. } `json:"output"`
  23384. RefmsgTime string `json:"refmsg_time"`
  23385. RespondTime string `json:"respond_time"`
  23386. Signtype interface{} `json:"signtype"`
  23387. WarnMsg interface{} `json:"warn_msg"`
  23388. }
  23389. type ResultSixteen10265 struct {
  23390. Cainfo string `json:"cainfo"`
  23391. ErrMsg string `json:"err_msg"`
  23392. InfRefmsgid string `json:"inf_refmsgid"`
  23393. Infcode string `json:"infcode"`
  23394. Output struct {
  23395. Setlinfo struct {
  23396. MdtrtID string `json:"mdtrt_id"`
  23397. SetlID string `json:"setl_id"`
  23398. ClrOptins string `json:"clr_optins"`
  23399. SetlTime string `json:"setl_time"`
  23400. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23401. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23402. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23403. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23404. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23405. ActPayDedc float64 `json:"act_pay_dedc"`
  23406. HifpPay float64 `json:"hifp_pay"`
  23407. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23408. Lfpay float64 `json:"selfpay"`
  23409. CvlservPay float64 `json:"cvlserv_pay"`
  23410. HifesPay float64 `json:"hifes_pay"`
  23411. HifmiPay float64 `json:"hifmi_pay"`
  23412. HifobPay float64 `json:"hifob_pay"`
  23413. MafPay float64 `json:"maf_pay"`
  23414. OthPay float64 `json:"oth_pay"`
  23415. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23416. PsnPartAmt float64 `json:"psn_part_amt"`
  23417. AcctPay float64 `json:"acct_pay"`
  23418. Balc float64 `json:"balc"`
  23419. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23420. HospPartAmt float64 `json:"hosp_part_amt"`
  23421. MedinsSetlID string `json:"medins_setl_id"`
  23422. PdnCashPay string `json:"pdn_cash_pay"`
  23423. } `json:"setlinfo"`
  23424. } `json:"output"`
  23425. RefmsgTime string `json:"refmsg_time"`
  23426. RespondTime string `json:"respond_time"`
  23427. Signtype interface{} `json:"signtype"`
  23428. WarnMsg interface{} `json:"warn_msg"`
  23429. }
  23430. type ResultSixteen10265Two struct {
  23431. Cainfo string `json:"cainfo"`
  23432. ErrMsg string `json:"err_msg"`
  23433. InfRefmsgid string `json:"inf_refmsgid"`
  23434. Infcode string `json:"infcode"`
  23435. Output struct {
  23436. Setlinfo interface{} `json:"setlinfo"`
  23437. } `json:"output"`
  23438. RefmsgTime string `json:"refmsg_time"`
  23439. RespondTime string `json:"respond_time"`
  23440. Signtype interface{} `json:"signtype"`
  23441. WarnMsg interface{} `json:"warn_msg"`
  23442. }
  23443. type ResultgzSixteen10265Two struct {
  23444. Cainfo string `json:"cainfo"`
  23445. ErrMsg string `json:"err_msg"`
  23446. InfRefmsgid string `json:"inf_refmsgid"`
  23447. Infcode int64 `json:"infcode"`
  23448. Output struct {
  23449. Setlinfo interface{} `json:"setlinfo"`
  23450. } `json:"output"`
  23451. RefmsgTime string `json:"refmsg_time"`
  23452. RespondTime string `json:"respond_time"`
  23453. Signtype interface{} `json:"signtype"`
  23454. WarnMsg interface{} `json:"warn_msg"`
  23455. }
  23456. type ResultSeventeen struct {
  23457. ErrMsg string `json:"err_msg"`
  23458. InfRefmsgid string `json:"inf_refmsgid"`
  23459. Infcode int64 `json:"infcode"`
  23460. Output struct {
  23461. SetlListId string `json:"setl_list_id"`
  23462. } `json:"output"`
  23463. RefmsgTime string `json:"refmsg_time"`
  23464. RespondTime string `json:"respond_time"`
  23465. Signtype string `json:"signtype"`
  23466. WarnInfo string `json:"warn_info"`
  23467. }
  23468. type ResultSeventeenOther struct {
  23469. ErrMsg string `json:"err_msg"`
  23470. InfRefmsgid string `json:"inf_refmsgid"`
  23471. Infcode string `json:"infcode"`
  23472. Output struct {
  23473. SetlListId string `json:"setl_list_id"`
  23474. } `json:"output"`
  23475. RefmsgTime string `json:"refmsg_time"`
  23476. RespondTime string `json:"respond_time"`
  23477. Signtype string `json:"signtype"`
  23478. WarnInfo string `json:"warn_info"`
  23479. }
  23480. type Result90991 struct {
  23481. ErrMsg string `json:"err_msg"`
  23482. InfRefmsgid string `json:"inf_refmsgid"`
  23483. Infcode int64 `json:"infcode"`
  23484. Output struct {
  23485. Result struct {
  23486. PsnNo string `json:"psn_no"`
  23487. CardStat string `json:"card_stat"`
  23488. Certno string `json:"certno"`
  23489. PsnName string `json:"psn_name"`
  23490. CheckStat string `json:"check_stat"`
  23491. SscnoCheckStat string `json:"sscno_check_stat"`
  23492. } `json:"result"`
  23493. } `json:"output"`
  23494. RefmsgTime string `json:"refmsg_time"`
  23495. RespondTime string `json:"respond_time"`
  23496. Signtype interface{} `json:"signtype"`
  23497. WarnInfo interface{} `json:"warn_info"`
  23498. }
  23499. type Result90100 struct {
  23500. ErrMsg string `json:"err_msg"`
  23501. InfRefmsgid string `json:"inf_refmsgid"`
  23502. Infcode int64 `json:"infcode"`
  23503. Output struct {
  23504. PoolareaNo string `json:"poolarea_no"`
  23505. PoolareaNoName string `json:"poolarea_no_name"`
  23506. Insutype string `json:"insutype"`
  23507. InsutypeName string `json:"insutype_name"`
  23508. ClctType string `json:"clct_type"`
  23509. ClctTypeName string `json:"clct_type_name"`
  23510. ClctFlag string `json:"clct_flag"`
  23511. ClctFlagName string `json:"clct_flag_name"`
  23512. AccrymBegn string `json:"accrym_begn"`
  23513. AccrymEnd string `json:"accrym_end"`
  23514. ClctTime string `json:"clct_time"`
  23515. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23516. } `json:"output"`
  23517. RefmsgTime string `json:"refmsg_time"`
  23518. RespondTime string `json:"respond_time"`
  23519. Signtype interface{} `json:"signtype"`
  23520. WarnInfo interface{} `json:"warn_info"`
  23521. }
  23522. type Custom struct {
  23523. DetItemFeeSumamt string
  23524. Cut string
  23525. FeedetlSn string
  23526. Price string
  23527. MedListCodg string
  23528. Type int64
  23529. AdviceId int64
  23530. ProjectId int64
  23531. ItemId int64
  23532. }
  23533. type Result5301 struct {
  23534. ErrMsg string `json:"err_msg"`
  23535. InfRefmsgid string `json:"inf_refmsgid"`
  23536. Infcode int64 `json:"infcode"`
  23537. Output struct {
  23538. Result []struct {
  23539. OpspDiseCode string `json:"opsp_dise_code"`
  23540. OpspDiseName string `json:"opsp_dise_name"`
  23541. Begndate string `json:"begndate"`
  23542. Enddate string `json:"enddate"`
  23543. } `json:"feedetail"`
  23544. } `json:"output"`
  23545. RefmsgTime string `json:"refmsg_time"`
  23546. RespondTime string `json:"respond_time"`
  23547. Signtype interface{} `json:"signtype"`
  23548. WarnInfo interface{} `json:"warn_info"`
  23549. }
  23550. type Result5301For10265 struct {
  23551. ErrMsg string `json:"err_msg"`
  23552. InfRefmsgid string `json:"inf_refmsgid"`
  23553. Infcode string `json:"infcode"`
  23554. Output struct {
  23555. Result []struct {
  23556. OpspDiseCode string `json:"opsp_dise_code"`
  23557. OpspDiseName string `json:"opsp_dise_name"`
  23558. Begndate string `json:"begndate"`
  23559. Enddate string `json:"enddate"`
  23560. } `json:"feedetail"`
  23561. } `json:"output"`
  23562. RefmsgTime string `json:"refmsg_time"`
  23563. RespondTime string `json:"respond_time"`
  23564. Signtype interface{} `json:"signtype"`
  23565. WarnInfo interface{} `json:"warn_info"`
  23566. }
  23567. //获取个人信息----挂号-----上传就诊信息
  23568. func (c *HisApiController) GetRegisterInfo() {
  23569. id, _ := c.GetInt64("id")
  23570. record_time := c.GetString("record_time")
  23571. settlementValue, _ := c.GetInt64("settlement_value")
  23572. medical_insurance_card := c.GetString("medical_insurance_card")
  23573. name := c.GetString("name")
  23574. id_card_type, _ := c.GetInt64("id_card_type")
  23575. certificates, _ := c.GetInt64("certificates")
  23576. medical_care, _ := c.GetInt64("medical_care")
  23577. birthday := c.GetString("birthday")
  23578. id_card := c.GetString("id_card")
  23579. register_type, _ := c.GetInt64("register")
  23580. doctor, _ := c.GetInt64("doctor")
  23581. department, _ := c.GetInt64("department")
  23582. gender, _ := c.GetInt64("sex")
  23583. registration_fee, _ := c.GetFloat("registration_fee")
  23584. medical_expenses, _ := c.GetFloat("medical_expenses")
  23585. social_type, _ := c.GetInt64("social_type")
  23586. admin_user_id, _ := c.GetInt64("admin_user_id")
  23587. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23588. mdtrt_type := c.GetString("mdtrt_type")
  23589. if id_card_type == 5 {
  23590. id_card_type = 4
  23591. }
  23592. timeLayout := "2006-01-02"
  23593. loc, _ := time.LoadLocation("Local")
  23594. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23595. birthUnix := birthdays.Unix()
  23596. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23597. if err != nil {
  23598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23599. return
  23600. }
  23601. recordDateTime := theTime.Unix()
  23602. adminInfo := c.GetAdminUserInfo()
  23603. var patient service.Patients
  23604. if id == 0 {
  23605. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23606. } else {
  23607. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23608. }
  23609. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23610. if patientPrescription.ID == 0 {
  23611. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23612. }
  23613. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23614. if patient.ID == 0 {
  23615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23616. return
  23617. }
  23618. if len(patient.IdCardNo) == 0 {
  23619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23620. return
  23621. }
  23622. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23623. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23624. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23625. //就诊结算未完成,不能进行二次挂号
  23626. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23627. if len(his) >= 1 {
  23628. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23629. if len(his) >= 1 && order.ID == 0 {
  23630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23631. return
  23632. }
  23633. }
  23634. //var register_log string
  23635. if config.IsOpen == 1 {
  23636. var res ResultTwo
  23637. var res10265 ResultTwo10265
  23638. var PsnNo string
  23639. var PsnCertType string
  23640. var Certno string
  23641. var PsnName string
  23642. var Gend string
  23643. var Naty string
  23644. var Brdy string
  23645. var Age float64
  23646. var infoStr string
  23647. var idetinfoStr string
  23648. var infocode int64
  23649. var verify_number string
  23650. fmt.Println(verify_number)
  23651. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23652. psn_info, _ := service.GetPsnByPatientId(id)
  23653. PsnNo = psn_info.PsnNo
  23654. PsnCertType = psn_info.PsnCertType
  23655. Certno = psn_info.Certno
  23656. PsnName = psn_info.PsnName
  23657. Gend = psn_info.Gend
  23658. Naty = psn_info.Naty
  23659. Brdy = psn_info.Brdy
  23660. Age = psn_info.Age
  23661. infoStr = psn_info.Insuinfo
  23662. idetinfoStr = psn_info.Idetinfo
  23663. infocode = 0
  23664. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23665. psn_info, _ := service.GetPsnByPatientId(id)
  23666. PsnNo = psn_info.PsnNo
  23667. PsnCertType = psn_info.PsnCertType
  23668. Certno = psn_info.Certno
  23669. PsnName = psn_info.PsnName
  23670. Gend = psn_info.Gend
  23671. Naty = psn_info.Naty
  23672. Brdy = psn_info.Brdy
  23673. Age = psn_info.Age
  23674. infoStr = psn_info.Insuinfo
  23675. idetinfoStr = psn_info.Idetinfo
  23676. infocode = 0
  23677. verify_number = psn_info.VerifyNumber
  23678. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23679. if id_card_type == 2 {
  23680. //请求内网数据
  23681. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23682. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23683. "&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
  23684. resp, requestErr := http.Get(api)
  23685. if requestErr != nil {
  23686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23687. return
  23688. }
  23689. body, ioErr := ioutil.ReadAll(resp.Body)
  23690. if ioErr != nil {
  23691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23693. return
  23694. }
  23695. var respJSON map[string]interface{}
  23696. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23699. return
  23700. }
  23701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23702. result_byte, _ := json.Marshal(respJSON)
  23703. result := string(result_byte)
  23704. var dat map[string]interface{}
  23705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23706. fmt.Println(dat)
  23707. } else {
  23708. fmt.Println(err)
  23709. }
  23710. userJSONBytes, _ := json.Marshal(dat)
  23711. var res ResultTwo
  23712. var resTwo10265 ResultTwo10265
  23713. if miConfig.Code == "H15049901371" {
  23714. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23715. utils.ErrorLog("解析失败:%v", err)
  23716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23717. return
  23718. }
  23719. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23720. res.Infcode = Infcode
  23721. res.ErrMsg = resTwo10265.ErrMsg
  23722. res.Output = resTwo10265.Output
  23723. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23724. res.RespondTime = resTwo10265.RespondTime
  23725. res.WarnInfo = resTwo10265.WarnInfo
  23726. } else {
  23727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23728. utils.ErrorLog("解析失败:%v", err)
  23729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23730. return
  23731. }
  23732. }
  23733. //var insutypes []string
  23734. //var insutype string
  23735. //var is390 int = 0
  23736. //var is310 int = 0
  23737. //for _, item := range res.Output.Iinfo {
  23738. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23739. // insutypes = append(insutypes, item.Insutype)
  23740. // }
  23741. //}
  23742. //if len(insutypes) == 1 {
  23743. // insutype = insutypes[0]
  23744. //} else {
  23745. // for _, i := range insutypes {
  23746. // if i == "390" {
  23747. // is390 = 1
  23748. // }
  23749. //
  23750. // if i == "310" {
  23751. // is310 = 1
  23752. // }
  23753. // }
  23754. //}
  23755. //if is390 == 1 {
  23756. // insutype = "390"
  23757. //}
  23758. //if is310 == 1 {
  23759. // insutype = "310"
  23760. //}
  23761. //if len(insutypes) == 0 {
  23762. // insutype = "310"
  23763. //}
  23764. PsnNo = res.Output.Baseinfo.PsnNo
  23765. PsnCertType = res.Output.Baseinfo.PsnCertType
  23766. Certno = res.Output.Baseinfo.Certno
  23767. PsnName = res.Output.Baseinfo.PsnName
  23768. Gend = res.Output.Baseinfo.Gend
  23769. Naty = res.Output.Baseinfo.Naty
  23770. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23771. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23772. infoStr = string(Iinfos)
  23773. idetinfoStr = string(Idetinfos)
  23774. infocode = res.Infcode
  23775. //infocode = 0
  23776. //verify_number = psn_info.VerifyNumber
  23777. } else {
  23778. psn_info, _ := service.GetPsnByPatientId(id)
  23779. PsnNo = psn_info.PsnNo
  23780. PsnCertType = psn_info.PsnCertType
  23781. Certno = psn_info.Certno
  23782. PsnName = psn_info.PsnName
  23783. Gend = psn_info.Gend
  23784. Naty = psn_info.Naty
  23785. Brdy = psn_info.Brdy
  23786. Age = psn_info.Age
  23787. infoStr = psn_info.Insuinfo
  23788. idetinfoStr = psn_info.Idetinfo
  23789. infocode = 0
  23790. verify_number = psn_info.VerifyNumber
  23791. }
  23792. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23793. if id_card_type == 1 {
  23794. psn_info, _ := service.GetPsnByPatientId(id)
  23795. PsnNo = psn_info.PsnNo
  23796. PsnCertType = psn_info.PsnCertType
  23797. Certno = psn_info.Certno
  23798. PsnName = psn_info.PsnName
  23799. Gend = psn_info.Gend
  23800. Naty = psn_info.Naty
  23801. Brdy = psn_info.Brdy
  23802. Age = psn_info.Age
  23803. infoStr = psn_info.Insuinfo
  23804. idetinfoStr = psn_info.Idetinfo
  23805. infocode = 0
  23806. verify_number = psn_info.VerifyNumber
  23807. } else if id_card_type == 2 {
  23808. 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)
  23809. fmt.Println(errMsgLog)
  23810. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23811. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23812. utils.ErrorLog("解析失败:%v", err)
  23813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23814. return
  23815. }
  23816. PsnNo = res.Output.Baseinfo.PsnNo
  23817. PsnCertType = res.Output.Baseinfo.PsnCertType
  23818. Certno = res.Output.Baseinfo.Certno
  23819. PsnName = res.Output.Baseinfo.PsnName
  23820. Gend = res.Output.Baseinfo.Gend
  23821. Naty = res.Output.Baseinfo.Naty
  23822. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23823. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23824. infoStr = string(Iinfos)
  23825. idetinfoStr = string(Idetinfos)
  23826. infocode = res.Infcode
  23827. }
  23828. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23829. if id_card_type == 1 {
  23830. psn_info, _ := service.GetPsnByPatientId(id)
  23831. PsnNo = psn_info.PsnNo
  23832. PsnCertType = psn_info.PsnCertType
  23833. Certno = psn_info.Certno
  23834. PsnName = psn_info.PsnName
  23835. Gend = psn_info.Gend
  23836. Naty = psn_info.Naty
  23837. Brdy = psn_info.Brdy
  23838. Age = psn_info.Age
  23839. infoStr = psn_info.Insuinfo
  23840. idetinfoStr = psn_info.Idetinfo
  23841. infocode = 0
  23842. verify_number = psn_info.VerifyNumber
  23843. } else if id_card_type == 2 {
  23844. 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, "")
  23845. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23846. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23847. utils.ErrorLog("解析失败:%v", err)
  23848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23849. return
  23850. }
  23851. PsnNo = res.Output.Baseinfo.PsnNo
  23852. PsnCertType = res.Output.Baseinfo.PsnCertType
  23853. Certno = res.Output.Baseinfo.Certno
  23854. PsnName = res.Output.Baseinfo.PsnName
  23855. Gend = res.Output.Baseinfo.Gend
  23856. Naty = res.Output.Baseinfo.Naty
  23857. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23858. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23859. infoStr = string(Iinfos)
  23860. idetinfoStr = string(Idetinfos)
  23861. infocode = res.Infcode
  23862. } else {
  23863. psn_info, _ := service.GetPsnByPatientId(id)
  23864. PsnNo = psn_info.PsnNo
  23865. PsnCertType = psn_info.PsnCertType
  23866. Certno = psn_info.Certno
  23867. PsnName = psn_info.PsnName
  23868. Gend = psn_info.Gend
  23869. Naty = psn_info.Naty
  23870. Brdy = psn_info.Brdy
  23871. Age = psn_info.Age
  23872. infoStr = psn_info.Insuinfo
  23873. idetinfoStr = psn_info.Idetinfo
  23874. infocode = 0
  23875. verify_number = psn_info.VerifyNumber
  23876. }
  23877. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23878. if id_card_type == 1 {
  23879. psn_info, _ := service.GetPsnByPatientId(id)
  23880. PsnNo = psn_info.PsnNo
  23881. PsnCertType = psn_info.PsnCertType
  23882. Certno = psn_info.Certno
  23883. PsnName = psn_info.PsnName
  23884. Gend = psn_info.Gend
  23885. Naty = psn_info.Naty
  23886. Brdy = psn_info.Brdy
  23887. Age = psn_info.Age
  23888. infoStr = psn_info.Insuinfo
  23889. idetinfoStr = psn_info.Idetinfo
  23890. infocode = 0
  23891. verify_number = psn_info.VerifyNumber
  23892. } else if id_card_type == 2 {
  23893. psn_info, _ := service.GetPsnByPatientId(id)
  23894. PsnNo = psn_info.PsnNo
  23895. PsnCertType = psn_info.PsnCertType
  23896. Certno = psn_info.Certno
  23897. PsnName = psn_info.PsnName
  23898. Gend = psn_info.Gend
  23899. Naty = psn_info.Naty
  23900. Brdy = psn_info.Brdy
  23901. Age = psn_info.Age
  23902. infoStr = psn_info.Insuinfo
  23903. idetinfoStr = psn_info.Idetinfo
  23904. infocode = 0
  23905. verify_number = psn_info.VerifyNumber
  23906. } else {
  23907. psn_info, _ := service.GetPsnByPatientId(id)
  23908. PsnNo = psn_info.PsnNo
  23909. PsnCertType = psn_info.PsnCertType
  23910. Certno = psn_info.Certno
  23911. PsnName = psn_info.PsnName
  23912. Gend = psn_info.Gend
  23913. Naty = psn_info.Naty
  23914. Brdy = psn_info.Brdy
  23915. Age = psn_info.Age
  23916. infoStr = psn_info.Insuinfo
  23917. idetinfoStr = psn_info.Idetinfo
  23918. infocode = 0
  23919. verify_number = psn_info.VerifyNumber
  23920. }
  23921. } else if miConfig.MdtrtareaAdmvs == "360100" {
  23922. if id_card_type == 1 {
  23923. psn_info, _ := service.GetPsnByPatientId(id)
  23924. PsnNo = psn_info.PsnNo
  23925. PsnCertType = psn_info.PsnCertType
  23926. Certno = psn_info.Certno
  23927. PsnName = psn_info.PsnName
  23928. Gend = psn_info.Gend
  23929. Naty = psn_info.Naty
  23930. Brdy = psn_info.Brdy
  23931. Age = psn_info.Age
  23932. infoStr = psn_info.Insuinfo
  23933. idetinfoStr = psn_info.Idetinfo
  23934. infocode = 0
  23935. verify_number = psn_info.VerifyNumber
  23936. } else if id_card_type == 2 {
  23937. psn_info, _ := service.GetPsnByPatientId(id)
  23938. PsnNo = psn_info.PsnNo
  23939. PsnCertType = psn_info.PsnCertType
  23940. Certno = psn_info.Certno
  23941. PsnName = psn_info.PsnName
  23942. Gend = psn_info.Gend
  23943. Naty = psn_info.Naty
  23944. Brdy = psn_info.Brdy
  23945. Age = psn_info.Age
  23946. infoStr = psn_info.Insuinfo
  23947. idetinfoStr = psn_info.Idetinfo
  23948. infocode = 0
  23949. verify_number = psn_info.VerifyNumber
  23950. } else {
  23951. psn_info, _ := service.GetPsnByPatientId(id)
  23952. PsnNo = psn_info.PsnNo
  23953. PsnCertType = psn_info.PsnCertType
  23954. Certno = psn_info.Certno
  23955. PsnName = psn_info.PsnName
  23956. Gend = psn_info.Gend
  23957. Naty = psn_info.Naty
  23958. Brdy = psn_info.Brdy
  23959. Age = psn_info.Age
  23960. infoStr = psn_info.Insuinfo
  23961. idetinfoStr = psn_info.Idetinfo
  23962. infocode = 0
  23963. verify_number = psn_info.VerifyNumber
  23964. }
  23965. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23966. psn_info, _ := service.GetPsnByPatientId(id)
  23967. PsnNo = psn_info.PsnNo
  23968. PsnCertType = psn_info.PsnCertType
  23969. Certno = psn_info.Certno
  23970. PsnName = psn_info.PsnName
  23971. Gend = psn_info.Gend
  23972. Naty = psn_info.Naty
  23973. Brdy = psn_info.Brdy
  23974. Age = psn_info.Age
  23975. infoStr = psn_info.Insuinfo
  23976. idetinfoStr = psn_info.Idetinfo
  23977. infocode = 0
  23978. verify_number = psn_info.VerifyNumber
  23979. idetinfoStr = psn_info.Idetinfo
  23980. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23981. if id_card_type == 1 {
  23982. psn_info, _ := service.GetPsnByPatientId(id)
  23983. PsnNo = psn_info.PsnNo
  23984. PsnCertType = psn_info.PsnCertType
  23985. Certno = psn_info.Certno
  23986. PsnName = psn_info.PsnName
  23987. Gend = psn_info.Gend
  23988. Naty = psn_info.Naty
  23989. Brdy = psn_info.Brdy
  23990. Age = psn_info.Age
  23991. infoStr = psn_info.Insuinfo
  23992. idetinfoStr = psn_info.Idetinfo
  23993. infocode = 0
  23994. verify_number = psn_info.VerifyNumber
  23995. } else if id_card_type == 2 {
  23996. 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)
  23997. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23998. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23999. utils.ErrorLog("解析失败:%v", err)
  24000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24001. return
  24002. }
  24003. PsnNo = res.Output.Baseinfo.PsnNo
  24004. PsnCertType = res.Output.Baseinfo.PsnCertType
  24005. Certno = res.Output.Baseinfo.Certno
  24006. PsnName = res.Output.Baseinfo.PsnName
  24007. Gend = res.Output.Baseinfo.Gend
  24008. Naty = res.Output.Baseinfo.Naty
  24009. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24010. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24011. infoStr = string(Iinfos)
  24012. idetinfoStr = string(Idetinfos)
  24013. infocode = res.Infcode
  24014. } else if id_card_type == 4 {
  24015. psn_info, _ := service.GetPsnByPatientId(id)
  24016. PsnNo = psn_info.PsnNo
  24017. PsnCertType = psn_info.PsnCertType
  24018. Certno = psn_info.Certno
  24019. PsnName = psn_info.PsnName
  24020. Gend = psn_info.Gend
  24021. Naty = psn_info.Naty
  24022. Brdy = psn_info.Brdy
  24023. Age = psn_info.Age
  24024. infoStr = psn_info.Insuinfo
  24025. idetinfoStr = psn_info.Idetinfo
  24026. infocode = 0
  24027. verify_number = psn_info.VerifyNumber
  24028. }
  24029. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24030. var result string
  24031. var requestLog string
  24032. 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), "")
  24033. if id_card_type == 4 {
  24034. psn_info, _ := service.GetPsnByPatientId(id)
  24035. PsnNo = psn_info.PsnNo
  24036. PsnCertType = psn_info.PsnCertType
  24037. Certno = psn_info.Certno
  24038. PsnName = psn_info.PsnName
  24039. Gend = psn_info.Gend
  24040. Naty = psn_info.Naty
  24041. Brdy = psn_info.Brdy
  24042. Age = psn_info.Age
  24043. infoStr = psn_info.Insuinfo
  24044. idetinfoStr = psn_info.Idetinfo
  24045. infocode = 0
  24046. verify_number = psn_info.VerifyNumber
  24047. } else {
  24048. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24049. if miConfig.Code == "H15049901371" {
  24050. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24051. utils.ErrorLog("解析失败:%v", err)
  24052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24053. return
  24054. }
  24055. res.ErrMsg = res10265.ErrMsg
  24056. res.Output = res10265.Output
  24057. res.InfRefmsgid = res10265.InfRefmsgid
  24058. } else {
  24059. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24060. utils.ErrorLog("解析失败:%v", err)
  24061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24062. return
  24063. }
  24064. }
  24065. PsnNo = res.Output.Baseinfo.PsnNo
  24066. PsnCertType = res.Output.Baseinfo.PsnCertType
  24067. Certno = res.Output.Baseinfo.Certno
  24068. PsnName = res.Output.Baseinfo.PsnName
  24069. Gend = res.Output.Baseinfo.Gend
  24070. Naty = res.Output.Baseinfo.Naty
  24071. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24072. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24073. infoStr = string(Iinfos)
  24074. idetinfoStr = string(Idetinfos)
  24075. if miConfig.Code == "H15049901371" {
  24076. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24077. } else {
  24078. infocode = res.Infcode
  24079. }
  24080. }
  24081. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24082. psn_info, _ := service.GetPsnByPatientId(id)
  24083. PsnNo = psn_info.PsnNo
  24084. PsnCertType = psn_info.PsnCertType
  24085. Certno = psn_info.Certno
  24086. PsnName = psn_info.PsnName
  24087. Gend = psn_info.Gend
  24088. Naty = psn_info.Naty
  24089. Brdy = psn_info.Brdy
  24090. Age = psn_info.Age
  24091. infoStr = psn_info.Insuinfo
  24092. idetinfoStr = psn_info.Idetinfo
  24093. infocode = 0
  24094. verify_number = psn_info.VerifyNumber
  24095. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24096. psn_info, _ := service.GetPsnByPatientId(id)
  24097. PsnNo = psn_info.PsnNo
  24098. PsnCertType = psn_info.PsnCertType
  24099. Certno = psn_info.Certno
  24100. PsnName = psn_info.PsnName
  24101. Gend = psn_info.Gend
  24102. Naty = psn_info.Naty
  24103. Brdy = psn_info.Brdy
  24104. Age = psn_info.Age
  24105. infoStr = psn_info.Insuinfo
  24106. idetinfoStr = psn_info.Idetinfo
  24107. infocode = 0
  24108. verify_number = psn_info.VerifyNumber
  24109. } else {
  24110. var result string
  24111. var requestLog string
  24112. //if miConfig.UserOrgId == 10138 {
  24113. if id_card_type != 4 || id_card_type != 1 {
  24114. var insa string
  24115. if len(patient.InsuplcAdmdvs) > 0 {
  24116. insa = patient.InsuplcAdmdvs
  24117. } else {
  24118. insa = miConfig.InsuplcAdmdvs
  24119. }
  24120. //psn_info, _ := service.GetPsnByPatientId(id)
  24121. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24122. 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)
  24123. }
  24124. //}
  24125. //else {
  24126. // var insa string
  24127. // if len(patient.InsuplcAdmdvs) > 0 {
  24128. // insa = patient.InsuplcAdmdvs
  24129. // } else {
  24130. // insa = miConfig.InsuplcAdmdvs
  24131. // }
  24132. // 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)
  24133. //}
  24134. if id_card_type == 4 || id_card_type == 1 {
  24135. psn_info, _ := service.GetPsnByPatientId(id)
  24136. PsnNo = psn_info.PsnNo
  24137. PsnCertType = psn_info.PsnCertType
  24138. Certno = psn_info.Certno
  24139. PsnName = psn_info.PsnName
  24140. Gend = psn_info.Gend
  24141. Naty = psn_info.Naty
  24142. Brdy = psn_info.Brdy
  24143. Age = psn_info.Age
  24144. infoStr = psn_info.Insuinfo
  24145. idetinfoStr = psn_info.Idetinfo
  24146. infocode = 0
  24147. verify_number = psn_info.VerifyNumber
  24148. } else {
  24149. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24150. if miConfig.Code == "H15049901371" {
  24151. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24152. utils.ErrorLog("解析失败:%v", err)
  24153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24154. return
  24155. }
  24156. res.ErrMsg = res10265.ErrMsg
  24157. res.Output = res10265.Output
  24158. res.InfRefmsgid = res10265.InfRefmsgid
  24159. } else {
  24160. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24161. utils.ErrorLog("解析失败:%v", err)
  24162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24163. return
  24164. }
  24165. }
  24166. PsnNo = res.Output.Baseinfo.PsnNo
  24167. PsnCertType = res.Output.Baseinfo.PsnCertType
  24168. Certno = res.Output.Baseinfo.Certno
  24169. PsnName = res.Output.Baseinfo.PsnName
  24170. Gend = res.Output.Baseinfo.Gend
  24171. Naty = res.Output.Baseinfo.Naty
  24172. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24173. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24174. infoStr = string(Iinfos)
  24175. idetinfoStr = string(Idetinfos)
  24176. if miConfig.Code == "H15049901371" {
  24177. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24178. } else {
  24179. infocode = res.Infcode
  24180. }
  24181. }
  24182. }
  24183. if infocode == 0 {
  24184. his := models.VMHisPatient{
  24185. Name: name,
  24186. Gender: gender,
  24187. Birthday: birthUnix,
  24188. MedicalTreatmentType: medical_care,
  24189. IdType: certificates,
  24190. IdCardNo: id_card,
  24191. BalanceAccountsType: settlementValue,
  24192. SocialType: social_type,
  24193. MedicalInsuranceNumber: medical_insurance_card,
  24194. RegisterType: register_type,
  24195. RegisterCost: registration_fee,
  24196. TreatmentCost: medical_expenses,
  24197. Status: 1,
  24198. Ctime: time.Now().Unix(),
  24199. Mtime: time.Now().Unix(),
  24200. PsnNo: PsnNo,
  24201. PsnCertType: PsnCertType,
  24202. Certno: Certno,
  24203. PsnName: PsnName,
  24204. Gend: Gend,
  24205. Naty: Naty,
  24206. Brdy: Brdy,
  24207. Age: Age,
  24208. Iinfo: infoStr,
  24209. Idetinfo: idetinfoStr,
  24210. PatientId: patient.ID,
  24211. RecordDate: theTime.Unix(),
  24212. UserOrgId: adminInfo.CurrentOrgId,
  24213. AdminUserId: admin_user_id,
  24214. IsReturn: 1,
  24215. IdCardType: id_card_type,
  24216. Doctor: doctor,
  24217. Departments: department,
  24218. MdtrtGrpType: mdtrt_type,
  24219. }
  24220. timestamp := time.Now().Unix()
  24221. tempTime := time.Unix(timestamp, 0)
  24222. timeFormat := tempTime.Format("20060102150405")
  24223. chrgBchno := rand.Intn(100000) + 10000
  24224. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24225. his.Number = ipt_otp_no
  24226. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24227. department, _ := service.GetDepartMentDetail(department)
  24228. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24229. IdCardNo := ""
  24230. if id_card_type == 1 {
  24231. // IdCardNo = medical_insurance_card
  24232. IdCardNo = patient.IdCardNo
  24233. } else {
  24234. IdCardNo = patient.IdCardNo
  24235. }
  24236. var rf []*ResultFive
  24237. json.Unmarshal([]byte(his.Iinfo), &rf)
  24238. var insutypes []*ResultFive
  24239. var insutype string
  24240. var insuplc_admdvs_temp string
  24241. var is390 int = 0
  24242. var is310 int = 0
  24243. for _, item := range rf {
  24244. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24245. insutypes = append(insutypes, item)
  24246. }
  24247. }
  24248. if len(insutypes) == 1 {
  24249. insutype = insutypes[0].Insutype
  24250. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24251. if insutype == "390" {
  24252. is390 = 1
  24253. }
  24254. if insutype == "310" {
  24255. is310 = 1
  24256. }
  24257. } else {
  24258. for _, i := range insutypes {
  24259. if i.Insutype == "390" {
  24260. is390 = 1
  24261. }
  24262. if i.Insutype == "310" {
  24263. is310 = 1
  24264. }
  24265. }
  24266. }
  24267. if is390 == 1 {
  24268. insutype = "390"
  24269. }
  24270. if is310 == 1 {
  24271. insutype = "310"
  24272. }
  24273. fmt.Println(social_type)
  24274. if social_type > 0 {
  24275. insutype = strconv.FormatInt(social_type, 10)
  24276. }
  24277. var infocode int64
  24278. var resThree ResultThree
  24279. var resThree10265 ResultThree10265
  24280. if len(insuplc_admdvs) == 0 {
  24281. psn_info, _ := service.GetPsnByPatientId(id)
  24282. //if len(psn_info.InsuplcAdmdvs) > 0 {
  24283. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24284. //}
  24285. } else {
  24286. insuplc_admdvs_temp = insuplc_admdvs
  24287. }
  24288. if miConfig.MdtrtareaAdmvs == "421300" {
  24289. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24290. psn_info, _ := service.GetPsnByPatientId(id)
  24291. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24292. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24293. "&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
  24294. resp, requestErr := http.Get(api)
  24295. if requestErr != nil {
  24296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24297. return
  24298. }
  24299. body, ioErr := ioutil.ReadAll(resp.Body)
  24300. if ioErr != nil {
  24301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24303. return
  24304. }
  24305. var respJSON map[string]interface{}
  24306. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24309. return
  24310. }
  24311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24312. result, _ := json.Marshal(respJSON)
  24313. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24314. utils.ErrorLog("解析失败:%v", err)
  24315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24316. return
  24317. }
  24318. infocode = resThree.Infcode
  24319. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24320. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24321. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24322. // insuplc_admdvs_temp =
  24323. //}
  24324. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24325. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24326. //}
  24327. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24328. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24329. "&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
  24330. resp, requestErr := http.Get(api)
  24331. if requestErr != nil {
  24332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24333. return
  24334. }
  24335. body, ioErr := ioutil.ReadAll(resp.Body)
  24336. if ioErr != nil {
  24337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24339. return
  24340. }
  24341. var respJSON map[string]interface{}
  24342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24348. result, _ := json.Marshal(respJSON)
  24349. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24350. utils.ErrorLog("解析失败:%v", err)
  24351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24352. return
  24353. }
  24354. infocode = resThree.Infcode
  24355. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24356. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24357. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24358. // insuplc_admdvs_temp =
  24359. //}
  24360. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24361. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24362. //}
  24363. utils.ErrorLog("解析失败:%v", insutype)
  24364. utils.ErrorLog("解析失败:%v", PsnNo)
  24365. utils.ErrorLog("解析失败:%v", Certno)
  24366. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  24367. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  24368. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24369. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  24370. utils.ErrorLog("解析失败:%v", PsnNo)
  24371. utils.ErrorLog("解析失败:%v", department.Number)
  24372. utils.ErrorLog("解析失败:%v", department.Name)
  24373. utils.ErrorLog("解析失败:%v", roles.UserName)
  24374. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24375. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24376. "&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
  24377. resp, requestErr := http.Get(api)
  24378. if requestErr != nil {
  24379. utils.ErrorLog("解析失败:%v", requestErr)
  24380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24381. return
  24382. }
  24383. body, ioErr := ioutil.ReadAll(resp.Body)
  24384. if ioErr != nil {
  24385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24387. return
  24388. }
  24389. var respJSON map[string]interface{}
  24390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24393. return
  24394. }
  24395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24396. result, _ := json.Marshal(respJSON)
  24397. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24398. utils.ErrorLog("解析失败:%v", err)
  24399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24400. return
  24401. }
  24402. infocode = resThree.Infcode
  24403. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24404. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24405. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24406. // insuplc_admdvs_temp =
  24407. //}
  24408. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24409. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24410. //}
  24411. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24412. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24413. "&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
  24414. resp, requestErr := http.Get(api)
  24415. if requestErr != nil {
  24416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24417. return
  24418. }
  24419. body, ioErr := ioutil.ReadAll(resp.Body)
  24420. if ioErr != nil {
  24421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24423. return
  24424. }
  24425. var respJSON map[string]interface{}
  24426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24429. return
  24430. }
  24431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24432. result, _ := json.Marshal(respJSON)
  24433. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24434. utils.ErrorLog("解析失败:%v", err)
  24435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24436. return
  24437. }
  24438. infocode = resThree.Infcode
  24439. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24440. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24441. psn_info, _ := service.GetPsnByPatientId(id)
  24442. var verify_number string
  24443. if id_card_type == 4 {
  24444. verify_number = psn_info.VerifyNumber
  24445. } else if id_card_type == 1 {
  24446. bas := strings.Split(psn_info.CardInfo, "|")
  24447. cardNumber := bas[2]
  24448. verify_number = cardNumber
  24449. }
  24450. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24451. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24452. "&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
  24453. resp, requestErr := http.Get(api)
  24454. if requestErr != nil {
  24455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24456. return
  24457. }
  24458. body, ioErr := ioutil.ReadAll(resp.Body)
  24459. if ioErr != nil {
  24460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24462. return
  24463. }
  24464. var respJSON map[string]interface{}
  24465. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24468. return
  24469. }
  24470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24471. result, _ := json.Marshal(respJSON)
  24472. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24473. // utils.ErrorLog("解析失败:%v", err)
  24474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24475. // return
  24476. //}
  24477. //infocode = resThree.Infcode
  24478. //result, _ := json.Marshal(respJSON)
  24479. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24480. utils.ErrorLog("解析失败:%v", err)
  24481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24482. return
  24483. }
  24484. resThree.ErrMsg = resThree10265.ErrMsg
  24485. resThree.Output = resThree10265.Output
  24486. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24487. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24488. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24489. psn_info, _ := service.GetPsnByPatientId(id)
  24490. his.PsnNo = psn_info.PsnNo
  24491. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24492. var cert_no string
  24493. if id_card_type == 3 {
  24494. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24495. cert_no = IdCardNo
  24496. } else if id_card_type == 4 {
  24497. cert_no = IdCardNo
  24498. psn_info.VerifyNumber = psn_info.VerifyNumber
  24499. } else {
  24500. bas := strings.Split(psn_info.CardInfo, "|")
  24501. cert_no = bas[2]
  24502. }
  24503. var hisPrescription []*models.HisPrescription
  24504. for _, item := range rf {
  24505. if item.Insutype == insutype {
  24506. //insuplc_admdvs = item.InsuplcAdmdvs
  24507. his.InsuplcAdmdvs = insuplc_admdvs
  24508. }
  24509. }
  24510. his.Insutype = insutype
  24511. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24512. fmt.Println(res3101)
  24513. fmt.Println(res3101.Infcode)
  24514. if res3101.Infcode == "0" {
  24515. fmt.Println("33333333")
  24516. if len(res3101.Output.Result) > 0 {
  24517. fmt.Println("222222")
  24518. for _, item := range res3101.Output.Result {
  24519. if len(res3101.ErrMsg) == 0 {
  24520. res3101.ErrMsg = item.VolaCont
  24521. } else {
  24522. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24523. }
  24524. }
  24525. c.ServeSuccessJSON(map[string]interface{}{
  24526. "failed_code": -10,
  24527. "msg": res3101.ErrMsg,
  24528. })
  24529. return
  24530. } else {
  24531. fmt.Println("11111")
  24532. var api string
  24533. if miConfig.MdtrtareaAdmvs == "320921" {
  24534. ipt_otp_no = timeFormat
  24535. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24536. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24537. "&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
  24538. } else {
  24539. ipt_otp_no = timeFormat
  24540. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24541. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24542. "&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
  24543. }
  24544. resp, requestErr := http.Get(api)
  24545. if requestErr != nil {
  24546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24547. return
  24548. }
  24549. body, ioErr := ioutil.ReadAll(resp.Body)
  24550. if ioErr != nil {
  24551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24553. return
  24554. }
  24555. var respJSON map[string]interface{}
  24556. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24559. return
  24560. }
  24561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24562. result, _ := json.Marshal(respJSON)
  24563. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24564. utils.ErrorLog("解析失败:%v", err)
  24565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24566. return
  24567. }
  24568. resThree.ErrMsg = resThree10265.ErrMsg
  24569. resThree.Output = resThree10265.Output
  24570. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24571. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24572. }
  24573. } else if res3101.Infcode != "0" {
  24574. c.ServeSuccessJSON(map[string]interface{}{
  24575. "failed_code": -10,
  24576. "msg": res3101.ErrMsg,
  24577. })
  24578. return
  24579. }
  24580. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24581. psn_info, _ := service.GetPsnByPatientId(id)
  24582. var cert_no string
  24583. if id_card_type == 1 {
  24584. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24585. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24586. } else if id_card_type == 4 {
  24587. cert_no = psn_info.VerifyNumber
  24588. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24589. } else {
  24590. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24591. cert_no = psn_info.VerifyNumber
  24592. }
  24593. 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)
  24594. saveLog(result, requestLog, "2201", "挂号")
  24595. if miConfig.Code == "H15049901371" {
  24596. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24597. utils.ErrorLog("解析失败:%v", err)
  24598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24599. return
  24600. }
  24601. resThree.ErrMsg = resThree10265.ErrMsg
  24602. resThree.Output = resThree10265.Output
  24603. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24604. } else {
  24605. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24606. utils.ErrorLog("解析失败:%v", err)
  24607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24608. return
  24609. }
  24610. }
  24611. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24612. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24613. psn_info, _ := service.GetPsnByPatientId(id)
  24614. var result string
  24615. var requestLog string
  24616. if id_card_type == 1 {
  24617. bas := strings.Split(psn_info.CardInfo, "|")
  24618. basNumber := bas[2]
  24619. card_sn := bas[3]
  24620. 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)
  24621. saveLog(result, requestLog, "2201A", "挂号")
  24622. } else if id_card_type == 2 {
  24623. 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, "", "", "", "", "", "")
  24624. saveLog(result, requestLog, "2201A", "挂号")
  24625. } else {
  24626. 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)
  24627. saveLog(result, requestLog, "2201A", "挂号")
  24628. }
  24629. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24630. utils.ErrorLog("解析失败:%v", err)
  24631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24632. return
  24633. }
  24634. infocode = resThree.Infcode
  24635. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24636. psn_info, _ := service.GetPsnByPatientId(id)
  24637. var result string
  24638. var requestLog string
  24639. if id_card_type == 1 {
  24640. bas := strings.Split(psn_info.CardInfo, "|")
  24641. basNumber := bas[2]
  24642. card_sn := ""
  24643. 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)
  24644. saveLog(result, requestLog, "2201A", "挂号")
  24645. } else if id_card_type == 2 {
  24646. 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, "", "", "", "", "", "")
  24647. saveLog(result, requestLog, "2201A", "挂号")
  24648. } else {
  24649. 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)
  24650. saveLog(result, requestLog, "2201A", "挂号")
  24651. }
  24652. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24653. utils.ErrorLog("解析失败:%v", err)
  24654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24655. return
  24656. }
  24657. infocode = resThree.Infcode
  24658. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  24659. psn_info, _ := service.GetPsnByPatientId(id)
  24660. var result string
  24661. var requestLog string
  24662. if id_card_type == 1 {
  24663. bas := strings.Split(psn_info.CardInfo, "|")
  24664. basNumber := bas[2]
  24665. card_sn := ""
  24666. 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)
  24667. saveLog(result, requestLog, "2201A", "挂号")
  24668. } else if id_card_type == 2 {
  24669. 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, "", "", "", "", "", "")
  24670. saveLog(result, requestLog, "2201A", "挂号")
  24671. } else {
  24672. 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)
  24673. saveLog(result, requestLog, "2201A", "挂号")
  24674. }
  24675. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24676. utils.ErrorLog("解析失败:%v", err)
  24677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24678. return
  24679. }
  24680. infocode = resThree.Infcode
  24681. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24682. psn_info, _ := service.GetPsnByPatientId(id)
  24683. his.PsnNo = psn_info.PsnNo
  24684. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24685. var cert_no string
  24686. if id_card_type == 1 {
  24687. bas := strings.Split(psn_info.CardInfo, "|")
  24688. cert_no = bas[2]
  24689. } else if id_card_type == 4 {
  24690. cert_no = psn_info.VerifyNumber
  24691. psn_info.VerifyNumber = psn_info.VerifyNumber
  24692. IdCardNo = psn_info.VerifyNumber
  24693. } else {
  24694. cert_no = IdCardNo
  24695. psn_info.VerifyNumber = cert_no
  24696. }
  24697. for _, item := range rf {
  24698. if item.Insutype == insutype {
  24699. his.InsuplcAdmdvs = insuplc_admdvs
  24700. }
  24701. }
  24702. his.Insutype = insutype
  24703. var api string
  24704. ipt_otp_no = timeFormat
  24705. 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 +
  24706. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24707. "&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
  24708. resp, requestErr := http.Get(api)
  24709. if requestErr != nil {
  24710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24711. return
  24712. }
  24713. body, ioErr := ioutil.ReadAll(resp.Body)
  24714. if ioErr != nil {
  24715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24717. return
  24718. }
  24719. var respJSON map[string]interface{}
  24720. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24723. return
  24724. }
  24725. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24726. if status == "0" {
  24727. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24728. c.ServeSuccessJSON(map[string]interface{}{
  24729. "failed_code": -10,
  24730. "msg": err_msg,
  24731. })
  24732. return
  24733. }
  24734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24735. result, _ := json.Marshal(respJSON)
  24736. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24737. utils.ErrorLog("解析失败:%v", err)
  24738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24739. return
  24740. }
  24741. infocode = resThree.Infcode
  24742. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24743. psn_info, _ := service.GetPsnByPatientId(id)
  24744. his.PsnNo = psn_info.PsnNo
  24745. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24746. var cert_no string
  24747. if id_card_type == 1 {
  24748. bas := strings.Split(psn_info.CardInfo, "|")
  24749. cert_no = bas[2]
  24750. } else if id_card_type == 4 {
  24751. cert_no = psn_info.VerifyNumber
  24752. psn_info.VerifyNumber = psn_info.VerifyNumber
  24753. IdCardNo = psn_info.VerifyNumber
  24754. } else {
  24755. cert_no = IdCardNo
  24756. psn_info.VerifyNumber = cert_no
  24757. }
  24758. for _, item := range rf {
  24759. if item.Insutype == insutype {
  24760. his.InsuplcAdmdvs = insuplc_admdvs
  24761. patient.InsuplcAdmdvs = insuplc_admdvs
  24762. }
  24763. }
  24764. his.Insutype = insutype
  24765. var api string
  24766. ipt_otp_no = timeFormat
  24767. 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 +
  24768. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24769. "&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
  24770. resp, requestErr := http.Get(api)
  24771. if requestErr != nil {
  24772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24773. return
  24774. }
  24775. body, ioErr := ioutil.ReadAll(resp.Body)
  24776. if ioErr != nil {
  24777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24779. return
  24780. }
  24781. var respJSON map[string]interface{}
  24782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24785. return
  24786. }
  24787. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24788. if status == "0" {
  24789. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24790. c.ServeSuccessJSON(map[string]interface{}{
  24791. "failed_code": -10,
  24792. "msg": err_msg,
  24793. })
  24794. return
  24795. }
  24796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24797. result, _ := json.Marshal(respJSON)
  24798. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24799. utils.ErrorLog("解析失败:%v", err)
  24800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24801. return
  24802. }
  24803. infocode = resThree.Infcode
  24804. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24805. psn_info, _ := service.GetPsnByPatientId(id)
  24806. var result string
  24807. var requestLog string
  24808. if id_card_type == 1 {
  24809. bas := strings.Split(psn_info.CardInfo, "|")
  24810. basNumber := bas[2]
  24811. card_sn := bas[3]
  24812. 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)
  24813. saveLog(result, requestLog, "2201A", "挂号")
  24814. } else if id_card_type == 2 {
  24815. 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, "", "")
  24816. saveLog(result, requestLog, "2201A", "挂号")
  24817. } else {
  24818. 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, "", "")
  24819. saveLog(result, requestLog, "2201A", "挂号")
  24820. }
  24821. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24822. utils.ErrorLog("解析失败:%v", err)
  24823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24824. return
  24825. }
  24826. infocode = resThree.Infcode
  24827. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24828. psn_info, _ := service.GetPsnByPatientId(id)
  24829. 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)
  24830. saveLog(result, requestLog, "2201A", "挂号")
  24831. if miConfig.Code == "H15049901371" {
  24832. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24833. utils.ErrorLog("解析失败:%v", err)
  24834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24835. return
  24836. }
  24837. resThree.ErrMsg = resThree10265.ErrMsg
  24838. resThree.Output = resThree10265.Output
  24839. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24840. } else {
  24841. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24842. utils.ErrorLog("解析失败:%v", err)
  24843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24844. return
  24845. }
  24846. }
  24847. if miConfig.Code == "H15049901371" {
  24848. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24849. } else {
  24850. infocode = resThree.Infcode
  24851. }
  24852. } else {
  24853. psn_info, _ := service.GetPsnByPatientId(id)
  24854. if id_card_type == 4 || id_card_type == 1 {
  24855. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24856. }
  24857. var rf []*ResultFive
  24858. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24859. var insutypes []*ResultFive
  24860. var insutype string
  24861. var is390 int = 0
  24862. var is310 int = 0
  24863. for _, item := range rf {
  24864. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24865. insutypes = append(insutypes, item)
  24866. }
  24867. }
  24868. if len(insutypes) == 1 {
  24869. insutype = insutypes[0].Insutype
  24870. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24871. } else {
  24872. for _, i := range insutypes {
  24873. if i.Insutype == "390" {
  24874. is390 = 1
  24875. }
  24876. if i.Insutype == "310" {
  24877. is310 = 1
  24878. }
  24879. }
  24880. }
  24881. if is390 == 1 {
  24882. insutype = "390"
  24883. }
  24884. if is310 == 1 {
  24885. insutype = "310"
  24886. }
  24887. fmt.Println(len(insutypes))
  24888. if len(insutypes) == 0 {
  24889. for index, item := range rf {
  24890. if index == 0 {
  24891. insutype = item.Insutype
  24892. insuplc_admdvs = item.InsuplcAdmdvs
  24893. }
  24894. }
  24895. fmt.Println(insutype)
  24896. fmt.Println(insuplc_admdvs)
  24897. }
  24898. if social_type > 0 {
  24899. insutype = strconv.FormatInt(social_type, 10)
  24900. }
  24901. fmt.Println("--------")
  24902. fmt.Println(psn_info)
  24903. fmt.Println(psn_info.PsnNo)
  24904. if miConfig.MdtrtareaAdmvs == "441202" {
  24905. var hisPrescription []*models.HisPrescription
  24906. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24907. if res3101.Infcode == 0 {
  24908. fmt.Println("33333333")
  24909. if len(res3101.Output.Result) > 0 {
  24910. fmt.Println("222222")
  24911. for _, item := range res3101.Output.Result {
  24912. if len(res3101.ErrMsg) == 0 {
  24913. res3101.ErrMsg = item.VolaCont
  24914. } else {
  24915. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24916. }
  24917. }
  24918. c.ServeSuccessJSON(map[string]interface{}{
  24919. "failed_code": -10,
  24920. "msg": res3101.ErrMsg,
  24921. })
  24922. return
  24923. } else {
  24924. hour := time.Now().Format("15")
  24925. min := time.Now().Format("04")
  24926. sec := time.Now().Format("05")
  24927. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24928. fmt.Println(record_time_two)
  24929. 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)
  24930. saveLog(result, requestLog, "2201A", "挂号")
  24931. if miConfig.Code == "H15049901371" {
  24932. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24933. utils.ErrorLog("解析失败:%v", err)
  24934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24935. return
  24936. }
  24937. resThree.ErrMsg = resThree10265.ErrMsg
  24938. resThree.Output = resThree10265.Output
  24939. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24940. } else {
  24941. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24942. utils.ErrorLog("解析失败:%v", err)
  24943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24944. return
  24945. }
  24946. }
  24947. if miConfig.Code == "H15049901371" {
  24948. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24949. } else {
  24950. infocode = resThree.Infcode
  24951. }
  24952. }
  24953. } else if res3101.Infcode != 0 {
  24954. c.ServeSuccessJSON(map[string]interface{}{
  24955. "failed_code": -10,
  24956. "msg": res3101.ErrMsg,
  24957. })
  24958. return
  24959. }
  24960. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24961. var hisPrescription []*models.HisPrescription
  24962. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24963. if res3101.Infcode == 0 {
  24964. fmt.Println("33333333")
  24965. if len(res3101.Output.Result) > 0 {
  24966. fmt.Println("222222")
  24967. for _, item := range res3101.Output.Result {
  24968. if len(res3101.ErrMsg) == 0 {
  24969. res3101.ErrMsg = item.VolaCont
  24970. } else {
  24971. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24972. }
  24973. }
  24974. c.ServeSuccessJSON(map[string]interface{}{
  24975. "failed_code": -10,
  24976. "msg": res3101.ErrMsg,
  24977. })
  24978. return
  24979. } else {
  24980. hour := time.Now().Format("15")
  24981. min := time.Now().Format("04")
  24982. sec := time.Now().Format("05")
  24983. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24984. fmt.Println(record_time_two)
  24985. 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)
  24986. saveLog(result, requestLog, "2201A", "挂号")
  24987. if miConfig.Code == "H15049901371" {
  24988. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24989. utils.ErrorLog("解析失败:%v", err)
  24990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24991. return
  24992. }
  24993. resThree.ErrMsg = resThree10265.ErrMsg
  24994. resThree.Output = resThree10265.Output
  24995. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24996. } else {
  24997. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24998. utils.ErrorLog("解析失败:%v", err)
  24999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25000. return
  25001. }
  25002. }
  25003. if miConfig.Code == "H15049901371" {
  25004. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25005. } else {
  25006. infocode = resThree.Infcode
  25007. }
  25008. }
  25009. } else if res3101.Infcode != 0 {
  25010. c.ServeSuccessJSON(map[string]interface{}{
  25011. "failed_code": -10,
  25012. "msg": res3101.ErrMsg,
  25013. })
  25014. return
  25015. }
  25016. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25017. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25018. psn_info, _ := service.GetPsnByPatientId(id)
  25019. var verify_number string
  25020. if id_card_type == 4 {
  25021. verify_number = psn_info.VerifyNumber
  25022. } else if id_card_type == 1 {
  25023. bas := strings.Split(psn_info.CardInfo, "|")
  25024. cardNumber := bas[2]
  25025. verify_number = cardNumber
  25026. } else {
  25027. verify_number = psn_info.Certno
  25028. }
  25029. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25030. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25031. "&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
  25032. resp, requestErr := http.Get(api)
  25033. if requestErr != nil {
  25034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25035. return
  25036. }
  25037. body, ioErr := ioutil.ReadAll(resp.Body)
  25038. if ioErr != nil {
  25039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25041. return
  25042. }
  25043. var respJSON map[string]interface{}
  25044. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25047. return
  25048. }
  25049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25050. result, _ := json.Marshal(respJSON)
  25051. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25052. utils.ErrorLog("解析失败:%v", err)
  25053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25054. return
  25055. }
  25056. infocode = resThree.Infcode
  25057. } else {
  25058. hour := time.Now().Format("15")
  25059. min := time.Now().Format("04")
  25060. sec := time.Now().Format("05")
  25061. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25062. if id_card_type == 1 {
  25063. for _, item := range rf {
  25064. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25065. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25066. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25067. } else if strconv.FormatInt(social_type, 10) == "390" {
  25068. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25069. } else {
  25070. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25071. }
  25072. }
  25073. }
  25074. }
  25075. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25076. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25077. }
  25078. if id_card_type == 1 {
  25079. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25080. bas := strings.Split(psn_info.CardInfo, "|")
  25081. basNumber := bas[1]
  25082. IdCardNo = basNumber
  25083. }
  25084. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25085. IdCardNo = psn_info.VerifyNumber
  25086. }
  25087. if len(insuplc_admdvs_temp) == 0 {
  25088. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25089. }
  25090. var result string
  25091. var requestLog string
  25092. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  25093. var hisPrescription []*models.HisPrescription
  25094. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25095. if res3101.Infcode == 0 {
  25096. if len(res3101.Output.Result) > 0 {
  25097. if len(res3101.Output.Result) > 0 {
  25098. c.ServeSuccessJSON(map[string]interface{}{
  25099. "failed_code": -10,
  25100. "failed_type": 100,
  25101. "warm_type": 1,
  25102. "msg": res3101.Output.Result,
  25103. })
  25104. return
  25105. } else {
  25106. c.ServeSuccessJSON(map[string]interface{}{
  25107. "failed_code": -10,
  25108. "msg": res3101.ErrMsg,
  25109. })
  25110. return
  25111. }
  25112. } else {
  25113. hour := time.Now().Format("15")
  25114. min := time.Now().Format("04")
  25115. sec := time.Now().Format("05")
  25116. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25117. fmt.Println(record_time_two)
  25118. if his.IdCardType == 2 {
  25119. IdCardNo = psn_info.Certno
  25120. psn_info.VerifyNumber = psn_info.Certno
  25121. } else if his.IdCardType == 4 {
  25122. IdCardNo = psn_info.Certno
  25123. } else {
  25124. bas := strings.Split(psn_info.CardInfo, "|")
  25125. IdCardNo = bas[2]
  25126. }
  25127. 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)
  25128. saveLog(result, requestLog, "2201A", "挂号")
  25129. if miConfig.Code == "H15049901371" {
  25130. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25131. utils.ErrorLog("解析失败:%v", err)
  25132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25133. return
  25134. }
  25135. resThree.ErrMsg = resThree10265.ErrMsg
  25136. resThree.Output = resThree10265.Output
  25137. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25138. } else {
  25139. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25140. utils.ErrorLog("解析失败:%v", err)
  25141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25142. return
  25143. }
  25144. }
  25145. if miConfig.Code == "H15049901371" {
  25146. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25147. } else {
  25148. infocode = resThree.Infcode
  25149. }
  25150. }
  25151. } else if res3101.Infcode != 0 {
  25152. c.ServeSuccessJSON(map[string]interface{}{
  25153. "failed_code": -10,
  25154. "msg": res3101.ErrMsg,
  25155. })
  25156. return
  25157. }
  25158. } else {
  25159. psn_info, _ := service.GetPsnByPatientId(id)
  25160. var rf []*ResultFive
  25161. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25162. //var insutypes []*ResultFive
  25163. var insutype string
  25164. var insutypes []*ResultFive
  25165. var is390 int = 0
  25166. var is310 int = 0
  25167. for _, item := range rf {
  25168. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25169. insutypes = append(insutypes, item)
  25170. }
  25171. }
  25172. if len(insutypes) == 1 {
  25173. insutype = insutypes[0].Insutype
  25174. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25175. } else {
  25176. for _, i := range insutypes {
  25177. if i.Insutype == "390" {
  25178. is390 = 1
  25179. }
  25180. if i.Insutype == "310" {
  25181. is310 = 1
  25182. }
  25183. }
  25184. }
  25185. if is390 == 1 {
  25186. insutype = "390"
  25187. }
  25188. if is310 == 1 {
  25189. insutype = "310"
  25190. }
  25191. if len(insutypes) == 0 {
  25192. insutype = "310"
  25193. }
  25194. if social_type > 0 {
  25195. insutype = strconv.FormatInt(social_type, 10)
  25196. }
  25197. for _, item := range rf {
  25198. utils.ErrorLog("解析失败:%v", item.Insutype)
  25199. utils.ErrorLog("解析失败:%v", insutype)
  25200. if item.Insutype == insutype {
  25201. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25202. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25203. }
  25204. }
  25205. 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)
  25206. saveLog(result, requestLog, "2201A", "挂号")
  25207. }
  25208. if miConfig.Code == "H15049901371" {
  25209. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25210. utils.ErrorLog("解析失败:%v", err)
  25211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25212. return
  25213. }
  25214. resThree.ErrMsg = resThree10265.ErrMsg
  25215. resThree.Output = resThree10265.Output
  25216. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25217. } else {
  25218. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25219. utils.ErrorLog("解析失败:%v", err)
  25220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25221. return
  25222. }
  25223. }
  25224. if miConfig.Code == "H15049901371" {
  25225. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25226. } else {
  25227. infocode = resThree.Infcode
  25228. }
  25229. }
  25230. }
  25231. if infocode == -1 {
  25232. adminUser := c.GetAdminUserInfo()
  25233. errlog := &models.HisOrderError{
  25234. UserOrgId: adminUser.CurrentOrgId,
  25235. Ctime: time.Now().Unix(),
  25236. Mtime: time.Now().Unix(),
  25237. ErrMsg: resThree.ErrMsg,
  25238. Status: 1,
  25239. PatientId: id,
  25240. RecordTime: recordDateTime,
  25241. Stage: 2,
  25242. }
  25243. service.CreateErrMsgLog(errlog)
  25244. c.ServeSuccessJSON(map[string]interface{}{
  25245. "failed_code": -10,
  25246. "msg": resThree.ErrMsg,
  25247. })
  25248. return
  25249. }
  25250. his.Number = resThree.Output.Data.MdtrtID
  25251. his.PsnNo = resThree.Output.Data.PsnNo
  25252. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  25253. his.IdCardNo = patient.IdCardNo
  25254. his.PhoneNumber = patient.Phone
  25255. his.UserOrgId = adminInfo.CurrentOrgId
  25256. his.Insutype = insutype
  25257. his.Ctime = time.Now().Unix()
  25258. his.Mtime = time.Now().Unix()
  25259. his.InsuplcAdmdvs = insuplc_admdvs_temp
  25260. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  25261. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25262. }
  25263. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  25264. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25265. }
  25266. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  25267. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25268. }
  25269. his.Status = 1
  25270. his.MdtrtGrpType = mdtrt_type
  25271. service.UpdateHisPatientStatus(&his)
  25272. service.UpdateHisPatient123(&patient)
  25273. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  25274. c.ServeSuccessJSON(map[string]interface{}{
  25275. "his_info": his,
  25276. })
  25277. } else {
  25278. adminUser := c.GetAdminUserInfo()
  25279. errlog := &models.HisOrderError{
  25280. UserOrgId: adminUser.CurrentOrgId,
  25281. Ctime: time.Now().Unix(),
  25282. Mtime: time.Now().Unix(),
  25283. ErrMsg: res.ErrMsg,
  25284. Status: 1,
  25285. PatientId: id,
  25286. RecordTime: recordDateTime,
  25287. Stage: 1,
  25288. }
  25289. service.CreateErrMsgLog(errlog)
  25290. c.ServeSuccessJSON(map[string]interface{}{
  25291. "failed_code": -10,
  25292. "msg": res.ErrMsg,
  25293. })
  25294. return
  25295. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  25296. }
  25297. }
  25298. }
  25299. func (c *HisApiController) GetUploadInfo() {
  25300. id, _ := c.GetInt64("id")
  25301. record_time := c.GetString("record_time")
  25302. his_patient_id, _ := c.GetInt64("his_patient_id")
  25303. order_id, _ := c.GetInt64("order_id")
  25304. pay_way, _ := c.GetInt64("pay_way")
  25305. pay_ways := c.GetString("pay_ways")
  25306. oth_desc := c.GetString("oth_desc")
  25307. pay_price, _ := c.GetFloat("pay_price")
  25308. pay_card_no := c.GetString("pay_card_no")
  25309. discount_price, _ := c.GetFloat("discount_price")
  25310. preferential_price, _ := c.GetFloat("preferential_price")
  25311. reality_price, _ := c.GetFloat("reality_price")
  25312. found_price, _ := c.GetFloat("found_price")
  25313. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  25314. private_price, _ := c.GetFloat("private_price")
  25315. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25316. admin_user_id, _ := c.GetInt64("admin_user_id")
  25317. fapiao_code := c.GetString("fapiao_code")
  25318. fapiao_number := c.GetString("fapiao_number")
  25319. diagnosis_id := c.GetString("diagnosis")
  25320. sick_type, _ := c.GetInt64("sick_type")
  25321. reg_type, _ := c.GetInt64("p_type")
  25322. begin_time := c.GetString("begin_time")
  25323. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  25324. cash_pay := c.GetString("cash_pay")
  25325. band_card_pay := c.GetString("band_card_pay")
  25326. wechat_pay := c.GetString("wechat_pay")
  25327. ali_pay := c.GetString("ali_pay")
  25328. jifen_pay := c.GetString("jifen_pay")
  25329. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  25330. fmt.Println(acct_used_flag)
  25331. id_str := c.GetString("ids")
  25332. ids_arr := strings.Split(id_str, ",")
  25333. timeLayout := "2006-01-02"
  25334. loc, _ := time.LoadLocation("Local")
  25335. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25336. if err != nil {
  25337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25338. return
  25339. }
  25340. recordDateTime := theTime.Unix()
  25341. adminUser := c.GetAdminUserInfo()
  25342. var tempOrder models.HisOrder
  25343. tempOrder, _ = service.GetHisOrderByID(order_id)
  25344. var prescriptions []*models.HisPrescription
  25345. var start_time int64
  25346. var end_time int64
  25347. //押金模块
  25348. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  25349. tmp_decimal := c.GetString("tmp_decimal")
  25350. var decimal float64 //本次使用的押金
  25351. var errmsg error
  25352. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  25353. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  25354. return
  25355. }
  25356. if len(tmp_decimal) > 0 {
  25357. if tmp_decimal[0] == 45 {
  25358. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  25359. return
  25360. }
  25361. }
  25362. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  25363. fmt.Println(errs)
  25364. decimal = tt
  25365. //if adminUser.CurrentOrgId == 10106{
  25366. // if len(fapiao_code) == 0{
  25367. // fapiao_code = "144072080589"
  25368. // }
  25369. // if len(fapiao_number) == 0{
  25370. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  25371. // if order.ID == 0{
  25372. // fapiao_number = "00001520"
  25373. // }else{
  25374. // //fapiao_code = "00001520"
  25375. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  25376. // var zero string
  25377. // if fpNumber >= 1000{
  25378. // zero = "0000" + strconv.Itoa(fpNumber)
  25379. // }else if fpNumber >= 10000{
  25380. // zero = "000" + strconv.Itoa(fpNumber)
  25381. // } else if fpNumber >= 100000{
  25382. // zero = "00" + strconv.Itoa(fpNumber)
  25383. // } else if fpNumber >= 1000000{
  25384. // zero = "0" + strconv.Itoa(fpNumber)
  25385. // }else {
  25386. // zero = strconv.Itoa(fpNumber)
  25387. // }
  25388. // fapiao_number = zero
  25389. // }
  25390. // }
  25391. //}
  25392. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25393. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25394. var patientPrescription models.HisPrescriptionInfo
  25395. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25396. if patientPrescription.ID == 0 {
  25397. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25398. }
  25399. //if patientPrescription.Do
  25400. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25401. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25402. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25403. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25404. var config []*models.HisXtDiagnoseConfig
  25405. for _, item := range diagnosis_ids {
  25406. id, _ := strconv.ParseInt(item, 10, 64)
  25407. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25408. config = append(config, &diagnosisConfig)
  25409. }
  25410. sickConfig, _ := service.FindSickById(sick_type)
  25411. //if tempOrder.ID == 0 {
  25412. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  25413. //}
  25414. if tempOrder.ID == 0 {
  25415. var result string
  25416. var requestLog string
  25417. var res2 ResultSix
  25418. var res3 GZResultSix
  25419. var ressix10265 ResultSix10265
  25420. if miConfig.MdtrtareaAdmvs == "421300" {
  25421. data := make(map[string]interface{})
  25422. client := &http.Client{}
  25423. data["psn_no"] = his.PsnNo
  25424. data["mdtrt_id"] = his.Number
  25425. data["opter"] = roles.UserName
  25426. data["org_name"] = miConfig.OrgName
  25427. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25428. data["doctor_id"] = doctor_info.DoctorNumber
  25429. data["doctor_name"] = doctor_info.UserName
  25430. data["department"] = department.Name
  25431. data["fixmedins_code"] = miConfig.Code
  25432. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25433. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25434. data["secret_key"] = miConfig.SecretKey
  25435. data["sick_code"] = sickConfig.CountryCode
  25436. data["sick_name"] = sickConfig.ClassName
  25437. data["dept"] = strconv.FormatInt(department.ID, 10)
  25438. data["config"] = config
  25439. data["begin_time"] = begin_time
  25440. bytesData, _ := json.Marshal(data)
  25441. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25442. resp, _ := client.Do(req)
  25443. defer resp.Body.Close()
  25444. body, ioErr := ioutil.ReadAll(resp.Body)
  25445. if ioErr != nil {
  25446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25448. return
  25449. }
  25450. var respJSON map[string]interface{}
  25451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25454. return
  25455. }
  25456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25457. userJSONBytes, _ := json.Marshal(respJSON)
  25458. fmt.Println("log")
  25459. fmt.Println(string(userJSONBytes))
  25460. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25461. utils.ErrorLog("解析失败:%v", err)
  25462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25463. return
  25464. }
  25465. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25466. data := make(map[string]interface{})
  25467. client := &http.Client{}
  25468. data["psn_no"] = his.PsnNo
  25469. data["mdtrt_id"] = his.Number
  25470. data["opter"] = roles.UserName
  25471. data["org_name"] = miConfig.OrgName
  25472. if reg_type == 11 && his.Insutype == "390" {
  25473. data["med_type"] = "110104"
  25474. } else {
  25475. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25476. }
  25477. data["doctor_id"] = doctor_info.DoctorNumber
  25478. data["doctor_name"] = doctor_info.UserName
  25479. data["department"] = department.Name
  25480. data["fixmedins_code"] = miConfig.Code
  25481. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25482. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25483. data["secret_key"] = miConfig.SecretKey
  25484. data["sick_code"] = sickConfig.CountryCode
  25485. data["sick_name"] = sickConfig.ClassName
  25486. data["dept"] = strconv.FormatInt(department.ID, 10)
  25487. data["config"] = config
  25488. data["begin_time"] = begin_time
  25489. bytesData, _ := json.Marshal(data)
  25490. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25491. resp, _ := client.Do(req)
  25492. defer resp.Body.Close()
  25493. body, ioErr := ioutil.ReadAll(resp.Body)
  25494. if ioErr != nil {
  25495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25497. return
  25498. }
  25499. var respJSON map[string]interface{}
  25500. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25503. return
  25504. }
  25505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25506. userJSONBytes, _ := json.Marshal(respJSON)
  25507. fmt.Println("log")
  25508. fmt.Println(string(userJSONBytes))
  25509. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25510. utils.ErrorLog("解析失败:%v", err)
  25511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25512. return
  25513. }
  25514. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25515. data := make(map[string]interface{})
  25516. client := &http.Client{}
  25517. data["psn_no"] = his.PsnNo
  25518. data["mdtrt_id"] = his.Number
  25519. data["opter"] = roles.UserName
  25520. data["org_name"] = miConfig.OrgName
  25521. if reg_type == 11 && his.Insutype == "390" {
  25522. data["med_type"] = "110104"
  25523. } else {
  25524. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25525. }
  25526. data["doctor_id"] = doctor_info.DoctorNumber
  25527. data["doctor_name"] = doctor_info.UserName
  25528. data["department"] = department.Name
  25529. data["fixmedins_code"] = miConfig.Code
  25530. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25531. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25532. data["secret_key"] = miConfig.SecretKey
  25533. data["sick_code"] = sickConfig.CountryCode
  25534. data["sick_name"] = sickConfig.ClassName
  25535. data["dept"] = strconv.FormatInt(department.ID, 10)
  25536. data["config"] = config
  25537. data["begin_time"] = begin_time
  25538. bytesData, _ := json.Marshal(data)
  25539. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25540. resp, _ := client.Do(req)
  25541. defer resp.Body.Close()
  25542. body, ioErr := ioutil.ReadAll(resp.Body)
  25543. if ioErr != nil {
  25544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25546. return
  25547. }
  25548. var respJSON map[string]interface{}
  25549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25552. return
  25553. }
  25554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25555. userJSONBytes, _ := json.Marshal(respJSON)
  25556. fmt.Println("log")
  25557. fmt.Println(string(userJSONBytes))
  25558. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25559. utils.ErrorLog("解析失败:%v", err)
  25560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25561. return
  25562. }
  25563. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25564. data := make(map[string]interface{})
  25565. client := &http.Client{}
  25566. data["psn_no"] = his.PsnNo
  25567. data["mdtrt_id"] = his.Number
  25568. data["opter"] = roles.UserName
  25569. data["org_name"] = miConfig.OrgName
  25570. if reg_type == 11 && his.Insutype == "390" {
  25571. data["med_type"] = "110104"
  25572. } else {
  25573. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25574. }
  25575. data["doctor_id"] = doctor_info.DoctorNumber
  25576. data["doctor_name"] = doctor_info.UserName
  25577. data["department"] = department.Name
  25578. data["fixmedins_code"] = miConfig.Code
  25579. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25580. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25581. data["secret_key"] = miConfig.SecretKey
  25582. data["sick_code"] = sickConfig.CountryCode
  25583. data["sick_name"] = sickConfig.ClassName
  25584. data["dept"] = strconv.FormatInt(department.ID, 10)
  25585. data["config"] = config
  25586. data["begin_time"] = begin_time
  25587. bytesData, _ := json.Marshal(data)
  25588. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25589. resp, _ := client.Do(req)
  25590. defer resp.Body.Close()
  25591. body, ioErr := ioutil.ReadAll(resp.Body)
  25592. if ioErr != nil {
  25593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25595. return
  25596. }
  25597. var respJSON map[string]interface{}
  25598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25601. return
  25602. }
  25603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25604. userJSONBytes, _ := json.Marshal(respJSON)
  25605. fmt.Println("log")
  25606. fmt.Println(string(userJSONBytes))
  25607. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25608. utils.ErrorLog("解析失败:%v", err)
  25609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25610. return
  25611. }
  25612. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25613. data := make(map[string]interface{})
  25614. client := &http.Client{}
  25615. data["psn_no"] = his.PsnNo
  25616. data["mdtrt_id"] = his.Number
  25617. data["doctor"] = roles.UserName
  25618. data["department"] = department.Name
  25619. data["org_name"] = miConfig.OrgName
  25620. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25621. data["doctor_id"] = doctor_info.DoctorNumber
  25622. data["new_doctor_name"] = doctor_info.UserName
  25623. data["fixmedins_code"] = miConfig.Code
  25624. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25625. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25626. data["secret_key"] = miConfig.SecretKey
  25627. data["sick_code"] = sickConfig.CountryCode
  25628. data["sick_name"] = sickConfig.ClassName
  25629. data["url"] = miConfig.Url
  25630. data["ak"] = miConfig.AccessKey
  25631. data["begin_time"] = begin_time
  25632. data["cainfo"] = miConfig.Cainfo
  25633. data["dept"] = strconv.FormatInt(department.ID, 10)
  25634. data["config"] = config
  25635. bytesData, _ := json.Marshal(data)
  25636. var req *http.Request
  25637. if miConfig.MdtrtareaAdmvs == "320921" {
  25638. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25639. //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 +
  25640. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25641. } else {
  25642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25643. }
  25644. resp, _ := client.Do(req)
  25645. defer resp.Body.Close()
  25646. body, ioErr := ioutil.ReadAll(resp.Body)
  25647. if ioErr != nil {
  25648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25650. return
  25651. }
  25652. var respJSON map[string]interface{}
  25653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25656. return
  25657. }
  25658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25659. userJSONBytes, _ := json.Marshal(respJSON)
  25660. fmt.Println("log")
  25661. fmt.Println(string(userJSONBytes))
  25662. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25663. utils.ErrorLog("解析失败:%v", err)
  25664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25665. return
  25666. }
  25667. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25668. res2.Output = ressix10265.Output
  25669. res2.ErrMsg = ressix10265.ErrMsg
  25670. res2.Cainfo = ressix10265.Cainfo
  25671. res2.WarnMsg = ressix10265.WarnMsg
  25672. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25673. res2.Infcode = infocode
  25674. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25675. data := make(map[string]interface{})
  25676. client := &http.Client{}
  25677. data["psn_no"] = his.PsnNo
  25678. data["mdtrt_id"] = his.Number
  25679. data["doctor"] = roles.UserName
  25680. data["department"] = department.Name
  25681. data["org_name"] = miConfig.OrgName
  25682. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25683. data["doctor_id"] = doctor_info.DoctorNumber
  25684. data["new_doctor_name"] = doctor_info.UserName
  25685. data["fixmedins_code"] = miConfig.Code
  25686. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25687. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25688. data["secret_key"] = miConfig.SecretKey
  25689. data["sick_code"] = sickConfig.CountryCode
  25690. data["sick_name"] = sickConfig.ClassName
  25691. data["url"] = miConfig.Url
  25692. data["ak"] = miConfig.AccessKey
  25693. data["begin_time"] = begin_time
  25694. data["cainfo"] = miConfig.Cainfo
  25695. data["dept"] = strconv.FormatInt(department.ID, 10)
  25696. data["config"] = config
  25697. bytesData, _ := json.Marshal(data)
  25698. var req *http.Request
  25699. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25700. resp, _ := client.Do(req)
  25701. defer resp.Body.Close()
  25702. body, ioErr := ioutil.ReadAll(resp.Body)
  25703. if ioErr != nil {
  25704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25706. return
  25707. }
  25708. var respJSON map[string]interface{}
  25709. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25712. return
  25713. }
  25714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25715. userJSONBytes, _ := json.Marshal(respJSON)
  25716. fmt.Println("log")
  25717. fmt.Println(string(userJSONBytes))
  25718. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25719. utils.ErrorLog("解析失败:%v", err)
  25720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25721. return
  25722. }
  25723. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25724. res2.Output = ressix10265.Output
  25725. res2.ErrMsg = ressix10265.ErrMsg
  25726. res2.Cainfo = ressix10265.Cainfo
  25727. res2.WarnMsg = ressix10265.WarnMsg
  25728. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25729. res2.Infcode = infocode
  25730. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25731. 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)
  25732. saveLog(result, requestLog, "2203", "上传就诊信息")
  25733. var respJSON2 map[string]interface{}
  25734. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25737. return
  25738. }
  25739. userJSONBytes2, _ := json.Marshal(respJSON2)
  25740. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25741. utils.ErrorLog("解析失败:%v", err)
  25742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25743. return
  25744. }
  25745. 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)
  25746. fmt.Println(result2)
  25747. fmt.Println(src_request)
  25748. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25749. data := make(map[string]interface{})
  25750. client := &http.Client{}
  25751. data["psn_no"] = his.PsnNo
  25752. data["mdtrt_id"] = his.Number
  25753. data["doctor"] = roles.UserName
  25754. data["department"] = department.Name
  25755. data["org_name"] = miConfig.OrgName
  25756. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25757. data["doctor_id"] = doctor_info.DoctorNumber
  25758. data["new_doctor_name"] = doctor_info.UserName
  25759. data["fixmedins_code"] = miConfig.Code
  25760. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25761. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25762. data["secret_key"] = miConfig.SecretKey
  25763. data["sick_code"] = sickConfig.CountryCode
  25764. data["sick_name"] = sickConfig.ClassName
  25765. data["url"] = miConfig.Url
  25766. data["ak"] = miConfig.AccessKey
  25767. data["begin_time"] = begin_time
  25768. data["cainfo"] = miConfig.Cainfo
  25769. data["dept"] = strconv.FormatInt(department.ID, 10)
  25770. data["config"] = config
  25771. bytesData, _ := json.Marshal(data)
  25772. var req *http.Request
  25773. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25774. resp, _ := client.Do(req)
  25775. defer resp.Body.Close()
  25776. body, ioErr := ioutil.ReadAll(resp.Body)
  25777. if ioErr != nil {
  25778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25780. return
  25781. }
  25782. var respJSON map[string]interface{}
  25783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25786. return
  25787. }
  25788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25789. userJSONBytes, _ := json.Marshal(respJSON)
  25790. fmt.Println("log")
  25791. fmt.Println(string(userJSONBytes))
  25792. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25793. utils.ErrorLog("解析失败:%v", err)
  25794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25795. return
  25796. }
  25797. } else {
  25798. if miConfig.MdtrtareaAdmvs == "440781" { //
  25799. 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)
  25800. } else {
  25801. if miConfig.Code == "H15049901371" {
  25802. //赤峰地区国家医保医疗类别
  25803. //职工透析:医疗类别选特殊情况门诊990502
  25804. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25805. var med_type string
  25806. if his.Insutype == "390" {
  25807. if reg_type == 14 {
  25808. med_type = "9933"
  25809. } else if reg_type == 11 {
  25810. med_type = "11"
  25811. }
  25812. } else if his.Insutype == "310" {
  25813. if reg_type == 14 {
  25814. med_type = "990502"
  25815. } else if reg_type == 11 {
  25816. med_type = "11"
  25817. }
  25818. }
  25819. 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)
  25820. } else {
  25821. 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)
  25822. }
  25823. }
  25824. saveLog(result, requestLog, "2203", "上传就诊信息")
  25825. var respJSON2 map[string]interface{}
  25826. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25829. return
  25830. }
  25831. userJSONBytes2, _ := json.Marshal(respJSON2)
  25832. if miConfig.Code == "H15049901371" {
  25833. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25834. utils.ErrorLog("解析失败:%v", err)
  25835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25836. return
  25837. }
  25838. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25839. res2.Output = ressix10265.Output
  25840. res2.ErrMsg = ressix10265.ErrMsg
  25841. res2.Cainfo = ressix10265.Cainfo
  25842. res2.WarnMsg = ressix10265.WarnMsg
  25843. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25844. res2.Infcode = infocode
  25845. } else {
  25846. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25847. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25848. utils.ErrorLog("解析失败:%v", err)
  25849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25850. return
  25851. }
  25852. res2.Infcode = res3.Infcode
  25853. } else {
  25854. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25855. utils.ErrorLog("解析失败:%v", err)
  25856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25857. return
  25858. }
  25859. }
  25860. }
  25861. }
  25862. if res2.Infcode == -1 {
  25863. adminUser := c.GetAdminUserInfo()
  25864. errlog := &models.HisOrderError{
  25865. UserOrgId: adminUser.CurrentOrgId,
  25866. Ctime: time.Now().Unix(),
  25867. Mtime: time.Now().Unix(),
  25868. ErrMsg: res2.ErrMsg,
  25869. Status: 1,
  25870. PatientId: id,
  25871. RecordTime: recordDateTime,
  25872. Stage: 3,
  25873. }
  25874. service.CreateErrMsgLog(errlog)
  25875. c.ServeSuccessJSON(map[string]interface{}{
  25876. "failed_code": -10,
  25877. "msg": res2.ErrMsg,
  25878. })
  25879. return
  25880. } else {
  25881. his.Diagnosis = diagnosis_id
  25882. his.SickType = sickConfig.ID
  25883. //var p_type int64
  25884. //if reg_type == 1111 || reg_type == 1112 {
  25885. // p_type = 11
  25886. //
  25887. //}
  25888. his.PType = fmt.Sprintf("%d", reg_type)
  25889. service.UpdateHisPatientThree(&his)
  25890. data := make(map[string]interface{})
  25891. if settle_accounts_type == 1 { //日结
  25892. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25893. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25894. } else {
  25895. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25896. }
  25897. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25898. data["pre"] = prescriptions
  25899. } else { //月结
  25900. start_time_str := c.GetString("start_time")
  25901. end_time_str := c.GetString("end_time")
  25902. timeLayout := "2006-01-02"
  25903. loc, _ := time.LoadLocation("Local")
  25904. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25905. if err != nil {
  25906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25907. return
  25908. }
  25909. recordStartTime := theStartTime.Unix()
  25910. start_time = recordStartTime
  25911. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25912. if err != nil {
  25913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25914. return
  25915. }
  25916. recordEndTime := theEndTime.Unix()
  25917. end_time = recordEndTime
  25918. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25919. data["pre"] = prescriptions
  25920. }
  25921. timestamp := time.Now().Unix()
  25922. tempTime := time.Unix(timestamp, 0)
  25923. timeFormat := tempTime.Format("20060102150405")
  25924. chrgBchno := rand.Intn(100000) + 10000
  25925. new_chrg_bchno := ""
  25926. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25927. new_chrg_bchno = chrg_bchno
  25928. strconv.FormatInt(his.PatientId, 10)
  25929. client := &http.Client{}
  25930. if adminUser.CurrentOrgId == 10265 {
  25931. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25932. new_chrg_bchno = "0000"
  25933. }
  25934. }
  25935. data["psn_no"] = his.PsnNo
  25936. data["mdtrt_id"] = his.Number
  25937. data["chrg_bchno"] = new_chrg_bchno
  25938. data["org_name"] = miConfig.OrgName
  25939. data["doctor"] = doctor_info.UserName
  25940. data["doctor_id"] = doctor_info.DoctorNumber
  25941. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25942. data["fixmedins_code"] = miConfig.Code
  25943. data["dept_code"] = department.Number
  25944. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25945. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25946. data["secret_key"] = miConfig.SecretKey
  25947. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25948. data["url"] = miConfig.Url
  25949. data["ak"] = miConfig.AccessKey
  25950. data["new_doctor_name"] = patientPrescription.Doctor
  25951. data["diag_code"] = sickConfig.CountryCode
  25952. data["cainfo"] = miConfig.Cainfo
  25953. data["opter"] = roles.UserName
  25954. var ids []int64
  25955. for _, item := range prescriptions {
  25956. ids = append(ids, item.ID)
  25957. }
  25958. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25959. if config.IsOpen == 1 { //对接了医保,走医保流程
  25960. var res ResultFour
  25961. var resFour10265 ResultFour10265
  25962. if miConfig.MdtrtareaAdmvs == "421300" {
  25963. bytesData, _ := json.Marshal(data)
  25964. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25965. resp, _ := client.Do(req)
  25966. defer resp.Body.Close()
  25967. body, ioErr := ioutil.ReadAll(resp.Body)
  25968. if ioErr != nil {
  25969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25971. return
  25972. }
  25973. var respJSON map[string]interface{}
  25974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25977. return
  25978. }
  25979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25980. userJSONBytes, _ := json.Marshal(respJSON)
  25981. fmt.Println("log")
  25982. fmt.Println(string(userJSONBytes))
  25983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25984. utils.ErrorLog("解析失败:%v", err)
  25985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25986. return
  25987. }
  25988. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25989. bytesData, _ := json.Marshal(data)
  25990. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25991. resp, _ := client.Do(req)
  25992. defer resp.Body.Close()
  25993. body, ioErr := ioutil.ReadAll(resp.Body)
  25994. if ioErr != nil {
  25995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. var respJSON map[string]interface{}
  26000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26006. userJSONBytes, _ := json.Marshal(respJSON)
  26007. fmt.Println("log")
  26008. fmt.Println(string(userJSONBytes))
  26009. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26010. utils.ErrorLog("解析失败:%v", err)
  26011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26012. return
  26013. }
  26014. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26015. bytesData, _ := json.Marshal(data)
  26016. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26017. resp, _ := client.Do(req)
  26018. defer resp.Body.Close()
  26019. body, ioErr := ioutil.ReadAll(resp.Body)
  26020. if ioErr != nil {
  26021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26023. return
  26024. }
  26025. var respJSON map[string]interface{}
  26026. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26029. return
  26030. }
  26031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26032. userJSONBytes, _ := json.Marshal(respJSON)
  26033. fmt.Println("log")
  26034. fmt.Println(string(userJSONBytes))
  26035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26036. utils.ErrorLog("解析失败:%v", err)
  26037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26038. return
  26039. }
  26040. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26041. bytesData, _ := json.Marshal(data)
  26042. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26043. resp, _ := client.Do(req)
  26044. defer resp.Body.Close()
  26045. body, ioErr := ioutil.ReadAll(resp.Body)
  26046. if ioErr != nil {
  26047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26049. return
  26050. }
  26051. var respJSON map[string]interface{}
  26052. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26055. return
  26056. }
  26057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26058. userJSONBytes, _ := json.Marshal(respJSON)
  26059. fmt.Println("log")
  26060. fmt.Println(string(userJSONBytes))
  26061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26062. utils.ErrorLog("解析失败:%v", err)
  26063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26064. return
  26065. }
  26066. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26067. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26068. if result3101.Infcode == "0" {
  26069. if len(result3101.Output.Result) > 0 {
  26070. var errMsgs []string
  26071. for _, item := range result3101.Output.Result {
  26072. errMsgs = append(errMsgs, item.VolaCont)
  26073. }
  26074. c.ServeSuccessJSON(map[string]interface{}{
  26075. "failed_code": -10,
  26076. "msg": errMsgs,
  26077. })
  26078. return
  26079. }
  26080. }
  26081. bytesData, _ := json.Marshal(data)
  26082. var req *http.Request
  26083. if miConfig.MdtrtareaAdmvs == "320921" {
  26084. data["diag_code"] = sickConfig.CountryCode
  26085. fmt.Println(data)
  26086. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26087. } else {
  26088. data["diag_code"] = sickConfig.CountryCode
  26089. fmt.Println(data)
  26090. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26091. }
  26092. resp, _ := client.Do(req)
  26093. defer resp.Body.Close()
  26094. body, ioErr := ioutil.ReadAll(resp.Body)
  26095. if ioErr != nil {
  26096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26098. return
  26099. }
  26100. var respJSON map[string]interface{}
  26101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26104. return
  26105. }
  26106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26107. userJSONBytes, _ := json.Marshal(respJSON)
  26108. fmt.Println("log")
  26109. fmt.Println(string(userJSONBytes))
  26110. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26111. utils.ErrorLog("解析失败:%v", err)
  26112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26113. return
  26114. }
  26115. res.InfRefmsgid = resFour10265.InfRefmsgid
  26116. res.Output = resFour10265.Output
  26117. res.ErrMsg = resFour10265.ErrMsg
  26118. res.Cainfo = resFour10265.Cainfo
  26119. res.WarnMsg = resFour10265.WarnMsg
  26120. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26121. res.Infcode = infocode
  26122. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26123. var pagesize int = 2
  26124. var start int = 1
  26125. var stop int
  26126. var pagecount int
  26127. var curpage int
  26128. var isSuccess bool = true
  26129. data["doctor_id"] = doctor_info.DoctorNumber
  26130. //总页数,向上取整,注意除之前要先转换类型为float64
  26131. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26132. for curpage = 1; curpage <= pagecount; curpage++ {
  26133. if curpage == 1 {
  26134. start = 1
  26135. } else {
  26136. start = (curpage-1)*pagesize + 1
  26137. }
  26138. stop = curpage * pagesize
  26139. if stop > len(prescriptions) {
  26140. stop = len(prescriptions)
  26141. }
  26142. //var requestLog string
  26143. data["pre"] = prescriptions[start-1 : stop]
  26144. fmt.Println(data["pre"])
  26145. bytesData, _ := json.Marshal(data)
  26146. var req *http.Request
  26147. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26148. resp, _ := client.Do(req)
  26149. defer resp.Body.Close()
  26150. body, ioErr := ioutil.ReadAll(resp.Body)
  26151. if ioErr != nil {
  26152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26154. return
  26155. }
  26156. var respJSON map[string]interface{}
  26157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26160. return
  26161. }
  26162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26163. userJSONBytes, _ := json.Marshal(respJSON)
  26164. fmt.Println("log")
  26165. fmt.Println(string(userJSONBytes))
  26166. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26167. utils.ErrorLog("解析失败:%v", err)
  26168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26169. return
  26170. }
  26171. res.InfRefmsgid = resFour10265.InfRefmsgid
  26172. res.Output = resFour10265.Output
  26173. res.ErrMsg = resFour10265.ErrMsg
  26174. res.Cainfo = resFour10265.Cainfo
  26175. res.WarnMsg = resFour10265.WarnMsg
  26176. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26177. res.Infcode = infocode
  26178. if infocode == 0 {
  26179. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  26180. } else {
  26181. isSuccess = false
  26182. errlog := &models.HisOrderError{
  26183. UserOrgId: adminUser.CurrentOrgId,
  26184. Ctime: time.Now().Unix(),
  26185. Mtime: time.Now().Unix(),
  26186. Number: chrg_bchno,
  26187. ErrMsg: "",
  26188. Status: 1,
  26189. PatientId: id,
  26190. RecordTime: recordDateTime,
  26191. Stage: 4,
  26192. }
  26193. service.CreateErrMsgLog(errlog)
  26194. c.ServeSuccessJSON(map[string]interface{}{
  26195. "failed_code": -10,
  26196. "msg": res.ErrMsg,
  26197. })
  26198. return
  26199. }
  26200. }
  26201. if isSuccess {
  26202. res.Infcode = 0
  26203. }
  26204. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26205. 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)
  26206. var dat map[string]interface{}
  26207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26208. fmt.Println(dat)
  26209. } else {
  26210. fmt.Println(err)
  26211. }
  26212. saveLog(result, request_log, "2204", "上传费用明细")
  26213. userJSONBytes, _ := json.Marshal(dat)
  26214. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26215. utils.ErrorLog("解析失败:%v", err)
  26216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26217. return
  26218. }
  26219. res.InfRefmsgid = resFour10265.InfRefmsgid
  26220. res.Output = resFour10265.Output
  26221. res.ErrMsg = resFour10265.ErrMsg
  26222. res.Cainfo = resFour10265.Cainfo
  26223. res.WarnMsg = resFour10265.WarnMsg
  26224. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26225. res.Infcode = infocode
  26226. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26227. bytesData, _ := json.Marshal(data)
  26228. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26229. resp, _ := client.Do(req)
  26230. defer resp.Body.Close()
  26231. body, ioErr := ioutil.ReadAll(resp.Body)
  26232. if ioErr != nil {
  26233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26235. return
  26236. }
  26237. var respJSON map[string]interface{}
  26238. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26241. return
  26242. }
  26243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26244. userJSONBytes, _ := json.Marshal(respJSON)
  26245. fmt.Println("log")
  26246. fmt.Println(string(userJSONBytes))
  26247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26248. utils.ErrorLog("解析失败:%v", err)
  26249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26250. return
  26251. }
  26252. } else {
  26253. if miConfig.Code == "H15049901371" {
  26254. 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)
  26255. var dat map[string]interface{}
  26256. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26257. fmt.Println(dat)
  26258. } else {
  26259. fmt.Println(err)
  26260. }
  26261. saveLog(result, request_log, "2204", "上传费用明细")
  26262. userJSONBytes, _ := json.Marshal(dat)
  26263. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26264. utils.ErrorLog("解析失败:%v", err)
  26265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26266. return
  26267. }
  26268. res.InfRefmsgid = resFour10265.InfRefmsgid
  26269. res.Output = resFour10265.Output
  26270. res.ErrMsg = resFour10265.ErrMsg
  26271. res.Cainfo = resFour10265.Cainfo
  26272. res.WarnMsg = resFour10265.WarnMsg
  26273. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26274. res.Infcode = infocode
  26275. } else {
  26276. 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)
  26277. var dat map[string]interface{}
  26278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26279. fmt.Println(dat)
  26280. } else {
  26281. fmt.Println(err)
  26282. }
  26283. saveLog(result, request_log, "2204", "上传费用明细")
  26284. userJSONBytes, _ := json.Marshal(dat)
  26285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26286. utils.ErrorLog("解析失败:%v", err)
  26287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26288. return
  26289. }
  26290. }
  26291. }
  26292. if res.Infcode == 0 {
  26293. order := &models.HisOrder{
  26294. UserOrgId: adminUser.CurrentOrgId,
  26295. HisPatientId: his.ID,
  26296. PatientId: his.PatientId,
  26297. SettleAccountsDate: recordDateTime,
  26298. MdtrtId: his.Number,
  26299. PsnNo: his.PsnNo,
  26300. MedType: strconv.FormatInt(reg_type, 10),
  26301. Ctime: time.Now().Unix(),
  26302. Mtime: time.Now().Unix(),
  26303. Status: 1,
  26304. Number: chrg_bchno,
  26305. Infcode: res.Infcode,
  26306. WarnMsg: res.WarnMsg,
  26307. Cainfo: res.Cainfo,
  26308. ErrMsg: res.ErrMsg,
  26309. RespondTime: res.RefmsgTime,
  26310. InfRefmsgid: res.InfRefmsgid,
  26311. OrderStatus: 1,
  26312. PayWay: pay_way,
  26313. PayWays: pay_ways,
  26314. OthDesc: oth_desc,
  26315. PayPrice: pay_price,
  26316. PayCardNo: pay_card_no,
  26317. DiscountPrice: discount_price,
  26318. PreferentialPrice: preferential_price,
  26319. RealityPrice: reality_price,
  26320. FoundPrice: found_price,
  26321. MedicalInsurancePrice: medical_insurance_price,
  26322. PrivatePrice: private_price,
  26323. IsMedicineInsurance: 1,
  26324. SettleType: settle_accounts_type,
  26325. SettleStartTime: start_time,
  26326. SettleEndTime: end_time,
  26327. Creator: roles.AdminUserId,
  26328. Modify: roles.AdminUserId,
  26329. FaPiaoNumber: fapiao_number,
  26330. FaPiaoCode: fapiao_code,
  26331. PType: 2,
  26332. Diagnosis: diagnosis_id,
  26333. CashPay: cash_pay,
  26334. WechatPay: wechat_pay,
  26335. AliPay: ali_pay,
  26336. JifenPay: jifen_pay,
  26337. BandCardPay: band_card_pay,
  26338. }
  26339. err = service.CreateOrder(order)
  26340. if err != nil {
  26341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26342. return
  26343. }
  26344. for _, item := range res.Output.Result {
  26345. temp := strings.Split(item.FeedetlSn, "-")
  26346. var advice_id int64 = 0
  26347. var project_id int64 = 0
  26348. var types int64 = 0
  26349. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26350. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26351. if temp[1] == "1" {
  26352. advice_id = id
  26353. project_id = 0
  26354. } else if temp[1] == "2" {
  26355. advice_id = 0
  26356. project_id = id
  26357. }
  26358. if item.MedChrgitmType == "9" {
  26359. item.MedChrgitmType = "09"
  26360. }
  26361. info := &models.HisOrderInfo{
  26362. OrderNumber: order.Number,
  26363. FeedetlSn: item.FeedetlSn,
  26364. UploadDate: time.Now().Unix(),
  26365. AdviceId: advice_id,
  26366. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26367. Cnt: item.Cnt,
  26368. Pric: float64(item.Pric),
  26369. PatientId: his.PatientId,
  26370. PricUplmtAmt: item.PricUplmtAmt,
  26371. SelfpayProp: item.SelfpayProp,
  26372. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26373. OverlmtAmt: item.OverlmtAmt,
  26374. PreselfpayAmt: item.PreselfpayAmt,
  26375. BasMednFlag: item.BasMednFlag,
  26376. MedChrgitmType: item.MedChrgitmType,
  26377. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26378. Status: 1,
  26379. Memo: item.Memo,
  26380. Mtime: time.Now().Unix(),
  26381. InscpScpAmt: item.InscpScpAmt,
  26382. DrtReimFlag: item.DrtReimFlag,
  26383. Ctime: time.Now().Unix(),
  26384. ListSpItemFlag: item.ListSpItemFlag,
  26385. ChldMedcFlag: item.ChldMedcFlag,
  26386. LmtUsedFlag: item.LmtUsedFlag,
  26387. ChrgitmLv: item.ChrgitmLv,
  26388. UserOrgId: adminUser.CurrentOrgId,
  26389. HisPatientId: his.ID,
  26390. OrderId: order.ID,
  26391. ProjectId: project_id,
  26392. Type: types,
  26393. }
  26394. service.CreateOrderInfo(info)
  26395. }
  26396. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  26397. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  26398. var total float64
  26399. for _, item := range prescriptions {
  26400. if item.Type == 1 { //药品
  26401. for _, subItem := range item.HisDoctorAdviceInfo {
  26402. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26403. total_one := price * subItem.PrescribingNumber
  26404. total = total + total_one
  26405. }
  26406. }
  26407. if item.Type == 2 { //项目
  26408. for _, subItem := range item.HisPrescriptionProject {
  26409. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  26410. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26411. total_one := price * cnt
  26412. total = total + total_one
  26413. }
  26414. }
  26415. }
  26416. allTotal := fmt.Sprintf("%.2f", total)
  26417. //if adminUser.CurrentOrgId == 9919 {
  26418. //
  26419. // allTotal = fmt.Sprintf("%.2f", total)
  26420. //
  26421. //} else {
  26422. //
  26423. // allTotal = fmt.Sprintf("%.2f", total)
  26424. //
  26425. //}
  26426. if res.Infcode == 0 {
  26427. var rf []*ResultFive
  26428. json.Unmarshal([]byte(his.Iinfo), &rf)
  26429. chrg_bchno := chrg_bchno
  26430. cert_no := his.Certno
  26431. var insutypes []string
  26432. var insutype string
  26433. var is390 int = 0
  26434. var is310 int = 0
  26435. for _, item := range rf {
  26436. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26437. insutypes = append(insutypes, item.Insutype)
  26438. }
  26439. }
  26440. if len(insutypes) == 1 {
  26441. insutype = insutypes[0]
  26442. } else {
  26443. for _, i := range insutypes {
  26444. if i == "390" {
  26445. is390 = 1
  26446. }
  26447. if i == "310" {
  26448. is310 = 1
  26449. }
  26450. }
  26451. }
  26452. if is390 == 1 {
  26453. insutype = "390"
  26454. }
  26455. if is310 == 1 {
  26456. insutype = "310"
  26457. }
  26458. if len(insutypes) == 0 {
  26459. insutype = "310"
  26460. }
  26461. if len(insutypes) == 2 {
  26462. insutype = strconv.FormatInt(his.SocialType, 10)
  26463. }
  26464. insutype = strconv.FormatInt(his.SocialType, 10)
  26465. //insutype = "390"
  26466. if his.IdCardType == 1 {
  26467. // cert_no = his.MedicalInsuranceNumber
  26468. cert_no = his.Certno
  26469. } else {
  26470. cert_no = his.Certno
  26471. }
  26472. var res ResultSeven
  26473. var resSeven10265 ResultSeven10265
  26474. var gzresSeven10265Two GZResultSeven10265Two
  26475. var src_resquest string
  26476. var result2 string
  26477. if miConfig.MdtrtareaAdmvs == "421300" {
  26478. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26479. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26480. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26481. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26482. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26483. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26484. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26485. resp, requestErr := http.Get(api)
  26486. if requestErr != nil {
  26487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26488. return
  26489. }
  26490. body, ioErr := ioutil.ReadAll(resp.Body)
  26491. if ioErr != nil {
  26492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26494. return
  26495. }
  26496. var respJSON map[string]interface{}
  26497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26500. return
  26501. }
  26502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26503. result, _ := json.Marshal(respJSON)
  26504. if miConfig.Code == "H15049901371" {
  26505. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26506. utils.ErrorLog("解析失败:%v", err)
  26507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26508. return
  26509. }
  26510. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26511. res.Output = resSeven10265.Output
  26512. res.ErrMsg = resSeven10265.ErrMsg
  26513. res.Cainfo = resSeven10265.Cainfo
  26514. res.WarnMsg = resSeven10265.WarnMsg
  26515. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26516. res.Infcode = infocode
  26517. } else {
  26518. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26519. utils.ErrorLog("解析失败:%v", err)
  26520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26521. return
  26522. }
  26523. }
  26524. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26525. if reg_type == 11 && his.Insutype == "390" {
  26526. reg_type = 110104
  26527. }
  26528. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26529. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26530. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26531. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26532. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26533. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26534. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26535. resp, requestErr := http.Get(api)
  26536. if requestErr != nil {
  26537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26538. return
  26539. }
  26540. body, ioErr := ioutil.ReadAll(resp.Body)
  26541. if ioErr != nil {
  26542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26544. return
  26545. }
  26546. var respJSON map[string]interface{}
  26547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26550. return
  26551. }
  26552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26553. result, _ := json.Marshal(respJSON)
  26554. if miConfig.Code == "H15049901371" {
  26555. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26556. utils.ErrorLog("解析失败:%v", err)
  26557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26558. return
  26559. }
  26560. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26561. res.Output = resSeven10265.Output
  26562. res.ErrMsg = resSeven10265.ErrMsg
  26563. res.Cainfo = resSeven10265.Cainfo
  26564. res.WarnMsg = resSeven10265.WarnMsg
  26565. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26566. res.Infcode = infocode
  26567. } else {
  26568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26569. utils.ErrorLog("解析失败:%v", err)
  26570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26571. return
  26572. }
  26573. }
  26574. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26575. if reg_type == 11 && his.Insutype == "390" {
  26576. reg_type = 110104
  26577. }
  26578. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26579. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26580. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26581. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26582. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26583. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26584. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26585. resp, requestErr := http.Get(api)
  26586. if requestErr != nil {
  26587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26588. return
  26589. }
  26590. body, ioErr := ioutil.ReadAll(resp.Body)
  26591. if ioErr != nil {
  26592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26594. return
  26595. }
  26596. var respJSON map[string]interface{}
  26597. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26600. return
  26601. }
  26602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26603. result, _ := json.Marshal(respJSON)
  26604. if miConfig.Code == "H15049901371" {
  26605. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26606. utils.ErrorLog("解析失败:%v", err)
  26607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26608. return
  26609. }
  26610. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26611. res.Output = resSeven10265.Output
  26612. res.ErrMsg = resSeven10265.ErrMsg
  26613. res.Cainfo = resSeven10265.Cainfo
  26614. res.WarnMsg = resSeven10265.WarnMsg
  26615. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26616. res.Infcode = infocode
  26617. } else {
  26618. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26619. utils.ErrorLog("解析失败:%v", err)
  26620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26621. return
  26622. }
  26623. }
  26624. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26625. if reg_type == 11 && his.Insutype == "390" {
  26626. reg_type = 110104
  26627. }
  26628. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26629. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26630. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26631. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26632. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26633. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26634. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26635. resp, requestErr := http.Get(api)
  26636. if requestErr != nil {
  26637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26638. return
  26639. }
  26640. body, ioErr := ioutil.ReadAll(resp.Body)
  26641. if ioErr != nil {
  26642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26644. return
  26645. }
  26646. var respJSON map[string]interface{}
  26647. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26650. return
  26651. }
  26652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26653. result, _ := json.Marshal(respJSON)
  26654. if miConfig.Code == "H15049901371" {
  26655. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26656. utils.ErrorLog("解析失败:%v", err)
  26657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26658. return
  26659. }
  26660. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26661. res.Output = resSeven10265.Output
  26662. res.ErrMsg = resSeven10265.ErrMsg
  26663. res.Cainfo = resSeven10265.Cainfo
  26664. res.WarnMsg = resSeven10265.WarnMsg
  26665. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26666. res.Infcode = infocode
  26667. } else {
  26668. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26669. utils.ErrorLog("解析失败:%v", err)
  26670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26671. return
  26672. }
  26673. }
  26674. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26675. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26676. if result3101.Infcode == "0" {
  26677. if len(result3101.Output.Result) > 0 {
  26678. var errMsgs []string
  26679. for _, item := range result3101.Output.Result {
  26680. errMsgs = append(errMsgs, item.VolaCont)
  26681. }
  26682. c.ServeSuccessJSON(map[string]interface{}{
  26683. "failed_code": -10,
  26684. "msg": errMsgs,
  26685. })
  26686. return
  26687. } else {
  26688. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26689. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26690. bas := strings.Split(psn_info.CardInfo, "|")
  26691. if his.IdCardType == 1 {
  26692. cert_no = bas[2]
  26693. } else if his.IdCardType == 3 {
  26694. cert_no = his.Certno
  26695. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26696. } else if his.IdCardType == 4 {
  26697. cert_no = his.Certno
  26698. psn_info.VerifyNumber = psn_info.VerifyNumber
  26699. }
  26700. var api string
  26701. if miConfig.MdtrtareaAdmvs == "320921" {
  26702. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26703. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26704. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26706. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26707. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26708. "&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
  26709. } else {
  26710. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26711. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26712. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26713. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26714. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26715. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26716. "&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
  26717. }
  26718. resp, requestErr := http.Get(api)
  26719. if requestErr != nil {
  26720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26721. return
  26722. }
  26723. body, ioErr := ioutil.ReadAll(resp.Body)
  26724. if ioErr != nil {
  26725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26727. return
  26728. }
  26729. var respJSON map[string]interface{}
  26730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26733. return
  26734. }
  26735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26736. result, _ := json.Marshal(respJSON)
  26737. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26738. utils.ErrorLog("解析失败:%v", err)
  26739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26740. return
  26741. }
  26742. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26743. res.Output = resSeven10265.Output
  26744. res.ErrMsg = resSeven10265.ErrMsg
  26745. res.Cainfo = resSeven10265.Cainfo
  26746. res.WarnMsg = resSeven10265.WarnMsg
  26747. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26748. res.Infcode = infocode
  26749. }
  26750. }
  26751. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26752. psn_info, _ := service.GetPsnByPatientId(id)
  26753. var verify_number string
  26754. if psn_info.IdCardType == 4 {
  26755. verify_number = psn_info.VerifyNumber
  26756. } else if psn_info.IdCardType == 1 {
  26757. bas := strings.Split(psn_info.CardInfo, "|")
  26758. cardNumber := bas[2]
  26759. verify_number = cardNumber
  26760. } else {
  26761. psn_info.IdCardType = 2
  26762. verify_number = psn_info.Certno
  26763. }
  26764. var api string
  26765. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26766. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26767. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26768. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26769. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26770. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26771. "&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
  26772. resp, requestErr := http.Get(api)
  26773. if requestErr != nil {
  26774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26775. return
  26776. }
  26777. body, ioErr := ioutil.ReadAll(resp.Body)
  26778. if ioErr != nil {
  26779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26781. return
  26782. }
  26783. var respJSON map[string]interface{}
  26784. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26787. return
  26788. }
  26789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26790. result, _ := json.Marshal(respJSON)
  26791. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26792. utils.ErrorLog("解析失败:%v", err)
  26793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26794. return
  26795. }
  26796. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26797. res.Output = resSeven10265.Output
  26798. res.ErrMsg = resSeven10265.ErrMsg
  26799. res.Cainfo = resSeven10265.Cainfo
  26800. res.WarnMsg = resSeven10265.WarnMsg
  26801. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26802. res.Infcode = infocode
  26803. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26804. var cert_no string
  26805. if his.IdCardType == 4 {
  26806. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26807. cert_no = psn_info.VerifyNumber
  26808. 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)
  26809. } else if his.IdCardType == 1 {
  26810. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26811. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26812. 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)
  26813. }
  26814. //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)
  26815. var dat map[string]interface{}
  26816. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26817. fmt.Println(dat)
  26818. } else {
  26819. fmt.Println(err)
  26820. }
  26821. saveLog(result2, src_resquest, "2207", "结算")
  26822. userJSONBytes, _ := json.Marshal(dat)
  26823. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26824. utils.ErrorLog("解析失败:%v", err)
  26825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26826. return
  26827. }
  26828. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26829. res.Output = resSeven10265.Output
  26830. res.ErrMsg = resSeven10265.ErrMsg
  26831. res.Cainfo = resSeven10265.Cainfo
  26832. res.WarnMsg = resSeven10265.WarnMsg
  26833. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26834. res.Infcode = infocode
  26835. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26836. res2 := c.GetoleInfo()
  26837. if res2.Infcode == 0 {
  26838. var result string
  26839. var request_log string
  26840. var result_log string
  26841. if res2.Output.MdtrtCertType == "02" {
  26842. 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)
  26843. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26844. } else if res2.Output.MdtrtCertType == "01" {
  26845. 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)
  26846. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26847. } else {
  26848. 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)
  26849. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26850. }
  26851. var dat map[string]interface{}
  26852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26853. fmt.Println(dat)
  26854. } else {
  26855. fmt.Println(err)
  26856. }
  26857. userJSONBytes, _ := json.Marshal(dat)
  26858. var res5 ResultTwo
  26859. //var resTwo10265 ResultTwo10265
  26860. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26861. utils.ErrorLog("解析失败:%v", err)
  26862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26863. return
  26864. }
  26865. if res5.Infcode == -1 {
  26866. c.ServeSuccessJSON(map[string]interface{}{
  26867. "failed_code": -10,
  26868. "msg": res5.ErrMsg,
  26869. })
  26870. return
  26871. }
  26872. var insutypes []string
  26873. var insutype string
  26874. var is390 int = 0
  26875. var is310 int = 0
  26876. for _, item := range res5.Output.Iinfo {
  26877. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26878. insutypes = append(insutypes, item.Insutype)
  26879. }
  26880. }
  26881. if len(insutypes) == 1 {
  26882. insutype = insutypes[0]
  26883. } else {
  26884. for _, i := range insutypes {
  26885. if i == "390" {
  26886. is390 = 1
  26887. }
  26888. if i == "310" {
  26889. is310 = 1
  26890. }
  26891. }
  26892. }
  26893. if is390 == 1 {
  26894. insutype = "390"
  26895. }
  26896. if is310 == 1 {
  26897. insutype = "310"
  26898. }
  26899. if len(insutypes) == 0 {
  26900. insutype = "310"
  26901. }
  26902. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26903. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26904. infoStr := string(Iinfos)
  26905. idetinfoStr := string(Idetinfos)
  26906. psn := &models.HisPsn{
  26907. PsnNo: res5.Output.Baseinfo.PsnNo,
  26908. PatientId: id,
  26909. Certno: res5.Output.Baseinfo.Certno,
  26910. Gend: res5.Output.Baseinfo.Gend,
  26911. Naty: res5.Output.Baseinfo.Naty,
  26912. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26913. PsnName: res5.Output.Baseinfo.PsnName,
  26914. Idetinfo: idetinfoStr,
  26915. Insuinfo: infoStr,
  26916. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26917. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26918. VerifyNumber: res2.Output.EcToken,
  26919. }
  26920. if res2.Output.MdtrtCertType == "01" {
  26921. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26922. psn.VerifyNumber = res2.Output.EcToken
  26923. } else if res2.Output.MdtrtCertType == "02" {
  26924. psn.VerifyNumber = res2.Output.CardNo
  26925. } else {
  26926. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26927. }
  26928. service.CreateHisPsn(psn)
  26929. if res2.Output.MdtrtCertType == "01" {
  26930. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26931. token := res2.Output.EcToken
  26932. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  26933. } else if res2.Output.MdtrtCertType == "02" {
  26934. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  26935. } else {
  26936. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  26937. }
  26938. var dat2 map[string]interface{}
  26939. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26940. fmt.Println(dat2)
  26941. } else {
  26942. fmt.Println(err)
  26943. }
  26944. userJSONBytes3, _ := json.Marshal(dat2)
  26945. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26946. utils.ErrorLog("解析失败:%v", err)
  26947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26948. return
  26949. }
  26950. saveLog(result2, src_resquest, "2207", "结算")
  26951. } else {
  26952. c.ServeSuccessJSON(map[string]interface{}{
  26953. "failed_code": -10,
  26954. "msg": res2.ErrMsg,
  26955. })
  26956. return
  26957. }
  26958. } else {
  26959. if miConfig.Code == "H15049901371" {
  26960. //赤峰地区国家医保医疗类别
  26961. //职工透析:医疗类别选特殊情况门诊990502
  26962. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26963. var med_type string
  26964. if his.Insutype == "390" {
  26965. if reg_type == 14 {
  26966. med_type = "9933"
  26967. } else if reg_type == 11 {
  26968. med_type = "11"
  26969. }
  26970. } else if his.Insutype == "310" {
  26971. if reg_type == 14 {
  26972. med_type = "990502"
  26973. } else if reg_type == 11 {
  26974. med_type = "11"
  26975. }
  26976. }
  26977. 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)
  26978. } else {
  26979. if his.IdCardType == 4 {
  26980. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26981. var token string
  26982. token = psn_info.VerifyNumber
  26983. 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)
  26984. } else {
  26985. if his.IdCardType == 1 {
  26986. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26987. bas := strings.Split(psn_info.CardInfo, "|")
  26988. basNumber := bas[2]
  26989. cert_no = basNumber
  26990. }
  26991. 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)
  26992. }
  26993. }
  26994. //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)
  26995. var dat map[string]interface{}
  26996. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26997. fmt.Println(dat)
  26998. } else {
  26999. fmt.Println(err)
  27000. }
  27001. saveLog(result2, src_resquest, "2207", "结算")
  27002. userJSONBytes, _ := json.Marshal(dat)
  27003. if miConfig.Code == "H15049901371" {
  27004. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27005. utils.ErrorLog("解析失败:%v", err)
  27006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27007. return
  27008. }
  27009. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27010. res.Output = resSeven10265.Output
  27011. res.ErrMsg = resSeven10265.ErrMsg
  27012. res.Cainfo = resSeven10265.Cainfo
  27013. res.WarnMsg = resSeven10265.WarnMsg
  27014. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27015. res.Infcode = infocode
  27016. } else {
  27017. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27018. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27019. utils.ErrorLog("解析失败:%v", err)
  27020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27021. return
  27022. }
  27023. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27024. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27025. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27026. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27027. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27028. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27029. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27030. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27031. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27032. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27033. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27034. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27035. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27036. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27037. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27038. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27039. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27040. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27041. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27042. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27043. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27044. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27045. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27046. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27047. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27048. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27049. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27050. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27051. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27052. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27053. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27054. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27055. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27056. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27057. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27058. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27059. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27060. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27061. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27062. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27063. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27064. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27065. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27066. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27067. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27068. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27069. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27070. res.Cainfo = gzresSeven10265Two.Cainfo
  27071. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27072. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27073. //res.Infcode = infocode
  27074. } else {
  27075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27076. utils.ErrorLog("解析失败:%v", err)
  27077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27078. return
  27079. }
  27080. }
  27081. }
  27082. }
  27083. if res.Infcode == -1 {
  27084. errlog := &models.HisOrderError{
  27085. UserOrgId: adminUser.CurrentOrgId,
  27086. Ctime: time.Now().Unix(),
  27087. Mtime: time.Now().Unix(),
  27088. Number: chrg_bchno,
  27089. ErrMsg: res.ErrMsg,
  27090. Status: 1,
  27091. PatientId: id,
  27092. RecordTime: recordDateTime,
  27093. Stage: 6,
  27094. }
  27095. service.CreateErrMsgLog(errlog)
  27096. c.ServeSuccessJSON(map[string]interface{}{
  27097. "failed_code": -10,
  27098. "msg": res.ErrMsg,
  27099. })
  27100. return
  27101. } else {
  27102. sickConfig, _ := service.FindSickById(his.SickType)
  27103. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27104. order.OrderStatus = 2
  27105. order.Status = 1
  27106. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27107. order.SetlId = res.Output.Setlinfo.SetlID
  27108. order.PsnNo = res.Output.Setlinfo.PsnNo
  27109. order.PsnName = res.Output.Setlinfo.PsnName
  27110. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27111. order.Certno = res.Output.Setlinfo.Certno
  27112. order.Gend = res.Output.Setlinfo.Gend
  27113. order.Naty = res.Output.Setlinfo.Naty
  27114. order.Age = res.Output.Setlinfo.Age
  27115. order.Insutype = res.Output.Setlinfo.Insutype
  27116. order.PsnType = res.Output.Setlinfo.PsnType
  27117. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27118. order.SetlTime = res.Output.Setlinfo.SetlTime
  27119. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27120. if res.Output.Setlinfo.MedType == "140101" {
  27121. order.MedType = "14"
  27122. } else {
  27123. if res.Output.Setlinfo.MedType == "110104" {
  27124. order.MedType = "11"
  27125. } else {
  27126. order.MedType = res.Output.Setlinfo.MedType
  27127. }
  27128. }
  27129. if reg_type == 1112 {
  27130. order.MedType = "1112"
  27131. }
  27132. if reg_type == 1111 {
  27133. order.MedType = "1111"
  27134. }
  27135. order.ClrType = res.Output.Setlinfo.ClrType
  27136. if adminUser.CurrentOrgId == 10480 {
  27137. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27138. order.ClrType = "11"
  27139. } else {
  27140. order.ClrType = "9903"
  27141. }
  27142. }
  27143. if adminUser.CurrentOrgId == 10721 {
  27144. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27145. order.ClrType = "11"
  27146. } else {
  27147. order.ClrType = "9903"
  27148. }
  27149. }
  27150. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27151. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27152. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27153. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27154. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27155. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27156. order.HifpPay = res.Output.Setlinfo.HifpPay
  27157. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27158. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27159. order.HifesPay = res.Output.Setlinfo.HifesPay
  27160. order.HifobPay = res.Output.Setlinfo.HifobPay
  27161. order.MafPay = res.Output.Setlinfo.MafPay
  27162. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27163. order.OthPay = res.Output.Setlinfo.OthPay
  27164. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27165. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27166. order.AcctPay = res.Output.Setlinfo.AcctPay
  27167. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27168. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27169. order.Balc = res.Output.Setlinfo.Balc
  27170. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27171. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27172. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27173. //order.ClrType = res.Output.Setlinfo.ClrType
  27174. order.ClrWay = res.Output.Setlinfo.ClrWay
  27175. order.Creator = order.Creator
  27176. order.Modify = roles.AdminUserId
  27177. order.RequestLog = src_resquest
  27178. order.FaPiaoNumber = fapiao_number
  27179. order.FaPiaoCode = fapiao_code
  27180. order.SickName = sickConfig.ClassName
  27181. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27182. //detailStr := string(setlDetail)
  27183. //order.SetlDetail = detailStr
  27184. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27185. err = service.UpDateOrder(order)
  27186. if err == nil {
  27187. //判断是否使用了押金
  27188. if dec_way == "true" {
  27189. tmpstring := strconv.FormatInt(order.ID, 10)
  27190. order.Decimal = decimal
  27191. service.UpDateOrder(order)
  27192. //扣押金
  27193. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27194. if errmsg != nil {
  27195. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27196. return
  27197. }
  27198. }
  27199. c.ServeSuccessJSON(map[string]interface{}{
  27200. "msg": "结算成功",
  27201. })
  27202. } else {
  27203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27204. return
  27205. }
  27206. }
  27207. } else {
  27208. adminUser := c.GetAdminUserInfo()
  27209. errlog := &models.HisOrderError{
  27210. UserOrgId: adminUser.CurrentOrgId,
  27211. Ctime: time.Now().Unix(),
  27212. Mtime: time.Now().Unix(),
  27213. ErrMsg: res.ErrMsg,
  27214. Status: 1,
  27215. PatientId: id,
  27216. RecordTime: recordDateTime,
  27217. Stage: 4,
  27218. }
  27219. service.CreateErrMsgLog(errlog)
  27220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  27221. return
  27222. }
  27223. } else {
  27224. adminUser := c.GetAdminUserInfo()
  27225. errlog := &models.HisOrderError{
  27226. UserOrgId: adminUser.CurrentOrgId,
  27227. Ctime: time.Now().Unix(),
  27228. Mtime: time.Now().Unix(),
  27229. ErrMsg: res.ErrMsg,
  27230. Status: 1,
  27231. PatientId: id,
  27232. RecordTime: recordDateTime,
  27233. Stage: 4,
  27234. }
  27235. service.CreateErrMsgLog(errlog)
  27236. c.ServeSuccessJSON(map[string]interface{}{
  27237. "failed_code": -10,
  27238. "msg": res.ErrMsg,
  27239. })
  27240. return
  27241. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  27242. //return
  27243. }
  27244. }
  27245. }
  27246. } else if tempOrder.ID > 0 {
  27247. if tempOrder.IsPre == 1 {
  27248. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  27249. var rf []*ResultFive
  27250. json.Unmarshal([]byte(his.Iinfo), &rf)
  27251. chrg_bchno := tempOrder.Number
  27252. cert_no := his.Certno
  27253. var insutypes []string
  27254. var insutype string
  27255. var is390 int = 0
  27256. var is310 int = 0
  27257. for _, item := range rf {
  27258. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27259. insutypes = append(insutypes, item.Insutype)
  27260. }
  27261. }
  27262. if len(insutypes) == 1 {
  27263. insutype = insutypes[0]
  27264. } else {
  27265. for _, i := range insutypes {
  27266. if i == "390" {
  27267. is390 = 1
  27268. }
  27269. if i == "310" {
  27270. is310 = 1
  27271. }
  27272. }
  27273. }
  27274. if is390 == 1 {
  27275. insutype = "390"
  27276. }
  27277. if is310 == 1 {
  27278. insutype = "310"
  27279. }
  27280. if len(insutypes) == 0 {
  27281. insutype = "310"
  27282. }
  27283. if len(insutypes) == 2 {
  27284. insutype = strconv.FormatInt(his.SocialType, 10)
  27285. }
  27286. //insutype = "390"
  27287. if his.IdCardType == 1 {
  27288. // cert_no = his.MedicalInsuranceNumber
  27289. cert_no = his.Certno
  27290. } else {
  27291. cert_no = his.Certno
  27292. }
  27293. var res ResultSeven
  27294. var ahres ResultSevenAH
  27295. var resSeven10265 ResultSeven10265
  27296. var gzresSeven10265Two GZResultSeven10265Two
  27297. var src_resquest string
  27298. var result2 string
  27299. if miConfig.MdtrtareaAdmvs == "450721" {
  27300. res2 := c.GetoleInfo()
  27301. if res2.Infcode == 0 {
  27302. var result string
  27303. var request_log string
  27304. var result_log string
  27305. if res2.Output.MdtrtCertType == "02" {
  27306. 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)
  27307. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27308. } else if res2.Output.MdtrtCertType == "01" {
  27309. 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)
  27310. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27311. } else {
  27312. 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)
  27313. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27314. }
  27315. var dat map[string]interface{}
  27316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27317. fmt.Println(dat)
  27318. } else {
  27319. fmt.Println(err)
  27320. }
  27321. userJSONBytes, _ := json.Marshal(dat)
  27322. var res5 ResultTwo
  27323. //var resTwo10265 ResultTwo10265
  27324. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27325. utils.ErrorLog("解析失败:%v", err)
  27326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27327. return
  27328. }
  27329. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  27330. if res5.Infcode == -1 {
  27331. c.ServeSuccessJSON(map[string]interface{}{
  27332. "failed_code": -10,
  27333. "msg": res5.ErrMsg,
  27334. })
  27335. return
  27336. }
  27337. var insutypes []string
  27338. var insutype string
  27339. var is390 int = 0
  27340. var is310 int = 0
  27341. for _, item := range res5.Output.Iinfo {
  27342. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27343. insutypes = append(insutypes, item.Insutype)
  27344. }
  27345. }
  27346. if len(insutypes) == 1 {
  27347. insutype = insutypes[0]
  27348. } else {
  27349. for _, i := range insutypes {
  27350. if i == "390" {
  27351. is390 = 1
  27352. }
  27353. if i == "310" {
  27354. is310 = 1
  27355. }
  27356. }
  27357. }
  27358. if is390 == 1 {
  27359. insutype = "390"
  27360. }
  27361. if is310 == 1 {
  27362. insutype = "310"
  27363. }
  27364. if len(insutypes) == 0 {
  27365. insutype = "310"
  27366. }
  27367. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27368. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27369. infoStr := string(Iinfos)
  27370. idetinfoStr := string(Idetinfos)
  27371. psn := &models.HisPsn{
  27372. PsnNo: res5.Output.Baseinfo.PsnNo,
  27373. PatientId: id,
  27374. Certno: res5.Output.Baseinfo.Certno,
  27375. Gend: res5.Output.Baseinfo.Gend,
  27376. Naty: res5.Output.Baseinfo.Naty,
  27377. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27378. PsnName: res5.Output.Baseinfo.PsnName,
  27379. Idetinfo: idetinfoStr,
  27380. Insuinfo: infoStr,
  27381. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27383. VerifyNumber: res2.Output.EcToken,
  27384. }
  27385. service.CreateHisPsn(psn)
  27386. if res2.Output.MdtrtCertType == "01" {
  27387. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27388. token := res2.Output.EcToken
  27389. 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)
  27390. } else if res2.Output.MdtrtCertType == "02" {
  27391. 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)
  27392. } else {
  27393. 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)
  27394. }
  27395. var dat2 map[string]interface{}
  27396. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27397. fmt.Println(dat2)
  27398. } else {
  27399. fmt.Println(err)
  27400. }
  27401. userJSONBytes3, _ := json.Marshal(dat2)
  27402. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27403. utils.ErrorLog("解析失败:%v", err)
  27404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27405. return
  27406. }
  27407. saveLog(result2, src_resquest, "2207", "结算")
  27408. } else {
  27409. c.ServeSuccessJSON(map[string]interface{}{
  27410. "failed_code": -10,
  27411. "msg": res2.ErrMsg,
  27412. })
  27413. return
  27414. }
  27415. } else if miConfig.MdtrtareaAdmvs == "421300" {
  27416. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27417. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27418. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27419. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27420. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27421. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27422. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27423. resp, requestErr := http.Get(api)
  27424. if requestErr != nil {
  27425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27426. return
  27427. }
  27428. body, ioErr := ioutil.ReadAll(resp.Body)
  27429. if ioErr != nil {
  27430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27432. return
  27433. }
  27434. var respJSON map[string]interface{}
  27435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27438. return
  27439. }
  27440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27441. result, _ := json.Marshal(respJSON)
  27442. fmt.Println("log")
  27443. fmt.Println(string(result))
  27444. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27445. utils.ErrorLog("解析失败:%v", err)
  27446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27447. return
  27448. }
  27449. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27450. if reg_type == 11 && his.Insutype == "390" {
  27451. reg_type = 110104
  27452. }
  27453. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27454. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27455. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27456. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27457. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27458. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27459. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27460. resp, requestErr := http.Get(api)
  27461. if requestErr != nil {
  27462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27463. return
  27464. }
  27465. body, ioErr := ioutil.ReadAll(resp.Body)
  27466. if ioErr != nil {
  27467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27469. return
  27470. }
  27471. var respJSON map[string]interface{}
  27472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27475. return
  27476. }
  27477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27478. result, _ := json.Marshal(respJSON)
  27479. fmt.Println("log")
  27480. fmt.Println(string(result))
  27481. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27482. utils.ErrorLog("解析失败:%v", err)
  27483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27484. return
  27485. }
  27486. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27487. if reg_type == 11 && his.Insutype == "390" {
  27488. reg_type = 110104
  27489. }
  27490. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27491. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27492. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27493. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27494. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27495. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27496. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27497. resp, requestErr := http.Get(api)
  27498. if requestErr != nil {
  27499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27500. return
  27501. }
  27502. body, ioErr := ioutil.ReadAll(resp.Body)
  27503. if ioErr != nil {
  27504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27506. return
  27507. }
  27508. var respJSON map[string]interface{}
  27509. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27512. return
  27513. }
  27514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27515. result, _ := json.Marshal(respJSON)
  27516. fmt.Println("log")
  27517. fmt.Println(string(result))
  27518. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27519. utils.ErrorLog("解析失败:%v", err)
  27520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27521. return
  27522. }
  27523. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27524. if reg_type == 11 && his.Insutype == "390" {
  27525. reg_type = 110104
  27526. }
  27527. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27528. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27529. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27530. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27531. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27532. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27533. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27534. resp, requestErr := http.Get(api)
  27535. if requestErr != nil {
  27536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27537. return
  27538. }
  27539. body, ioErr := ioutil.ReadAll(resp.Body)
  27540. if ioErr != nil {
  27541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27543. return
  27544. }
  27545. var respJSON map[string]interface{}
  27546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27549. return
  27550. }
  27551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27552. result, _ := json.Marshal(respJSON)
  27553. fmt.Println("log")
  27554. fmt.Println(string(result))
  27555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27556. utils.ErrorLog("解析失败:%v", err)
  27557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27558. return
  27559. }
  27560. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27561. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27562. if result3101.Infcode == "0" {
  27563. if len(result3101.Output.Result) > 0 {
  27564. var errMsgs []string
  27565. for _, item := range result3101.Output.Result {
  27566. errMsgs = append(errMsgs, item.VolaCont)
  27567. }
  27568. c.ServeSuccessJSON(map[string]interface{}{
  27569. "failed_code": -10,
  27570. "msg": errMsgs,
  27571. })
  27572. return
  27573. } else {
  27574. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27575. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27576. bas := strings.Split(psn_info.CardInfo, "|")
  27577. if his.IdCardType == 1 {
  27578. cert_no = bas[2]
  27579. } else if his.IdCardType == 3 {
  27580. cert_no = his.Certno
  27581. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27582. } else if his.IdCardType == 4 {
  27583. cert_no = his.Certno
  27584. psn_info.VerifyNumber = psn_info.VerifyNumber
  27585. }
  27586. //江苏地区国家医保医疗类别
  27587. //职工透析:医疗类别选特殊情况门诊9933
  27588. //居民血透门慢: 医疗类别选门诊慢病1402
  27589. //var med_type string
  27590. //if his.Insutype == "310" {
  27591. // if reg_type == 14 {
  27592. // med_type = "9933"
  27593. // } else if reg_type == 11 {
  27594. // med_type = "11"
  27595. //
  27596. // }
  27597. //} else if his.Insutype == "390" {
  27598. // if reg_type == 14 {
  27599. // med_type = "1402"
  27600. // } else if reg_type == 11 {
  27601. // med_type = "11"
  27602. // }
  27603. //}
  27604. var api string
  27605. if miConfig.MdtrtareaAdmvs == "320921" {
  27606. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27607. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27608. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27609. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27610. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27611. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27612. "&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
  27613. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27614. } else {
  27615. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27616. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27617. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27618. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27620. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27621. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27622. "&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
  27623. }
  27624. resp, requestErr := http.Get(api)
  27625. if requestErr != nil {
  27626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27627. return
  27628. }
  27629. body, ioErr := ioutil.ReadAll(resp.Body)
  27630. if ioErr != nil {
  27631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27633. return
  27634. }
  27635. var respJSON map[string]interface{}
  27636. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27639. return
  27640. }
  27641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27642. result, _ := json.Marshal(respJSON)
  27643. fmt.Println("log")
  27644. fmt.Println(string(result))
  27645. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27646. utils.ErrorLog("解析失败:%v", err)
  27647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27648. return
  27649. }
  27650. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27651. res.Output = resSeven10265.Output
  27652. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27653. res.ErrMsg = resSeven10265.ErrMsg
  27654. res.Cainfo = resSeven10265.Cainfo
  27655. res.WarnMsg = resSeven10265.WarnMsg
  27656. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27657. res.Infcode = infocode
  27658. }
  27659. }
  27660. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27661. psn_info, _ := service.GetPsnByPatientId(id)
  27662. var verify_number string
  27663. if psn_info.IdCardType == 4 {
  27664. verify_number = psn_info.VerifyNumber
  27665. } else if psn_info.IdCardType == 1 {
  27666. bas := strings.Split(psn_info.CardInfo, "|")
  27667. cardNumber := bas[2]
  27668. verify_number = cardNumber
  27669. } else {
  27670. verify_number = psn_info.Certno
  27671. psn_info.IdCardType = 2
  27672. }
  27673. var api string
  27674. new_chrg_bchno := chrg_bchno
  27675. if adminUser.CurrentOrgId == 10265 {
  27676. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27677. new_chrg_bchno = "0000"
  27678. }
  27679. }
  27680. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27681. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27682. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27684. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27685. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27686. "&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
  27687. resp, requestErr := http.Get(api)
  27688. if requestErr != nil {
  27689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27690. return
  27691. }
  27692. body, ioErr := ioutil.ReadAll(resp.Body)
  27693. if ioErr != nil {
  27694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27696. return
  27697. }
  27698. var respJSON map[string]interface{}
  27699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27702. return
  27703. }
  27704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27705. result, _ := json.Marshal(respJSON)
  27706. fmt.Println("log")
  27707. fmt.Println(string(result))
  27708. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27709. utils.ErrorLog("解析失败:%v", err)
  27710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27711. return
  27712. }
  27713. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27714. res.Output = resSeven10265.Output
  27715. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27716. res.ErrMsg = resSeven10265.ErrMsg
  27717. res.Cainfo = resSeven10265.Cainfo
  27718. res.WarnMsg = resSeven10265.WarnMsg
  27719. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27720. res.Infcode = infocode
  27721. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27722. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27723. var cert_no string
  27724. if his.IdCardType == 1 {
  27725. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27726. } else {
  27727. cert_no = psn_info.VerifyNumber
  27728. }
  27729. 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)
  27730. var dat map[string]interface{}
  27731. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27732. fmt.Println(dat)
  27733. } else {
  27734. fmt.Println(err)
  27735. }
  27736. saveLog(result2, src_resquest, "2207", "结算")
  27737. userJSONBytes, _ := json.Marshal(dat)
  27738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27739. utils.ErrorLog("解析失败:%v", err)
  27740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27741. return
  27742. }
  27743. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27744. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27745. var cert_no string
  27746. var card_sn string
  27747. if his.IdCardType == 1 {
  27748. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27749. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27750. bas := strings.Split(psn_info.CardInfo, "|")
  27751. card_sn = bas[3]
  27752. } else if his.IdCardType == 2 {
  27753. cert_no = his.IdCardNo
  27754. } else {
  27755. cert_no = psn_info.VerifyNumber
  27756. }
  27757. var rf []*ResultFive
  27758. json.Unmarshal([]byte(his.Iinfo), &rf)
  27759. var psn_type string
  27760. for _, item := range rf {
  27761. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27762. psn_type = item.PsnType
  27763. }
  27764. }
  27765. 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)
  27766. var dat map[string]interface{}
  27767. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27768. fmt.Println(dat)
  27769. } else {
  27770. fmt.Println(err)
  27771. }
  27772. saveLog(result2, src_resquest, "2207", "结算")
  27773. userJSONBytes, _ := json.Marshal(dat)
  27774. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27775. utils.ErrorLog("解析失败:%v", err)
  27776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27777. return
  27778. }
  27779. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27780. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27781. var cert_no string
  27782. var card_sn string
  27783. if his.IdCardType == 1 {
  27784. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27785. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27786. //bas := strings.Split(psn_info.CardInfo, "|")
  27787. card_sn = ""
  27788. } else if his.IdCardType == 2 {
  27789. cert_no = his.IdCardNo
  27790. } else {
  27791. cert_no = psn_info.VerifyNumber
  27792. }
  27793. var rf []*ResultFive
  27794. json.Unmarshal([]byte(his.Iinfo), &rf)
  27795. var psn_type string
  27796. for _, item := range rf {
  27797. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27798. psn_type = item.PsnType
  27799. }
  27800. }
  27801. 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)
  27802. var dat map[string]interface{}
  27803. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27804. fmt.Println(dat)
  27805. } else {
  27806. fmt.Println(err)
  27807. }
  27808. saveLog(result2, src_resquest, "2207", "结算")
  27809. userJSONBytes, _ := json.Marshal(dat)
  27810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27811. utils.ErrorLog("解析失败:%v", err)
  27812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27813. return
  27814. }
  27815. } else if miConfig.MdtrtareaAdmvs == "360100" {
  27816. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27817. var cert_no string
  27818. var card_sn string
  27819. if his.IdCardType == 1 {
  27820. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27821. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27822. //bas := strings.Split(psn_info.CardInfo, "|")
  27823. card_sn = ""
  27824. } else if his.IdCardType == 2 {
  27825. cert_no = his.IdCardNo
  27826. } else {
  27827. cert_no = psn_info.VerifyNumber
  27828. }
  27829. var rf []*ResultFive
  27830. json.Unmarshal([]byte(his.Iinfo), &rf)
  27831. var psn_type string
  27832. for _, item := range rf {
  27833. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27834. psn_type = item.PsnType
  27835. }
  27836. }
  27837. 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)
  27838. var dat map[string]interface{}
  27839. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27840. fmt.Println(dat)
  27841. } else {
  27842. fmt.Println(err)
  27843. }
  27844. saveLog(result2, src_resquest, "2207", "结算")
  27845. userJSONBytes, _ := json.Marshal(dat)
  27846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27847. utils.ErrorLog("解析失败:%v", err)
  27848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27849. return
  27850. }
  27851. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27852. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27853. if his.IdCardType == 1 {
  27854. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27855. bas := strings.Split(psn_info.CardInfo, "|")
  27856. cert_no = bas[2]
  27857. } else if his.IdCardType == 3 {
  27858. cert_no = his.Certno
  27859. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27860. } else if his.IdCardType == 4 {
  27861. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27862. cert_no = psn_info.VerifyNumber
  27863. psn_info.VerifyNumber = psn_info.VerifyNumber
  27864. } else {
  27865. cert_no = his.Certno
  27866. psn_info.VerifyNumber = his.Certno
  27867. }
  27868. var api string
  27869. var med_type string
  27870. if his.Insutype == "390" {
  27871. if reg_type == 992102 {
  27872. med_type = "992102"
  27873. }
  27874. if reg_type == 140104 {
  27875. med_type = "140104"
  27876. }
  27877. if reg_type == 140201 {
  27878. med_type = "140201"
  27879. }
  27880. if reg_type == 14 {
  27881. med_type = "14"
  27882. }
  27883. } else if his.Insutype == "310" {
  27884. if reg_type == 992102 {
  27885. med_type = "992102"
  27886. }
  27887. if reg_type == 140104 {
  27888. med_type = "140104"
  27889. }
  27890. if reg_type == 140201 {
  27891. med_type = "140201"
  27892. }
  27893. if reg_type == 14 {
  27894. med_type = "14"
  27895. }
  27896. }
  27897. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27898. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27899. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27901. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27902. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27903. "&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
  27904. resp, requestErr := http.Get(api)
  27905. if requestErr != nil {
  27906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27907. return
  27908. }
  27909. body, ioErr := ioutil.ReadAll(resp.Body)
  27910. if ioErr != nil {
  27911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27913. return
  27914. }
  27915. var respJSON map[string]interface{}
  27916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27919. return
  27920. }
  27921. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27922. if status == "0" {
  27923. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27924. c.ServeSuccessJSON(map[string]interface{}{
  27925. "failed_code": -10,
  27926. "msg": err_msg,
  27927. })
  27928. return
  27929. }
  27930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27931. result, _ := json.Marshal(respJSON)
  27932. fmt.Println("log")
  27933. fmt.Println(string(result))
  27934. if err := json.Unmarshal(result, &ahres); err != nil {
  27935. utils.ErrorLog("解析失败:%v", err)
  27936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27937. return
  27938. }
  27939. res.InfRefmsgid = ahres.InfRefmsgid
  27940. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27941. // 创建对应的Time类型
  27942. t := time.UnixMilli(timestamp)
  27943. // 格式化成指定的日期字符串
  27944. str := t.Format("2006-01-02 15:04:05")
  27945. res.Output.Setlinfo.SetlTime = str
  27946. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27947. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27948. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27949. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27950. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27951. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27952. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27953. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27954. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27955. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27956. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27957. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27958. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27959. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27960. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27961. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27962. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27963. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27964. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27965. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27966. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27967. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27968. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27969. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27970. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27971. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27972. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27973. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27974. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27975. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27976. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27977. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27978. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27979. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27980. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27981. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27982. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27983. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27984. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27985. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27986. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27987. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27988. res.Output.Setldetail = ahres.Output.Setldetail
  27989. res.ErrMsg = ahres.ErrMsg
  27990. res.Cainfo = ahres.Cainfo
  27991. res.WarnMsg = ahres.WarnMsg
  27992. res.Infcode = ahres.Infcode
  27993. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27994. res.Output.Setlinfo.ClrType = "11"
  27995. } else {
  27996. res.Output.Setlinfo.ClrType = "9903"
  27997. }
  27998. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27999. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28000. if his.IdCardType == 1 {
  28001. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28002. bas := strings.Split(psn_info.CardInfo, "|")
  28003. cert_no = bas[2]
  28004. } else if his.IdCardType == 3 {
  28005. cert_no = his.Certno
  28006. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28007. } else if his.IdCardType == 4 {
  28008. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28009. cert_no = his.Certno
  28010. psn_info.VerifyNumber = psn_info.VerifyNumber
  28011. } else {
  28012. cert_no = his.Certno
  28013. psn_info.VerifyNumber = his.Certno
  28014. }
  28015. var api string
  28016. var med_type string
  28017. if his.Insutype == "390" {
  28018. if reg_type == 992102 {
  28019. med_type = "992102"
  28020. }
  28021. if reg_type == 140104 {
  28022. med_type = "140104"
  28023. }
  28024. if reg_type == 14 {
  28025. med_type = "14"
  28026. }
  28027. if reg_type == 140201 {
  28028. med_type = "140201"
  28029. }
  28030. } else if his.Insutype == "310" {
  28031. if reg_type == 992102 {
  28032. med_type = "992102"
  28033. }
  28034. if reg_type == 14 {
  28035. med_type = "14"
  28036. }
  28037. if reg_type == 140104 {
  28038. med_type = "140104"
  28039. }
  28040. if reg_type == 140201 {
  28041. med_type = "140201"
  28042. }
  28043. }
  28044. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28045. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28046. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28048. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28049. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28050. "&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
  28051. resp, requestErr := http.Get(api)
  28052. if requestErr != nil {
  28053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28054. return
  28055. }
  28056. body, ioErr := ioutil.ReadAll(resp.Body)
  28057. if ioErr != nil {
  28058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28060. return
  28061. }
  28062. var respJSON map[string]interface{}
  28063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28066. return
  28067. }
  28068. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28069. if status == "0" {
  28070. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28071. c.ServeSuccessJSON(map[string]interface{}{
  28072. "failed_code": -10,
  28073. "msg": err_msg,
  28074. })
  28075. return
  28076. }
  28077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28078. result, _ := json.Marshal(respJSON)
  28079. fmt.Println("log")
  28080. fmt.Println(string(result))
  28081. if err := json.Unmarshal(result, &ahres); err != nil {
  28082. utils.ErrorLog("解析失败:%v", err)
  28083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28084. return
  28085. }
  28086. res.InfRefmsgid = ahres.InfRefmsgid
  28087. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28088. // 创建对应的Time类型
  28089. t := time.UnixMilli(timestamp)
  28090. // 格式化成指定的日期字符串
  28091. str := t.Format("2006-01-02 15:04:05")
  28092. res.Output.Setlinfo.SetlTime = str
  28093. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28094. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28095. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28096. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28097. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28098. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28099. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28100. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28101. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28102. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28103. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28104. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28105. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28106. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28107. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28108. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28109. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28110. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28111. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28112. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28113. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28114. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28115. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28116. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28117. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28118. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28119. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28120. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28121. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28122. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28123. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28124. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28125. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28126. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28127. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28128. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28129. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28130. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28131. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28132. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28133. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28134. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28135. res.Output.Setldetail = ahres.Output.Setldetail
  28136. res.ErrMsg = ahres.ErrMsg
  28137. res.Cainfo = ahres.Cainfo
  28138. res.WarnMsg = ahres.WarnMsg
  28139. res.Infcode = ahres.Infcode
  28140. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28141. res.Output.Setlinfo.ClrType = "11"
  28142. } else {
  28143. res.Output.Setlinfo.ClrType = "9903"
  28144. }
  28145. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28146. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28147. var cert_no string
  28148. if his.IdCardType == 1 {
  28149. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28150. } else if his.IdCardType == 2 {
  28151. cert_no = his.IdCardNo
  28152. } else {
  28153. cert_no = psn_info.VerifyNumber
  28154. }
  28155. 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, "")
  28156. var dat map[string]interface{}
  28157. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28158. fmt.Println(dat)
  28159. } else {
  28160. fmt.Println(err)
  28161. }
  28162. saveLog(result2, src_resquest, "2207", "结算")
  28163. userJSONBytes, _ := json.Marshal(dat)
  28164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28165. utils.ErrorLog("解析失败:%v", err)
  28166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28167. return
  28168. }
  28169. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28170. psn_info, _ := service.GetPsnByPatientId(id)
  28171. var verify_number string
  28172. if psn_info.IdCardType == 4 {
  28173. verify_number = psn_info.VerifyNumber
  28174. } else if psn_info.IdCardType == 1 {
  28175. bas := strings.Split(psn_info.CardInfo, "|")
  28176. cardNumber := bas[2]
  28177. verify_number = cardNumber
  28178. } else {
  28179. verify_number = psn_info.Certno
  28180. psn_info.IdCardType = 2
  28181. }
  28182. var api string
  28183. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28184. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28185. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28186. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28187. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28188. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28189. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  28190. resp, requestErr := http.Get(api)
  28191. if requestErr != nil {
  28192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28193. return
  28194. }
  28195. body, ioErr := ioutil.ReadAll(resp.Body)
  28196. if ioErr != nil {
  28197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28199. return
  28200. }
  28201. var respJSON map[string]interface{}
  28202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28205. return
  28206. }
  28207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28208. result, _ := json.Marshal(respJSON)
  28209. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28210. utils.ErrorLog("解析失败:%v", err)
  28211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28212. return
  28213. }
  28214. } else {
  28215. var src_resquest string
  28216. if miConfig.Code == "H15049901371" {
  28217. //赤峰地区国家医保医疗类别
  28218. //职工透析:医疗类别选特殊情况门诊990502
  28219. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28220. var med_type string
  28221. if his.Insutype == "390" {
  28222. if reg_type == 14 {
  28223. med_type = "9933"
  28224. } else if reg_type == 11 {
  28225. med_type = "11"
  28226. }
  28227. } else if his.Insutype == "310" {
  28228. if reg_type == 14 {
  28229. med_type = "990502"
  28230. } else if reg_type == 11 {
  28231. med_type = "11"
  28232. }
  28233. }
  28234. 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)
  28235. } else {
  28236. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  28237. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28238. if result3101.Infcode == 0 {
  28239. if len(result3101.Output.Result) > 0 {
  28240. c.ServeSuccessJSON(map[string]interface{}{
  28241. "failed_code": -10,
  28242. "failed_type": 100,
  28243. "warm_type": 2,
  28244. "msg": result3101.Output.Result,
  28245. })
  28246. return
  28247. }
  28248. } else {
  28249. c.ServeSuccessJSON(map[string]interface{}{
  28250. "failed_code": -10,
  28251. "msg": result3101.ErrMsg,
  28252. })
  28253. return
  28254. }
  28255. }
  28256. if his.IdCardType == 4 {
  28257. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28258. token := psn_info.VerifyNumber
  28259. 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)
  28260. } else {
  28261. 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)
  28262. }
  28263. }
  28264. var dat map[string]interface{}
  28265. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28266. fmt.Println(dat)
  28267. } else {
  28268. fmt.Println(err)
  28269. }
  28270. saveLog(result2, src_resquest, "2207", "结算")
  28271. userJSONBytes, _ := json.Marshal(dat)
  28272. if miConfig.Code == "H15049901371" {
  28273. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28274. utils.ErrorLog("解析失败:%v", err)
  28275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28276. return
  28277. }
  28278. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28279. res.Output = resSeven10265.Output
  28280. res.ErrMsg = resSeven10265.ErrMsg
  28281. res.Cainfo = resSeven10265.Cainfo
  28282. res.WarnMsg = resSeven10265.WarnMsg
  28283. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28284. res.Infcode = infocode
  28285. } else {
  28286. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28287. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28288. utils.ErrorLog("解析失败:%v", err)
  28289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28290. return
  28291. }
  28292. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28293. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28294. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28295. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28296. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28297. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28298. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28299. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28300. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28301. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28302. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28303. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28304. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28305. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28306. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28307. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28308. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28309. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28310. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28311. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28312. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28313. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28314. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28315. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28316. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28317. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28318. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28319. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28320. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28321. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28322. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28323. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28324. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28325. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28326. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28327. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28328. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28329. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28330. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28331. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28332. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28333. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28334. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28335. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28336. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28337. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28338. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28339. res.Cainfo = gzresSeven10265Two.Cainfo
  28340. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28341. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28342. //res.Infcode = infocode
  28343. } else {
  28344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28345. utils.ErrorLog("解析失败:%v", err)
  28346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28347. return
  28348. }
  28349. }
  28350. }
  28351. }
  28352. if res.Infcode == -1 {
  28353. errlog := &models.HisOrderError{
  28354. UserOrgId: adminUser.CurrentOrgId,
  28355. Ctime: time.Now().Unix(),
  28356. Mtime: time.Now().Unix(),
  28357. Number: chrg_bchno,
  28358. ErrMsg: res.ErrMsg,
  28359. Status: 1,
  28360. PatientId: id,
  28361. RecordTime: recordDateTime,
  28362. Stage: 6,
  28363. }
  28364. service.CreateErrMsgLog(errlog)
  28365. c.ServeSuccessJSON(map[string]interface{}{
  28366. "failed_code": -10,
  28367. "msg": res.ErrMsg,
  28368. })
  28369. return
  28370. } else {
  28371. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28372. order.OrderStatus = 2
  28373. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28374. order.SetlId = res.Output.Setlinfo.SetlID
  28375. order.PsnNo = res.Output.Setlinfo.PsnNo
  28376. order.PsnName = res.Output.Setlinfo.PsnName
  28377. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28378. order.Certno = res.Output.Setlinfo.Certno
  28379. order.Gend = res.Output.Setlinfo.Gend
  28380. order.Naty = res.Output.Setlinfo.Naty
  28381. order.Age = res.Output.Setlinfo.Age
  28382. order.Insutype = res.Output.Setlinfo.Insutype
  28383. order.PsnType = res.Output.Setlinfo.PsnType
  28384. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28385. order.SetlTime = res.Output.Setlinfo.SetlTime
  28386. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28387. order.PayWays = pay_ways
  28388. order.AcctUsedFlag = acct_used_flag
  28389. order.WechatPay = wechat_pay
  28390. order.AliPay = ali_pay
  28391. order.JifenPay = jifen_pay
  28392. order.BandCardPay = band_card_pay
  28393. order.CashPay = cash_pay
  28394. order.OthDesc = oth_desc
  28395. //order.MedType = res.Output.Setlinfo.MedType
  28396. if reg_type == 1112 {
  28397. order.MedType = "1112"
  28398. }
  28399. if reg_type == 1111 {
  28400. order.MedType = "1111"
  28401. }
  28402. order.ClrType = res.Output.Setlinfo.ClrType
  28403. if adminUser.CurrentOrgId == 10480 {
  28404. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28405. order.ClrType = "11"
  28406. } else {
  28407. order.ClrType = "9903"
  28408. }
  28409. }
  28410. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28411. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28412. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28413. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28414. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28415. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28416. order.HifpPay = res.Output.Setlinfo.HifpPay
  28417. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28418. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28419. order.HifesPay = res.Output.Setlinfo.HifesPay
  28420. order.HifobPay = res.Output.Setlinfo.HifobPay
  28421. order.MafPay = res.Output.Setlinfo.MafPay
  28422. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28423. order.OthPay = res.Output.Setlinfo.OthPay
  28424. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28425. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28426. order.AcctPay = res.Output.Setlinfo.AcctPay
  28427. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28428. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28429. order.Balc = res.Output.Setlinfo.Balc
  28430. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28431. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28432. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28433. order.ClrWay = res.Output.Setlinfo.ClrWay
  28434. order.Creator = order.Creator
  28435. order.Modify = roles.AdminUserId
  28436. order.RequestLog = src_resquest
  28437. order.Diagnosis = diagnosis_id
  28438. order.FaPiaoNumber = fapiao_number
  28439. order.FaPiaoCode = fapiao_code
  28440. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28441. detailStr := string(setlDetail)
  28442. order.SetlDetail = detailStr
  28443. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28444. err = service.UpDateOrder(order)
  28445. if err == nil {
  28446. //判断是否使用了押金
  28447. if dec_way == "true" {
  28448. tmpstring := strconv.FormatInt(order.ID, 10)
  28449. //扣押金
  28450. order.Decimal = decimal
  28451. service.UpDateOrder(order)
  28452. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28453. if errmsg != nil {
  28454. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28455. return
  28456. }
  28457. }
  28458. c.ServeSuccessJSON(map[string]interface{}{
  28459. "msg": "结算成功",
  28460. })
  28461. } else {
  28462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28463. return
  28464. }
  28465. }
  28466. }
  28467. }
  28468. }
  28469. // 上传明细-预结算-
  28470. func (c *HisApiController) GetPreUploadInfo() {
  28471. id, _ := c.GetInt64("id")
  28472. record_time := c.GetString("record_time")
  28473. his_patient_id, _ := c.GetInt64("his_patient_id")
  28474. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  28475. admin_user_id, _ := c.GetInt64("admin_user_id")
  28476. diagnosis_id := c.GetString("diagnosis")
  28477. sick_type, _ := c.GetInt64("sick_type")
  28478. reg_type, _ := c.GetInt64("p_type")
  28479. begin_time := c.GetString("begin_time")
  28480. acct_used_flag := c.GetString("acct_used_flag")
  28481. id_str := c.GetString("ids")
  28482. ids_arr := strings.Split(id_str, ",")
  28483. timeLayout := "2006-01-02"
  28484. loc, _ := time.LoadLocation("Local")
  28485. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28486. if err != nil {
  28487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28488. return
  28489. }
  28490. recordDateTime := theTime.Unix()
  28491. adminUser := c.GetAdminUserInfo()
  28492. diagnosis_ids := strings.Split(diagnosis_id, ",")
  28493. var config []*models.HisXtDiagnoseConfig
  28494. for _, item := range diagnosis_ids {
  28495. id, _ := strconv.ParseInt(item, 10, 64)
  28496. if id > 0 {
  28497. diagnosisConfig, _ := service.FindDiagnoseById(id)
  28498. config = append(config, &diagnosisConfig)
  28499. }
  28500. }
  28501. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28502. sickConfig, _ := service.FindSickById(sick_type)
  28503. var prescriptions []*models.HisPrescription
  28504. var start_time int64
  28505. var end_time int64
  28506. var isSuccess bool = true
  28507. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28508. fmt.Println(his_patient_id)
  28509. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28510. timestamp := time.Now().Unix()
  28511. tempTime := time.Unix(timestamp, 0)
  28512. timeFormat := tempTime.Format("20060102150405")
  28513. chrgBchno := rand.Intn(100000) + 10000
  28514. new_chrg_bchno := ""
  28515. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  28516. new_chrg_bchno = chrg_bchno
  28517. if adminUser.CurrentOrgId == 10265 {
  28518. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28519. new_chrg_bchno = "0000"
  28520. }
  28521. }
  28522. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28523. var patientPrescription models.HisPrescriptionInfo
  28524. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28525. if patientPrescription.ID == 0 {
  28526. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  28527. }
  28528. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28529. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28530. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28531. strconv.FormatInt(his.PatientId, 10)
  28532. var res2406 Result2406
  28533. //安徽单病种处理
  28534. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  28535. data := make(map[string]interface{})
  28536. client := &http.Client{}
  28537. data["psn_no"] = his.PsnNo
  28538. data["mdtrt_id"] = his.Number
  28539. data["operator"] = roles.UserName
  28540. data["cert_no"] = his.IdCardNo
  28541. data["org_name"] = miConfig.OrgName
  28542. data["psn_name"] = his.Name
  28543. data["ipt_otp_no"] = his.IptOtpNo
  28544. data["ipt_psn_sp_flag_type"] = "0901"
  28545. data["ipt_psn_sp_flag"] = "1"
  28546. data["fixmedins_code"] = miConfig.Code
  28547. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28548. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28549. data["url"] = miConfig.Url
  28550. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28551. bytesData, _ := json.Marshal(data)
  28552. var req *http.Request
  28553. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28554. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28555. resp, _ := client.Do(req)
  28556. defer resp.Body.Close()
  28557. body, ioErr := ioutil.ReadAll(resp.Body)
  28558. if ioErr != nil {
  28559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28561. return
  28562. }
  28563. var respJSON map[string]interface{}
  28564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28567. return
  28568. }
  28569. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28570. if status == "0" {
  28571. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28572. c.ServeSuccessJSON(map[string]interface{}{
  28573. "failed_code": -10,
  28574. "msg": err_msg,
  28575. })
  28576. return
  28577. }
  28578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28579. userJSONBytes, _ := json.Marshal(respJSON)
  28580. fmt.Println("log")
  28581. fmt.Println(string(userJSONBytes))
  28582. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28583. utils.ErrorLog("解析失败:%v", err)
  28584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28585. return
  28586. }
  28587. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28588. data := make(map[string]interface{})
  28589. client := &http.Client{}
  28590. data["psn_no"] = his.PsnNo
  28591. data["mdtrt_id"] = his.Number
  28592. data["operator"] = roles.UserName
  28593. data["cert_no"] = his.IdCardNo
  28594. data["org_name"] = miConfig.OrgName
  28595. data["psn_name"] = his.Name
  28596. data["ipt_otp_no"] = his.IptOtpNo
  28597. data["ipt_psn_sp_flag_type"] = "0901"
  28598. data["ipt_psn_sp_flag"] = "1"
  28599. data["fixmedins_code"] = miConfig.Code
  28600. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28601. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28602. data["url"] = miConfig.Url
  28603. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28604. bytesData, _ := json.Marshal(data)
  28605. var req *http.Request
  28606. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28607. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28608. resp, _ := client.Do(req)
  28609. defer resp.Body.Close()
  28610. body, ioErr := ioutil.ReadAll(resp.Body)
  28611. if ioErr != nil {
  28612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28614. return
  28615. }
  28616. var respJSON map[string]interface{}
  28617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28620. return
  28621. }
  28622. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28623. if status == "0" {
  28624. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28625. c.ServeSuccessJSON(map[string]interface{}{
  28626. "failed_code": -10,
  28627. "msg": err_msg,
  28628. })
  28629. return
  28630. }
  28631. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28632. userJSONBytes, _ := json.Marshal(respJSON)
  28633. fmt.Println("log")
  28634. fmt.Println(string(userJSONBytes))
  28635. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28636. utils.ErrorLog("解析失败:%v", err)
  28637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28638. return
  28639. }
  28640. }
  28641. if res2406.Infcode != 0 {
  28642. adminUser := c.GetAdminUserInfo()
  28643. errlog := &models.HisOrderError{
  28644. UserOrgId: adminUser.CurrentOrgId,
  28645. Ctime: time.Now().Unix(),
  28646. Mtime: time.Now().Unix(),
  28647. ErrMsg: res2406.ErrMsg,
  28648. Status: 1,
  28649. PatientId: id,
  28650. RecordTime: recordDateTime,
  28651. Stage: 3,
  28652. }
  28653. service.CreateErrMsgLog(errlog)
  28654. c.ServeSuccessJSON(map[string]interface{}{
  28655. "failed_code": -10,
  28656. "msg": res2406.ErrMsg,
  28657. })
  28658. return
  28659. }
  28660. var res2 ResultSix
  28661. var res3 GZResultSix
  28662. var resSix10265 ResultSix10265
  28663. //var time_stamp string
  28664. if miConfig.MdtrtareaAdmvs == "421300" {
  28665. data := make(map[string]interface{})
  28666. client := &http.Client{}
  28667. data["psn_no"] = his.PsnNo
  28668. data["mdtrt_id"] = his.Number
  28669. data["department"] = department.Name
  28670. data["org_name"] = miConfig.OrgName
  28671. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28672. data["doctor_id"] = doctor_info.DoctorNumber
  28673. data["doctor_name"] = roles.UserName
  28674. data["fixmedins_code"] = miConfig.Code
  28675. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28676. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28677. data["secret_key"] = miConfig.SecretKey
  28678. data["sick_code"] = sickConfig.CountryCode
  28679. data["sick_name"] = sickConfig.ClassName
  28680. data["begin_time"] = begin_time
  28681. data["dept"] = strconv.FormatInt(department.ID, 10)
  28682. data["config"] = config
  28683. data["opter"] = roles.UserName
  28684. fmt.Println(data)
  28685. bytesData, _ := json.Marshal(data)
  28686. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28687. resp, _ := client.Do(req)
  28688. defer resp.Body.Close()
  28689. body, ioErr := ioutil.ReadAll(resp.Body)
  28690. if ioErr != nil {
  28691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28693. return
  28694. }
  28695. var respJSON map[string]interface{}
  28696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28699. return
  28700. }
  28701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28702. userJSONBytes, _ := json.Marshal(respJSON)
  28703. fmt.Println("log")
  28704. fmt.Println(string(userJSONBytes))
  28705. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28706. utils.ErrorLog("解析失败:%v", err)
  28707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28708. return
  28709. }
  28710. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28711. data := make(map[string]interface{})
  28712. client := &http.Client{}
  28713. data["psn_no"] = his.PsnNo
  28714. data["mdtrt_id"] = his.Number
  28715. data["department"] = department.Name
  28716. data["org_name"] = miConfig.OrgName
  28717. if reg_type == 11 && his.Insutype == "390" {
  28718. data["med_type"] = "110104"
  28719. } else {
  28720. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28721. }
  28722. data["doctor_id"] = doctor_info.DoctorNumber
  28723. data["doctor_name"] = roles.UserName
  28724. data["fixmedins_code"] = miConfig.Code
  28725. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28726. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28727. data["secret_key"] = miConfig.SecretKey
  28728. data["sick_code"] = sickConfig.CountryCode
  28729. data["sick_name"] = sickConfig.ClassName
  28730. data["begin_time"] = begin_time
  28731. data["dept"] = strconv.FormatInt(department.ID, 10)
  28732. data["config"] = config
  28733. data["opter"] = roles.UserName
  28734. fmt.Println(data)
  28735. bytesData, _ := json.Marshal(data)
  28736. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28737. resp, _ := client.Do(req)
  28738. defer resp.Body.Close()
  28739. body, ioErr := ioutil.ReadAll(resp.Body)
  28740. if ioErr != nil {
  28741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28743. return
  28744. }
  28745. var respJSON map[string]interface{}
  28746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28749. return
  28750. }
  28751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28752. userJSONBytes, _ := json.Marshal(respJSON)
  28753. fmt.Println("log")
  28754. fmt.Println(string(userJSONBytes))
  28755. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28756. utils.ErrorLog("解析失败:%v", err)
  28757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28758. return
  28759. }
  28760. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28761. data := make(map[string]interface{})
  28762. client := &http.Client{}
  28763. data["psn_no"] = his.PsnNo
  28764. data["mdtrt_id"] = his.Number
  28765. data["department"] = department.Name
  28766. data["org_name"] = miConfig.OrgName
  28767. if reg_type == 11 && his.Insutype == "390" {
  28768. data["med_type"] = "110104"
  28769. } else {
  28770. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28771. }
  28772. data["doctor_id"] = doctor_info.DoctorNumber
  28773. data["doctor_name"] = roles.UserName
  28774. data["fixmedins_code"] = miConfig.Code
  28775. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28776. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28777. data["secret_key"] = miConfig.SecretKey
  28778. data["sick_code"] = sickConfig.CountryCode
  28779. data["sick_name"] = sickConfig.ClassName
  28780. data["begin_time"] = begin_time
  28781. data["dept"] = strconv.FormatInt(department.ID, 10)
  28782. data["config"] = config
  28783. data["opter"] = roles.UserName
  28784. fmt.Println(data)
  28785. bytesData, _ := json.Marshal(data)
  28786. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28787. resp, _ := client.Do(req)
  28788. defer resp.Body.Close()
  28789. body, ioErr := ioutil.ReadAll(resp.Body)
  28790. if ioErr != nil {
  28791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28793. return
  28794. }
  28795. var respJSON map[string]interface{}
  28796. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28799. return
  28800. }
  28801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28802. userJSONBytes, _ := json.Marshal(respJSON)
  28803. fmt.Println("log")
  28804. fmt.Println(string(userJSONBytes))
  28805. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28806. utils.ErrorLog("解析失败:%v", err)
  28807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28808. return
  28809. }
  28810. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28811. data := make(map[string]interface{})
  28812. client := &http.Client{}
  28813. data["psn_no"] = his.PsnNo
  28814. data["mdtrt_id"] = his.Number
  28815. data["department"] = department.Name
  28816. data["org_name"] = miConfig.OrgName
  28817. if reg_type == 11 && his.Insutype == "390" {
  28818. data["med_type"] = "110104"
  28819. } else {
  28820. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28821. }
  28822. data["doctor_id"] = doctor_info.DoctorNumber
  28823. data["doctor_name"] = roles.UserName
  28824. data["fixmedins_code"] = miConfig.Code
  28825. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28826. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28827. data["secret_key"] = miConfig.SecretKey
  28828. data["sick_code"] = sickConfig.CountryCode
  28829. data["sick_name"] = sickConfig.ClassName
  28830. data["begin_time"] = begin_time
  28831. data["dept"] = strconv.FormatInt(department.ID, 10)
  28832. data["config"] = config
  28833. data["opter"] = roles.UserName
  28834. fmt.Println(data)
  28835. bytesData, _ := json.Marshal(data)
  28836. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28837. resp, _ := client.Do(req)
  28838. defer resp.Body.Close()
  28839. body, ioErr := ioutil.ReadAll(resp.Body)
  28840. if ioErr != nil {
  28841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28843. return
  28844. }
  28845. var respJSON map[string]interface{}
  28846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28849. return
  28850. }
  28851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28852. userJSONBytes, _ := json.Marshal(respJSON)
  28853. fmt.Println("log")
  28854. fmt.Println(string(userJSONBytes))
  28855. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28856. utils.ErrorLog("解析失败:%v", err)
  28857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28858. return
  28859. }
  28860. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28861. data := make(map[string]interface{})
  28862. client := &http.Client{}
  28863. data["psn_no"] = his.PsnNo
  28864. data["mdtrt_id"] = his.Number
  28865. data["doctor"] = roles.UserName
  28866. data["department"] = department.Name
  28867. data["org_name"] = miConfig.OrgName
  28868. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28869. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28870. data["fixmedins_code"] = miConfig.Code
  28871. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28872. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28873. data["secret_key"] = miConfig.SecretKey
  28874. data["sick_code"] = sickConfig.CountryCode
  28875. data["sick_name"] = sickConfig.ClassName
  28876. data["begin_time"] = begin_time
  28877. data["dept"] = strconv.FormatInt(department.ID, 10)
  28878. data["config"] = config
  28879. data["url"] = miConfig.Url
  28880. data["ak"] = miConfig.AccessKey
  28881. data["cainfo"] = miConfig.Cainfo
  28882. bytesData, _ := json.Marshal(data)
  28883. var req *http.Request
  28884. if miConfig.MdtrtareaAdmvs == "320921" {
  28885. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28886. } else {
  28887. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28888. }
  28889. resp, _ := client.Do(req)
  28890. defer resp.Body.Close()
  28891. body, ioErr := ioutil.ReadAll(resp.Body)
  28892. if ioErr != nil {
  28893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28895. return
  28896. }
  28897. var respJSON map[string]interface{}
  28898. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28901. return
  28902. }
  28903. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28904. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28905. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28907. userJSONBytes, _ := json.Marshal(respJSON)
  28908. fmt.Println("log")
  28909. fmt.Println(string(userJSONBytes))
  28910. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28911. utils.ErrorLog("解析失败:%v", err)
  28912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28913. return
  28914. }
  28915. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28916. res2.Output = resSix10265.Output
  28917. res2.ErrMsg = resSix10265.ErrMsg
  28918. res2.Cainfo = resSix10265.Cainfo
  28919. res2.WarnMsg = resSix10265.WarnMsg
  28920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28921. res2.Infcode = infocode
  28922. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28923. data := make(map[string]interface{})
  28924. client := &http.Client{}
  28925. data["psn_no"] = his.PsnNo
  28926. data["mdtrt_id"] = his.Number
  28927. data["doctor"] = roles.UserName
  28928. data["department"] = department.Name
  28929. data["org_name"] = miConfig.OrgName
  28930. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28931. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28932. data["fixmedins_code"] = miConfig.Code
  28933. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28934. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28935. data["secret_key"] = miConfig.SecretKey
  28936. data["sick_code"] = sickConfig.CountryCode
  28937. data["sick_name"] = sickConfig.ClassName
  28938. data["begin_time"] = begin_time
  28939. data["dept"] = strconv.FormatInt(department.ID, 10)
  28940. data["config"] = config
  28941. //data["url"] = miConfig.Url
  28942. //data["ak"] = miConfig.AccessKey
  28943. data["cainfo"] = miConfig.Cainfo
  28944. fmt.Println(data)
  28945. bytesData, _ := json.Marshal(data)
  28946. var req *http.Request
  28947. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28948. resp, _ := client.Do(req)
  28949. defer resp.Body.Close()
  28950. body, ioErr := ioutil.ReadAll(resp.Body)
  28951. if ioErr != nil {
  28952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28954. return
  28955. }
  28956. var respJSON map[string]interface{}
  28957. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28960. return
  28961. }
  28962. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28963. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28964. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28966. userJSONBytes, _ := json.Marshal(respJSON)
  28967. fmt.Println("log")
  28968. fmt.Println(string(userJSONBytes))
  28969. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28970. utils.ErrorLog("解析失败:%v", err)
  28971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28972. return
  28973. }
  28974. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28975. res2.Output = resSix10265.Output
  28976. res2.ErrMsg = resSix10265.ErrMsg
  28977. res2.Cainfo = resSix10265.Cainfo
  28978. res2.WarnMsg = resSix10265.WarnMsg
  28979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28980. res2.Infcode = infocode
  28981. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28982. 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)
  28983. saveLog(result, requestLog, "2203", "上传就诊信息")
  28984. var respJSON2 map[string]interface{}
  28985. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28988. return
  28989. }
  28990. userJSONBytes2, _ := json.Marshal(respJSON2)
  28991. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28992. utils.ErrorLog("解析失败:%v", err)
  28993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28994. return
  28995. }
  28996. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28997. var result string
  28998. var requestLog string
  28999. 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, "")
  29000. saveLog(result, requestLog, "2203", "上传就诊信息")
  29001. var respJSON2 map[string]interface{}
  29002. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29005. return
  29006. }
  29007. userJSONBytes2, _ := json.Marshal(respJSON2)
  29008. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29009. utils.ErrorLog("解析失败:%v", err)
  29010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29011. return
  29012. }
  29013. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29014. var result string
  29015. var requestLog string
  29016. 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, "")
  29017. saveLog(result, requestLog, "2203", "上传就诊信息")
  29018. var respJSON2 map[string]interface{}
  29019. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29022. return
  29023. }
  29024. userJSONBytes2, _ := json.Marshal(respJSON2)
  29025. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29026. utils.ErrorLog("解析失败:%v", err)
  29027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29028. return
  29029. }
  29030. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29031. var result string
  29032. var requestLog string
  29033. 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, "")
  29034. saveLog(result, requestLog, "2203", "上传就诊信息")
  29035. var respJSON2 map[string]interface{}
  29036. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29039. return
  29040. }
  29041. userJSONBytes2, _ := json.Marshal(respJSON2)
  29042. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29043. utils.ErrorLog("解析失败:%v", err)
  29044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29045. return
  29046. }
  29047. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29048. data := make(map[string]interface{})
  29049. client := &http.Client{}
  29050. data["psn_no"] = his.PsnNo
  29051. data["mdtrt_id"] = his.Number
  29052. data["operator"] = roles.UserName
  29053. data["department"] = department.Name
  29054. data["org_name"] = miConfig.OrgName
  29055. var med_type string
  29056. if his.Insutype == "390" {
  29057. if reg_type == 992102 {
  29058. med_type = "992102"
  29059. data["sick_code"] = "ZDZ940"
  29060. data["sick_name"] = "慢性肾衰竭"
  29061. }
  29062. if reg_type == 140104 {
  29063. med_type = "140104"
  29064. data["sick_code"] = sickConfig.CountryCode
  29065. data["sick_name"] = sickConfig.ClassName
  29066. }
  29067. if reg_type == 14 {
  29068. med_type = "140104"
  29069. data["sick_code"] = sickConfig.CountryCode
  29070. data["sick_name"] = sickConfig.ClassName
  29071. }
  29072. } else if his.Insutype == "310" {
  29073. if reg_type == 992102 {
  29074. med_type = "992102"
  29075. data["sick_code"] = "ZDZ940"
  29076. data["sick_name"] = "慢性肾衰竭"
  29077. }
  29078. if reg_type == 140104 {
  29079. med_type = "140104"
  29080. data["sick_code"] = sickConfig.CountryCode
  29081. data["sick_name"] = sickConfig.ClassName
  29082. }
  29083. if reg_type == 14 {
  29084. med_type = "14"
  29085. data["sick_code"] = sickConfig.CountryCode
  29086. data["sick_name"] = sickConfig.ClassName
  29087. }
  29088. }
  29089. data["med_type"] = med_type
  29090. data["doctor_number"] = doctor_info.DoctorNumber
  29091. data["doctor_name"] = doctor_info.UserName
  29092. data["fixmedins_code"] = miConfig.Code
  29093. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29094. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29095. data["secret_key"] = miConfig.SecretKey
  29096. data["begin_time"] = begin_time
  29097. data["dept"] = strconv.FormatInt(department.ID, 10)
  29098. data["config"] = config
  29099. data["url"] = miConfig.Url
  29100. data["ak"] = miConfig.AccessKey
  29101. data["cainfo"] = miConfig.Cainfo
  29102. bytesData, _ := json.Marshal(data)
  29103. var req *http.Request
  29104. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29105. resp, _ := client.Do(req)
  29106. defer resp.Body.Close()
  29107. body, ioErr := ioutil.ReadAll(resp.Body)
  29108. if ioErr != nil {
  29109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29111. return
  29112. }
  29113. var respJSON map[string]interface{}
  29114. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29117. return
  29118. }
  29119. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29120. if status == "0" {
  29121. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29122. c.ServeSuccessJSON(map[string]interface{}{
  29123. "failed_code": -10,
  29124. "msg": err_msg,
  29125. })
  29126. return
  29127. }
  29128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29129. userJSONBytes, _ := json.Marshal(respJSON)
  29130. fmt.Println("log")
  29131. fmt.Println(string(userJSONBytes))
  29132. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29133. utils.ErrorLog("解析失败:%v", err)
  29134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29135. return
  29136. }
  29137. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29138. data := make(map[string]interface{})
  29139. client := &http.Client{}
  29140. data["psn_no"] = his.PsnNo
  29141. data["mdtrt_id"] = his.Number
  29142. data["operator"] = roles.UserName
  29143. data["department"] = department.Name
  29144. data["org_name"] = miConfig.OrgName
  29145. var med_type string
  29146. if his.Insutype == "390" {
  29147. if reg_type == 992102 {
  29148. med_type = "992102"
  29149. data["sick_code"] = sickConfig.CountryCode
  29150. data["sick_name"] = sickConfig.ClassName
  29151. }
  29152. if reg_type == 140104 {
  29153. med_type = "140104"
  29154. data["sick_code"] = sickConfig.CountryCode
  29155. data["sick_name"] = sickConfig.ClassName
  29156. }
  29157. if reg_type == 140201 {
  29158. med_type = "140201"
  29159. data["sick_code"] = sickConfig.CountryCode
  29160. data["sick_name"] = sickConfig.ClassName
  29161. }
  29162. if reg_type == 14 {
  29163. med_type = "14"
  29164. data["sick_code"] = sickConfig.CountryCode
  29165. data["sick_name"] = sickConfig.ClassName
  29166. }
  29167. } else if his.Insutype == "310" {
  29168. if reg_type == 992102 {
  29169. med_type = "992102"
  29170. data["sick_code"] = sickConfig.CountryCode
  29171. data["sick_name"] = sickConfig.ClassName
  29172. }
  29173. if reg_type == 140104 {
  29174. med_type = "140104"
  29175. data["sick_code"] = sickConfig.CountryCode
  29176. data["sick_name"] = sickConfig.ClassName
  29177. }
  29178. if reg_type == 140201 {
  29179. med_type = "140201"
  29180. data["sick_code"] = sickConfig.CountryCode
  29181. data["sick_name"] = sickConfig.ClassName
  29182. }
  29183. if reg_type == 14 {
  29184. med_type = "14"
  29185. data["sick_code"] = sickConfig.CountryCode
  29186. data["sick_name"] = sickConfig.ClassName
  29187. }
  29188. }
  29189. data["med_type"] = med_type
  29190. data["doctor_number"] = doctor_info.DoctorNumber
  29191. data["doctor_name"] = doctor_info.UserName
  29192. data["fixmedins_code"] = miConfig.Code
  29193. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29194. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29195. data["secret_key"] = miConfig.SecretKey
  29196. data["begin_time"] = begin_time
  29197. data["dept"] = strconv.FormatInt(department.ID, 10)
  29198. data["config"] = config
  29199. data["url"] = miConfig.Url
  29200. data["ak"] = miConfig.AccessKey
  29201. data["cainfo"] = miConfig.Cainfo
  29202. bytesData, _ := json.Marshal(data)
  29203. var req *http.Request
  29204. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29205. resp, _ := client.Do(req)
  29206. defer resp.Body.Close()
  29207. body, ioErr := ioutil.ReadAll(resp.Body)
  29208. if ioErr != nil {
  29209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29211. return
  29212. }
  29213. var respJSON map[string]interface{}
  29214. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29217. return
  29218. }
  29219. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29220. if status == "0" {
  29221. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29222. c.ServeSuccessJSON(map[string]interface{}{
  29223. "failed_code": -10,
  29224. "msg": err_msg,
  29225. })
  29226. return
  29227. }
  29228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29229. userJSONBytes, _ := json.Marshal(respJSON)
  29230. fmt.Println("log")
  29231. fmt.Println(string(userJSONBytes))
  29232. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29233. utils.ErrorLog("解析失败:%v", err)
  29234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29235. return
  29236. }
  29237. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29238. var result string
  29239. var requestLog string
  29240. 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, "")
  29241. saveLog(result, requestLog, "2203", "上传就诊信息")
  29242. var respJSON2 map[string]interface{}
  29243. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29246. return
  29247. }
  29248. userJSONBytes2, _ := json.Marshal(respJSON2)
  29249. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29250. utils.ErrorLog("解析失败:%v", err)
  29251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29252. return
  29253. }
  29254. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29255. data := make(map[string]interface{})
  29256. client := &http.Client{}
  29257. data["psn_no"] = his.PsnNo
  29258. data["mdtrt_id"] = his.Number
  29259. data["doctor"] = roles.UserName
  29260. data["department"] = department.Name
  29261. data["org_name"] = miConfig.OrgName
  29262. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29263. data["doctor_id"] = doctor_info.DoctorNumber
  29264. data["fixmedins_code"] = miConfig.Code
  29265. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29266. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29267. data["secret_key"] = miConfig.SecretKey
  29268. data["sick_code"] = sickConfig.CountryCode
  29269. data["sick_name"] = sickConfig.ClassName
  29270. data["begin_time"] = begin_time
  29271. data["new_doctor_name"] = doctor_info.UserName
  29272. data["dept"] = strconv.FormatInt(department.ID, 10)
  29273. data["config"] = config
  29274. bytesData, _ := json.Marshal(data)
  29275. var req *http.Request
  29276. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  29277. resp, _ := client.Do(req)
  29278. defer resp.Body.Close()
  29279. body, ioErr := ioutil.ReadAll(resp.Body)
  29280. if ioErr != nil {
  29281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29283. return
  29284. }
  29285. var respJSON map[string]interface{}
  29286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29289. return
  29290. }
  29291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29292. userJSONBytes, _ := json.Marshal(respJSON)
  29293. fmt.Println("log")
  29294. fmt.Println(string(userJSONBytes))
  29295. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29296. utils.ErrorLog("解析失败:%v", err)
  29297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29298. return
  29299. }
  29300. } else {
  29301. var result string
  29302. var requestLog string
  29303. if miConfig.MdtrtareaAdmvs == "440781" { //
  29304. 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)
  29305. } else {
  29306. if miConfig.Code == "H15049901371" {
  29307. //赤峰地区国家医保医疗类别
  29308. //职工透析:医疗类别选特殊情况门诊990502
  29309. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29310. var med_type string
  29311. if his.Insutype == "390" {
  29312. if reg_type == 14 {
  29313. med_type = "9933"
  29314. } else if reg_type == 11 {
  29315. med_type = "11"
  29316. }
  29317. } else if his.Insutype == "310" {
  29318. if reg_type == 14 {
  29319. med_type = "990502"
  29320. } else if reg_type == 11 {
  29321. med_type = "11"
  29322. }
  29323. }
  29324. 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)
  29325. } else {
  29326. 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)
  29327. }
  29328. saveLog(result, requestLog, "2203", "上传就诊信息")
  29329. var respJSON2 map[string]interface{}
  29330. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29333. return
  29334. }
  29335. userJSONBytes2, _ := json.Marshal(respJSON2)
  29336. if miConfig.Code == "H15049901371" {
  29337. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  29338. utils.ErrorLog("解析失败:%v", err)
  29339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29340. return
  29341. }
  29342. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29343. res2.Output = resSix10265.Output
  29344. res2.ErrMsg = resSix10265.ErrMsg
  29345. res2.Cainfo = resSix10265.Cainfo
  29346. res2.WarnMsg = resSix10265.WarnMsg
  29347. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29348. res2.Infcode = infocode
  29349. } else {
  29350. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29351. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  29352. utils.ErrorLog("解析失败:%v", err)
  29353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29354. return
  29355. }
  29356. res2.Infcode = res3.Infcode
  29357. } else {
  29358. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29359. utils.ErrorLog("解析失败:%v", err)
  29360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29361. return
  29362. }
  29363. }
  29364. }
  29365. }
  29366. }
  29367. if res2.Infcode == -1 {
  29368. adminUser := c.GetAdminUserInfo()
  29369. errlog := &models.HisOrderError{
  29370. UserOrgId: adminUser.CurrentOrgId,
  29371. Ctime: time.Now().Unix(),
  29372. Mtime: time.Now().Unix(),
  29373. ErrMsg: res2.ErrMsg,
  29374. Status: 1,
  29375. PatientId: id,
  29376. RecordTime: recordDateTime,
  29377. Stage: 3,
  29378. }
  29379. service.CreateErrMsgLog(errlog)
  29380. c.ServeSuccessJSON(map[string]interface{}{
  29381. "failed_code": -10,
  29382. "msg": res2.ErrMsg,
  29383. })
  29384. return
  29385. }
  29386. if res2.Infcode != 0 {
  29387. adminUser := c.GetAdminUserInfo()
  29388. errlog := &models.HisOrderError{
  29389. UserOrgId: adminUser.CurrentOrgId,
  29390. Ctime: time.Now().Unix(),
  29391. Mtime: time.Now().Unix(),
  29392. ErrMsg: res2.ErrMsg,
  29393. Status: 1,
  29394. PatientId: id,
  29395. RecordTime: recordDateTime,
  29396. Stage: 3,
  29397. }
  29398. service.CreateErrMsgLog(errlog)
  29399. c.ServeSuccessJSON(map[string]interface{}{
  29400. "failed_code": -10,
  29401. "msg": res2.ErrMsg,
  29402. })
  29403. return
  29404. } else {
  29405. his.Diagnosis = diagnosis_id
  29406. his.SickType = sickConfig.ID
  29407. his.PType = fmt.Sprintf("%d", reg_type)
  29408. service.UpdateHisPatientThree(&his)
  29409. data := make(map[string]interface{})
  29410. if settle_accounts_type == 1 { //日结
  29411. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  29412. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  29413. } else {
  29414. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  29415. }
  29416. data["pre"] = prescriptions
  29417. } else { //月结
  29418. start_time_str := c.GetString("start_time")
  29419. end_time_str := c.GetString("end_time")
  29420. timeLayout := "2006-01-02"
  29421. loc, _ := time.LoadLocation("Local")
  29422. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  29423. if err != nil {
  29424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29425. return
  29426. }
  29427. recordStartTime := theStartTime.Unix()
  29428. start_time = recordStartTime
  29429. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  29430. if err != nil {
  29431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29432. return
  29433. }
  29434. recordEndTime := theEndTime.Unix()
  29435. end_time = recordEndTime
  29436. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  29437. data["pre"] = prescriptions
  29438. }
  29439. client := &http.Client{}
  29440. data["psn_no"] = his.PsnNo
  29441. data["mdtrt_id"] = his.Number
  29442. data["chrg_bchno"] = new_chrg_bchno
  29443. data["org_name"] = miConfig.OrgName
  29444. data["doctor"] = doctor_info.UserName
  29445. data["doctor_id"] = doctor_info.DoctorNumber
  29446. data["dept"] = department.Name
  29447. data["fixmedins_code"] = miConfig.Code
  29448. data["opter"] = roles.UserName
  29449. data["dept_code"] = department.Number
  29450. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29451. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29452. data["secret_key"] = miConfig.SecretKey
  29453. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  29454. data["url"] = miConfig.Url
  29455. data["ak"] = miConfig.AccessKey
  29456. data["new_doctor_name"] = patientPrescription.Doctor
  29457. if his.Insutype == "390" {
  29458. if reg_type == 992102 {
  29459. data["diag_code"] = "ZDZ940"
  29460. }
  29461. if reg_type == 140104 {
  29462. data["diag_code"] = sickConfig.CountryCode
  29463. }
  29464. if reg_type == 140201 {
  29465. data["diag_code"] = sickConfig.CountryCode
  29466. }
  29467. if reg_type == 14 {
  29468. data["diag_code"] = sickConfig.CountryCode
  29469. }
  29470. } else if his.Insutype == "310" {
  29471. if miConfig.MdtrtareaAdmvs == "341203" {
  29472. if reg_type == 992102 {
  29473. data["diag_code"] = "ZDZ940"
  29474. }
  29475. if reg_type != 992102 {
  29476. data["diag_code"] = sickConfig.CountryCode
  29477. }
  29478. } else {
  29479. data["diag_code"] = sickConfig.CountryCode
  29480. }
  29481. }
  29482. data["cainfo"] = miConfig.Cainfo
  29483. data["opter"] = roles.UserName
  29484. var ids []int64
  29485. for _, item := range prescriptions {
  29486. ids = append(ids, item.ID)
  29487. }
  29488. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29489. if config.IsOpen == 1 { //对接了医保,走医保流程
  29490. var res ResultFour
  29491. var resFour10265 ResultFour10265
  29492. if miConfig.MdtrtareaAdmvs == "421300" {
  29493. bytesData, _ := json.Marshal(data)
  29494. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29495. resp, _ := client.Do(req)
  29496. defer resp.Body.Close()
  29497. body, ioErr := ioutil.ReadAll(resp.Body)
  29498. if ioErr != nil {
  29499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29501. return
  29502. }
  29503. var respJSON map[string]interface{}
  29504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29507. return
  29508. }
  29509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29510. userJSONBytes, _ := json.Marshal(respJSON)
  29511. fmt.Println("log")
  29512. fmt.Println(string(userJSONBytes))
  29513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29514. utils.ErrorLog("解析失败:%v", err)
  29515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29516. return
  29517. }
  29518. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29519. bytesData, _ := json.Marshal(data)
  29520. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29521. resp, _ := client.Do(req)
  29522. defer resp.Body.Close()
  29523. body, ioErr := ioutil.ReadAll(resp.Body)
  29524. if ioErr != nil {
  29525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29527. return
  29528. }
  29529. var respJSON map[string]interface{}
  29530. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29533. return
  29534. }
  29535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29536. userJSONBytes, _ := json.Marshal(respJSON)
  29537. fmt.Println("log")
  29538. fmt.Println(string(userJSONBytes))
  29539. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29540. utils.ErrorLog("解析失败:%v", err)
  29541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29542. return
  29543. }
  29544. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29545. bytesData, _ := json.Marshal(data)
  29546. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29547. resp, _ := client.Do(req)
  29548. defer resp.Body.Close()
  29549. body, ioErr := ioutil.ReadAll(resp.Body)
  29550. if ioErr != nil {
  29551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29553. return
  29554. }
  29555. var respJSON map[string]interface{}
  29556. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29559. return
  29560. }
  29561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29562. userJSONBytes, _ := json.Marshal(respJSON)
  29563. fmt.Println("log")
  29564. fmt.Println(string(userJSONBytes))
  29565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29566. utils.ErrorLog("解析失败:%v", err)
  29567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29568. return
  29569. }
  29570. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29571. bytesData, _ := json.Marshal(data)
  29572. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29573. resp, _ := client.Do(req)
  29574. defer resp.Body.Close()
  29575. body, ioErr := ioutil.ReadAll(resp.Body)
  29576. if ioErr != nil {
  29577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29579. return
  29580. }
  29581. var respJSON map[string]interface{}
  29582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29585. return
  29586. }
  29587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29588. userJSONBytes, _ := json.Marshal(respJSON)
  29589. fmt.Println("log")
  29590. fmt.Println(string(userJSONBytes))
  29591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29592. utils.ErrorLog("解析失败:%v", err)
  29593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29594. return
  29595. }
  29596. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29597. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29598. if result3101.Infcode == "0" {
  29599. if len(result3101.Output.Result) > 0 {
  29600. var errMsgs []string
  29601. for _, item := range result3101.Output.Result {
  29602. errMsgs = append(errMsgs, item.VolaCont)
  29603. }
  29604. c.ServeSuccessJSON(map[string]interface{}{
  29605. "failed_code": -10,
  29606. "msg": errMsgs,
  29607. })
  29608. return
  29609. } else {
  29610. if miConfig.MdtrtareaAdmvs == "320921" {
  29611. data["doctor_id"] = "D320923012139"
  29612. } else {
  29613. data["doctor_id"] = "D371621008686"
  29614. }
  29615. bytesData, _ := json.Marshal(data)
  29616. var req *http.Request
  29617. if miConfig.MdtrtareaAdmvs == "320921" {
  29618. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29619. } else {
  29620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29621. }
  29622. resp, _ := client.Do(req)
  29623. defer resp.Body.Close()
  29624. body, ioErr := ioutil.ReadAll(resp.Body)
  29625. if ioErr != nil {
  29626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29628. return
  29629. }
  29630. var respJSON map[string]interface{}
  29631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29634. return
  29635. }
  29636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29637. userJSONBytes, _ := json.Marshal(respJSON)
  29638. fmt.Println("log")
  29639. fmt.Println(string(userJSONBytes))
  29640. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29641. utils.ErrorLog("解析失败:%v", err)
  29642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29643. return
  29644. }
  29645. res.InfRefmsgid = resFour10265.InfRefmsgid
  29646. res.Output = resFour10265.Output
  29647. res.ErrMsg = resFour10265.ErrMsg
  29648. res.Cainfo = resFour10265.Cainfo
  29649. res.WarnMsg = resFour10265.WarnMsg
  29650. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29651. res.Infcode = infocode
  29652. }
  29653. }
  29654. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29655. var pagesize int = 5
  29656. var start int = 1
  29657. var stop int
  29658. var pagecount int
  29659. var curpage int
  29660. data["doctor_id"] = doctor_info.DoctorNumber
  29661. var res2 ResultFour
  29662. //var result res.
  29663. //总页数,向上取整,注意除之前要先转换类型为float64
  29664. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29665. for curpage = 1; curpage <= pagecount; curpage++ {
  29666. if curpage == 1 {
  29667. start = 1
  29668. } else {
  29669. start = (curpage-1)*pagesize + 1
  29670. }
  29671. stop = curpage * pagesize
  29672. if stop > len(prescriptions) {
  29673. stop = len(prescriptions)
  29674. }
  29675. //var requestLog string
  29676. data["pre"] = prescriptions[start-1 : stop]
  29677. fmt.Println(data["pre"])
  29678. bytesData, _ := json.Marshal(data)
  29679. var req *http.Request
  29680. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29681. resp, _ := client.Do(req)
  29682. defer resp.Body.Close()
  29683. body, ioErr := ioutil.ReadAll(resp.Body)
  29684. if ioErr != nil {
  29685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29687. return
  29688. }
  29689. var respJSON map[string]interface{}
  29690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29693. return
  29694. }
  29695. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29696. userJSONBytes, _ := json.Marshal(respJSON)
  29697. fmt.Println("log")
  29698. fmt.Println(string(userJSONBytes))
  29699. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29700. utils.ErrorLog("解析失败:%v", err)
  29701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29702. return
  29703. }
  29704. res.InfRefmsgid = resFour10265.InfRefmsgid
  29705. res.Output = resFour10265.Output
  29706. res.ErrMsg = resFour10265.ErrMsg
  29707. res.Cainfo = resFour10265.Cainfo
  29708. res.WarnMsg = resFour10265.WarnMsg
  29709. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29710. res.Infcode = infocode
  29711. if infocode == 0 {
  29712. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29713. } else {
  29714. isSuccess = false
  29715. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29716. res.Infcode = -1
  29717. res.ErrMsg = resFour10265.ErrMsg
  29718. errlog := &models.HisOrderError{
  29719. UserOrgId: adminUser.CurrentOrgId,
  29720. Ctime: time.Now().Unix(),
  29721. Mtime: time.Now().Unix(),
  29722. Number: chrg_bchno,
  29723. ErrMsg: "",
  29724. Status: 1,
  29725. PatientId: id,
  29726. RecordTime: recordDateTime,
  29727. Stage: 4,
  29728. }
  29729. service.CreateErrMsgLog(errlog)
  29730. }
  29731. }
  29732. if isSuccess {
  29733. res.Infcode = 0
  29734. res.Output.Result = res2.Output.Result
  29735. } else {
  29736. order := &models.HisOrder{
  29737. UserOrgId: adminUser.CurrentOrgId,
  29738. HisPatientId: his.ID,
  29739. PatientId: his.PatientId,
  29740. SettleAccountsDate: recordDateTime,
  29741. Ctime: time.Now().Unix(),
  29742. Mtime: time.Now().Unix(),
  29743. MdtrtId: his.Number,
  29744. PsnNo: his.PsnNo,
  29745. MedType: strconv.FormatInt(reg_type, 10),
  29746. Status: 1,
  29747. Number: chrg_bchno,
  29748. Infcode: res.Infcode,
  29749. WarnMsg: res.WarnMsg,
  29750. Cainfo: res.Cainfo,
  29751. ErrMsg: res.ErrMsg,
  29752. RespondTime: res.RefmsgTime,
  29753. InfRefmsgid: res.InfRefmsgid,
  29754. OrderStatus: 1,
  29755. IsMedicineInsurance: 1,
  29756. SettleType: settle_accounts_type,
  29757. SettleStartTime: start_time,
  29758. SettleEndTime: end_time,
  29759. Creator: roles.AdminUserId,
  29760. Modify: roles.AdminUserId,
  29761. PType: 2,
  29762. Diagnosis: diagnosis_id,
  29763. }
  29764. err = service.CreateOrder(order)
  29765. if err != nil {
  29766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29767. return
  29768. }
  29769. c.ServeSuccessJSON(map[string]interface{}{
  29770. "failed_code": -10,
  29771. "msg": res2.ErrMsg,
  29772. })
  29773. return
  29774. }
  29775. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29776. 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)
  29777. var dat map[string]interface{}
  29778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29779. fmt.Println(dat)
  29780. } else {
  29781. fmt.Println(err)
  29782. }
  29783. saveLog(result, request_log, "2204", "上传费用明细")
  29784. userJSONBytes, _ := json.Marshal(dat)
  29785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29786. utils.ErrorLog("解析失败:%v", err)
  29787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29788. return
  29789. }
  29790. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29791. 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, "", "")
  29792. var dat map[string]interface{}
  29793. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29794. fmt.Println(dat)
  29795. } else {
  29796. fmt.Println(err)
  29797. }
  29798. saveLog(result, request_log, "2204", "上传费用明细")
  29799. userJSONBytes, _ := json.Marshal(dat)
  29800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29801. utils.ErrorLog("解析失败:%v", err)
  29802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29803. return
  29804. }
  29805. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29806. 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, "", "")
  29807. var dat map[string]interface{}
  29808. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29809. fmt.Println(dat)
  29810. } else {
  29811. fmt.Println(err)
  29812. }
  29813. saveLog(result, request_log, "2204", "上传费用明细")
  29814. userJSONBytes, _ := json.Marshal(dat)
  29815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29816. utils.ErrorLog("解析失败:%v", err)
  29817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29818. return
  29819. }
  29820. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29821. 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, "", "")
  29822. var dat map[string]interface{}
  29823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29824. fmt.Println(dat)
  29825. } else {
  29826. fmt.Println(err)
  29827. }
  29828. saveLog(result, request_log, "2204", "上传费用明细")
  29829. userJSONBytes, _ := json.Marshal(dat)
  29830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29831. utils.ErrorLog("解析失败:%v", err)
  29832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29833. return
  29834. }
  29835. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29836. bytesData, _ := json.Marshal(data)
  29837. var req *http.Request
  29838. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29839. resp, _ := client.Do(req)
  29840. defer resp.Body.Close()
  29841. body, ioErr := ioutil.ReadAll(resp.Body)
  29842. if ioErr != nil {
  29843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29845. return
  29846. }
  29847. var respJSON map[string]interface{}
  29848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29851. return
  29852. }
  29853. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29854. if status == "0" {
  29855. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29856. c.ServeSuccessJSON(map[string]interface{}{
  29857. "failed_code": -10,
  29858. "msg": err_msg,
  29859. })
  29860. return
  29861. }
  29862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29863. userJSONBytes, _ := json.Marshal(respJSON)
  29864. fmt.Println("log")
  29865. fmt.Println(string(userJSONBytes))
  29866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29867. utils.ErrorLog("解析失败:%v", err)
  29868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29869. return
  29870. }
  29871. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29872. bytesData, _ := json.Marshal(data)
  29873. var req *http.Request
  29874. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29875. resp, _ := client.Do(req)
  29876. defer resp.Body.Close()
  29877. body, ioErr := ioutil.ReadAll(resp.Body)
  29878. if ioErr != nil {
  29879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29881. return
  29882. }
  29883. var respJSON map[string]interface{}
  29884. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29887. return
  29888. }
  29889. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29890. if status == "0" {
  29891. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29892. c.ServeSuccessJSON(map[string]interface{}{
  29893. "failed_code": -10,
  29894. "msg": err_msg,
  29895. })
  29896. return
  29897. }
  29898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29899. userJSONBytes, _ := json.Marshal(respJSON)
  29900. fmt.Println("log")
  29901. fmt.Println(string(userJSONBytes))
  29902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29903. utils.ErrorLog("解析失败:%v", err)
  29904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29905. return
  29906. }
  29907. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29908. 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, "", "")
  29909. var dat map[string]interface{}
  29910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29911. fmt.Println(dat)
  29912. } else {
  29913. fmt.Println(err)
  29914. }
  29915. saveLog(result, request_log, "2204", "上传费用明细")
  29916. userJSONBytes, _ := json.Marshal(dat)
  29917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29918. utils.ErrorLog("解析失败:%v", err)
  29919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29920. return
  29921. }
  29922. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29923. bytesData, _ := json.Marshal(data)
  29924. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29925. resp, _ := client.Do(req)
  29926. defer resp.Body.Close()
  29927. body, ioErr := ioutil.ReadAll(resp.Body)
  29928. if ioErr != nil {
  29929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29931. return
  29932. }
  29933. var respJSON map[string]interface{}
  29934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29937. return
  29938. }
  29939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29940. userJSONBytes, _ := json.Marshal(respJSON)
  29941. fmt.Println("log")
  29942. fmt.Println(string(userJSONBytes))
  29943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29944. utils.ErrorLog("解析失败:%v", err)
  29945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29946. return
  29947. }
  29948. } else {
  29949. if miConfig.MdtrtareaAdmvs == "441202" {
  29950. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29951. if result3101.Infcode == 0 {
  29952. if len(result3101.Output.Result) > 0 {
  29953. var errMsgs []string
  29954. for _, item := range result3101.Output.Result {
  29955. errMsgs = append(errMsgs, item.VolaCont)
  29956. }
  29957. c.ServeSuccessJSON(map[string]interface{}{
  29958. "failed_code": -10,
  29959. "msg": errMsgs,
  29960. })
  29961. return
  29962. } else {
  29963. 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)
  29964. var dat map[string]interface{}
  29965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29966. fmt.Println(dat)
  29967. } else {
  29968. fmt.Println(err)
  29969. }
  29970. saveLog(result, request_log, "2204", "上传费用明细")
  29971. userJSONBytes, _ := json.Marshal(dat)
  29972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29973. utils.ErrorLog("解析失败:%v", err)
  29974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29975. return
  29976. }
  29977. }
  29978. } else {
  29979. c.ServeSuccessJSON(map[string]interface{}{
  29980. "failed_code": -10,
  29981. "msg": result3101.ErrMsg,
  29982. })
  29983. return
  29984. }
  29985. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29986. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29987. if result3101.Infcode == 0 {
  29988. if len(result3101.Output.Result) > 0 {
  29989. var errMsgs []string
  29990. for _, item := range result3101.Output.Result {
  29991. errMsgs = append(errMsgs, item.VolaCont)
  29992. }
  29993. c.ServeSuccessJSON(map[string]interface{}{
  29994. "failed_code": -10,
  29995. "msg": errMsgs,
  29996. })
  29997. return
  29998. } else {
  29999. 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)
  30000. var dat map[string]interface{}
  30001. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30002. fmt.Println(dat)
  30003. } else {
  30004. fmt.Println(err)
  30005. }
  30006. saveLog(result, request_log, "2204", "上传费用明细")
  30007. userJSONBytes, _ := json.Marshal(dat)
  30008. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30009. utils.ErrorLog("解析失败:%v", err)
  30010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30011. return
  30012. }
  30013. }
  30014. } else {
  30015. c.ServeSuccessJSON(map[string]interface{}{
  30016. "failed_code": -10,
  30017. "msg": result3101.ErrMsg,
  30018. })
  30019. return
  30020. }
  30021. } else {
  30022. if miConfig.Code == "H15049901371" {
  30023. 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)
  30024. var dat map[string]interface{}
  30025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30026. fmt.Println(dat)
  30027. } else {
  30028. fmt.Println(err)
  30029. }
  30030. saveLog(result, request_log, "2204", "上传费用明细")
  30031. userJSONBytes, _ := json.Marshal(dat)
  30032. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30033. utils.ErrorLog("解析失败:%v", err)
  30034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30035. return
  30036. }
  30037. res.InfRefmsgid = resFour10265.InfRefmsgid
  30038. res.Output = resFour10265.Output
  30039. res.ErrMsg = resFour10265.ErrMsg
  30040. res.Cainfo = resFour10265.Cainfo
  30041. res.WarnMsg = resFour10265.WarnMsg
  30042. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30043. res.Infcode = infocode
  30044. } else {
  30045. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" {
  30046. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30047. if result3101.Infcode == 0 {
  30048. if len(result3101.Output.Result) > 0 {
  30049. c.ServeSuccessJSON(map[string]interface{}{
  30050. "failed_code": -10,
  30051. "failed_type": 100,
  30052. "warm_type": 1,
  30053. "msg": result3101.Output.Result,
  30054. })
  30055. return
  30056. } else {
  30057. 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)
  30058. var dat map[string]interface{}
  30059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30060. fmt.Println(dat)
  30061. } else {
  30062. fmt.Println(err)
  30063. }
  30064. saveLog(result, request_log, "2204", "上传费用明细")
  30065. userJSONBytes, _ := json.Marshal(dat)
  30066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30067. utils.ErrorLog("解析失败:%v", err)
  30068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30069. return
  30070. }
  30071. }
  30072. } else {
  30073. c.ServeSuccessJSON(map[string]interface{}{
  30074. "failed_code": -10,
  30075. "msg": result3101.ErrMsg,
  30076. })
  30077. return
  30078. }
  30079. } else {
  30080. 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)
  30081. var dat map[string]interface{}
  30082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30083. fmt.Println(dat)
  30084. } else {
  30085. fmt.Println(err)
  30086. }
  30087. saveLog(result, request_log, "2204", "上传费用明细")
  30088. userJSONBytes, _ := json.Marshal(dat)
  30089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30090. utils.ErrorLog("解析失败:%v", err)
  30091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30092. return
  30093. }
  30094. }
  30095. }
  30096. }
  30097. }
  30098. var total_two float64
  30099. if res.Infcode == -1 {
  30100. errlog := &models.HisOrderError{
  30101. UserOrgId: adminUser.CurrentOrgId,
  30102. Ctime: time.Now().Unix(),
  30103. Mtime: time.Now().Unix(),
  30104. Number: chrg_bchno,
  30105. ErrMsg: res.ErrMsg,
  30106. Status: 1,
  30107. PatientId: id,
  30108. RecordTime: recordDateTime,
  30109. Stage: 4,
  30110. }
  30111. service.CreateErrMsgLog(errlog)
  30112. c.ServeSuccessJSON(map[string]interface{}{
  30113. "failed_code": -10,
  30114. "msg": res.ErrMsg,
  30115. })
  30116. return
  30117. }
  30118. if res.Infcode == 0 {
  30119. order := &models.HisOrder{
  30120. UserOrgId: adminUser.CurrentOrgId,
  30121. HisPatientId: his.ID,
  30122. PatientId: his.PatientId,
  30123. SettleAccountsDate: recordDateTime,
  30124. Ctime: time.Now().Unix(),
  30125. Mtime: time.Now().Unix(),
  30126. MdtrtId: his.Number,
  30127. PsnNo: his.PsnNo,
  30128. MedType: strconv.FormatInt(reg_type, 10),
  30129. Status: 1,
  30130. Number: chrg_bchno,
  30131. Infcode: res.Infcode,
  30132. WarnMsg: res.WarnMsg,
  30133. Cainfo: res.Cainfo,
  30134. ErrMsg: res.ErrMsg,
  30135. RespondTime: res.RefmsgTime,
  30136. InfRefmsgid: res.InfRefmsgid,
  30137. OrderStatus: 1,
  30138. IsMedicineInsurance: 1,
  30139. SettleType: settle_accounts_type,
  30140. SettleStartTime: start_time,
  30141. SettleEndTime: end_time,
  30142. Creator: roles.AdminUserId,
  30143. Modify: roles.AdminUserId,
  30144. PType: 2,
  30145. Diagnosis: diagnosis_id,
  30146. }
  30147. err = service.CreateOrder(order)
  30148. if err != nil {
  30149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30150. return
  30151. }
  30152. for _, item := range res.Output.Result {
  30153. temp := strings.Split(item.FeedetlSn, "-")
  30154. var advice_id int64 = 0
  30155. var project_id int64 = 0
  30156. var types int64 = 0
  30157. id, _ := strconv.ParseInt(temp[2], 10, 64)
  30158. types, _ = strconv.ParseInt(temp[1], 10, 64)
  30159. if temp[1] == "1" {
  30160. advice_id = id
  30161. project_id = 0
  30162. } else if temp[1] == "2" {
  30163. advice_id = 0
  30164. project_id = id
  30165. }
  30166. total_two = total_two + item.DetItemFeeSumamt
  30167. info := &models.HisOrderInfo{
  30168. OrderNumber: order.Number,
  30169. FeedetlSn: item.FeedetlSn,
  30170. UploadDate: time.Now().Unix(),
  30171. AdviceId: advice_id,
  30172. DetItemFeeSumamt: item.DetItemFeeSumamt,
  30173. Cnt: item.Cnt,
  30174. Pric: float64(item.Pric),
  30175. PatientId: his.PatientId,
  30176. PricUplmtAmt: item.PricUplmtAmt,
  30177. SelfpayProp: item.SelfpayProp,
  30178. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  30179. OverlmtAmt: item.OverlmtAmt,
  30180. PreselfpayAmt: item.PreselfpayAmt,
  30181. BasMednFlag: item.BasMednFlag,
  30182. MedChrgitmType: item.MedChrgitmType,
  30183. HiNegoDrugFlag: item.HiNegoDrugFlag,
  30184. Status: 1,
  30185. Memo: item.Memo,
  30186. Mtime: time.Now().Unix(),
  30187. InscpScpAmt: item.InscpScpAmt,
  30188. DrtReimFlag: item.DrtReimFlag,
  30189. Ctime: time.Now().Unix(),
  30190. ListSpItemFlag: item.ListSpItemFlag,
  30191. ChldMedcFlag: item.ChldMedcFlag,
  30192. LmtUsedFlag: item.LmtUsedFlag,
  30193. ChrgitmLv: item.ChrgitmLv,
  30194. UserOrgId: adminUser.CurrentOrgId,
  30195. HisPatientId: his.ID,
  30196. OrderId: order.ID,
  30197. ProjectId: project_id,
  30198. Type: types,
  30199. }
  30200. service.CreateOrderInfo(info)
  30201. }
  30202. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  30203. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  30204. var total float64
  30205. for _, item := range prescriptions {
  30206. if item.Type == 1 { //药品
  30207. for _, subItem := range item.HisDoctorAdviceInfo {
  30208. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30209. total_one := price * subItem.PrescribingNumber
  30210. fmt.Println("subItem")
  30211. fmt.Println(subItem.Price)
  30212. fmt.Println("price")
  30213. fmt.Println(price)
  30214. fmt.Println("total_one")
  30215. fmt.Println(total_one)
  30216. total = total + total_one
  30217. fmt.Println(total)
  30218. }
  30219. }
  30220. if item.Type == 2 { //项目
  30221. for _, subItem := range item.HisPrescriptionProject {
  30222. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  30223. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30224. total_one := price * cnt
  30225. total = total + total_one
  30226. }
  30227. }
  30228. }
  30229. allTotal := fmt.Sprintf("%.2f", total)
  30230. if res.Infcode == 0 {
  30231. var rf []*ResultFive
  30232. json.Unmarshal([]byte(his.Iinfo), &rf)
  30233. chrg_bchno := chrg_bchno
  30234. cert_no := his.Certno
  30235. var insutypes []string
  30236. var insutype string
  30237. var is390 int = 0
  30238. var is310 int = 0
  30239. for _, item := range rf {
  30240. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  30241. insutypes = append(insutypes, item.Insutype)
  30242. }
  30243. }
  30244. if len(insutypes) == 1 {
  30245. insutype = insutypes[0]
  30246. } else {
  30247. for _, i := range insutypes {
  30248. if i == "390" {
  30249. is390 = 1
  30250. }
  30251. if i == "310" {
  30252. is310 = 1
  30253. }
  30254. }
  30255. }
  30256. if is390 == 1 {
  30257. insutype = "390"
  30258. }
  30259. if is310 == 1 {
  30260. insutype = "310"
  30261. }
  30262. if len(insutypes) == 0 {
  30263. insutype = "390"
  30264. }
  30265. if len(insutypes) == 2 {
  30266. insutype = strconv.FormatInt(his.SocialType, 10)
  30267. }
  30268. //insutype = "390"
  30269. if his.IdCardType == 1 {
  30270. cert_no = his.MedicalInsuranceNumber
  30271. } else {
  30272. cert_no = his.Certno
  30273. }
  30274. var res ResultSeven
  30275. var ahres ResultSevenAH
  30276. var resSeven10265 ResultSeven10265
  30277. var resSeven10265Two ResultSeven10265Two
  30278. var gzresSeven10265Two GZResultSeven10265Two
  30279. if miConfig.MdtrtareaAdmvs == "421300" {
  30280. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  30281. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30282. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30283. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30284. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30285. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30286. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30287. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30288. resp, requestErr := http.Get(api)
  30289. if requestErr != nil {
  30290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30291. return
  30292. }
  30293. body, ioErr := ioutil.ReadAll(resp.Body)
  30294. if ioErr != nil {
  30295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30297. return
  30298. }
  30299. var respJSON map[string]interface{}
  30300. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30303. return
  30304. }
  30305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30306. result, _ := json.Marshal(respJSON)
  30307. fmt.Println("log")
  30308. fmt.Println(string(result))
  30309. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30310. utils.ErrorLog("解析失败:%v", err)
  30311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30312. return
  30313. }
  30314. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30315. if reg_type == 11 && his.Insutype == "390" {
  30316. reg_type = 110104
  30317. }
  30318. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30319. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30320. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30321. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30322. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30323. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30324. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30325. resp, requestErr := http.Get(api)
  30326. if requestErr != nil {
  30327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30328. return
  30329. }
  30330. body, ioErr := ioutil.ReadAll(resp.Body)
  30331. if ioErr != nil {
  30332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30334. return
  30335. }
  30336. var respJSON map[string]interface{}
  30337. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30340. return
  30341. }
  30342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30343. result, _ := json.Marshal(respJSON)
  30344. fmt.Println("log")
  30345. fmt.Println(string(result))
  30346. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30347. utils.ErrorLog("解析失败:%v", err)
  30348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30349. return
  30350. }
  30351. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30352. if reg_type == 11 && his.Insutype == "390" {
  30353. reg_type = 110104
  30354. }
  30355. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30356. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30357. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30358. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30359. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30360. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30361. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30362. resp, requestErr := http.Get(api)
  30363. if requestErr != nil {
  30364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30365. return
  30366. }
  30367. body, ioErr := ioutil.ReadAll(resp.Body)
  30368. if ioErr != nil {
  30369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30371. return
  30372. }
  30373. var respJSON map[string]interface{}
  30374. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30377. return
  30378. }
  30379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30380. result, _ := json.Marshal(respJSON)
  30381. fmt.Println("log")
  30382. fmt.Println(string(result))
  30383. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30384. utils.ErrorLog("解析失败:%v", err)
  30385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30386. return
  30387. }
  30388. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30389. if reg_type == 11 && his.Insutype == "390" {
  30390. reg_type = 110104
  30391. }
  30392. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30393. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30394. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30395. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30396. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30397. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30398. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30399. resp, requestErr := http.Get(api)
  30400. if requestErr != nil {
  30401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30402. return
  30403. }
  30404. body, ioErr := ioutil.ReadAll(resp.Body)
  30405. if ioErr != nil {
  30406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30408. return
  30409. }
  30410. var respJSON map[string]interface{}
  30411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30414. return
  30415. }
  30416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30417. result, _ := json.Marshal(respJSON)
  30418. fmt.Println("log")
  30419. fmt.Println(string(result))
  30420. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30421. utils.ErrorLog("解析失败:%v", err)
  30422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30423. return
  30424. }
  30425. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30426. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30427. if result3101.Infcode == "0" {
  30428. if len(result3101.Output.Result) > 0 {
  30429. var errMsgs []string
  30430. for _, item := range result3101.Output.Result {
  30431. errMsgs = append(errMsgs, item.VolaCont)
  30432. }
  30433. c.ServeSuccessJSON(map[string]interface{}{
  30434. "failed_code": -10,
  30435. "msg": errMsgs,
  30436. })
  30437. return
  30438. } else {
  30439. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30440. if his.IdCardType != 4 {
  30441. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30442. bas := strings.Split(psn_info.CardInfo, "|")
  30443. if his.IdCardType == 1 {
  30444. cert_no = bas[2]
  30445. } else {
  30446. cert_no = bas[1]
  30447. }
  30448. } else {
  30449. cert_no = his.Certno
  30450. }
  30451. //江苏地区国家医保医疗类别
  30452. //职工透析:医疗类别选特殊情况门诊9933
  30453. //居民血透门慢: 医疗类别选门诊慢病1402
  30454. //var med_type string
  30455. //if his.Insutype == "310" {
  30456. // if reg_type == 14 {
  30457. // med_type = "9933"
  30458. // } else if reg_type == 11 {
  30459. // med_type = "11"
  30460. //
  30461. // }
  30462. //} else if his.Insutype == "390" {
  30463. // if reg_type == 14 {
  30464. // med_type = "1402"
  30465. // } else if reg_type == 11 {
  30466. // med_type = "11"
  30467. // }
  30468. //}
  30469. var api string
  30470. if miConfig.MdtrtareaAdmvs == "320921" {
  30471. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30472. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30473. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30475. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30476. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30477. "&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
  30478. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30479. } else {
  30480. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30481. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30482. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30483. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30485. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30486. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30487. "&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
  30488. }
  30489. resp, requestErr := http.Get(api)
  30490. if requestErr != nil {
  30491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30492. return
  30493. }
  30494. body, ioErr := ioutil.ReadAll(resp.Body)
  30495. if ioErr != nil {
  30496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30498. return
  30499. }
  30500. var respJSON map[string]interface{}
  30501. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30504. return
  30505. }
  30506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30507. result, _ := json.Marshal(respJSON)
  30508. fmt.Println("log")
  30509. fmt.Println(string(result))
  30510. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  30511. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30512. utils.ErrorLog("解析失败:%v", err)
  30513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30514. return
  30515. }
  30516. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30517. res.Output = resSeven10265.Output
  30518. res.ErrMsg = resSeven10265.ErrMsg
  30519. res.Cainfo = resSeven10265.Cainfo
  30520. res.WarnMsg = resSeven10265.WarnMsg
  30521. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30522. res.Infcode = infocode
  30523. } else {
  30524. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  30525. utils.ErrorLog("解析失败:%v", err)
  30526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30527. return
  30528. }
  30529. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  30530. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  30531. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  30532. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  30533. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30534. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  30535. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  30536. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  30537. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  30538. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  30539. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  30540. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30541. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  30542. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  30543. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30544. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30545. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  30546. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  30547. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  30548. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  30549. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  30550. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30551. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  30552. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  30553. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  30554. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  30555. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  30556. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  30557. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  30558. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  30559. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30560. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  30561. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  30562. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  30563. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30564. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30565. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30566. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30567. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  30568. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30569. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30570. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30571. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30572. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30573. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30574. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30575. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30576. res.ErrMsg = resSeven10265Two.ErrMsg
  30577. res.Cainfo = resSeven10265Two.Cainfo
  30578. res.WarnMsg = resSeven10265Two.WarnMsg
  30579. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30580. res.Infcode = infocode
  30581. }
  30582. }
  30583. }
  30584. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30585. psn_info, _ := service.GetPsnByPatientId(id)
  30586. var verify_number string
  30587. if psn_info.IdCardType == 4 {
  30588. verify_number = psn_info.VerifyNumber
  30589. } else if psn_info.IdCardType == 1 {
  30590. bas := strings.Split(psn_info.CardInfo, "|")
  30591. cardNumber := bas[2]
  30592. verify_number = cardNumber
  30593. } else {
  30594. psn_info.IdCardType = 2
  30595. verify_number = psn_info.Certno
  30596. }
  30597. var api string
  30598. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30599. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30600. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30602. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30603. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30604. "&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
  30605. resp, requestErr := http.Get(api)
  30606. if requestErr != nil {
  30607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30608. return
  30609. }
  30610. body, ioErr := ioutil.ReadAll(resp.Body)
  30611. if ioErr != nil {
  30612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30614. return
  30615. }
  30616. var respJSON map[string]interface{}
  30617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30620. return
  30621. }
  30622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30623. result, _ := json.Marshal(respJSON)
  30624. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30625. utils.ErrorLog("解析失败:%v", err)
  30626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30627. return
  30628. }
  30629. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30630. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30631. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30632. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30633. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30634. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30635. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30636. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30637. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30638. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30639. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30640. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30641. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30642. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30643. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30644. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30645. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30646. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30647. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30648. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30649. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30650. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30651. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30652. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30653. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30654. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30655. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30656. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30657. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30658. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30659. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30660. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30661. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30662. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30663. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30664. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30665. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30666. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30667. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30668. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30669. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30670. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30671. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30672. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30673. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30674. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30675. res.ErrMsg = resSeven10265.ErrMsg
  30676. res.Cainfo = resSeven10265.Cainfo
  30677. res.WarnMsg = resSeven10265.WarnMsg
  30678. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30679. res.Infcode = infocode
  30680. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30681. acct_used_flag := "1"
  30682. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30683. var result string
  30684. var request_log string
  30685. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30686. 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)
  30687. } else {
  30688. 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)
  30689. }
  30690. var dat map[string]interface{}
  30691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30692. fmt.Println(dat)
  30693. } else {
  30694. fmt.Println(err)
  30695. }
  30696. saveLog(result, request_log, "2206", "预结算")
  30697. userJSONBytes, _ := json.Marshal(dat)
  30698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30699. utils.ErrorLog("解析失败:%v", err)
  30700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30701. return
  30702. }
  30703. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30704. var result string
  30705. var request_log string
  30706. if his.IdCardType == 2 {
  30707. insutype = strconv.FormatInt(his.SocialType, 10)
  30708. 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, "")
  30709. } else if his.IdCardType == 1 {
  30710. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30711. bas := strings.Split(psn_info.CardInfo, "|")
  30712. basNumber := bas[2]
  30713. card_sn := bas[3]
  30714. var rf []*ResultFive
  30715. json.Unmarshal([]byte(his.Iinfo), &rf)
  30716. var psn_type string
  30717. for _, item := range rf {
  30718. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30719. psn_type = item.PsnType
  30720. }
  30721. }
  30722. insutype = strconv.FormatInt(his.SocialType, 10)
  30723. 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)
  30724. } else {
  30725. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30726. //bas := strings.Split(psn_info.CardInfo, "|")
  30727. //basNumber := bas[2]
  30728. //card_sn := bas[3]
  30729. var rf []*ResultFive
  30730. json.Unmarshal([]byte(his.Iinfo), &rf)
  30731. var psn_type string
  30732. for _, item := range rf {
  30733. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30734. psn_type = item.PsnType
  30735. }
  30736. }
  30737. insutype = strconv.FormatInt(his.SocialType, 10)
  30738. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30739. 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)
  30740. }
  30741. var dat map[string]interface{}
  30742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30743. fmt.Println(dat)
  30744. } else {
  30745. fmt.Println(err)
  30746. }
  30747. saveLog(result, request_log, "2206", "预结算")
  30748. userJSONBytes, _ := json.Marshal(dat)
  30749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30750. utils.ErrorLog("解析失败:%v", err)
  30751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30752. return
  30753. }
  30754. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30755. var result string
  30756. var request_log string
  30757. if his.IdCardType == 2 {
  30758. insutype = strconv.FormatInt(his.SocialType, 10)
  30759. 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, "")
  30760. } else if his.IdCardType == 1 {
  30761. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30762. bas := strings.Split(psn_info.CardInfo, "|")
  30763. basNumber := bas[0]
  30764. card_sn := ""
  30765. var rf []*ResultFive
  30766. json.Unmarshal([]byte(his.Iinfo), &rf)
  30767. var psn_type string
  30768. for _, item := range rf {
  30769. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30770. psn_type = item.PsnType
  30771. }
  30772. }
  30773. insutype = strconv.FormatInt(his.SocialType, 10)
  30774. 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)
  30775. } else {
  30776. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30777. //bas := strings.Split(psn_info.CardInfo, "|")
  30778. //basNumber := bas[2]
  30779. //card_sn := bas[3]
  30780. var rf []*ResultFive
  30781. json.Unmarshal([]byte(his.Iinfo), &rf)
  30782. var psn_type string
  30783. for _, item := range rf {
  30784. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30785. psn_type = item.PsnType
  30786. }
  30787. }
  30788. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30789. 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)
  30790. }
  30791. var dat map[string]interface{}
  30792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30793. fmt.Println(dat)
  30794. } else {
  30795. fmt.Println(err)
  30796. }
  30797. saveLog(result, request_log, "2206", "预结算")
  30798. userJSONBytes, _ := json.Marshal(dat)
  30799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30800. utils.ErrorLog("解析失败:%v", err)
  30801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30802. return
  30803. }
  30804. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30805. var result string
  30806. var request_log string
  30807. if his.IdCardType == 2 {
  30808. insutype = strconv.FormatInt(his.SocialType, 10)
  30809. 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, "")
  30810. } else if his.IdCardType == 1 {
  30811. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30812. bas := strings.Split(psn_info.CardInfo, "|")
  30813. basNumber := bas[0]
  30814. card_sn := ""
  30815. var rf []*ResultFive
  30816. json.Unmarshal([]byte(his.Iinfo), &rf)
  30817. var psn_type string
  30818. for _, item := range rf {
  30819. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30820. psn_type = item.PsnType
  30821. }
  30822. }
  30823. insutype = strconv.FormatInt(his.SocialType, 10)
  30824. 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)
  30825. } else {
  30826. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30827. //bas := strings.Split(psn_info.CardInfo, "|")
  30828. //basNumber := bas[2]
  30829. //card_sn := bas[3]
  30830. var rf []*ResultFive
  30831. json.Unmarshal([]byte(his.Iinfo), &rf)
  30832. var psn_type string
  30833. for _, item := range rf {
  30834. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30835. psn_type = item.PsnType
  30836. }
  30837. }
  30838. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30839. 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)
  30840. }
  30841. var dat map[string]interface{}
  30842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30843. fmt.Println(dat)
  30844. } else {
  30845. fmt.Println(err)
  30846. }
  30847. saveLog(result, request_log, "2206", "预结算")
  30848. userJSONBytes, _ := json.Marshal(dat)
  30849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30850. utils.ErrorLog("解析失败:%v", err)
  30851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30852. return
  30853. }
  30854. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30855. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30856. if his.IdCardType == 4 {
  30857. psn_info.VerifyNumber = psn_info.VerifyNumber
  30858. cert_no = psn_info.VerifyNumber
  30859. } else if his.IdCardType == 2 {
  30860. cert_no = psn_info.Certno
  30861. psn_info.VerifyNumber = psn_info.Certno
  30862. } else {
  30863. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30864. bas := strings.Split(psn_info.CardInfo, "|")
  30865. if his.IdCardType == 1 {
  30866. cert_no = bas[2]
  30867. } else {
  30868. cert_no = bas[1]
  30869. }
  30870. }
  30871. var api string
  30872. var med_type string
  30873. if his.Insutype == "390" {
  30874. if reg_type == 992102 {
  30875. med_type = "992102"
  30876. }
  30877. if reg_type == 140104 {
  30878. med_type = "140104"
  30879. }
  30880. if reg_type == 140201 {
  30881. med_type = "140201"
  30882. }
  30883. if reg_type == 14 {
  30884. med_type = "140104"
  30885. }
  30886. } else if his.Insutype == "310" {
  30887. if reg_type == 992102 {
  30888. med_type = "992102"
  30889. }
  30890. if reg_type == 140104 {
  30891. med_type = "140104"
  30892. }
  30893. if reg_type == 140201 {
  30894. med_type = "140201"
  30895. }
  30896. if reg_type == 14 {
  30897. med_type = "140104"
  30898. }
  30899. }
  30900. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30901. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30902. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30903. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30904. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30905. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30906. "&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
  30907. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30908. resp, requestErr := http.Get(api)
  30909. if requestErr != nil {
  30910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30911. return
  30912. }
  30913. body, ioErr := ioutil.ReadAll(resp.Body)
  30914. if ioErr != nil {
  30915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30917. return
  30918. }
  30919. var respJSON map[string]interface{}
  30920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30923. return
  30924. }
  30925. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30926. if status == "0" {
  30927. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30928. c.ServeSuccessJSON(map[string]interface{}{
  30929. "failed_code": -10,
  30930. "msg": err_msg,
  30931. })
  30932. return
  30933. }
  30934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30935. result, _ := json.Marshal(respJSON)
  30936. fmt.Println("log")
  30937. fmt.Println(string(result))
  30938. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30939. utils.ErrorLog("解析失败:%v", err)
  30940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30941. return
  30942. }
  30943. res.InfRefmsgid = ahres.InfRefmsgid
  30944. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30945. // 创建对应的Time类型
  30946. t := time.UnixMilli(timestamp)
  30947. // 格式化成指定的日期字符串
  30948. str := t.Format("2006-01-02 15:04:05")
  30949. res.Output.Setlinfo.SetlTime = str
  30950. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30951. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30952. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30953. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30954. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30955. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30956. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30957. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30958. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30959. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30960. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30961. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30962. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30963. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30964. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30965. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30966. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30967. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30968. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30969. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30970. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30971. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30972. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30973. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30974. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30975. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30976. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30977. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30978. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30979. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30980. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30981. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30982. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30983. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30984. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30985. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30986. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30987. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30988. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30989. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30990. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30991. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30992. //res.Output.Setldetail = ahres.Output.Setldetail
  30993. res.ErrMsg = ahres.ErrMsg
  30994. res.Cainfo = ahres.Cainfo
  30995. res.WarnMsg = ahres.WarnMsg
  30996. res.Infcode = ahres.Infcode
  30997. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30998. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30999. if his.IdCardType == 4 {
  31000. psn_info.VerifyNumber = psn_info.VerifyNumber
  31001. cert_no = psn_info.Certno
  31002. } else if his.IdCardType == 2 {
  31003. cert_no = psn_info.Certno
  31004. psn_info.VerifyNumber = psn_info.Certno
  31005. } else {
  31006. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31007. bas := strings.Split(psn_info.CardInfo, "|")
  31008. if his.IdCardType == 1 {
  31009. cert_no = bas[2]
  31010. } else {
  31011. cert_no = bas[1]
  31012. }
  31013. }
  31014. var api string
  31015. var med_type string
  31016. if his.Insutype == "390" {
  31017. if reg_type == 992102 {
  31018. med_type = "992102"
  31019. }
  31020. if reg_type == 140104 {
  31021. med_type = "140104"
  31022. }
  31023. if reg_type == 140201 {
  31024. med_type = "140201"
  31025. }
  31026. if reg_type == 14 {
  31027. med_type = "14"
  31028. }
  31029. } else if his.Insutype == "310" {
  31030. if reg_type == 992102 {
  31031. med_type = "992102"
  31032. }
  31033. if reg_type == 140104 {
  31034. med_type = "140104"
  31035. }
  31036. if reg_type == 140201 {
  31037. med_type = "140201"
  31038. }
  31039. if reg_type == 14 {
  31040. med_type = "14"
  31041. }
  31042. }
  31043. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31044. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31045. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31047. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31048. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31049. "&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
  31050. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31051. resp, requestErr := http.Get(api)
  31052. if requestErr != nil {
  31053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31054. return
  31055. }
  31056. body, ioErr := ioutil.ReadAll(resp.Body)
  31057. if ioErr != nil {
  31058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31060. return
  31061. }
  31062. var respJSON map[string]interface{}
  31063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31066. return
  31067. }
  31068. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31069. if status == "0" {
  31070. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31071. c.ServeSuccessJSON(map[string]interface{}{
  31072. "failed_code": -10,
  31073. "msg": err_msg,
  31074. })
  31075. return
  31076. }
  31077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31078. result, _ := json.Marshal(respJSON)
  31079. fmt.Println("log")
  31080. fmt.Println(string(result))
  31081. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31082. utils.ErrorLog("解析失败:%v", err)
  31083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31084. return
  31085. }
  31086. res.InfRefmsgid = ahres.InfRefmsgid
  31087. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31088. // 创建对应的Time类型
  31089. t := time.UnixMilli(timestamp)
  31090. // 格式化成指定的日期字符串
  31091. str := t.Format("2006-01-02 15:04:05")
  31092. res.Output.Setlinfo.SetlTime = str
  31093. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31094. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31095. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31096. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31097. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31098. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31099. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31100. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31101. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31102. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31103. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31104. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31105. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31106. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31107. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31108. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31109. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31110. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31111. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31112. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31113. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31114. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31115. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31116. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31117. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31118. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31119. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31120. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31121. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31122. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31123. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31124. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31125. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31126. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31127. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31128. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31129. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31130. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31131. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31132. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31133. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31134. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31135. //res.Output.Setldetail = ahres.Output.Setldetail
  31136. res.ErrMsg = ahres.ErrMsg
  31137. res.Cainfo = ahres.Cainfo
  31138. res.WarnMsg = ahres.WarnMsg
  31139. res.Infcode = ahres.Infcode
  31140. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31141. var result string
  31142. var request_log string
  31143. if his.IdCardType == 2 {
  31144. 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")
  31145. } else if his.IdCardType == 1 {
  31146. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31147. bas := strings.Split(psn_info.CardInfo, "|")
  31148. basNumber := bas[2]
  31149. card_sn := bas[3]
  31150. 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")
  31151. } else {
  31152. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31153. 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")
  31154. }
  31155. var dat map[string]interface{}
  31156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31157. fmt.Println(dat)
  31158. } else {
  31159. fmt.Println(err)
  31160. }
  31161. saveLog(result, request_log, "2206", "预结算")
  31162. userJSONBytes, _ := json.Marshal(dat)
  31163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31164. utils.ErrorLog("解析失败:%v", err)
  31165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31166. return
  31167. }
  31168. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31169. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31170. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31171. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31172. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31173. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31174. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31175. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31176. resp, requestErr := http.Get(api)
  31177. if requestErr != nil {
  31178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31179. return
  31180. }
  31181. body, ioErr := ioutil.ReadAll(resp.Body)
  31182. if ioErr != nil {
  31183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31185. return
  31186. }
  31187. var respJSON map[string]interface{}
  31188. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31191. return
  31192. }
  31193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31194. result, _ := json.Marshal(respJSON)
  31195. fmt.Println("log")
  31196. fmt.Println(string(result))
  31197. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31198. utils.ErrorLog("解析失败:%v", err)
  31199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31200. return
  31201. }
  31202. } else {
  31203. if miConfig.MdtrtareaAdmvs == "441202" {
  31204. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31205. if result3101.Infcode == 0 {
  31206. if len(result3101.Output.Result) > 0 {
  31207. c.ServeSuccessJSON(map[string]interface{}{
  31208. "failed_code": -10,
  31209. "failed_type": 100,
  31210. "msg": result3101.Output.Result,
  31211. })
  31212. return
  31213. } else {
  31214. var result string
  31215. var request_log string
  31216. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31217. allTotal = fmt.Sprintf("%.2f", total_two)
  31218. if his.IdCardType == 4 {
  31219. 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)
  31220. } else {
  31221. 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)
  31222. }
  31223. var dat map[string]interface{}
  31224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31225. fmt.Println(dat)
  31226. } else {
  31227. fmt.Println(err)
  31228. }
  31229. saveLog(result, request_log, "2206", "预结算")
  31230. //userJSONBytes, _ := json.Marshal(dat)
  31231. //
  31232. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31233. // utils.ErrorLog("解析失败:%v", err)
  31234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31235. // return
  31236. //}
  31237. userJSONBytes, _ := json.Marshal(dat)
  31238. if miConfig.Code == "H15049901371" {
  31239. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31240. utils.ErrorLog("解析失败:%v", err)
  31241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31242. return
  31243. }
  31244. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31245. res.Output = resSeven10265.Output
  31246. res.ErrMsg = resSeven10265.ErrMsg
  31247. res.Cainfo = resSeven10265.Cainfo
  31248. res.WarnMsg = resSeven10265.WarnMsg
  31249. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31250. res.Infcode = infocode
  31251. } else {
  31252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31253. utils.ErrorLog("解析失败:%v", err)
  31254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31255. return
  31256. }
  31257. }
  31258. }
  31259. } else {
  31260. c.ServeSuccessJSON(map[string]interface{}{
  31261. "failed_code": -10,
  31262. "msg": result3101.ErrMsg,
  31263. })
  31264. return
  31265. }
  31266. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31267. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31268. if result3101.Infcode == 0 {
  31269. if len(result3101.Output.Result) > 0 {
  31270. var errMsgs []string
  31271. for _, item := range result3101.Output.Result {
  31272. errMsgs = append(errMsgs, item.VolaCont)
  31273. }
  31274. c.ServeSuccessJSON(map[string]interface{}{
  31275. "failed_code": -10,
  31276. "msg": errMsgs,
  31277. })
  31278. return
  31279. } else {
  31280. var result string
  31281. var request_log string
  31282. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31283. allTotal = fmt.Sprintf("%.2f", total_two)
  31284. if his.IdCardType == 4 {
  31285. 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)
  31286. } else {
  31287. 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)
  31288. }
  31289. var dat map[string]interface{}
  31290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31291. fmt.Println(dat)
  31292. } else {
  31293. fmt.Println(err)
  31294. }
  31295. saveLog(result, request_log, "2206", "预结算")
  31296. //userJSONBytes, _ := json.Marshal(dat)
  31297. //
  31298. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31299. // utils.ErrorLog("解析失败:%v", err)
  31300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31301. // return
  31302. //}
  31303. userJSONBytes, _ := json.Marshal(dat)
  31304. if miConfig.Code == "H15049901371" {
  31305. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31306. utils.ErrorLog("解析失败:%v", err)
  31307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31308. return
  31309. }
  31310. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31311. res.Output = resSeven10265.Output
  31312. res.ErrMsg = resSeven10265.ErrMsg
  31313. res.Cainfo = resSeven10265.Cainfo
  31314. res.WarnMsg = resSeven10265.WarnMsg
  31315. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31316. res.Infcode = infocode
  31317. } else {
  31318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31319. utils.ErrorLog("解析失败:%v", err)
  31320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31321. return
  31322. }
  31323. }
  31324. }
  31325. } else {
  31326. c.ServeSuccessJSON(map[string]interface{}{
  31327. "failed_code": -10,
  31328. "msg": result3101.ErrMsg,
  31329. })
  31330. return
  31331. }
  31332. } else {
  31333. var result string
  31334. var request_log string
  31335. var dat map[string]interface{}
  31336. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31337. allTotal = fmt.Sprintf("%.2f", total_two)
  31338. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  31339. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31340. if result3101.Infcode == 0 {
  31341. if len(result3101.Output.Result) > 0 {
  31342. c.ServeSuccessJSON(map[string]interface{}{
  31343. "failed_code": -10,
  31344. "failed_type": 100,
  31345. "warm_type": 2,
  31346. "msg": result3101.Output.Result,
  31347. })
  31348. return
  31349. } else {
  31350. var result string
  31351. var request_log string
  31352. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31353. allTotal = fmt.Sprintf("%.2f", total_two)
  31354. if his.IdCardType == 4 {
  31355. 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)
  31356. } else {
  31357. if his.IdCardType == 2 {
  31358. cert_no = psn_info.Certno
  31359. psn_info.VerifyNumber = psn_info.Certno
  31360. } else {
  31361. bas := strings.Split(psn_info.CardInfo, "|")
  31362. cert_no = bas[2]
  31363. }
  31364. 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)
  31365. }
  31366. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31367. fmt.Println(dat)
  31368. } else {
  31369. fmt.Println(err)
  31370. }
  31371. saveLog(result, request_log, "2206", "预结算")
  31372. }
  31373. } else {
  31374. c.ServeSuccessJSON(map[string]interface{}{
  31375. "failed_code": -10,
  31376. "msg": result3101.ErrMsg,
  31377. })
  31378. return
  31379. }
  31380. } else {
  31381. if his.IdCardType == 4 {
  31382. 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)
  31383. } else {
  31384. if his.IdCardType == 2 {
  31385. cert_no = psn_info.Certno
  31386. psn_info.VerifyNumber = psn_info.Certno
  31387. } else {
  31388. bas := strings.Split(psn_info.CardInfo, "|")
  31389. cert_no = bas[2]
  31390. }
  31391. 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)
  31392. }
  31393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31394. fmt.Println(dat)
  31395. } else {
  31396. fmt.Println(err)
  31397. }
  31398. saveLog(result, request_log, "2206", "预结算")
  31399. }
  31400. //userJSONBytes, _ := json.Marshal(dat)
  31401. //
  31402. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31403. // utils.ErrorLog("解析失败:%v", err)
  31404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31405. // return
  31406. //}
  31407. userJSONBytes, _ := json.Marshal(dat)
  31408. if miConfig.Code == "H15049901371" {
  31409. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31410. utils.ErrorLog("解析失败:%v", err)
  31411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31412. return
  31413. }
  31414. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31415. res.Output = resSeven10265.Output
  31416. res.ErrMsg = resSeven10265.ErrMsg
  31417. res.Cainfo = resSeven10265.Cainfo
  31418. res.WarnMsg = resSeven10265.WarnMsg
  31419. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31420. res.Infcode = infocode
  31421. } else {
  31422. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31423. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  31424. utils.ErrorLog("解析失败:%v", err)
  31425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31426. return
  31427. }
  31428. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  31429. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  31430. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  31431. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  31432. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  31433. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  31434. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  31435. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31436. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  31437. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31438. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31439. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31440. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31441. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  31442. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31443. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  31444. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  31445. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  31446. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  31447. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  31448. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31449. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  31450. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  31451. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  31452. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  31453. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  31454. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  31455. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  31456. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  31457. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31458. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  31459. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  31460. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  31461. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31462. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31463. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31464. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31465. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  31466. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31467. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  31468. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  31469. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  31470. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  31471. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  31472. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  31473. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  31474. res.ErrMsg = gzresSeven10265Two.ErrMsg
  31475. res.Cainfo = gzresSeven10265Two.Cainfo
  31476. res.WarnMsg = gzresSeven10265Two.WarnMsg
  31477. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31478. //res.Infcode = infocode
  31479. } else {
  31480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31481. utils.ErrorLog("解析失败:%v", err)
  31482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31483. return
  31484. }
  31485. }
  31486. }
  31487. }
  31488. }
  31489. utils.ErrorLog("解析失败:%v", res.Infcode)
  31490. if res.Infcode == -1 {
  31491. errlog := &models.HisOrderError{
  31492. UserOrgId: adminUser.CurrentOrgId,
  31493. Ctime: time.Now().Unix(),
  31494. Mtime: time.Now().Unix(),
  31495. Number: chrg_bchno,
  31496. ErrMsg: res.ErrMsg,
  31497. Status: 1,
  31498. PatientId: id,
  31499. RecordTime: recordDateTime,
  31500. Stage: 20,
  31501. }
  31502. service.CreateErrMsgLog(errlog)
  31503. c.ServeSuccessJSON(map[string]interface{}{
  31504. "failed_code": -10,
  31505. "msg": res.ErrMsg,
  31506. })
  31507. return
  31508. }
  31509. if res.Infcode != 0 {
  31510. errlog := &models.HisOrderError{
  31511. UserOrgId: adminUser.CurrentOrgId,
  31512. Ctime: time.Now().Unix(),
  31513. Mtime: time.Now().Unix(),
  31514. Number: chrg_bchno,
  31515. ErrMsg: res.ErrMsg,
  31516. Status: 1,
  31517. PatientId: id,
  31518. RecordTime: recordDateTime,
  31519. Stage: 20,
  31520. }
  31521. service.CreateErrMsgLog(errlog)
  31522. c.ServeSuccessJSON(map[string]interface{}{
  31523. "failed_code": -10,
  31524. "msg": res.ErrMsg,
  31525. })
  31526. return
  31527. } else {
  31528. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  31529. order.OrderStatus = 1
  31530. order.IsPre = 1
  31531. order.Status = 1
  31532. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  31533. order.SetlId = res.Output.Setlinfo.SetlID
  31534. order.PsnNo = res.Output.Setlinfo.PsnNo
  31535. order.PsnName = res.Output.Setlinfo.PsnName
  31536. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  31537. order.Certno = res.Output.Setlinfo.Certno
  31538. order.Gend = res.Output.Setlinfo.Gend
  31539. order.Naty = res.Output.Setlinfo.Naty
  31540. order.Age = res.Output.Setlinfo.Age
  31541. order.Insutype = res.Output.Setlinfo.Insutype
  31542. order.PsnType = res.Output.Setlinfo.PsnType
  31543. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  31544. order.SetlTime = res.Output.Setlinfo.SetlTime
  31545. order.AcctUsedFlag = acct_used_flag
  31546. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  31547. if res.Output.Setlinfo.MedType == "140101" {
  31548. order.MedType = "14"
  31549. } else {
  31550. if res.Output.Setlinfo.MedType == "110104" {
  31551. order.MedType = "11"
  31552. } else {
  31553. order.MedType = res.Output.Setlinfo.MedType
  31554. }
  31555. }
  31556. if res.Output.Setlinfo.MedType == "992102" {
  31557. order.MedType = "992102"
  31558. }
  31559. if res.Output.Setlinfo.MedType == "140104" {
  31560. order.MedType = "140104"
  31561. }
  31562. if res.Output.Setlinfo.MedType == "140201" {
  31563. order.MedType = "140201"
  31564. }
  31565. if res.Output.Setlinfo.MedType == "14" {
  31566. order.MedType = "14"
  31567. }
  31568. if reg_type == 1112 {
  31569. order.MedType = "1112"
  31570. }
  31571. if reg_type == 1111 {
  31572. order.MedType = "1111"
  31573. }
  31574. order.ClrType = res.Output.Setlinfo.ClrType
  31575. if adminUser.CurrentOrgId == 10480 {
  31576. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  31577. order.ClrType = "11"
  31578. } else {
  31579. order.ClrType = "9903"
  31580. }
  31581. }
  31582. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  31583. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  31584. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  31585. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  31586. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  31587. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  31588. order.HifpPay = res.Output.Setlinfo.HifpPay
  31589. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  31590. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  31591. order.HifesPay = res.Output.Setlinfo.HifesPay
  31592. order.HifobPay = res.Output.Setlinfo.HifobPay
  31593. order.MafPay = res.Output.Setlinfo.MafPay
  31594. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  31595. order.OthPay = res.Output.Setlinfo.OthPay
  31596. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  31597. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  31598. order.AcctPay = res.Output.Setlinfo.AcctPay
  31599. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  31600. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  31601. order.Balc = res.Output.Setlinfo.Balc
  31602. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  31603. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  31604. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  31605. order.ClrWay = res.Output.Setlinfo.ClrWay
  31606. order.Creator = order.Creator
  31607. order.Modify = roles.AdminUserId
  31608. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  31609. //detailStr := string(setlDetail)
  31610. //order.SetlDetail = detailStr
  31611. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  31612. err = service.UpDateOrder(order)
  31613. if err == nil {
  31614. c.ServeSuccessJSON(map[string]interface{}{
  31615. "msg": "预结算成功",
  31616. })
  31617. } else {
  31618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  31619. return
  31620. }
  31621. }
  31622. } else {
  31623. adminUser := c.GetAdminUserInfo()
  31624. errlog := &models.HisOrderError{
  31625. UserOrgId: adminUser.CurrentOrgId,
  31626. Ctime: time.Now().Unix(),
  31627. Mtime: time.Now().Unix(),
  31628. ErrMsg: res.ErrMsg,
  31629. Status: 1,
  31630. PatientId: id,
  31631. RecordTime: recordDateTime,
  31632. Stage: 4,
  31633. }
  31634. service.CreateErrMsgLog(errlog)
  31635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31636. return
  31637. }
  31638. } else {
  31639. if miConfig.MdtrtareaAdmvs == "150499" {
  31640. order := &models.HisOrder{
  31641. UserOrgId: adminUser.CurrentOrgId,
  31642. HisPatientId: his.ID,
  31643. PatientId: his.PatientId,
  31644. SettleAccountsDate: recordDateTime,
  31645. Ctime: time.Now().Unix(),
  31646. Mtime: time.Now().Unix(),
  31647. MdtrtId: his.Number,
  31648. PsnNo: his.PsnNo,
  31649. MedType: strconv.FormatInt(reg_type, 10),
  31650. Status: 1,
  31651. Number: chrg_bchno,
  31652. Infcode: res.Infcode,
  31653. WarnMsg: res.WarnMsg,
  31654. Cainfo: res.Cainfo,
  31655. ErrMsg: res.ErrMsg,
  31656. RespondTime: res.RefmsgTime,
  31657. InfRefmsgid: res.InfRefmsgid,
  31658. OrderStatus: 1,
  31659. IsMedicineInsurance: 1,
  31660. SettleType: settle_accounts_type,
  31661. SettleStartTime: start_time,
  31662. SettleEndTime: end_time,
  31663. Creator: roles.AdminUserId,
  31664. Modify: roles.AdminUserId,
  31665. PType: 2,
  31666. Diagnosis: diagnosis_id,
  31667. }
  31668. err = service.CreateOrder(order)
  31669. if err != nil {
  31670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31671. return
  31672. }
  31673. }
  31674. adminUser := c.GetAdminUserInfo()
  31675. errlog := &models.HisOrderError{
  31676. UserOrgId: adminUser.CurrentOrgId,
  31677. Ctime: time.Now().Unix(),
  31678. Mtime: time.Now().Unix(),
  31679. ErrMsg: res.ErrMsg,
  31680. Status: 1,
  31681. PatientId: id,
  31682. RecordTime: recordDateTime,
  31683. Stage: 4,
  31684. }
  31685. service.CreateErrMsgLog(errlog)
  31686. c.ServeSuccessJSON(map[string]interface{}{
  31687. "failed_code": -10,
  31688. "msg": res.ErrMsg,
  31689. })
  31690. return
  31691. }
  31692. }
  31693. }
  31694. }
  31695. // 退款
  31696. func (c *HisApiController) Refund() {
  31697. order_id, _ := c.GetInt64("order_id")
  31698. admin_user_id, _ := c.GetInt64("admin_user_id")
  31699. adminUser := c.GetAdminUserInfo()
  31700. var order models.HisOrder
  31701. order, _ = service.GetHisOrderByID(order_id)
  31702. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31703. if fapiao.ID > 0 {
  31704. c.ServeSuccessJSON(map[string]interface{}{
  31705. "failed_code": -10,
  31706. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31707. })
  31708. return
  31709. }
  31710. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31711. if order.ID == 0 {
  31712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31713. return
  31714. }
  31715. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31716. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31717. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31718. if config.IsOpen == 1 { //对接了医保,走医保流程
  31719. var res ResultSixteen
  31720. var ahres ResultSevenAH
  31721. var resSixteen10265 ResultSixteen10265
  31722. var resSixteen10265Two ResultSixteen10265Two
  31723. var gz ResultgzSixteen10265Two
  31724. var src_resquest string
  31725. var result string
  31726. if miConfig.MdtrtareaAdmvs == "421300" {
  31727. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31728. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31729. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31730. resp3, requestErr3 := http.Get(api3)
  31731. if requestErr3 != nil {
  31732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31733. return
  31734. }
  31735. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31736. if ioErr3 != nil {
  31737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31739. return
  31740. }
  31741. var respJSON3 map[string]interface{}
  31742. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31745. return
  31746. }
  31747. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31748. userJSONBytes3, _ := json.Marshal(respJSON3)
  31749. fmt.Println("log")
  31750. fmt.Println(string(userJSONBytes3))
  31751. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31752. utils.ErrorLog("解析失败:%v", err)
  31753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31754. return
  31755. }
  31756. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31757. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31758. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31759. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31760. resp3, requestErr3 := http.Get(api3)
  31761. if requestErr3 != nil {
  31762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31763. return
  31764. }
  31765. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31766. if ioErr3 != nil {
  31767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31769. return
  31770. }
  31771. var respJSON3 map[string]interface{}
  31772. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31775. return
  31776. }
  31777. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31778. userJSONBytes3, _ := json.Marshal(respJSON3)
  31779. fmt.Println("log")
  31780. fmt.Println(string(userJSONBytes3))
  31781. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31782. utils.ErrorLog("解析失败:%v", err)
  31783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31784. return
  31785. }
  31786. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31787. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31788. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31789. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31790. resp3, requestErr3 := http.Get(api3)
  31791. if requestErr3 != nil {
  31792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31793. return
  31794. }
  31795. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31796. if ioErr3 != nil {
  31797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31799. return
  31800. }
  31801. var respJSON3 map[string]interface{}
  31802. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31805. return
  31806. }
  31807. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31808. userJSONBytes3, _ := json.Marshal(respJSON3)
  31809. fmt.Println("log")
  31810. fmt.Println(string(userJSONBytes3))
  31811. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31812. utils.ErrorLog("解析失败:%v", err)
  31813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31814. return
  31815. }
  31816. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31817. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31818. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31819. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31820. resp3, requestErr3 := http.Get(api3)
  31821. if requestErr3 != nil {
  31822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31823. return
  31824. }
  31825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31826. if ioErr3 != nil {
  31827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31829. return
  31830. }
  31831. var respJSON3 map[string]interface{}
  31832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31835. return
  31836. }
  31837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31838. userJSONBytes3, _ := json.Marshal(respJSON3)
  31839. fmt.Println("log")
  31840. fmt.Println(string(userJSONBytes3))
  31841. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31842. utils.ErrorLog("解析失败:%v", err)
  31843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31844. return
  31845. }
  31846. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31847. var api3 string
  31848. if miConfig.MdtrtareaAdmvs == "320921" {
  31849. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31850. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31851. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31852. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31853. } else {
  31854. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31855. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31856. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31857. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31858. }
  31859. resp3, requestErr3 := http.Get(api3)
  31860. if requestErr3 != nil {
  31861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31862. return
  31863. }
  31864. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31865. if ioErr3 != nil {
  31866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31868. return
  31869. }
  31870. var respJSON3 map[string]interface{}
  31871. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31874. return
  31875. }
  31876. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31877. userJSONBytes3, _ := json.Marshal(respJSON3)
  31878. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31879. utils.ErrorLog("解析失败:%v", err)
  31880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31881. return
  31882. }
  31883. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31884. res.Output = resSixteen10265.Output
  31885. res.ErrMsg = resSixteen10265.ErrMsg
  31886. res.Cainfo = resSixteen10265.Cainfo
  31887. res.WarnMsg = resSixteen10265.WarnMsg
  31888. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31889. res.Infcode = infocode
  31890. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31891. var api3 string
  31892. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31893. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31894. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31895. resp3, requestErr3 := http.Get(api3)
  31896. if requestErr3 != nil {
  31897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31898. return
  31899. }
  31900. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31901. if ioErr3 != nil {
  31902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31904. return
  31905. }
  31906. var respJSON3 map[string]interface{}
  31907. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31910. return
  31911. }
  31912. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31913. userJSONBytes3, _ := json.Marshal(respJSON3)
  31914. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31915. utils.ErrorLog("解析失败:%v", err)
  31916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31917. return
  31918. }
  31919. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31920. res.Output = resSixteen10265.Output
  31921. res.ErrMsg = resSixteen10265.ErrMsg
  31922. res.Cainfo = resSixteen10265.Cainfo
  31923. res.WarnMsg = resSixteen10265.WarnMsg
  31924. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31925. res.Infcode = infocode
  31926. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31927. 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)
  31928. var dat map[string]interface{}
  31929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31930. fmt.Println(dat)
  31931. } else {
  31932. fmt.Println(err)
  31933. }
  31934. saveLog(result, src_resquest, "2208", "退费")
  31935. userJSONBytes, _ := json.Marshal(dat)
  31936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31937. utils.ErrorLog("解析失败:%v", err)
  31938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31939. return
  31940. }
  31941. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31942. 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, "")
  31943. var dat map[string]interface{}
  31944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31945. fmt.Println(dat)
  31946. } else {
  31947. fmt.Println(err)
  31948. }
  31949. saveLog(result, src_resquest, "2208", "退费")
  31950. userJSONBytes, _ := json.Marshal(dat)
  31951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31952. utils.ErrorLog("解析失败:%v", err)
  31953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31954. return
  31955. }
  31956. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31957. 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, "")
  31958. var dat map[string]interface{}
  31959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31960. fmt.Println(dat)
  31961. } else {
  31962. fmt.Println(err)
  31963. }
  31964. saveLog(result, src_resquest, "2208", "退费")
  31965. userJSONBytes, _ := json.Marshal(dat)
  31966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31967. utils.ErrorLog("解析失败:%v", err)
  31968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31969. return
  31970. }
  31971. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31972. 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, "")
  31973. var dat map[string]interface{}
  31974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31975. fmt.Println(dat)
  31976. } else {
  31977. fmt.Println(err)
  31978. }
  31979. saveLog(result, src_resquest, "2208", "退费")
  31980. userJSONBytes, _ := json.Marshal(dat)
  31981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31982. utils.ErrorLog("解析失败:%v", err)
  31983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31984. return
  31985. }
  31986. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31987. var api3 string
  31988. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31989. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31991. resp3, requestErr3 := http.Get(api3)
  31992. if requestErr3 != nil {
  31993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31994. return
  31995. }
  31996. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31997. if ioErr3 != nil {
  31998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32000. return
  32001. }
  32002. var respJSON3 map[string]interface{}
  32003. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32006. return
  32007. }
  32008. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32009. if status == "0" {
  32010. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32011. c.ServeSuccessJSON(map[string]interface{}{
  32012. "failed_code": -10,
  32013. "msg": err_msg,
  32014. })
  32015. return
  32016. }
  32017. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32018. userJSONBytes3, _ := json.Marshal(respJSON3)
  32019. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32020. // utils.ErrorLog("解析失败:%v", err)
  32021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32022. // return
  32023. //}
  32024. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32025. utils.ErrorLog("解析失败:%v", err)
  32026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32027. return
  32028. }
  32029. res.InfRefmsgid = ahres.InfRefmsgid
  32030. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32031. // 创建对应的Time类型
  32032. t := time.UnixMilli(timestamp)
  32033. // 格式化成指定的日期字符串
  32034. str := t.Format("2006-01-02 15:04:05")
  32035. res.Output.Setlinfo.SetlTime = str
  32036. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32037. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32038. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32039. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32040. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32041. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32042. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32043. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32044. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32045. //
  32046. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32047. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32048. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32049. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32050. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32051. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32052. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32053. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32054. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32055. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32056. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32057. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32058. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32059. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32060. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32061. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32062. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32063. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32064. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32065. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32066. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32067. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32068. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32069. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32070. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32071. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32072. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32073. //res.Output.Setldetail = ahres.Output.Setldetail
  32074. res.ErrMsg = ahres.ErrMsg
  32075. res.Cainfo = ahres.Cainfo
  32076. res.WarnMsg = ahres.WarnMsg
  32077. res.Infcode = ahres.Infcode
  32078. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32079. var api3 string
  32080. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32081. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32083. resp3, requestErr3 := http.Get(api3)
  32084. if requestErr3 != nil {
  32085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32086. return
  32087. }
  32088. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32089. if ioErr3 != nil {
  32090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32092. return
  32093. }
  32094. var respJSON3 map[string]interface{}
  32095. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32098. return
  32099. }
  32100. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32101. if status == "0" {
  32102. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32103. c.ServeSuccessJSON(map[string]interface{}{
  32104. "failed_code": -10,
  32105. "msg": err_msg,
  32106. })
  32107. return
  32108. }
  32109. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32110. userJSONBytes3, _ := json.Marshal(respJSON3)
  32111. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32112. // utils.ErrorLog("解析失败:%v", err)
  32113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32114. // return
  32115. //}
  32116. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32117. utils.ErrorLog("解析失败:%v", err)
  32118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32119. return
  32120. }
  32121. res.InfRefmsgid = ahres.InfRefmsgid
  32122. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32123. // 创建对应的Time类型
  32124. t := time.UnixMilli(timestamp)
  32125. // 格式化成指定的日期字符串
  32126. str := t.Format("2006-01-02 15:04:05")
  32127. res.Output.Setlinfo.SetlTime = str
  32128. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32129. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32130. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32131. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32132. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32133. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32134. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32135. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32136. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32137. //
  32138. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32139. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32140. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32141. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32142. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32143. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32144. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32145. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32146. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32147. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32148. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32149. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32150. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32151. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32152. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32153. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32154. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32155. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32156. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32157. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32158. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32159. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32160. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32161. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32162. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32163. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32164. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32165. //res.Output.Setldetail = ahres.Output.Setldetail
  32166. res.ErrMsg = ahres.ErrMsg
  32167. res.Cainfo = ahres.Cainfo
  32168. res.WarnMsg = ahres.WarnMsg
  32169. res.Infcode = ahres.Infcode
  32170. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32171. 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, "")
  32172. var dat map[string]interface{}
  32173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32174. fmt.Println(dat)
  32175. } else {
  32176. fmt.Println(err)
  32177. }
  32178. saveLog(result, src_resquest, "2208", "退费")
  32179. userJSONBytes, _ := json.Marshal(dat)
  32180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32181. utils.ErrorLog("解析失败:%v", err)
  32182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32183. return
  32184. }
  32185. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32186. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  32187. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32189. resp3, requestErr3 := http.Get(api3)
  32190. if requestErr3 != nil {
  32191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32192. return
  32193. }
  32194. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32195. if ioErr3 != nil {
  32196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32198. return
  32199. }
  32200. var respJSON3 map[string]interface{}
  32201. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32204. return
  32205. }
  32206. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32207. userJSONBytes3, _ := json.Marshal(respJSON3)
  32208. fmt.Println("log")
  32209. fmt.Println(string(userJSONBytes3))
  32210. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32211. utils.ErrorLog("解析失败:%v", err)
  32212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32213. return
  32214. }
  32215. } else {
  32216. if miConfig.Code == "H15049901371" {
  32217. 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)
  32218. var dat map[string]interface{}
  32219. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32220. fmt.Println(dat)
  32221. } else {
  32222. fmt.Println(err)
  32223. }
  32224. saveLog(result, src_resquest, "2208", "退费")
  32225. if strings.Contains(result, "Post") {
  32226. res.Infcode = -1
  32227. res.ErrMsg = result
  32228. }
  32229. userJSONBytes, _ := json.Marshal(dat)
  32230. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  32231. utils.ErrorLog("解析失败:%v", err)
  32232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32233. return
  32234. }
  32235. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32236. res.Output = resSixteen10265.Output
  32237. res.ErrMsg = resSixteen10265.ErrMsg
  32238. res.Cainfo = resSixteen10265.Cainfo
  32239. res.WarnMsg = resSixteen10265.WarnMsg
  32240. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32241. res.Infcode = infocode
  32242. } else {
  32243. 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)
  32244. var dat map[string]interface{}
  32245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32246. fmt.Println(dat)
  32247. } else {
  32248. fmt.Println(err)
  32249. }
  32250. saveLog(result, src_resquest, "2208", "退费")
  32251. userJSONBytes, _ := json.Marshal(dat)
  32252. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32253. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  32254. utils.ErrorLog("解析失败:%v", err)
  32255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32256. return
  32257. }
  32258. res.Infcode = gz.Infcode
  32259. } else {
  32260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32261. utils.ErrorLog("解析失败:%v", err)
  32262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32263. return
  32264. }
  32265. }
  32266. if strings.Contains(result, "Post") {
  32267. res.Infcode = -1
  32268. res.ErrMsg = result
  32269. }
  32270. }
  32271. }
  32272. if res.Infcode == -1 {
  32273. c.ServeSuccessJSON(map[string]interface{}{
  32274. "failed_code": -10,
  32275. "msg": res.ErrMsg,
  32276. })
  32277. return
  32278. }
  32279. if res.Infcode != -1 {
  32280. var res2 ResultSix
  32281. var resSix10265 ResultSix10265
  32282. if miConfig.MdtrtareaAdmvs == "421300" {
  32283. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32284. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32286. resp3, requestErr3 := http.Get(api3)
  32287. if requestErr3 != nil {
  32288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32289. return
  32290. }
  32291. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32292. if ioErr3 != nil {
  32293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32295. return
  32296. }
  32297. var respJSON3 map[string]interface{}
  32298. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32301. return
  32302. }
  32303. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32304. userJSONBytes3, _ := json.Marshal(respJSON3)
  32305. fmt.Println("log")
  32306. fmt.Println(string(userJSONBytes3))
  32307. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32308. utils.ErrorLog("解析失败:%v", err)
  32309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32310. return
  32311. }
  32312. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32313. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32314. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32316. resp3, requestErr3 := http.Get(api3)
  32317. if requestErr3 != nil {
  32318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32319. return
  32320. }
  32321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32322. if ioErr3 != nil {
  32323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32325. return
  32326. }
  32327. var respJSON3 map[string]interface{}
  32328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32331. return
  32332. }
  32333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32334. userJSONBytes3, _ := json.Marshal(respJSON3)
  32335. fmt.Println("log")
  32336. fmt.Println(string(userJSONBytes3))
  32337. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32338. utils.ErrorLog("解析失败:%v", err)
  32339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32340. return
  32341. }
  32342. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32343. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32344. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32345. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32346. resp3, requestErr3 := http.Get(api3)
  32347. if requestErr3 != nil {
  32348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32349. return
  32350. }
  32351. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32352. if ioErr3 != nil {
  32353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32355. return
  32356. }
  32357. var respJSON3 map[string]interface{}
  32358. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32361. return
  32362. }
  32363. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32364. userJSONBytes3, _ := json.Marshal(respJSON3)
  32365. fmt.Println("log")
  32366. fmt.Println(string(userJSONBytes3))
  32367. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32368. utils.ErrorLog("解析失败:%v", err)
  32369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32370. return
  32371. }
  32372. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32373. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32374. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32376. resp3, requestErr3 := http.Get(api3)
  32377. if requestErr3 != nil {
  32378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32379. return
  32380. }
  32381. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32382. if ioErr3 != nil {
  32383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32385. return
  32386. }
  32387. var respJSON3 map[string]interface{}
  32388. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32391. return
  32392. }
  32393. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32394. userJSONBytes3, _ := json.Marshal(respJSON3)
  32395. fmt.Println("log")
  32396. fmt.Println(string(userJSONBytes3))
  32397. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32398. utils.ErrorLog("解析失败:%v", err)
  32399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32400. return
  32401. }
  32402. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32403. var api3 string
  32404. if miConfig.MdtrtareaAdmvs == "320921" {
  32405. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32406. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32407. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32408. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32409. } else {
  32410. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32411. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32412. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32414. }
  32415. resp3, requestErr3 := http.Get(api3)
  32416. if requestErr3 != nil {
  32417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32418. return
  32419. }
  32420. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32421. if ioErr3 != nil {
  32422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32424. return
  32425. }
  32426. var respJSON3 map[string]interface{}
  32427. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32430. return
  32431. }
  32432. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32433. userJSONBytes3, _ := json.Marshal(respJSON3)
  32434. fmt.Println("log")
  32435. fmt.Println(string(userJSONBytes3))
  32436. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32437. utils.ErrorLog("解析失败:%v", err)
  32438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32439. return
  32440. }
  32441. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32442. res2.Output = resSix10265.Output
  32443. res2.ErrMsg = resSix10265.ErrMsg
  32444. res2.Cainfo = resSix10265.Cainfo
  32445. res2.WarnMsg = resSix10265.WarnMsg
  32446. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32447. res2.Infcode = infocode
  32448. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32449. var api3 string
  32450. new_chrg_bchno := order.Number
  32451. if adminUser.CurrentOrgId == 10265 {
  32452. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32453. new_chrg_bchno = "0000"
  32454. }
  32455. }
  32456. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32457. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32458. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32459. resp3, requestErr3 := http.Get(api3)
  32460. if requestErr3 != nil {
  32461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32462. return
  32463. }
  32464. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32465. if ioErr3 != nil {
  32466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32468. return
  32469. }
  32470. var respJSON3 map[string]interface{}
  32471. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32474. return
  32475. }
  32476. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32477. userJSONBytes3, _ := json.Marshal(respJSON3)
  32478. fmt.Println("log")
  32479. fmt.Println(string(userJSONBytes3))
  32480. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32481. utils.ErrorLog("解析失败:%v", err)
  32482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32483. return
  32484. }
  32485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32486. res2.Output = resSix10265.Output
  32487. res2.ErrMsg = resSix10265.ErrMsg
  32488. res2.Cainfo = resSix10265.Cainfo
  32489. res2.WarnMsg = resSix10265.WarnMsg
  32490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32491. res2.Infcode = infocode
  32492. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32493. 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)
  32494. var dat map[string]interface{}
  32495. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32496. fmt.Println(dat)
  32497. } else {
  32498. fmt.Println(err)
  32499. }
  32500. saveLog(result2, src_request, "2205", "撤销明细")
  32501. userJSONBytes, _ := json.Marshal(dat)
  32502. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32503. utils.ErrorLog("解析失败:%v", err)
  32504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32505. return
  32506. }
  32507. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32508. 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, "")
  32509. var dat map[string]interface{}
  32510. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32511. fmt.Println(dat)
  32512. } else {
  32513. fmt.Println(err)
  32514. }
  32515. saveLog(result2, src_request, "2205", "撤销明细")
  32516. userJSONBytes, _ := json.Marshal(dat)
  32517. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32518. utils.ErrorLog("解析失败:%v", err)
  32519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32520. return
  32521. }
  32522. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32523. 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, "")
  32524. var dat map[string]interface{}
  32525. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32526. fmt.Println(dat)
  32527. } else {
  32528. fmt.Println(err)
  32529. }
  32530. saveLog(result2, src_request, "2205", "撤销明细")
  32531. userJSONBytes, _ := json.Marshal(dat)
  32532. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32533. utils.ErrorLog("解析失败:%v", err)
  32534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32535. return
  32536. }
  32537. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32538. 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, "")
  32539. var dat map[string]interface{}
  32540. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32541. fmt.Println(dat)
  32542. } else {
  32543. fmt.Println(err)
  32544. }
  32545. saveLog(result2, src_request, "2205", "撤销明细")
  32546. userJSONBytes, _ := json.Marshal(dat)
  32547. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32548. utils.ErrorLog("解析失败:%v", err)
  32549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32550. return
  32551. }
  32552. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32553. var api3 string
  32554. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32555. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32556. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32557. resp3, requestErr3 := http.Get(api3)
  32558. if requestErr3 != nil {
  32559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32560. return
  32561. }
  32562. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32563. if ioErr3 != nil {
  32564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32566. return
  32567. }
  32568. var respJSON3 map[string]interface{}
  32569. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32572. return
  32573. }
  32574. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32575. if status == "0" {
  32576. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32577. c.ServeSuccessJSON(map[string]interface{}{
  32578. "failed_code": -10,
  32579. "msg": err_msg,
  32580. })
  32581. return
  32582. }
  32583. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32584. userJSONBytes3, _ := json.Marshal(respJSON3)
  32585. fmt.Println("log")
  32586. fmt.Println(string(userJSONBytes3))
  32587. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32588. utils.ErrorLog("解析失败:%v", err)
  32589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32590. return
  32591. }
  32592. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32593. 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, "")
  32594. var dat map[string]interface{}
  32595. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32596. fmt.Println(dat)
  32597. } else {
  32598. fmt.Println(err)
  32599. }
  32600. saveLog(result2, src_request, "2205", "撤销明细")
  32601. userJSONBytes, _ := json.Marshal(dat)
  32602. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32603. utils.ErrorLog("解析失败:%v", err)
  32604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32605. return
  32606. }
  32607. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32608. 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, "")
  32609. var dat map[string]interface{}
  32610. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32611. fmt.Println(dat)
  32612. } else {
  32613. fmt.Println(err)
  32614. }
  32615. saveLog(result2, src_request, "2205", "撤销明细")
  32616. userJSONBytes, _ := json.Marshal(dat)
  32617. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32618. utils.ErrorLog("解析失败:%v", err)
  32619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32620. return
  32621. }
  32622. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32623. 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, "")
  32624. var dat map[string]interface{}
  32625. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32626. fmt.Println(dat)
  32627. } else {
  32628. fmt.Println(err)
  32629. }
  32630. saveLog(result2, src_request, "2205", "撤销明细")
  32631. userJSONBytes, _ := json.Marshal(dat)
  32632. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32633. utils.ErrorLog("解析失败:%v", err)
  32634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32635. return
  32636. }
  32637. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32638. var api3 string
  32639. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32640. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32641. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32642. resp3, requestErr3 := http.Get(api3)
  32643. if requestErr3 != nil {
  32644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32645. return
  32646. }
  32647. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32648. if ioErr3 != nil {
  32649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32651. return
  32652. }
  32653. var respJSON3 map[string]interface{}
  32654. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32657. return
  32658. }
  32659. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32660. if status == "0" {
  32661. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32662. c.ServeSuccessJSON(map[string]interface{}{
  32663. "failed_code": -10,
  32664. "msg": err_msg,
  32665. })
  32666. return
  32667. }
  32668. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32669. userJSONBytes3, _ := json.Marshal(respJSON3)
  32670. fmt.Println("log")
  32671. fmt.Println(string(userJSONBytes3))
  32672. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32673. utils.ErrorLog("解析失败:%v", err)
  32674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32675. return
  32676. }
  32677. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32678. 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, "")
  32679. var dat map[string]interface{}
  32680. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32681. fmt.Println(dat)
  32682. } else {
  32683. fmt.Println(err)
  32684. }
  32685. saveLog(result2, src_request, "2205", "撤销明细")
  32686. userJSONBytes, _ := json.Marshal(dat)
  32687. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32688. utils.ErrorLog("解析失败:%v", err)
  32689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32690. return
  32691. }
  32692. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32693. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32694. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32695. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32696. resp3, requestErr3 := http.Get(api3)
  32697. if requestErr3 != nil {
  32698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32699. return
  32700. }
  32701. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32702. if ioErr3 != nil {
  32703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32705. return
  32706. }
  32707. var respJSON3 map[string]interface{}
  32708. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32711. return
  32712. }
  32713. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32714. userJSONBytes3, _ := json.Marshal(respJSON3)
  32715. fmt.Println("log")
  32716. fmt.Println(string(userJSONBytes3))
  32717. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32718. utils.ErrorLog("解析失败:%v", err)
  32719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32720. return
  32721. }
  32722. } else {
  32723. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32724. res2.Infcode = 0
  32725. } else {
  32726. 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)
  32727. var dat map[string]interface{}
  32728. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32729. fmt.Println(dat)
  32730. } else {
  32731. fmt.Println(err)
  32732. }
  32733. saveLog(result2, src_request, "2205", "撤销明细")
  32734. userJSONBytes, _ := json.Marshal(dat)
  32735. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32736. utils.ErrorLog("解析失败:%v", err)
  32737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32738. return
  32739. }
  32740. }
  32741. }
  32742. if res2.Infcode == -1 {
  32743. c.ServeSuccessJSON(map[string]interface{}{
  32744. "failed_code": -10,
  32745. "msg": res2.ErrMsg,
  32746. })
  32747. return
  32748. }
  32749. if res2.Infcode == 0 {
  32750. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32751. if err == nil {
  32752. //当押金不为零时产生退费记录
  32753. if order.Decimal != 0 {
  32754. tmp := strconv.FormatInt(order.ID, 10)
  32755. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32756. if err != nil {
  32757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32758. return
  32759. }
  32760. }
  32761. c.ServeSuccessJSON(map[string]interface{}{
  32762. "msg": "退费成功",
  32763. })
  32764. } else {
  32765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32766. return
  32767. }
  32768. } else {
  32769. c.ServeSuccessJSON(map[string]interface{}{
  32770. "failed_code": -10,
  32771. "msg": res2.ErrMsg,
  32772. })
  32773. }
  32774. } else {
  32775. c.ServeSuccessJSON(map[string]interface{}{
  32776. "failed_code": -10,
  32777. "msg": res.ErrMsg,
  32778. })
  32779. }
  32780. }
  32781. }
  32782. func (c *HisApiController) RefundNumber() {
  32783. record_time := c.GetString("record_time")
  32784. //patient_id, _ := c.GetInt64("patient_id")
  32785. admin_user_id, _ := c.GetInt64("admin_user_id")
  32786. his_patient_id, _ := c.GetInt64("id")
  32787. timeLayout := "2006-01-02"
  32788. loc, _ := time.LoadLocation("Local")
  32789. adminUser := c.GetAdminUserInfo()
  32790. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32791. fmt.Println(err)
  32792. if err != nil {
  32793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32794. return
  32795. }
  32796. recordDateTime := theTime.Unix()
  32797. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32798. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32799. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32800. //order, _ := service.GetHisOrderByID(order_id)
  32801. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32802. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32803. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32804. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32805. if count > 0 {
  32806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32807. return
  32808. }
  32809. if config.IsOpen == 1 { //对接了医保,走医保流程
  32810. var res2 ResultSix
  32811. var res3 GZResultSix
  32812. var resSix10265 ResultSix10265
  32813. if miConfig.MdtrtareaAdmvs == "421300" {
  32814. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32815. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32817. resp3, requestErr3 := http.Get(api3)
  32818. if requestErr3 != nil {
  32819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32820. return
  32821. }
  32822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32823. if ioErr3 != nil {
  32824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32826. return
  32827. }
  32828. var respJSON3 map[string]interface{}
  32829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32832. return
  32833. }
  32834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32835. userJSONBytes3, _ := json.Marshal(respJSON3)
  32836. fmt.Println("log")
  32837. fmt.Println(string(userJSONBytes3))
  32838. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32839. utils.ErrorLog("解析失败:%v", err)
  32840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32841. return
  32842. }
  32843. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32844. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32845. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32847. resp3, requestErr3 := http.Get(api3)
  32848. if requestErr3 != nil {
  32849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32850. return
  32851. }
  32852. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32853. if ioErr3 != nil {
  32854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32856. return
  32857. }
  32858. var respJSON3 map[string]interface{}
  32859. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32862. return
  32863. }
  32864. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32865. userJSONBytes3, _ := json.Marshal(respJSON3)
  32866. fmt.Println("log")
  32867. fmt.Println(string(userJSONBytes3))
  32868. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32869. utils.ErrorLog("解析失败:%v", err)
  32870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32871. return
  32872. }
  32873. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32874. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32875. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32876. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32877. resp3, requestErr3 := http.Get(api3)
  32878. if requestErr3 != nil {
  32879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32880. return
  32881. }
  32882. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32883. if ioErr3 != nil {
  32884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32886. return
  32887. }
  32888. var respJSON3 map[string]interface{}
  32889. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32892. return
  32893. }
  32894. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32895. userJSONBytes3, _ := json.Marshal(respJSON3)
  32896. fmt.Println("log")
  32897. fmt.Println(string(userJSONBytes3))
  32898. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32899. utils.ErrorLog("解析失败:%v", err)
  32900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32901. return
  32902. }
  32903. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32904. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32905. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32906. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32907. resp3, requestErr3 := http.Get(api3)
  32908. if requestErr3 != nil {
  32909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32910. return
  32911. }
  32912. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32913. if ioErr3 != nil {
  32914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32916. return
  32917. }
  32918. var respJSON3 map[string]interface{}
  32919. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32922. return
  32923. }
  32924. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32925. userJSONBytes3, _ := json.Marshal(respJSON3)
  32926. fmt.Println("log")
  32927. fmt.Println(string(userJSONBytes3))
  32928. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32929. utils.ErrorLog("解析失败:%v", err)
  32930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32931. return
  32932. }
  32933. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32934. var api3 string
  32935. if miConfig.MdtrtareaAdmvs == "320921" {
  32936. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32937. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32938. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32939. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32940. } else {
  32941. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32942. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32943. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32944. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32945. }
  32946. resp3, requestErr3 := http.Get(api3)
  32947. if requestErr3 != nil {
  32948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32949. return
  32950. }
  32951. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32952. if ioErr3 != nil {
  32953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32955. return
  32956. }
  32957. var respJSON3 map[string]interface{}
  32958. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32961. return
  32962. }
  32963. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32964. userJSONBytes3, _ := json.Marshal(respJSON3)
  32965. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32966. utils.ErrorLog("解析失败:%v", err)
  32967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32968. return
  32969. }
  32970. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32971. res2.Output = resSix10265.Output
  32972. res2.ErrMsg = resSix10265.ErrMsg
  32973. res2.Cainfo = resSix10265.Cainfo
  32974. res2.WarnMsg = resSix10265.WarnMsg
  32975. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32976. res2.Infcode = infocode
  32977. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32978. var api3 string
  32979. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32980. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32981. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32982. resp3, requestErr3 := http.Get(api3)
  32983. if requestErr3 != nil {
  32984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32985. return
  32986. }
  32987. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32988. if ioErr3 != nil {
  32989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32991. return
  32992. }
  32993. var respJSON3 map[string]interface{}
  32994. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32997. return
  32998. }
  32999. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33000. userJSONBytes3, _ := json.Marshal(respJSON3)
  33001. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33002. utils.ErrorLog("解析失败:%v", err)
  33003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33004. return
  33005. }
  33006. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33007. res2.Output = resSix10265.Output
  33008. res2.ErrMsg = resSix10265.ErrMsg
  33009. res2.Cainfo = resSix10265.Cainfo
  33010. res2.WarnMsg = resSix10265.WarnMsg
  33011. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33012. res2.Infcode = infocode
  33013. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33014. 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)
  33015. var dat map[string]interface{}
  33016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33017. fmt.Println(dat)
  33018. } else {
  33019. fmt.Println(err)
  33020. }
  33021. saveLog(result, request, "2202", "退号")
  33022. userJSONBytes, _ := json.Marshal(dat)
  33023. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33024. utils.ErrorLog("解析失败:%v", err)
  33025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33026. return
  33027. }
  33028. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33029. 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, "")
  33030. var dat map[string]interface{}
  33031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33032. fmt.Println(dat)
  33033. } else {
  33034. fmt.Println(err)
  33035. }
  33036. saveLog(result, request, "2202", "退号")
  33037. userJSONBytes, _ := json.Marshal(dat)
  33038. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33039. utils.ErrorLog("解析失败:%v", err)
  33040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33041. return
  33042. }
  33043. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33044. 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, "")
  33045. var dat map[string]interface{}
  33046. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33047. fmt.Println(dat)
  33048. } else {
  33049. fmt.Println(err)
  33050. }
  33051. saveLog(result, request, "2202", "退号")
  33052. userJSONBytes, _ := json.Marshal(dat)
  33053. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33054. utils.ErrorLog("解析失败:%v", err)
  33055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33056. return
  33057. }
  33058. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33059. 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, "")
  33060. var dat map[string]interface{}
  33061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33062. fmt.Println(dat)
  33063. } else {
  33064. fmt.Println(err)
  33065. }
  33066. saveLog(result, request, "2202", "退号")
  33067. userJSONBytes, _ := json.Marshal(dat)
  33068. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33069. utils.ErrorLog("解析失败:%v", err)
  33070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33071. return
  33072. }
  33073. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33074. var api3 string
  33075. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33076. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33077. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33078. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33079. resp3, requestErr3 := http.Get(api3)
  33080. if requestErr3 != nil {
  33081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33082. return
  33083. }
  33084. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33085. if ioErr3 != nil {
  33086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33088. return
  33089. }
  33090. var respJSON3 map[string]interface{}
  33091. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33094. return
  33095. }
  33096. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33097. if status == "0" {
  33098. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33099. c.ServeSuccessJSON(map[string]interface{}{
  33100. "failed_code": -10,
  33101. "msg": err_msg,
  33102. })
  33103. return
  33104. }
  33105. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33106. userJSONBytes3, _ := json.Marshal(respJSON3)
  33107. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33108. utils.ErrorLog("解析失败:%v", err)
  33109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33110. return
  33111. }
  33112. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33113. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33114. var api3 string
  33115. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33116. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33117. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33118. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33119. resp3, requestErr3 := http.Get(api3)
  33120. if requestErr3 != nil {
  33121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33122. return
  33123. }
  33124. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33125. if ioErr3 != nil {
  33126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33128. return
  33129. }
  33130. var respJSON3 map[string]interface{}
  33131. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33134. return
  33135. }
  33136. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33137. if status == "0" {
  33138. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33139. c.ServeSuccessJSON(map[string]interface{}{
  33140. "failed_code": -10,
  33141. "msg": err_msg,
  33142. })
  33143. return
  33144. }
  33145. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33146. userJSONBytes3, _ := json.Marshal(respJSON3)
  33147. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33148. utils.ErrorLog("解析失败:%v", err)
  33149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33150. return
  33151. }
  33152. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33153. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33154. 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, "")
  33155. var dat map[string]interface{}
  33156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33157. fmt.Println(dat)
  33158. } else {
  33159. fmt.Println(err)
  33160. }
  33161. saveLog(result, request, "2202", "退号")
  33162. userJSONBytes, _ := json.Marshal(dat)
  33163. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33164. utils.ErrorLog("解析失败:%v", err)
  33165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33166. return
  33167. }
  33168. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33169. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  33170. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33171. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33172. resp3, requestErr3 := http.Get(api3)
  33173. if requestErr3 != nil {
  33174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33175. return
  33176. }
  33177. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33178. if ioErr3 != nil {
  33179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33181. return
  33182. }
  33183. var respJSON3 map[string]interface{}
  33184. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33187. return
  33188. }
  33189. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33190. userJSONBytes3, _ := json.Marshal(respJSON3)
  33191. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33192. utils.ErrorLog("解析失败:%v", err)
  33193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33194. return
  33195. }
  33196. } else {
  33197. var api3 string
  33198. if miConfig.Code == "H15049901371" {
  33199. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  33200. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33201. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33202. } else {
  33203. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  33204. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33206. }
  33207. resp3, requestErr3 := http.Get(api3)
  33208. if requestErr3 != nil {
  33209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33210. return
  33211. }
  33212. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33213. if ioErr3 != nil {
  33214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33216. return
  33217. }
  33218. var respJSON3 map[string]interface{}
  33219. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33222. return
  33223. }
  33224. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33225. userJSONBytes3, _ := json.Marshal(respJSON3)
  33226. if miConfig.Code == "H15049901371" {
  33227. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33228. utils.ErrorLog("解析失败:%v", err)
  33229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33230. return
  33231. }
  33232. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33233. res2.Output = resSix10265.Output
  33234. res2.ErrMsg = resSix10265.ErrMsg
  33235. res2.Cainfo = resSix10265.Cainfo
  33236. res2.WarnMsg = resSix10265.WarnMsg
  33237. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33238. res2.Infcode = infocode
  33239. } else {
  33240. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33241. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33242. utils.ErrorLog("解析失败:%v", err)
  33243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33244. return
  33245. }
  33246. res2.Infcode = res3.Infcode
  33247. } else {
  33248. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33249. utils.ErrorLog("解析失败:%v", err)
  33250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33251. return
  33252. }
  33253. }
  33254. }
  33255. }
  33256. if res2.Infcode == -1 {
  33257. c.ServeSuccessJSON(map[string]interface{}{
  33258. "failed_code": -10,
  33259. "msg": res2.ErrMsg,
  33260. })
  33261. return
  33262. }
  33263. if res2.Infcode == 0 {
  33264. if err == nil {
  33265. c.ServeSuccessJSON(map[string]interface{}{
  33266. "msg": "退号成功",
  33267. })
  33268. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  33269. } else {
  33270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33271. return
  33272. }
  33273. }
  33274. } else {
  33275. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  33276. //if err == nil {
  33277. // c.ServeSuccessJSON(map[string]interface{}{
  33278. // "msg": "退费成功",
  33279. // })
  33280. //} else {
  33281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33282. // return
  33283. //}
  33284. }
  33285. }
  33286. func (c *HisApiController) RefundDetail() {
  33287. order_id, _ := c.GetInt64("order_id")
  33288. admin_user_id, _ := c.GetInt64("admin_user_id")
  33289. //his_patient_id, _ := c.GetInt64("his_patient_id")
  33290. number := c.GetString("number")
  33291. record_time := c.GetString("record_time")
  33292. patient_id, _ := c.GetInt64("patient_id")
  33293. //med_type, _ := c.GetInt64("med_type")
  33294. timeLayout := "2006-01-02"
  33295. loc, _ := time.LoadLocation("Local")
  33296. adminUser := c.GetAdminUserInfo()
  33297. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33298. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33299. fmt.Println(err)
  33300. if err != nil {
  33301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33302. return
  33303. }
  33304. recordDateTime := theTime.Unix()
  33305. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  33306. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33307. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33308. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33309. var order models.HisOrder
  33310. order, _ = service.GetHisOrderByID(order_id)
  33311. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33312. if config.IsOpen == 1 { //对接了医保,走医保流程
  33313. var res2 ResultSix
  33314. if miConfig.MdtrtareaAdmvs == "421300" {
  33315. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33316. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33317. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33318. resp3, requestErr3 := http.Get(api3)
  33319. if requestErr3 != nil {
  33320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33321. return
  33322. }
  33323. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33324. if ioErr3 != nil {
  33325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33327. return
  33328. }
  33329. var respJSON3 map[string]interface{}
  33330. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. return
  33334. }
  33335. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33336. userJSONBytes3, _ := json.Marshal(respJSON3)
  33337. fmt.Println("log")
  33338. fmt.Println(string(userJSONBytes3))
  33339. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33340. utils.ErrorLog("解析失败:%v", err)
  33341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33342. return
  33343. }
  33344. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33345. if err == nil {
  33346. c.ServeSuccessJSON(map[string]interface{}{
  33347. "msg": "撤销明细成功",
  33348. })
  33349. return
  33350. } else {
  33351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33352. return
  33353. }
  33354. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33355. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33356. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33357. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33358. resp3, requestErr3 := http.Get(api3)
  33359. if requestErr3 != nil {
  33360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33361. return
  33362. }
  33363. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33364. if ioErr3 != nil {
  33365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33367. return
  33368. }
  33369. var respJSON3 map[string]interface{}
  33370. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33373. return
  33374. }
  33375. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33376. userJSONBytes3, _ := json.Marshal(respJSON3)
  33377. fmt.Println("log")
  33378. fmt.Println(string(userJSONBytes3))
  33379. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33380. utils.ErrorLog("解析失败:%v", err)
  33381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33382. return
  33383. }
  33384. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33385. if err == nil {
  33386. c.ServeSuccessJSON(map[string]interface{}{
  33387. "msg": "撤销明细成功",
  33388. })
  33389. return
  33390. } else {
  33391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33392. return
  33393. }
  33394. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33395. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33396. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33397. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33398. resp3, requestErr3 := http.Get(api3)
  33399. if requestErr3 != nil {
  33400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33401. return
  33402. }
  33403. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33404. if ioErr3 != nil {
  33405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33407. return
  33408. }
  33409. var respJSON3 map[string]interface{}
  33410. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33413. return
  33414. }
  33415. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33416. userJSONBytes3, _ := json.Marshal(respJSON3)
  33417. fmt.Println("log")
  33418. fmt.Println(string(userJSONBytes3))
  33419. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33420. utils.ErrorLog("解析失败:%v", err)
  33421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33422. return
  33423. }
  33424. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33425. if err == nil {
  33426. c.ServeSuccessJSON(map[string]interface{}{
  33427. "msg": "撤销明细成功",
  33428. })
  33429. return
  33430. } else {
  33431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33432. return
  33433. }
  33434. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33435. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33436. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33437. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33438. resp3, requestErr3 := http.Get(api3)
  33439. if requestErr3 != nil {
  33440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33441. return
  33442. }
  33443. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33444. if ioErr3 != nil {
  33445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33447. return
  33448. }
  33449. var respJSON3 map[string]interface{}
  33450. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33453. return
  33454. }
  33455. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33456. userJSONBytes3, _ := json.Marshal(respJSON3)
  33457. fmt.Println("log")
  33458. fmt.Println(string(userJSONBytes3))
  33459. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33460. utils.ErrorLog("解析失败:%v", err)
  33461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33462. return
  33463. }
  33464. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33465. if err == nil {
  33466. c.ServeSuccessJSON(map[string]interface{}{
  33467. "msg": "撤销明细成功",
  33468. })
  33469. return
  33470. } else {
  33471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33472. return
  33473. }
  33474. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33475. var resSix10265 ResultSix10265
  33476. var api3 string
  33477. if miConfig.MdtrtareaAdmvs == "320921" {
  33478. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33479. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33480. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33481. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33482. } else {
  33483. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33484. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33485. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33486. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33487. }
  33488. resp3, requestErr3 := http.Get(api3)
  33489. utils.ErrorLog("接口: %v", requestErr3)
  33490. if requestErr3 != nil {
  33491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33492. return
  33493. }
  33494. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33495. if ioErr3 != nil {
  33496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33498. return
  33499. }
  33500. var respJSON3 map[string]interface{}
  33501. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33504. return
  33505. }
  33506. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33507. userJSONBytes3, _ := json.Marshal(respJSON3)
  33508. fmt.Println("log")
  33509. fmt.Println(string(userJSONBytes3))
  33510. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33511. utils.ErrorLog("解析失败:%v", err)
  33512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33513. return
  33514. }
  33515. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33516. res2.Output = resSix10265.Output
  33517. res2.ErrMsg = resSix10265.ErrMsg
  33518. res2.Cainfo = resSix10265.Cainfo
  33519. res2.WarnMsg = resSix10265.WarnMsg
  33520. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33521. res2.Infcode = infocode
  33522. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33523. if err == nil {
  33524. c.ServeSuccessJSON(map[string]interface{}{
  33525. "msg": "撤销明细成功",
  33526. })
  33527. return
  33528. } else {
  33529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33530. return
  33531. }
  33532. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33533. var api3 string
  33534. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33535. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33536. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33537. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33538. resp3, requestErr3 := http.Get(api3)
  33539. utils.ErrorLog("接口: %v", requestErr3)
  33540. if requestErr3 != nil {
  33541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33542. return
  33543. }
  33544. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33545. if ioErr3 != nil {
  33546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33548. return
  33549. }
  33550. var respJSON3 map[string]interface{}
  33551. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33554. return
  33555. }
  33556. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33557. if status == "0" {
  33558. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33559. c.ServeSuccessJSON(map[string]interface{}{
  33560. "failed_code": -10,
  33561. "msg": err_msg,
  33562. })
  33563. return
  33564. }
  33565. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33566. userJSONBytes3, _ := json.Marshal(respJSON3)
  33567. fmt.Println("log")
  33568. fmt.Println(string(userJSONBytes3))
  33569. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33570. utils.ErrorLog("解析失败:%v", err)
  33571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33572. return
  33573. }
  33574. fmt.Println(res2.Infcode)
  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, number, adminUser.CurrentOrgId, "", "")
  33584. if err == nil {
  33585. c.ServeSuccessJSON(map[string]interface{}{
  33586. "msg": "撤销明细成功",
  33587. })
  33588. return
  33589. } else {
  33590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33591. return
  33592. }
  33593. } else {
  33594. c.ServeSuccessJSON(map[string]interface{}{
  33595. "failed_code": -10,
  33596. "msg": res2.ErrMsg,
  33597. })
  33598. }
  33599. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33600. if err == nil {
  33601. c.ServeSuccessJSON(map[string]interface{}{
  33602. "msg": "撤销明细成功",
  33603. })
  33604. return
  33605. } else {
  33606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33607. return
  33608. }
  33609. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33610. var api3 string
  33611. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33612. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33613. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33614. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33615. resp3, requestErr3 := http.Get(api3)
  33616. utils.ErrorLog("接口: %v", requestErr3)
  33617. if requestErr3 != nil {
  33618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33619. return
  33620. }
  33621. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33622. if ioErr3 != nil {
  33623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33625. return
  33626. }
  33627. var respJSON3 map[string]interface{}
  33628. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33631. return
  33632. }
  33633. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33634. if status == "0" {
  33635. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33636. c.ServeSuccessJSON(map[string]interface{}{
  33637. "failed_code": -10,
  33638. "msg": err_msg,
  33639. })
  33640. return
  33641. }
  33642. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33643. userJSONBytes3, _ := json.Marshal(respJSON3)
  33644. fmt.Println("log")
  33645. fmt.Println(string(userJSONBytes3))
  33646. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33647. utils.ErrorLog("解析失败:%v", err)
  33648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33649. return
  33650. }
  33651. fmt.Println(res2.Infcode)
  33652. if res2.Infcode == -1 {
  33653. c.ServeSuccessJSON(map[string]interface{}{
  33654. "failed_code": -10,
  33655. "msg": res2.ErrMsg,
  33656. })
  33657. return
  33658. }
  33659. if res2.Infcode == 0 {
  33660. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33661. if err == nil {
  33662. c.ServeSuccessJSON(map[string]interface{}{
  33663. "msg": "撤销明细成功",
  33664. })
  33665. return
  33666. } else {
  33667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33668. return
  33669. }
  33670. } else {
  33671. c.ServeSuccessJSON(map[string]interface{}{
  33672. "failed_code": -10,
  33673. "msg": res2.ErrMsg,
  33674. })
  33675. }
  33676. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33677. if err == nil {
  33678. c.ServeSuccessJSON(map[string]interface{}{
  33679. "msg": "撤销明细成功",
  33680. })
  33681. return
  33682. } else {
  33683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33684. return
  33685. }
  33686. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33687. var resSix10265 ResultSix10265
  33688. new_chrg_bchno := order.Number
  33689. if adminUser.CurrentOrgId == 10265 {
  33690. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33691. new_chrg_bchno = "0000"
  33692. }
  33693. }
  33694. var api3 string
  33695. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33696. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33698. resp3, requestErr3 := http.Get(api3)
  33699. if requestErr3 != nil {
  33700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33701. return
  33702. }
  33703. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33704. if ioErr3 != nil {
  33705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33707. return
  33708. }
  33709. var respJSON3 map[string]interface{}
  33710. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33713. return
  33714. }
  33715. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33716. userJSONBytes3, _ := json.Marshal(respJSON3)
  33717. fmt.Println("log")
  33718. fmt.Println(string(userJSONBytes3))
  33719. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33720. utils.ErrorLog("解析失败:%v", err)
  33721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33722. return
  33723. }
  33724. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33725. res2.Output = resSix10265.Output
  33726. res2.ErrMsg = resSix10265.ErrMsg
  33727. res2.Cainfo = resSix10265.Cainfo
  33728. res2.WarnMsg = resSix10265.WarnMsg
  33729. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33730. res2.Infcode = infocode
  33731. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33732. if err == nil {
  33733. c.ServeSuccessJSON(map[string]interface{}{
  33734. "msg": "撤销明细成功",
  33735. })
  33736. return
  33737. } else {
  33738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33739. return
  33740. }
  33741. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33742. 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)
  33743. var dat map[string]interface{}
  33744. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33745. fmt.Println(dat)
  33746. } else {
  33747. fmt.Println(err)
  33748. }
  33749. saveLog(result2, src_request, "2205", "撤销明细")
  33750. userJSONBytes, _ := json.Marshal(dat)
  33751. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33752. utils.ErrorLog("解析失败:%v", err)
  33753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33754. return
  33755. }
  33756. if res2.Infcode == 0 {
  33757. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33758. if err == nil {
  33759. c.ServeSuccessJSON(map[string]interface{}{
  33760. "msg": "撤销明细成功",
  33761. })
  33762. return
  33763. } else {
  33764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33765. return
  33766. }
  33767. } else {
  33768. c.ServeSuccessJSON(map[string]interface{}{
  33769. "failed_code": -10,
  33770. "msg": res2.ErrMsg,
  33771. })
  33772. }
  33773. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33774. 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, "")
  33775. var dat map[string]interface{}
  33776. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33777. fmt.Println(dat)
  33778. } else {
  33779. fmt.Println(err)
  33780. }
  33781. saveLog(result2, src_request, "2205", "撤销明细")
  33782. userJSONBytes, _ := json.Marshal(dat)
  33783. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33784. utils.ErrorLog("解析失败:%v", err)
  33785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33786. return
  33787. }
  33788. if res2.Infcode == 0 {
  33789. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33790. if err == nil {
  33791. c.ServeSuccessJSON(map[string]interface{}{
  33792. "msg": "撤销明细成功",
  33793. })
  33794. return
  33795. } else {
  33796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33797. return
  33798. }
  33799. } else {
  33800. c.ServeSuccessJSON(map[string]interface{}{
  33801. "failed_code": -10,
  33802. "msg": res2.ErrMsg,
  33803. })
  33804. }
  33805. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33806. 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, "")
  33807. var dat map[string]interface{}
  33808. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33809. fmt.Println(dat)
  33810. } else {
  33811. fmt.Println(err)
  33812. }
  33813. saveLog(result2, src_request, "2205", "撤销明细")
  33814. userJSONBytes, _ := json.Marshal(dat)
  33815. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33816. utils.ErrorLog("解析失败:%v", err)
  33817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33818. return
  33819. }
  33820. if res2.Infcode == 0 {
  33821. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33822. if err == nil {
  33823. c.ServeSuccessJSON(map[string]interface{}{
  33824. "msg": "撤销明细成功",
  33825. })
  33826. return
  33827. } else {
  33828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33829. return
  33830. }
  33831. } else {
  33832. c.ServeSuccessJSON(map[string]interface{}{
  33833. "failed_code": -10,
  33834. "msg": res2.ErrMsg,
  33835. })
  33836. }
  33837. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33838. 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, "")
  33839. var dat map[string]interface{}
  33840. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33841. fmt.Println(dat)
  33842. } else {
  33843. fmt.Println(err)
  33844. }
  33845. saveLog(result2, src_request, "2205", "撤销明细")
  33846. userJSONBytes, _ := json.Marshal(dat)
  33847. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33848. utils.ErrorLog("解析失败:%v", err)
  33849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. return
  33851. }
  33852. if res2.Infcode == 0 {
  33853. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33854. if err == nil {
  33855. c.ServeSuccessJSON(map[string]interface{}{
  33856. "msg": "撤销明细成功",
  33857. })
  33858. return
  33859. } else {
  33860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33861. return
  33862. }
  33863. } else {
  33864. c.ServeSuccessJSON(map[string]interface{}{
  33865. "failed_code": -10,
  33866. "msg": res2.ErrMsg,
  33867. })
  33868. }
  33869. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33870. 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, "")
  33871. var dat map[string]interface{}
  33872. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33873. fmt.Println(dat)
  33874. } else {
  33875. fmt.Println(err)
  33876. }
  33877. saveLog(result2, src_request, "2205", "撤销明细")
  33878. userJSONBytes, _ := json.Marshal(dat)
  33879. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33880. utils.ErrorLog("解析失败:%v", err)
  33881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33882. return
  33883. }
  33884. if res2.Infcode == 0 {
  33885. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33886. if err == nil {
  33887. c.ServeSuccessJSON(map[string]interface{}{
  33888. "msg": "撤销明细成功",
  33889. })
  33890. return
  33891. } else {
  33892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33893. return
  33894. }
  33895. } else {
  33896. c.ServeSuccessJSON(map[string]interface{}{
  33897. "failed_code": -10,
  33898. "msg": res2.ErrMsg,
  33899. })
  33900. }
  33901. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33902. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33903. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33904. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33905. resp2, requestErr2 := http.Get(api2)
  33906. if requestErr2 != nil {
  33907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33908. return
  33909. }
  33910. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33911. if ioErr2 != nil {
  33912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33914. return
  33915. }
  33916. var respJSON2 map[string]interface{}
  33917. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33920. return
  33921. }
  33922. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33923. userJSONBytes3, _ := json.Marshal(respJSON2)
  33924. fmt.Println("log")
  33925. fmt.Println(string(userJSONBytes3))
  33926. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33927. utils.ErrorLog("解析失败:%v", err)
  33928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33929. return
  33930. }
  33931. if res2.Infcode == 0 {
  33932. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33933. if err == nil {
  33934. c.ServeSuccessJSON(map[string]interface{}{
  33935. "msg": "撤销明细成功",
  33936. })
  33937. return
  33938. } else {
  33939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33940. return
  33941. }
  33942. } else {
  33943. c.ServeSuccessJSON(map[string]interface{}{
  33944. "failed_code": -10,
  33945. "msg": res2.ErrMsg,
  33946. })
  33947. }
  33948. } else {
  33949. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33950. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33951. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33952. resp2, requestErr2 := http.Get(api2)
  33953. if requestErr2 != nil {
  33954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33955. return
  33956. }
  33957. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33958. if ioErr2 != nil {
  33959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33961. return
  33962. }
  33963. var respJSON2 map[string]interface{}
  33964. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33967. return
  33968. }
  33969. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33970. userJSONBytes3, _ := json.Marshal(respJSON2)
  33971. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33972. utils.ErrorLog("解析失败:%v", err)
  33973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33974. return
  33975. }
  33976. if res2.Infcode == -1 {
  33977. c.ServeSuccessJSON(map[string]interface{}{
  33978. "failed_code": -10,
  33979. "msg": res2.ErrMsg,
  33980. })
  33981. return
  33982. } else {
  33983. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33984. if err == nil {
  33985. c.ServeSuccessJSON(map[string]interface{}{
  33986. "msg": "撤销明细成功",
  33987. })
  33988. return
  33989. } else {
  33990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33991. return
  33992. }
  33993. }
  33994. }
  33995. } else {
  33996. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33997. if err == nil {
  33998. c.ServeSuccessJSON(map[string]interface{}{
  33999. "msg": "退费成功",
  34000. })
  34001. } else {
  34002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34003. return
  34004. }
  34005. }
  34006. }
  34007. // 对账
  34008. func (c *HisApiController) GetCheckAccount() {
  34009. start_time := c.GetString("start_time")
  34010. end_time := c.GetString("end_time")
  34011. insutype := c.GetString("insutype")
  34012. clr_type := c.GetString("clr_type")
  34013. clr_org := c.GetString("clr_optins")
  34014. admin_user_id, _ := c.GetInt64("admin_user_id")
  34015. adminUser := c.GetAdminUserInfo()
  34016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34017. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34018. if len(clr_org) == 0 {
  34019. clr_org = miConfig.InsuplcAdmdvs
  34020. }
  34021. timeLayout := "2006-01-02"
  34022. loc, _ := time.LoadLocation("Local")
  34023. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34024. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34025. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34026. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34027. fixmedins_setl_cnt := int64(len(orders))
  34028. var medfee_sumamt float64
  34029. var acct_pay float64
  34030. var fund_pay_sumamt float64
  34031. for _, item := range orders {
  34032. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34033. acct_pay = acct_pay + item.AcctPay
  34034. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  34035. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  34036. } else {
  34037. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34038. }
  34039. }
  34040. var user_name string
  34041. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34042. if role.ID == 0 {
  34043. user_name = "xxx"
  34044. } else {
  34045. user_name = role.UserName
  34046. }
  34047. var res ResultEight
  34048. var res10188 ResultEightFor10188
  34049. if config.IsOpen == 1 {
  34050. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34051. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  34052. "insutype=" + insutype +
  34053. "&clr_type=" + clr_type +
  34054. "&setl_optins=" + clr_org +
  34055. "&stmt_begndate=" + start_time +
  34056. "&stm_enddate=" + end_time +
  34057. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34058. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34059. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34060. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34061. "&fixmedins_code=" + miConfig.Code +
  34062. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34063. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34064. "&secret_key=" + miConfig.SecretKey +
  34065. "&org_name=" + miConfig.OrgName +
  34066. "&doctor=" + user_name +
  34067. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34068. fmt.Println(api)
  34069. resp, requestErr := http.Get(api)
  34070. if requestErr != nil {
  34071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34072. return
  34073. }
  34074. body, ioErr := ioutil.ReadAll(resp.Body)
  34075. fmt.Println(body)
  34076. if ioErr != nil {
  34077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34079. return
  34080. }
  34081. var respJSON map[string]interface{}
  34082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34085. return
  34086. }
  34087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34088. userJSONBytes, _ := json.Marshal(respJSON)
  34089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34090. utils.ErrorLog("解析失败:%v", err)
  34091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34092. return
  34093. }
  34094. res.InfRefmsgid = res10188.InfRefmsgid
  34095. res.Output = res10188.Output
  34096. res.ErrMsg = res10188.ErrMsg
  34097. res.Cainfo = res10188.Cainfo
  34098. res.WarnMsg = res10188.WarnMsg
  34099. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34100. res.Infcode = infocode
  34101. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34102. if clr_type != "9903" {
  34103. clr_type = "99" // 就诊 ID(来自2201接口返回)
  34104. }
  34105. if clr_type == "9903" {
  34106. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  34107. }
  34108. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  34109. "insutype=" + insutype +
  34110. "&clr_type=" + clr_type +
  34111. "&setl_optins=" + clr_org +
  34112. "&stmt_begndate=" + start_time +
  34113. "&stm_enddate=" + end_time +
  34114. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34115. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34116. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34117. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34118. "&fixmedins_code=" + miConfig.Code +
  34119. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34120. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34121. "&secret_key=" + miConfig.SecretKey +
  34122. "&org_name=" + miConfig.OrgName +
  34123. "&doctor=" + user_name
  34124. resp, requestErr := http.Get(api)
  34125. if requestErr != nil {
  34126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34127. return
  34128. }
  34129. body, ioErr := ioutil.ReadAll(resp.Body)
  34130. if ioErr != nil {
  34131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34133. return
  34134. }
  34135. var respJSON map[string]interface{}
  34136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34139. return
  34140. }
  34141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34142. result, _ := json.Marshal(respJSON)
  34143. fmt.Println("log")
  34144. fmt.Println(string(result))
  34145. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  34146. utils.ErrorLog("解析失败:%v", err)
  34147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34148. return
  34149. }
  34150. res.InfRefmsgid = res10188.InfRefmsgid
  34151. res.Output = res10188.Output
  34152. res.ErrMsg = res10188.ErrMsg
  34153. res.Cainfo = res10188.Cainfo
  34154. res.WarnMsg = res10188.WarnMsg
  34155. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34156. res.Infcode = infocode
  34157. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34158. var baseParams models.BaseParams
  34159. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34160. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34161. baseParams.SecretKey = miConfig.SecretKey
  34162. baseParams.OrgName = miConfig.OrgName
  34163. baseParams.FixmedinsCode = miConfig.Code
  34164. baseParams.EncKey = miConfig.EncKey
  34165. baseParams.AppSecret = miConfig.AppSecret
  34166. baseParams.SignKey = miConfig.SignKey
  34167. baseParams.AppID = miConfig.Code
  34168. baseParams.Doctor = role.UserName
  34169. baseParams.RequestUrl = miConfig.Url
  34170. businessParams := models.BusinessParams{
  34171. Insutype: insutype,
  34172. ClrType: clr_type,
  34173. SetlOptins: clr_org,
  34174. StmtBegndate: start_time,
  34175. StmtEnddate: end_time,
  34176. MedfeeSumamt: medfee_sumamt,
  34177. FundPaySumamt: fund_pay_sumamt,
  34178. AcctPay: acct_pay,
  34179. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34180. }
  34181. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34182. fmt.Println(requestLog)
  34183. fmt.Println(result)
  34184. fmt.Println(err_msg)
  34185. var dat map[string]interface{}
  34186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34187. fmt.Println(dat)
  34188. } else {
  34189. fmt.Println(err)
  34190. }
  34191. userJSONBytes, _ := json.Marshal(dat)
  34192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34193. utils.ErrorLog("解析失败:%v", err)
  34194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34195. return
  34196. }
  34197. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34198. var baseParams models.BaseParams
  34199. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34200. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34201. baseParams.SecretKey = miConfig.SecretKey
  34202. baseParams.OrgName = miConfig.OrgName
  34203. baseParams.FixmedinsCode = miConfig.Code
  34204. baseParams.EncKey = miConfig.EncKey
  34205. baseParams.AppSecret = miConfig.AppSecret
  34206. baseParams.SignKey = miConfig.SignKey
  34207. baseParams.AppID = miConfig.Code
  34208. baseParams.Doctor = role.UserName
  34209. baseParams.RequestUrl = miConfig.Url
  34210. baseParams.AccessKey = miConfig.AccessKey
  34211. businessParams := models.BusinessParams{
  34212. Insutype: insutype,
  34213. ClrType: clr_type,
  34214. SetlOptins: "430822",
  34215. StmtBegndate: start_time,
  34216. StmtEnddate: end_time,
  34217. MedfeeSumamt: medfee_sumamt,
  34218. FundPaySumamt: fund_pay_sumamt,
  34219. AcctPay: acct_pay,
  34220. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34221. }
  34222. 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)
  34223. fmt.Println(requestLog)
  34224. fmt.Println(result)
  34225. var dat map[string]interface{}
  34226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34227. fmt.Println(dat)
  34228. } else {
  34229. fmt.Println(err)
  34230. }
  34231. userJSONBytes, _ := json.Marshal(dat)
  34232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34233. utils.ErrorLog("解析失败:%v", err)
  34234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34235. return
  34236. }
  34237. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34238. var baseParams models.BaseParams
  34239. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34240. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34241. baseParams.SecretKey = miConfig.SecretKey
  34242. baseParams.OrgName = miConfig.OrgName
  34243. baseParams.FixmedinsCode = miConfig.Code
  34244. baseParams.EncKey = miConfig.EncKey
  34245. baseParams.AppSecret = miConfig.AppSecret
  34246. baseParams.SignKey = miConfig.SignKey
  34247. baseParams.AppID = miConfig.Code
  34248. baseParams.Doctor = role.UserName
  34249. baseParams.RequestUrl = miConfig.Url
  34250. businessParams := models.BusinessParams{
  34251. Insutype: insutype,
  34252. ClrType: clr_type,
  34253. SetlOptins: clr_org,
  34254. StmtBegndate: start_time,
  34255. StmtEnddate: end_time,
  34256. MedfeeSumamt: medfee_sumamt,
  34257. FundPaySumamt: fund_pay_sumamt,
  34258. AcctPay: acct_pay,
  34259. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34260. }
  34261. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34262. fmt.Println(requestLog)
  34263. fmt.Println(result)
  34264. fmt.Println(err_msg)
  34265. var dat map[string]interface{}
  34266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34267. fmt.Println(dat)
  34268. } else {
  34269. fmt.Println(err)
  34270. }
  34271. userJSONBytes, _ := json.Marshal(dat)
  34272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34273. utils.ErrorLog("解析失败:%v", err)
  34274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34275. return
  34276. }
  34277. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34278. if len(clr_type) == 0 {
  34279. clr_type = "11"
  34280. }
  34281. api := miConfig.Url + "gdyb/ten?" +
  34282. "insutype=" + insutype +
  34283. "&clr_type=" + clr_type +
  34284. "&setl_optins=" + clr_org +
  34285. "&stmt_begndate=" + start_time +
  34286. "&stm_enddate=" + end_time +
  34287. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34288. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34289. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34290. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34291. "&fixmedins_code=" + miConfig.Code +
  34292. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34293. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34294. "&secret_key=" + miConfig.SecretKey +
  34295. "&org_name=" + miConfig.OrgName +
  34296. "&doctor=" + user_name
  34297. fmt.Println(api)
  34298. resp, requestErr := http.Get(api)
  34299. if requestErr != nil {
  34300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34301. return
  34302. }
  34303. body, ioErr := ioutil.ReadAll(resp.Body)
  34304. fmt.Println(body)
  34305. if ioErr != nil {
  34306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34308. return
  34309. }
  34310. var respJSON map[string]interface{}
  34311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34314. return
  34315. }
  34316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34317. userJSONBytes, _ := json.Marshal(respJSON)
  34318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34319. utils.ErrorLog("解析失败:%v", err)
  34320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34321. return
  34322. }
  34323. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34324. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34325. //fixmedins_setl_cnt := int64(len(orders_two))
  34326. //var medfee_sumamt float64
  34327. //var acct_pay float64
  34328. //var fund_pay_sumamt float64
  34329. //for _, item := range orders_two {
  34330. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34331. // acct_pay = acct_pay + item.AcctPay
  34332. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34333. //}
  34334. var baseParams models.BaseParams
  34335. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34336. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34337. baseParams.SecretKey = miConfig.SecretKey
  34338. baseParams.OrgName = miConfig.OrgName
  34339. baseParams.FixmedinsCode = miConfig.Code
  34340. baseParams.EncKey = miConfig.EncKey
  34341. baseParams.AppSecret = miConfig.AppSecret
  34342. baseParams.SignKey = miConfig.SignKey
  34343. baseParams.AppID = miConfig.Code
  34344. baseParams.Doctor = role.UserName
  34345. baseParams.RequestUrl = miConfig.Url
  34346. if clr_type == "9903" {
  34347. clr_type = "9994"
  34348. }
  34349. businessParams := models.BusinessParams{
  34350. Insutype: insutype,
  34351. ClrType: clr_type,
  34352. SetlOptins: "360302",
  34353. StmtBegndate: start_time,
  34354. StmtEnddate: end_time,
  34355. MedfeeSumamt: 0,
  34356. FundPaySumamt: 0,
  34357. AcctPay: 0,
  34358. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34359. }
  34360. 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))
  34361. fmt.Println(requestLog)
  34362. fmt.Println(result)
  34363. var dat map[string]interface{}
  34364. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34365. fmt.Println(dat)
  34366. } else {
  34367. fmt.Println(err)
  34368. }
  34369. userJSONBytes, _ := json.Marshal(dat)
  34370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34371. utils.ErrorLog("解析失败:%v", err)
  34372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34373. return
  34374. }
  34375. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34376. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34377. //fixmedins_setl_cnt := int64(len(orders_two))
  34378. //var medfee_sumamt float64
  34379. //var acct_pay float64
  34380. //var fund_pay_sumamt float64
  34381. //for _, item := range orders_two {
  34382. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34383. // acct_pay = acct_pay + item.AcctPay
  34384. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34385. //}
  34386. var baseParams models.BaseParams
  34387. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34388. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34389. baseParams.SecretKey = miConfig.SecretKey
  34390. baseParams.OrgName = miConfig.OrgName
  34391. baseParams.FixmedinsCode = miConfig.Code
  34392. baseParams.EncKey = miConfig.EncKey
  34393. baseParams.AppSecret = miConfig.AppSecret
  34394. baseParams.SignKey = miConfig.SignKey
  34395. baseParams.AppID = miConfig.Code
  34396. baseParams.Doctor = role.UserName
  34397. baseParams.RequestUrl = miConfig.Url
  34398. if clr_type == "9903" {
  34399. clr_type = "9994"
  34400. }
  34401. businessParams := models.BusinessParams{
  34402. Insutype: insutype,
  34403. ClrType: clr_type,
  34404. SetlOptins: "361025",
  34405. StmtBegndate: start_time,
  34406. StmtEnddate: end_time,
  34407. MedfeeSumamt: 0,
  34408. FundPaySumamt: 0,
  34409. AcctPay: 0,
  34410. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34411. }
  34412. 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))
  34413. fmt.Println(requestLog)
  34414. fmt.Println(result)
  34415. var dat map[string]interface{}
  34416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34417. fmt.Println(dat)
  34418. } else {
  34419. fmt.Println(err)
  34420. }
  34421. userJSONBytes, _ := json.Marshal(dat)
  34422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34423. utils.ErrorLog("解析失败:%v", err)
  34424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34425. return
  34426. }
  34427. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34428. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34429. //fixmedins_setl_cnt := int64(len(orders_two))
  34430. //var medfee_sumamt float64
  34431. //var acct_pay float64
  34432. //var fund_pay_sumamt float64
  34433. //for _, item := range orders_two {
  34434. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34435. // acct_pay = acct_pay + item.AcctPay
  34436. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34437. //}
  34438. var baseParams models.BaseParams
  34439. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34440. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34441. baseParams.SecretKey = miConfig.SecretKey
  34442. baseParams.OrgName = miConfig.OrgName
  34443. baseParams.FixmedinsCode = miConfig.Code
  34444. baseParams.EncKey = miConfig.EncKey
  34445. baseParams.AppSecret = miConfig.AppSecret
  34446. baseParams.SignKey = miConfig.SignKey
  34447. baseParams.AppID = miConfig.Code
  34448. baseParams.Doctor = role.UserName
  34449. baseParams.RequestUrl = miConfig.Url
  34450. if clr_type == "9903" {
  34451. clr_type = "9994"
  34452. }
  34453. businessParams := models.BusinessParams{
  34454. Insutype: insutype,
  34455. ClrType: clr_type,
  34456. SetlOptins: "360100",
  34457. StmtBegndate: start_time,
  34458. StmtEnddate: end_time,
  34459. MedfeeSumamt: 0,
  34460. FundPaySumamt: 0,
  34461. AcctPay: 0,
  34462. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34463. }
  34464. 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))
  34465. fmt.Println(requestLog)
  34466. fmt.Println(result)
  34467. var dat map[string]interface{}
  34468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34469. fmt.Println(dat)
  34470. } else {
  34471. fmt.Println(err)
  34472. }
  34473. userJSONBytes, _ := json.Marshal(dat)
  34474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34475. utils.ErrorLog("解析失败:%v", err)
  34476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34477. return
  34478. }
  34479. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34480. var api string
  34481. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  34482. "&clr_type=" + clr_type +
  34483. "&setl_optins=" + clr_org +
  34484. "&stmt_begndate=" + start_time +
  34485. "&stm_enddate=" + end_time +
  34486. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34487. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34488. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34489. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34490. "&fixmedins_code=" + miConfig.Code +
  34491. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34492. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34493. "&secret_key=" + miConfig.SecretKey +
  34494. "&org_name=" + miConfig.OrgName +
  34495. "&doctor=" + user_name + "&url=" + miConfig.Url
  34496. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34497. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34498. resp, requestErr := http.Get(api)
  34499. if requestErr != nil {
  34500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34501. return
  34502. }
  34503. body, ioErr := ioutil.ReadAll(resp.Body)
  34504. if ioErr != nil {
  34505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34507. return
  34508. }
  34509. var respJSON map[string]interface{}
  34510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34513. return
  34514. }
  34515. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34516. if status == "0" {
  34517. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34518. c.ServeSuccessJSON(map[string]interface{}{
  34519. "failed_code": -10,
  34520. "msg": err_msg,
  34521. })
  34522. return
  34523. }
  34524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34525. userJSONBytes, _ := json.Marshal(respJSON)
  34526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34527. utils.ErrorLog("解析失败:%v", err)
  34528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34529. return
  34530. }
  34531. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34532. var api string
  34533. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  34534. "&clr_type=" + clr_type +
  34535. "&setl_optins=" + clr_org +
  34536. "&stmt_begndate=" + start_time +
  34537. "&stm_enddate=" + end_time +
  34538. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34539. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34540. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34541. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34542. "&fixmedins_code=" + miConfig.Code +
  34543. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34544. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34545. "&secret_key=" + miConfig.SecretKey +
  34546. "&org_name=" + miConfig.OrgName +
  34547. "&doctor=" + user_name + "&url=" + miConfig.Url
  34548. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34549. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34550. resp, requestErr := http.Get(api)
  34551. if requestErr != nil {
  34552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34553. return
  34554. }
  34555. body, ioErr := ioutil.ReadAll(resp.Body)
  34556. if ioErr != nil {
  34557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34559. return
  34560. }
  34561. var respJSON map[string]interface{}
  34562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34565. return
  34566. }
  34567. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34568. if status == "0" {
  34569. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34570. c.ServeSuccessJSON(map[string]interface{}{
  34571. "failed_code": -10,
  34572. "msg": err_msg,
  34573. })
  34574. return
  34575. }
  34576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34577. userJSONBytes, _ := json.Marshal(respJSON)
  34578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34579. utils.ErrorLog("解析失败:%v", err)
  34580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34581. return
  34582. }
  34583. } else {
  34584. if len(clr_type) == 0 {
  34585. clr_type = "11"
  34586. }
  34587. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34588. "insutype=" + insutype +
  34589. "&clr_type=" + clr_type +
  34590. "&setl_optins=" + clr_org +
  34591. "&stmt_begndate=" + start_time +
  34592. "&stm_enddate=" + end_time +
  34593. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34594. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34595. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34596. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34597. "&fixmedins_code=" + miConfig.Code +
  34598. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34599. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34600. "&secret_key=" + miConfig.SecretKey +
  34601. "&org_name=" + miConfig.OrgName +
  34602. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34603. fmt.Println(api)
  34604. resp, requestErr := http.Get(api)
  34605. if requestErr != nil {
  34606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34607. return
  34608. }
  34609. body, ioErr := ioutil.ReadAll(resp.Body)
  34610. fmt.Println(body)
  34611. if ioErr != nil {
  34612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34614. return
  34615. }
  34616. var respJSON map[string]interface{}
  34617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34620. return
  34621. }
  34622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34623. userJSONBytes, _ := json.Marshal(respJSON)
  34624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34625. utils.ErrorLog("解析失败:%v", err)
  34626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34627. return
  34628. }
  34629. }
  34630. if res.Infcode == 0 {
  34631. if res.Output.Stmtinfo.StmtRslt == "0" {
  34632. micc := &models.MedicalInsuranceCostCompare{
  34633. StartTime: startime.Unix(),
  34634. EndTime: endtime.Unix(),
  34635. Insutype: insutype,
  34636. CheckType: 1,
  34637. Num: fixmedins_setl_cnt,
  34638. Mtime: time.Now().Unix(),
  34639. Status: 1,
  34640. UserOrgId: adminUser.CurrentOrgId,
  34641. CostTotal: medfee_sumamt,
  34642. FuncTotal: fund_pay_sumamt,
  34643. PsnPay: acct_pay,
  34644. Creator: admin_user_id,
  34645. Ctime: time.Now().Unix(),
  34646. ClrType: clr_type,
  34647. }
  34648. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  34649. if err == nil {
  34650. c.ServeSuccessJSON(map[string]interface{}{
  34651. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34652. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34653. })
  34654. } else {
  34655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34656. }
  34657. } else {
  34658. c.ServeSuccessJSON(map[string]interface{}{
  34659. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34660. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34661. })
  34662. }
  34663. } else {
  34664. c.ServeSuccessJSON(map[string]interface{}{
  34665. "failed_code": -10,
  34666. "msg": res.ErrMsg,
  34667. })
  34668. }
  34669. }
  34670. }
  34671. func (c *HisApiController) Check310() {
  34672. adminUser := c.GetAdminUserInfo()
  34673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34674. var user_name string
  34675. user_name = "高慧裕"
  34676. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34677. "insutype=" + "310" +
  34678. "&clr_type=" + "" +
  34679. "&setl_optins=" + "441202" +
  34680. "&stmt_begndate=" + "2022-03-01" +
  34681. "&stm_enddate=" + "2022-03-31" +
  34682. "&medfee_sumamt=" + "194930.12" +
  34683. "&fund_pay_sumamt=" + "188741.46" +
  34684. "&acct_pay=" + "0" +
  34685. "&fixmedins_setl_cnt=" + "452" +
  34686. "&fixmedins_code=" + miConfig.Code +
  34687. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34688. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34689. "&secret_key=" + miConfig.SecretKey +
  34690. "&org_name=" + miConfig.OrgName +
  34691. "&doctor=" + user_name
  34692. fmt.Println(api)
  34693. resp, requestErr := http.Get(api)
  34694. if requestErr != nil {
  34695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34696. return
  34697. }
  34698. body, ioErr := ioutil.ReadAll(resp.Body)
  34699. fmt.Println(body)
  34700. if ioErr != nil {
  34701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34703. return
  34704. }
  34705. var respJSON map[string]interface{}
  34706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34709. return
  34710. }
  34711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34712. userJSONBytes, _ := json.Marshal(respJSON)
  34713. var res ResultEight
  34714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34715. utils.ErrorLog("解析失败:%v", err)
  34716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34717. return
  34718. }
  34719. }
  34720. func (c *HisApiController) Check390() {
  34721. adminUser := c.GetAdminUserInfo()
  34722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34723. var user_name string
  34724. user_name = "高慧裕"
  34725. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34726. "insutype=" + "390" +
  34727. "&clr_type=" + "" +
  34728. "&setl_optins=" + "441202" +
  34729. "&stmt_begndate=" + "2022-03-01" +
  34730. "&stm_enddate=" + "2022-03-31" +
  34731. "&medfee_sumamt=" + "1068448.89" +
  34732. "&fund_pay_sumamt=" + "1014677.62" +
  34733. "&acct_pay=" + "0" +
  34734. "&fixmedins_setl_cnt=" + "1950" +
  34735. "&fixmedins_code=" + miConfig.Code +
  34736. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34737. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34738. "&secret_key=" + miConfig.SecretKey +
  34739. "&org_name=" + miConfig.OrgName +
  34740. "&doctor=" + user_name
  34741. fmt.Println(api)
  34742. resp, requestErr := http.Get(api)
  34743. if requestErr != nil {
  34744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34745. return
  34746. }
  34747. body, ioErr := ioutil.ReadAll(resp.Body)
  34748. fmt.Println(body)
  34749. if ioErr != nil {
  34750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34752. return
  34753. }
  34754. var respJSON map[string]interface{}
  34755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34758. return
  34759. }
  34760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34761. userJSONBytes, _ := json.Marshal(respJSON)
  34762. var res ResultEight
  34763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34764. utils.ErrorLog("解析失败:%v", err)
  34765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34766. return
  34767. }
  34768. }
  34769. // 对账明细
  34770. func (c *HisApiController) GetCheckDetailAccount() {
  34771. start_time := c.GetString("start_time")
  34772. end_time := c.GetString("end_time")
  34773. admin_user_id, _ := c.GetInt64("admin_user_id")
  34774. adminUser := c.GetAdminUserInfo()
  34775. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34776. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34777. timeLayout := "2006-01-02"
  34778. loc, _ := time.LoadLocation("Local")
  34779. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34780. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34781. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34782. rand.Seed(time.Now().UnixNano())
  34783. num := rand.Intn(30000)
  34784. Mkdir(miConfig.OrgName)
  34785. file := strconv.FormatInt(int64(num), 10)
  34786. file_name := file + ".txt"
  34787. zip_name := file + ".zip"
  34788. zip_path := miConfig.OrgName + "/" + zip_name
  34789. file_path := miConfig.OrgName + "/" + file_name
  34790. decimal.DivisionPrecision = 2
  34791. var medfee_sumamt float64
  34792. var psn_cash_pay float64
  34793. var fund_pay_sumamt float64
  34794. fixmedins_setl_cnt := int64(len(orders))
  34795. for _, item := range orders {
  34796. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34797. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34798. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34799. }
  34800. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34801. defer f.Close()
  34802. if err != nil {
  34803. fmt.Println(err.Error())
  34804. } else {
  34805. for _, item := range orders {
  34806. var refd_setl_flag string
  34807. if item.OrderStatus == 2 {
  34808. refd_setl_flag = "0"
  34809. var str string
  34810. str = item.SetlId + " " +
  34811. item.MdtrtId + " " +
  34812. item.PsnNo + " " +
  34813. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34814. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34815. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34816. _, err = f.Write([]byte(str))
  34817. }
  34818. if item.OrderStatus == 3 {
  34819. var str string
  34820. str = item.SetlId + " " +
  34821. item.MdtrtId + " " +
  34822. item.PsnNo + " " +
  34823. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34824. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34825. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34826. _, err = f.Write([]byte(str))
  34827. var str2 string
  34828. str2 = item.SetlId + " " +
  34829. item.MdtrtId + " " +
  34830. item.PsnNo + " " +
  34831. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34832. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34833. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34834. _, err = f.Write([]byte(str2))
  34835. }
  34836. }
  34837. }
  34838. Zip(file_path, zip_path)
  34839. fmt.Println(ReadFile(zip_path))
  34840. fmt.Println(string(ReadFile(zip_path)))
  34841. if config.IsOpen == 1 {
  34842. var user_name string
  34843. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34844. if role.ID == 0 {
  34845. user_name = "管理员"
  34846. } else {
  34847. user_name = role.UserName
  34848. }
  34849. baseParams := models.BaseParams{
  34850. SecretKey: miConfig.SecretKey,
  34851. FixmedinsCode: miConfig.Code,
  34852. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34853. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34854. OrgName: miConfig.OrgName,
  34855. Doctor: user_name,
  34856. }
  34857. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34858. var dat map[string]interface{}
  34859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34860. fmt.Println(dat)
  34861. } else {
  34862. fmt.Println(err)
  34863. }
  34864. userJSONBytes, _ := json.Marshal(dat)
  34865. var res ResultNine
  34866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34867. utils.ErrorLog("解析失败:%v", err)
  34868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34869. return
  34870. }
  34871. if res.Infcode == 0 {
  34872. fileNo := res.Output.FileQuryNo
  34873. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34874. "file_qury_no=" + fileNo +
  34875. "&setl_optins=" + "定点医保中心" +
  34876. "&stmt_begndate=" + start_time +
  34877. "&stm_enddate=" + end_time +
  34878. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34879. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34880. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34881. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34882. "&fixmedins_code=" + miConfig.Code +
  34883. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34884. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34885. "&secret_key=" + miConfig.SecretKey +
  34886. "&org_name=" + miConfig.OrgName +
  34887. "&doctor=" + user_name
  34888. resp, requestErr := http.Get(api)
  34889. if requestErr != nil {
  34890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34891. return
  34892. }
  34893. body, ioErr := ioutil.ReadAll(resp.Body)
  34894. if ioErr != nil {
  34895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34897. return
  34898. }
  34899. var respJSON map[string]interface{}
  34900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34903. return
  34904. }
  34905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34906. userJSONBytes, _ := json.Marshal(respJSON)
  34907. var res ResultTen
  34908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34909. utils.ErrorLog("解析失败:%v", err)
  34910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34911. return
  34912. }
  34913. if res.Infcode == 0 {
  34914. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34915. micc := &models.MedicalInsuranceCostCompare{
  34916. StartTime: startime.Unix(),
  34917. EndTime: endtime.Unix(),
  34918. Insutype: "0",
  34919. CheckType: 2,
  34920. Num: fixmedins_setl_cnt,
  34921. Mtime: time.Now().Unix(),
  34922. Status: 1,
  34923. UserOrgId: adminUser.CurrentOrgId,
  34924. CostTotal: medfee_sumamt,
  34925. FuncTotal: fund_pay_sumamt,
  34926. PsnPay: psn_cash_pay,
  34927. Creator: admin_user_id,
  34928. Ctime: time.Now().Unix(),
  34929. }
  34930. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34931. c.ServeSuccessJSON(map[string]interface{}{
  34932. "msg": "明细对账成功",
  34933. })
  34934. }
  34935. } else {
  34936. }
  34937. }
  34938. }
  34939. type CustomOrderInfo struct {
  34940. Name string
  34941. Spec string
  34942. Unit string
  34943. Count float64
  34944. Price float64
  34945. Total float64
  34946. }
  34947. func (c *HisApiController) GetBatchSettleAccounts() {
  34948. admin_user_id, _ := c.GetInt64("admin_user_id")
  34949. order_ids := c.GetString("order_ids")
  34950. order_ids_arr := strings.Split(order_ids, ",")
  34951. data3 := []map[string]interface{}{}
  34952. for _, item := range order_ids_arr {
  34953. id, _ := strconv.ParseInt(item, 10, 64)
  34954. order_id := id
  34955. adminUser := c.GetAdminUserInfo()
  34956. order, _ := service.GetHisOrderByID(order_id)
  34957. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34958. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34959. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34960. orderInfos = append(orderInfos, orderInfos_two...)
  34961. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34962. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34963. var diagnosis_ids []string
  34964. if his.ID > 0 {
  34965. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34966. } else {
  34967. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34968. }
  34969. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34970. var dia_config []*models.HisXtDiagnoseConfig
  34971. var name string
  34972. for _, item := range diagnosis_ids {
  34973. id, _ := strconv.ParseInt(item, 10, 64)
  34974. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34975. dia_config = append(dia_config, &diagnosisConfig)
  34976. if len(name) == 0 {
  34977. name = diagnosisConfig.ClassName
  34978. }
  34979. //} else {
  34980. // name = name + "," + diagnosisConfig.ClassName
  34981. //}
  34982. }
  34983. var bedCostTotal float64 = 0 //床位总费
  34984. var bedCostSelfTotal float64 = 0 //床位自费
  34985. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34986. var bedSelfTotal float64 = 0 //床位部分项目自费
  34987. var bedInscpTotal float64 = 0 //床位部分项目自费
  34988. var operationCostTotal float64 = 0 //手术费
  34989. var operationCostSelfTotal float64 = 0 //手术费
  34990. var operationCostPartSelfTotal float64 = 0 //手术费
  34991. var operationSelfTotal float64 = 0 //床位部分项目自费
  34992. var operationInscpTotal float64 = 0 //床位部分项目自费
  34993. var otherCostTotal float64 = 0 //其他费用
  34994. var otherCostSelfTotal float64 = 0 //其他费用
  34995. var otherCostPartSelfTotal float64 = 0 //其他费用
  34996. var otherSelfTotal float64 = 0 //床位部分项目自费
  34997. var otherInscpTotal float64 = 0 //床位部分项目自费
  34998. var materialCostTotal float64 = 0 //材料费
  34999. var materialCostSelfTotal float64 = 0 //材料费
  35000. var materialCostPartSelfTotal float64 = 0 //材料费
  35001. var materialSelfTotal float64 = 0 //床位部分项目自费
  35002. var materialInscpTotal float64 = 0 //床位部分项目自费
  35003. var westernMedicineCostTotal float64 = 0 //西药费
  35004. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35005. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35006. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35007. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35008. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35009. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35010. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35011. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35012. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35013. var checkCostTotal float64 = 0 //检查费
  35014. var checkCostSelfTotal float64 = 0 //检查费
  35015. var checkCostPartSelfTotal float64 = 0 //检查费
  35016. var checkSelfTotal float64 = 0 //床位部分项目自费
  35017. var checkInscpTotal float64 = 0 //床位部分项目自费
  35018. var laboratoryCostTotal float64 = 0 //化验费
  35019. var laboratoryCostSelfTotal float64 = 0 //化验费
  35020. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35021. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35022. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35023. var treatCostTotal float64 = 0 //治疗费用
  35024. var treatCostSelfTotal float64 = 0 //治疗费用
  35025. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35026. var treatSelfTotal float64 = 0 //床位部分项目自费
  35027. var treatInscpTotal float64 = 0 //床位部分项目自费
  35028. decimal.DivisionPrecision = 2
  35029. for _, item := range orderInfos {
  35030. if item.MedChrgitmType == "01" { //床位费
  35031. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35032. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35033. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35034. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35035. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35036. }
  35037. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  35038. if item.MedChrgitmType == "03" { //检查费
  35039. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35040. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35041. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35042. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35043. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35044. }
  35045. } else {
  35046. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  35047. fmt.Println("------------")
  35048. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35049. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35050. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35051. }
  35052. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  35053. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35054. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35055. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35056. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35057. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35058. }
  35059. }
  35060. if item.MedChrgitmType == "04" { //化验费
  35061. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35062. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35063. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35064. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35065. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35066. }
  35067. if item.MedChrgitmType == "05" { //治疗费
  35068. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35069. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35070. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35071. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35072. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35073. }
  35074. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35075. fmt.Println("------------")
  35076. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35077. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35078. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35079. }
  35080. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35081. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35082. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35083. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35084. }
  35085. //if item.MedChrgitmType == "06" { //手术费
  35086. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35087. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35088. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35089. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35090. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35091. //
  35092. //}
  35093. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35094. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35095. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35096. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35097. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35098. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35099. }
  35100. if item.MedChrgitmType == "09" { //西药费
  35101. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35102. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35103. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35104. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35105. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35106. }
  35107. if item.MedChrgitmType == "11" { //中成费
  35108. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35109. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35110. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35111. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35112. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35113. }
  35114. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  35115. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35116. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35117. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35118. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35119. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35120. }
  35121. }
  35122. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35123. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35124. var user_name string
  35125. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35126. if role.ID == 0 {
  35127. user_name = "管理员"
  35128. } else {
  35129. user_name = role.UserName
  35130. }
  35131. baseParams := models.BaseParams{
  35132. SecretKey: miConfig.SecretKey,
  35133. FixmedinsCode: miConfig.Code,
  35134. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35135. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35136. OrgName: miConfig.OrgName,
  35137. Doctor: user_name,
  35138. RequestUrl: miConfig.Url,
  35139. AccessKey: miConfig.AccessKey,
  35140. }
  35141. businessParams := models.BusinessParams{
  35142. PsnNo: order.PsnNo,
  35143. MdtrtId: order.MdtrtId,
  35144. SetlId: order.SetlId,
  35145. }
  35146. var res ResultEleven
  35147. var resEleven10265 ResultEleven10265
  35148. if config.IsOpen == 1 {
  35149. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35150. result := service.Gdyb5203(baseParams, businessParams)
  35151. service.Gdyb5204(baseParams, businessParams)
  35152. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35153. var dat map[string]interface{}
  35154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35155. fmt.Println(dat)
  35156. } else {
  35157. fmt.Println(err)
  35158. }
  35159. userJSONBytes, _ := json.Marshal(dat)
  35160. if miConfig.Code == "H15049901371" {
  35161. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35162. utils.ErrorLog("解析失败:%v", err)
  35163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35164. return
  35165. }
  35166. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35167. res.Output = resEleven10265.Output
  35168. res.ErrMsg = resEleven10265.ErrMsg
  35169. res.Cainfo = resEleven10265.Cainfo
  35170. res.WarnMsg = resEleven10265.WarnMsg
  35171. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35172. res.Infcode = infocode
  35173. } else {
  35174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35175. utils.ErrorLog("解析失败:%v", err)
  35176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35177. return
  35178. }
  35179. }
  35180. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35181. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35182. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35183. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35184. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35185. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35186. var doctor_name string
  35187. if roles.ID == 0 {
  35188. doctor_name = "管理员"
  35189. } else {
  35190. doctor_name = roles.UserName
  35191. }
  35192. yiliao_leibie := ""
  35193. switch order.MedType {
  35194. case "11":
  35195. yiliao_leibie = "普通门诊"
  35196. break
  35197. case "12":
  35198. yiliao_leibie = "门诊挂号"
  35199. break
  35200. case "13":
  35201. yiliao_leibie = "急诊"
  35202. break
  35203. case "14":
  35204. yiliao_leibie = "门诊特殊病"
  35205. break
  35206. case "15":
  35207. yiliao_leibie = "门诊统筹"
  35208. break
  35209. case "16":
  35210. yiliao_leibie = "门诊慢性病"
  35211. break
  35212. case "21":
  35213. yiliao_leibie = "普通住院"
  35214. break
  35215. }
  35216. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35217. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  35218. if res.Infcode == 0 {
  35219. data2 := map[string]interface{}{
  35220. "diagnosis": name,
  35221. "order_infos": orderInfos,
  35222. "number": order.MdtrtId,
  35223. "date": order.SettleAccountsDate,
  35224. "charge_admin": charge_admin,
  35225. "printor_admin": printor_admin,
  35226. "info": res.Output.Setlinfo,
  35227. "order": order,
  35228. "bedCostTotal": bedCostTotal,
  35229. "bedCostSelfTotal": bedCostSelfTotal,
  35230. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35231. "bedSelfTotal": bedSelfTotal,
  35232. "bedInscpTotal": bedInscpTotal,
  35233. "operationCostTotal": operationCostTotal,
  35234. "operationCostSelfTotal": operationCostSelfTotal,
  35235. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35236. "operationSelfTotal": operationSelfTotal,
  35237. "operationInscpTotal": operationInscpTotal,
  35238. "otherCostTotal": otherCostTotal,
  35239. "otherCostSelfTotal": otherCostSelfTotal,
  35240. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35241. "otherSelfTotal": otherSelfTotal,
  35242. "otherInscpTotal": otherInscpTotal,
  35243. "materialCostTotal": materialCostTotal,
  35244. "materialCostSelfTotal": materialCostSelfTotal,
  35245. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35246. "materialSelfTotal": materialSelfTotal,
  35247. "materialInscpTotal": materialInscpTotal,
  35248. "westernMedicineCostTotal": westernMedicineCostTotal,
  35249. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35250. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35251. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35252. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35253. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35254. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35255. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35256. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35257. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35258. "checkCostTotal": checkCostTotal,
  35259. "checkCostSelfTotal": checkCostSelfTotal,
  35260. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35261. "checkSelfTotal": checkSelfTotal,
  35262. "checkInscpTotal": checkInscpTotal,
  35263. "laboratoryCostTotal": laboratoryCostTotal,
  35264. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35265. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35266. "laboratorySelfTotal": laboratorySelfTotal,
  35267. "laboratoryInscpTotal": laboratoryInscpTotal,
  35268. "treatCostTotal": treatCostTotal,
  35269. "treatCostSelfTotal": treatCostSelfTotal,
  35270. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35271. "treatSelfTotal": treatSelfTotal,
  35272. "treatInscpTotal": treatInscpTotal,
  35273. "doctor_info": doctor_info,
  35274. "doctor_code": adminRole_two.DoctorCode,
  35275. "doctor_name": doctor_name,
  35276. "health_card_no": order.PsnNo,
  35277. "department": departments.Name,
  35278. "yiliao_leibie": yiliao_leibie,
  35279. "after_money": order.AccountPrice,
  35280. "patient": patient,
  35281. "org_name": miConfig.OrgName,
  35282. "org_code": miConfig.Code,
  35283. "order_number": order.Number,
  35284. "his_hospital": his_hospital,
  35285. "his": his,
  35286. "dia_config": dia_config,
  35287. "psn_cash_pay": order.PsnCashPay,
  35288. //"check_order_info": cus_slice,
  35289. }
  35290. data3 = append(data3, data2)
  35291. }
  35292. }
  35293. }
  35294. c.ServeSuccessJSON(map[string]interface{}{
  35295. "infos": data3,
  35296. })
  35297. }
  35298. func (c *HisApiController) GetSettleAccounts() {
  35299. //id, _ := c.GetInt64("id")
  35300. //record_time := c.GetString("record_time")
  35301. order_id, _ := c.GetInt64("order_id")
  35302. admin_user_id, _ := c.GetInt64("admin_user_id")
  35303. //timeLayout := "2006-01-02"
  35304. //loc, _ := time.LoadLocation("Local")
  35305. //
  35306. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35307. //if err != nil {
  35308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35309. // return
  35310. //}Hbyb5203
  35311. //recordDateTime := theTime.Unix()
  35312. adminUser := c.GetAdminUserInfo()
  35313. order, _ := service.GetHisOrderByID(order_id)
  35314. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35315. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  35316. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  35317. orderInfos = append(orderInfos, orderInfos_two...)
  35318. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  35319. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  35320. var diagnosis_ids []string
  35321. if his.ID > 0 {
  35322. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  35323. } else {
  35324. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  35325. }
  35326. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  35327. var dia_config []*models.HisXtDiagnoseConfig
  35328. var name string
  35329. for _, item := range diagnosis_ids {
  35330. id, _ := strconv.ParseInt(item, 10, 64)
  35331. diagnosisConfig, _ := service.FindDiagnoseById(id)
  35332. dia_config = append(dia_config, &diagnosisConfig)
  35333. if len(name) == 0 {
  35334. name = diagnosisConfig.ClassName
  35335. } else {
  35336. name = name + "," + diagnosisConfig.ClassName
  35337. }
  35338. }
  35339. if patient.UserOrgId == 10215 {
  35340. name = "慢性肾功能不全(血透治疗)"
  35341. }
  35342. var bedCostTotal float64 = 0 //床位总费
  35343. var bedCostSelfTotal float64 = 0 //床位自费
  35344. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  35345. var bedSelfTotal float64 = 0 //床位部分项目自费
  35346. var bedInscpTotal float64 = 0 //床位部分项目自费
  35347. var operationCostTotal float64 = 0 //手术费
  35348. var operationCostSelfTotal float64 = 0 //手术费
  35349. var operationCostPartSelfTotal float64 = 0 //手术费
  35350. var operationSelfTotal float64 = 0 //床位部分项目自费
  35351. var operationInscpTotal float64 = 0 //床位部分项目自费
  35352. var otherCostTotal float64 = 0 //其他费用
  35353. var otherCostSelfTotal float64 = 0 //其他费用
  35354. var otherCostPartSelfTotal float64 = 0 //其他费用
  35355. var otherSelfTotal float64 = 0 //床位部分项目自费
  35356. var otherInscpTotal float64 = 0 //床位部分项目自费
  35357. var materialCostTotal float64 = 0 //材料费
  35358. var materialCostSelfTotal float64 = 0 //材料费
  35359. var materialCostPartSelfTotal float64 = 0 //材料费
  35360. var materialSelfTotal float64 = 0 //床位部分项目自费
  35361. var materialInscpTotal float64 = 0 //床位部分项目自费
  35362. var westernMedicineCostTotal float64 = 0 //西药费
  35363. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35364. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35365. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35366. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35367. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35368. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35369. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35370. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35371. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35372. var checkCostTotal float64 = 0 //检查费
  35373. var checkCostSelfTotal float64 = 0 //检查费
  35374. var checkCostPartSelfTotal float64 = 0 //检查费
  35375. var checkSelfTotal float64 = 0 //床位部分项目自费
  35376. var checkInscpTotal float64 = 0 //床位部分项目自费
  35377. var laboratoryCostTotal float64 = 0 //化验费
  35378. var laboratoryCostSelfTotal float64 = 0 //化验费
  35379. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35380. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35381. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35382. var treatCostTotal float64 = 0 //治疗费用
  35383. var treatCostSelfTotal float64 = 0 //治疗费用
  35384. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35385. var treatSelfTotal float64 = 0 //床位部分项目自费
  35386. var treatInscpTotal float64 = 0 //床位部分项目自费
  35387. var zcCostTotal float64 = 0 //治疗费用
  35388. var zcCostSelfTotal float64 = 0 //治疗费用
  35389. var zcCostPartSelfTotal float64 = 0 //治疗费用
  35390. var zcSelfTotal float64 = 0 //床位部分项目自费
  35391. var zcInscpTotal float64 = 0 //床位部分项目自费
  35392. var huliCostTotal float64 = 0 //治疗费用
  35393. var huliCostSelfTotal float64 = 0 //治疗费用
  35394. var huliCostPartSelfTotal float64 = 0 //治疗费用
  35395. var huliSelfTotal float64 = 0 //床位部分项目自费
  35396. var huliInscpTotal float64 = 0 //床位部分项目自费
  35397. decimal.DivisionPrecision = 2
  35398. for _, item := range orderInfos {
  35399. if item.MedChrgitmType == "01" { //床位费
  35400. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35401. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35402. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35403. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35404. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35405. }
  35406. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  35407. if item.MedChrgitmType == "03" { //检查费
  35408. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35409. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35410. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35411. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35412. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35413. }
  35414. } else {
  35415. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  35416. fmt.Println("------------")
  35417. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35418. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35419. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35420. }
  35421. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  35422. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35423. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35424. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35425. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35426. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35427. }
  35428. }
  35429. if item.MedChrgitmType == "04" { //化验费
  35430. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35431. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35432. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35433. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35434. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35435. }
  35436. if item.MedChrgitmType == "05" { //治疗费
  35437. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35438. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35439. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35440. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35441. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35442. }
  35443. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35444. fmt.Println("------------")
  35445. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35446. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35447. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35448. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35449. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35450. }
  35451. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35452. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35453. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35454. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35455. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35456. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35457. }
  35458. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35459. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35460. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35461. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35462. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35463. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35464. }
  35465. if item.MedChrgitmType == "09" { //西药费
  35466. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35467. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35468. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35469. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35470. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35471. }
  35472. if item.MedChrgitmType == "11" { //中成费
  35473. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35474. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35475. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35476. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35477. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35478. }
  35479. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  35480. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35481. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35482. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35483. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35484. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35485. }
  35486. if item.MedChrgitmType == "02" { //其他费
  35487. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35488. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35489. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35490. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35491. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35492. }
  35493. if item.MedChrgitmType == "07" { //其他费
  35494. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35495. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35496. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35497. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35498. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35499. }
  35500. }
  35501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35502. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35503. var user_name string
  35504. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35505. if role.ID == 0 {
  35506. user_name = "管理员"
  35507. } else {
  35508. user_name = role.UserName
  35509. }
  35510. baseParams := models.BaseParams{
  35511. SecretKey: miConfig.SecretKey,
  35512. FixmedinsCode: miConfig.Code,
  35513. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35514. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35515. OrgName: miConfig.OrgName,
  35516. Doctor: user_name,
  35517. RequestUrl: miConfig.Url,
  35518. AccessKey: miConfig.AccessKey,
  35519. }
  35520. businessParams := models.BusinessParams{
  35521. PsnNo: order.PsnNo,
  35522. MdtrtId: order.MdtrtId,
  35523. SetlId: order.SetlId,
  35524. }
  35525. var res ResultEleven
  35526. var resah ResultElevenah
  35527. var resEleven10265 ResultEleven10265
  35528. if config.IsOpen == 1 {
  35529. if miConfig.MdtrtareaAdmvs == "421300" {
  35530. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35531. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35532. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35533. resp, requestErr := http.Get(api)
  35534. if requestErr != nil {
  35535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35536. return
  35537. }
  35538. body, ioErr := ioutil.ReadAll(resp.Body)
  35539. if ioErr != nil {
  35540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35542. return
  35543. }
  35544. var respJSON map[string]interface{}
  35545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35548. return
  35549. }
  35550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35551. result, _ := json.Marshal(respJSON)
  35552. fmt.Println("log")
  35553. fmt.Println(string(result))
  35554. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35555. utils.ErrorLog("解析失败:%v", err)
  35556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35557. return
  35558. }
  35559. } else if miConfig.MdtrtareaAdmvs == "420200" {
  35560. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35561. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35562. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35563. resp, requestErr := http.Get(api)
  35564. if requestErr != nil {
  35565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35566. return
  35567. }
  35568. body, ioErr := ioutil.ReadAll(resp.Body)
  35569. if ioErr != nil {
  35570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35572. return
  35573. }
  35574. var respJSON map[string]interface{}
  35575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35578. return
  35579. }
  35580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35581. result, _ := json.Marshal(respJSON)
  35582. fmt.Println("log")
  35583. fmt.Println(string(result))
  35584. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35585. utils.ErrorLog("解析失败:%v", err)
  35586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35587. return
  35588. }
  35589. } else if miConfig.MdtrtareaAdmvs == "420902" {
  35590. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35591. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35592. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35593. resp, requestErr := http.Get(api)
  35594. if requestErr != nil {
  35595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35596. return
  35597. }
  35598. body, ioErr := ioutil.ReadAll(resp.Body)
  35599. if ioErr != nil {
  35600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35602. return
  35603. }
  35604. var respJSON map[string]interface{}
  35605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35608. return
  35609. }
  35610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35611. result, _ := json.Marshal(respJSON)
  35612. fmt.Println("log")
  35613. fmt.Println(string(result))
  35614. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35615. utils.ErrorLog("解析失败:%v", err)
  35616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35617. return
  35618. }
  35619. } else if miConfig.MdtrtareaAdmvs == "421182" {
  35620. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35621. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35622. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  35623. resp, requestErr := http.Get(api)
  35624. if requestErr != nil {
  35625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35626. return
  35627. }
  35628. body, ioErr := ioutil.ReadAll(resp.Body)
  35629. if ioErr != nil {
  35630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35632. return
  35633. }
  35634. var respJSON map[string]interface{}
  35635. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35638. return
  35639. }
  35640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35641. result, _ := json.Marshal(respJSON)
  35642. fmt.Println("log")
  35643. fmt.Println(string(result))
  35644. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35645. utils.ErrorLog("解析失败:%v", err)
  35646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35647. return
  35648. }
  35649. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35650. var api string
  35651. if miConfig.MdtrtareaAdmvs == "320921" {
  35652. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35653. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35655. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35656. } else {
  35657. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35658. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35659. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35660. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35661. }
  35662. resp, requestErr := http.Get(api)
  35663. if requestErr != nil {
  35664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35665. return
  35666. }
  35667. body, ioErr := ioutil.ReadAll(resp.Body)
  35668. if ioErr != nil {
  35669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35671. return
  35672. }
  35673. var respJSON map[string]interface{}
  35674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35677. return
  35678. }
  35679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35680. result, _ := json.Marshal(respJSON)
  35681. fmt.Println("log")
  35682. fmt.Println(string(result))
  35683. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35684. utils.ErrorLog("解析失败:%v", err)
  35685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35686. return
  35687. }
  35688. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35689. res.Output = resEleven10265.Output
  35690. res.ErrMsg = resEleven10265.ErrMsg
  35691. res.Cainfo = resEleven10265.Cainfo
  35692. res.WarnMsg = resEleven10265.WarnMsg
  35693. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35694. res.Infcode = infocode
  35695. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35696. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  35697. saveLog(result, requestLog, "5203", "结算单")
  35698. var dat map[string]interface{}
  35699. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35700. fmt.Println(dat)
  35701. } else {
  35702. fmt.Println(err)
  35703. }
  35704. userJSONBytes, _ := json.Marshal(dat)
  35705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35706. utils.ErrorLog("解析失败:%v", err)
  35707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35708. return
  35709. }
  35710. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35711. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35712. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35713. saveLog(result, requestLog, "5203", "结算单")
  35714. var dat map[string]interface{}
  35715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35716. fmt.Println(dat)
  35717. } else {
  35718. fmt.Println(err)
  35719. }
  35720. userJSONBytes, _ := json.Marshal(dat)
  35721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35722. utils.ErrorLog("解析失败:%v", err)
  35723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35724. return
  35725. }
  35726. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35727. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35728. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35729. saveLog(result, requestLog, "5203", "结算单")
  35730. var dat map[string]interface{}
  35731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35732. fmt.Println(dat)
  35733. } else {
  35734. fmt.Println(err)
  35735. }
  35736. userJSONBytes, _ := json.Marshal(dat)
  35737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35738. utils.ErrorLog("解析失败:%v", err)
  35739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35740. return
  35741. }
  35742. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35743. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35744. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35745. saveLog(result, requestLog, "5203", "结算单")
  35746. var dat map[string]interface{}
  35747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35748. fmt.Println(dat)
  35749. } else {
  35750. fmt.Println(err)
  35751. }
  35752. userJSONBytes, _ := json.Marshal(dat)
  35753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35754. utils.ErrorLog("解析失败:%v", err)
  35755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35756. return
  35757. }
  35758. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35759. var api string
  35760. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35761. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35762. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35763. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35764. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35765. resp, requestErr := http.Get(api)
  35766. if requestErr != nil {
  35767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35768. return
  35769. }
  35770. body, ioErr := ioutil.ReadAll(resp.Body)
  35771. if ioErr != nil {
  35772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35774. return
  35775. }
  35776. var respJSON map[string]interface{}
  35777. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35780. return
  35781. }
  35782. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35783. if status == "0" {
  35784. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35785. c.ServeSuccessJSON(map[string]interface{}{
  35786. "failed_code": -10,
  35787. "msg": err_msg,
  35788. })
  35789. return
  35790. }
  35791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35792. result, _ := json.Marshal(respJSON)
  35793. fmt.Println("log")
  35794. fmt.Println(string(result))
  35795. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35796. utils.ErrorLog("解析失败:%v", err)
  35797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35798. return
  35799. }
  35800. res.InfRefmsgid = resah.InfRefmsgid
  35801. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35802. // 创建对应的Time类型
  35803. t := time.UnixMilli(timestamp)
  35804. // 格式化成指定的日期字符串
  35805. str := t.Format("2006-01-02 15:04:05")
  35806. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35807. // 创建对应的Time类型
  35808. t3 := time.UnixMilli(timestamp2)
  35809. // 格式化成指定的日期字符串
  35810. str2 := t3.Format("2006-01-02 15:04:05")
  35811. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35812. // 创建对应的Time类型
  35813. t4 := time.UnixMilli(timestamp3)
  35814. // 格式化成指定的日期字符串
  35815. str3 := t4.Format("2006-01-02 15:04:05")
  35816. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35817. // 创建对应的Time类型
  35818. t5 := time.UnixMilli(timestamp4)
  35819. // 格式化成指定的日期字符串
  35820. str5 := t5.Format("2006-01-02 15:04:05")
  35821. res.Output.Setlinfo.Brdy = str2
  35822. res.Output.Setlinfo.SetlTime = str
  35823. res.Output.Setlinfo.Begndate = str3
  35824. res.Output.Setlinfo.Enddate = str5
  35825. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35826. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35827. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35828. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35829. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35830. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35831. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35832. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35833. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35834. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35835. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35836. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35837. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35838. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35839. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35840. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35841. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35842. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35843. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35844. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35845. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35846. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35847. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35848. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35849. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35850. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35851. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35852. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35853. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35854. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35855. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35856. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35857. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35858. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35859. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35860. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35861. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35862. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35863. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35864. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35865. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35866. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35867. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35868. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35869. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35870. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35871. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35872. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35873. //res.Output.Setldetail = resah.Output.Setldetail
  35874. res.ErrMsg = resah.ErrMsg
  35875. res.Cainfo = resah.Cainfo
  35876. res.WarnMsg = resah.WarnMsg
  35877. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35878. var api string
  35879. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35880. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35881. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35882. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35883. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35884. resp, requestErr := http.Get(api)
  35885. if requestErr != nil {
  35886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35887. return
  35888. }
  35889. body, ioErr := ioutil.ReadAll(resp.Body)
  35890. if ioErr != nil {
  35891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35893. return
  35894. }
  35895. var respJSON map[string]interface{}
  35896. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35899. return
  35900. }
  35901. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35902. if status == "0" {
  35903. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35904. c.ServeSuccessJSON(map[string]interface{}{
  35905. "failed_code": -10,
  35906. "msg": err_msg,
  35907. })
  35908. return
  35909. }
  35910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35911. result, _ := json.Marshal(respJSON)
  35912. fmt.Println("log")
  35913. fmt.Println(string(result))
  35914. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35915. utils.ErrorLog("解析失败:%v", err)
  35916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35917. return
  35918. }
  35919. res.InfRefmsgid = resah.InfRefmsgid
  35920. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35921. // 创建对应的Time类型
  35922. t := time.UnixMilli(timestamp)
  35923. // 格式化成指定的日期字符串
  35924. str := t.Format("2006-01-02 15:04:05")
  35925. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35926. // 创建对应的Time类型
  35927. t3 := time.UnixMilli(timestamp2)
  35928. // 格式化成指定的日期字符串
  35929. str2 := t3.Format("2006-01-02 15:04:05")
  35930. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35931. // 创建对应的Time类型
  35932. t4 := time.UnixMilli(timestamp3)
  35933. // 格式化成指定的日期字符串
  35934. str3 := t4.Format("2006-01-02 15:04:05")
  35935. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35936. // 创建对应的Time类型
  35937. t5 := time.UnixMilli(timestamp4)
  35938. // 格式化成指定的日期字符串
  35939. str5 := t5.Format("2006-01-02 15:04:05")
  35940. res.Output.Setlinfo.Brdy = str2
  35941. res.Output.Setlinfo.SetlTime = str
  35942. res.Output.Setlinfo.Begndate = str3
  35943. res.Output.Setlinfo.Enddate = str5
  35944. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35945. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35946. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35947. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35948. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35949. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35950. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35951. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35952. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35953. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35954. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35955. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35956. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35957. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35958. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35959. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35960. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35961. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35962. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35963. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35964. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35965. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35966. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35967. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35968. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35969. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35970. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35971. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35972. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35973. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35974. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35975. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35976. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35977. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35978. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35979. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35980. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35981. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35982. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35983. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35984. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35985. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35986. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35987. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35988. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35989. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35990. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35991. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35992. //res.Output.Setldetail = resah.Output.Setldetail
  35993. res.ErrMsg = resah.ErrMsg
  35994. res.Cainfo = resah.Cainfo
  35995. res.WarnMsg = resah.WarnMsg
  35996. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35997. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35998. saveLog(result, requestLog, "5203", "结算单")
  35999. var dat map[string]interface{}
  36000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36001. fmt.Println(dat)
  36002. } else {
  36003. fmt.Println(err)
  36004. }
  36005. userJSONBytes, _ := json.Marshal(dat)
  36006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36007. utils.ErrorLog("解析失败:%v", err)
  36008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36009. return
  36010. }
  36011. } else if miConfig.MdtrtareaAdmvs == "150499" {
  36012. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36013. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36014. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36015. resp, requestErr := http.Get(api)
  36016. if requestErr != nil {
  36017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36018. return
  36019. }
  36020. body, ioErr := ioutil.ReadAll(resp.Body)
  36021. if ioErr != nil {
  36022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36024. return
  36025. }
  36026. var respJSON map[string]interface{}
  36027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36030. return
  36031. }
  36032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36033. result, _ := json.Marshal(respJSON)
  36034. fmt.Println("log")
  36035. fmt.Println(string(result))
  36036. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36037. utils.ErrorLog("解析失败:%v", err)
  36038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36039. return
  36040. }
  36041. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36042. res.Output = resEleven10265.Output
  36043. res.ErrMsg = resEleven10265.ErrMsg
  36044. res.Cainfo = resEleven10265.Cainfo
  36045. res.WarnMsg = resEleven10265.WarnMsg
  36046. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36047. res.Infcode = infocode
  36048. } else if miConfig.MdtrtareaAdmvs == "441799" {
  36049. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36050. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36051. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36052. resp, requestErr := http.Get(api)
  36053. if requestErr != nil {
  36054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36055. return
  36056. }
  36057. body, ioErr := ioutil.ReadAll(resp.Body)
  36058. if ioErr != nil {
  36059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36061. return
  36062. }
  36063. var respJSON map[string]interface{}
  36064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36067. return
  36068. }
  36069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36070. result, _ := json.Marshal(respJSON)
  36071. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36072. utils.ErrorLog("解析失败:%v", err)
  36073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36074. return
  36075. }
  36076. } else if miConfig.MdtrtareaAdmvs == "450721" {
  36077. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  36078. //return
  36079. } else {
  36080. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36081. if len(his.InsuplcAdmdvs) == 0 {
  36082. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  36083. } else {
  36084. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36085. }
  36086. result := service.Gdyb5203(baseParams, businessParams)
  36087. //service.Gdyb5204(baseParams, businessParams)
  36088. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36089. var dat map[string]interface{}
  36090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36091. fmt.Println(dat)
  36092. } else {
  36093. fmt.Println(err)
  36094. }
  36095. userJSONBytes, _ := json.Marshal(dat)
  36096. if miConfig.Code == "H15049901371" {
  36097. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36098. utils.ErrorLog("解析失败:%v", err)
  36099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36100. return
  36101. }
  36102. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36103. res.Output = resEleven10265.Output
  36104. res.ErrMsg = resEleven10265.ErrMsg
  36105. res.Cainfo = resEleven10265.Cainfo
  36106. res.WarnMsg = resEleven10265.WarnMsg
  36107. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36108. res.Infcode = infocode
  36109. } else {
  36110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36111. utils.ErrorLog("解析失败:%v", err)
  36112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36113. return
  36114. }
  36115. }
  36116. }
  36117. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36118. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36119. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36120. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36122. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36123. var doctor_name string
  36124. if roles.ID == 0 {
  36125. doctor_name = "管理员"
  36126. } else {
  36127. doctor_name = roles.UserName
  36128. }
  36129. yiliao_leibie := ""
  36130. switch order.MedType {
  36131. case "11":
  36132. yiliao_leibie = "普通门诊"
  36133. break
  36134. case "12":
  36135. yiliao_leibie = "门诊挂号"
  36136. break
  36137. case "13":
  36138. yiliao_leibie = "急诊"
  36139. break
  36140. case "14":
  36141. yiliao_leibie = "门诊特殊病"
  36142. break
  36143. case "15":
  36144. yiliao_leibie = "门诊统筹"
  36145. break
  36146. case "16":
  36147. yiliao_leibie = "门诊慢性病"
  36148. break
  36149. case "21":
  36150. yiliao_leibie = "普通住院"
  36151. break
  36152. }
  36153. //var rf []CustomFundPay
  36154. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  36155. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36156. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  36157. if res.Infcode == 0 {
  36158. 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 {
  36159. c.ServeSuccessJSON(map[string]interface{}{
  36160. "diagnosis": name,
  36161. "order_infos": orderInfos,
  36162. "number": order.MdtrtId,
  36163. "date": order.SettleAccountsDate,
  36164. "charge_admin": charge_admin,
  36165. "printor_admin": printor_admin,
  36166. "info": res.Output.Setlinfo,
  36167. "order": order,
  36168. "bedCostTotal": bedCostTotal,
  36169. "bedCostSelfTotal": bedCostSelfTotal,
  36170. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36171. "bedSelfTotal": bedSelfTotal,
  36172. "bedInscpTotal": bedInscpTotal,
  36173. "operationCostTotal": operationCostTotal,
  36174. "operationCostSelfTotal": operationCostSelfTotal,
  36175. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36176. "operationSelfTotal": operationSelfTotal,
  36177. "operationInscpTotal": operationInscpTotal,
  36178. "otherCostTotal": otherCostTotal,
  36179. "otherCostSelfTotal": otherCostSelfTotal,
  36180. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36181. "otherSelfTotal": otherSelfTotal,
  36182. "otherInscpTotal": otherInscpTotal,
  36183. "materialCostTotal": materialCostTotal,
  36184. "materialCostSelfTotal": materialCostSelfTotal,
  36185. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36186. "materialSelfTotal": materialSelfTotal,
  36187. "materialInscpTotal": materialInscpTotal,
  36188. "westernMedicineCostTotal": westernMedicineCostTotal,
  36189. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36190. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36191. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36192. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36193. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36194. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36195. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36196. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36197. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36198. "checkCostTotal": checkCostTotal,
  36199. "checkCostSelfTotal": checkCostSelfTotal,
  36200. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36201. "checkSelfTotal": checkSelfTotal,
  36202. "checkInscpTotal": checkInscpTotal,
  36203. "laboratoryCostTotal": laboratoryCostTotal,
  36204. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36205. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36206. "laboratorySelfTotal": laboratorySelfTotal,
  36207. "laboratoryInscpTotal": laboratoryInscpTotal,
  36208. "treatCostTotal": treatCostTotal,
  36209. "treatCostSelfTotal": treatCostSelfTotal,
  36210. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36211. "treatSelfTotal": treatSelfTotal,
  36212. "treatInscpTotal": treatInscpTotal,
  36213. "doctor_info": doctor_info,
  36214. "doctor_code": adminRole_two.DoctorCode,
  36215. "doctor_name": doctor_name,
  36216. "health_card_no": order.PsnNo,
  36217. "department": departments.Name,
  36218. "yiliao_leibie": yiliao_leibie,
  36219. "after_money": order.AccountPrice,
  36220. "patient": patient,
  36221. "org_name": miConfig.OrgName,
  36222. "org_code": miConfig.Code,
  36223. "order_number": order.Number,
  36224. "his_hospital": his_hospital,
  36225. "his": his,
  36226. "dia_config": dia_config,
  36227. "psn_cash_pay": order.PsnCashPay,
  36228. "zcCostTotal": zcCostTotal,
  36229. "zcCostSelfTotal": zcCostSelfTotal,
  36230. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36231. "zcSelfTotal": zcSelfTotal,
  36232. "zcInscpTotal": zcInscpTotal,
  36233. "huliCostTotal": huliCostTotal,
  36234. "huliCostSelfTotal": huliCostSelfTotal,
  36235. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36236. "huliSelfTotal": huliSelfTotal,
  36237. "huliInscpTotal": huliInscpTotal,
  36238. //"funds": rf,
  36239. //"check_order_info": cus_slice,
  36240. })
  36241. } else {
  36242. c.ServeSuccessJSON(map[string]interface{}{
  36243. "diagnosis": name,
  36244. "order_infos": orderInfos,
  36245. "number": order.MdtrtId,
  36246. "date": order.SettleAccountsDate,
  36247. "charge_admin": charge_admin,
  36248. "printor_admin": printor_admin,
  36249. "info": order,
  36250. "order": order,
  36251. "bedCostTotal": bedCostTotal,
  36252. "bedCostSelfTotal": bedCostSelfTotal,
  36253. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36254. "bedSelfTotal": bedSelfTotal,
  36255. "bedInscpTotal": bedInscpTotal,
  36256. "operationCostTotal": operationCostTotal,
  36257. "operationCostSelfTotal": operationCostSelfTotal,
  36258. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36259. "operationSelfTotal": operationSelfTotal,
  36260. "operationInscpTotal": operationInscpTotal,
  36261. "otherCostTotal": otherCostTotal,
  36262. "otherCostSelfTotal": otherCostSelfTotal,
  36263. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36264. "otherSelfTotal": otherSelfTotal,
  36265. "otherInscpTotal": otherInscpTotal,
  36266. "materialCostTotal": materialCostTotal,
  36267. "materialCostSelfTotal": materialCostSelfTotal,
  36268. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36269. "materialSelfTotal": materialSelfTotal,
  36270. "materialInscpTotal": materialInscpTotal,
  36271. "westernMedicineCostTotal": westernMedicineCostTotal,
  36272. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36273. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36274. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36275. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36276. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36277. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36278. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36279. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36280. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36281. "checkCostTotal": checkCostTotal,
  36282. "checkCostSelfTotal": checkCostSelfTotal,
  36283. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36284. "checkSelfTotal": checkSelfTotal,
  36285. "checkInscpTotal": checkInscpTotal,
  36286. "laboratoryCostTotal": laboratoryCostTotal,
  36287. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36288. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36289. "laboratorySelfTotal": laboratorySelfTotal,
  36290. "laboratoryInscpTotal": laboratoryInscpTotal,
  36291. "treatCostTotal": treatCostTotal,
  36292. "treatCostSelfTotal": treatCostSelfTotal,
  36293. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36294. "treatSelfTotal": treatSelfTotal,
  36295. "treatInscpTotal": treatInscpTotal,
  36296. "doctor_info": doctor_info,
  36297. "doctor_code": adminRole_two.DoctorCode,
  36298. "doctor_name": doctor_name,
  36299. "health_card_no": order.PsnNo,
  36300. "department": departments.Name,
  36301. "yiliao_leibie": yiliao_leibie,
  36302. "after_money": order.AccountPrice,
  36303. "patient": patient,
  36304. "org_name": miConfig.OrgName,
  36305. "org_code": miConfig.Code,
  36306. "order_number": order.Number,
  36307. "his_hospital": his_hospital,
  36308. "his": his,
  36309. "dia_config": dia_config,
  36310. "psn_cash_pay": order.PsnCashPay,
  36311. "zcCostTotal": zcCostTotal,
  36312. "zcCostSelfTotal": zcCostSelfTotal,
  36313. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36314. "zcSelfTotal": zcSelfTotal,
  36315. "zcInscpTotal": zcInscpTotal,
  36316. "huliCostTotal": huliCostTotal,
  36317. "huliCostSelfTotal": huliCostSelfTotal,
  36318. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36319. "huliSelfTotal": huliSelfTotal,
  36320. "huliInscpTotal": huliInscpTotal,
  36321. //"funds": rf,
  36322. //"check_order_info": cus_slice,
  36323. })
  36324. }
  36325. }
  36326. }
  36327. }
  36328. //func (c *HisApiController) CheckTreatment() {
  36329. // patient_id, _ := c.GetInt64("patient_id")
  36330. // id_card_no := c.GetString("id_card_no")
  36331. // insutype := c.GetString("insutype")
  36332. // med_type := c.GetString("med_type")
  36333. // admin_user_id, _ := c.GetInt64("admin_user_id")
  36334. //
  36335. // adminUser := c.GetAdminUserInfo()
  36336. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36337. //
  36338. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36339. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36340. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36341. //
  36342. // if miConfig.MdtrtareaAdmvs == "421300" {
  36343. // var res ResultTwo
  36344. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  36345. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  36346. // "&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)
  36347. // resp, requestErr := http.Get(api)
  36348. // if requestErr != nil {
  36349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36350. // return
  36351. // }
  36352. //
  36353. // body, ioErr := ioutil.ReadAll(resp.Body)
  36354. // if ioErr != nil {
  36355. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36357. // return
  36358. // }
  36359. // var respJSON map[string]interface{}
  36360. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36361. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36363. // return
  36364. // }
  36365. //
  36366. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36367. // result, _ := json.Marshal(respJSON)
  36368. //
  36369. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  36370. // utils.ErrorLog("解析失败:%v", err)
  36371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36372. // return
  36373. // }
  36374. //
  36375. // if res.Infcode == 0 {
  36376. //
  36377. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  36378. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  36379. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  36380. // resp, requestErr := http.Get(api)
  36381. // if requestErr != nil {
  36382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36383. // return
  36384. // }
  36385. //
  36386. // body, ioErr := ioutil.ReadAll(resp.Body)
  36387. // if ioErr != nil {
  36388. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36390. // return
  36391. // }
  36392. // var respJSON map[string]interface{}
  36393. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36394. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36396. // return
  36397. // }
  36398. // var res Result2001
  36399. //
  36400. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36401. // result2, _ := json.Marshal(respJSON)
  36402. //
  36403. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  36404. // utils.ErrorLog("解析失败:%v", err)
  36405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36406. // return
  36407. // }
  36408. //
  36409. // if res.Infcode == 0 {
  36410. // c.ServeSuccessJSON(map[string]interface{}{
  36411. // "msg": res.Output.Trtinfo,
  36412. // })
  36413. // }
  36414. //
  36415. // } else {
  36416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36417. // return
  36418. // }
  36419. //
  36420. // } else {
  36421. //
  36422. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36423. // var dat map[string]interface{}
  36424. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36425. // fmt.Println(dat)
  36426. // } else {
  36427. // fmt.Println(err)
  36428. // }
  36429. // userJSONBytes, _ := json.Marshal(dat)
  36430. // var res ResultTwo
  36431. // var res10265 ResultTwo10265
  36432. // if miConfig.Code == "H15049901371" {
  36433. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36434. // utils.ErrorLog("解析失败:%v", err)
  36435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36436. // return
  36437. // }
  36438. // res.ErrMsg = res10265.ErrMsg
  36439. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36440. // res.Infcode = infocode
  36441. // res.Output = res10265.Output
  36442. // res.InfRefmsgid = res10265.InfRefmsgid
  36443. // } else {
  36444. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36445. // utils.ErrorLog("解析失败:%v", err)
  36446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36447. // return
  36448. // }
  36449. // }
  36450. //
  36451. // var user_name string
  36452. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  36453. // if role.ID == 0 {
  36454. // user_name = "xxx"
  36455. // } else {
  36456. // user_name = role.UserName
  36457. // }
  36458. //
  36459. // baseParams := models.BaseParams{
  36460. // SecretKey: miConfig.SecretKey,
  36461. // FixmedinsCode: miConfig.Code,
  36462. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36463. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36464. // OrgName: miConfig.OrgName,
  36465. // Doctor: user_name,
  36466. // }
  36467. //
  36468. // if config.IsOpen == 1 {
  36469. // if miConfig.Code == "H15049901371" {
  36470. // if med_type == "14" {
  36471. // if insutype == "390" {
  36472. // med_type = "9933"
  36473. // } else if insutype == "310" {
  36474. // med_type = "990502"
  36475. // }
  36476. // } else if med_type == "11" {
  36477. // med_type = "11"
  36478. // }
  36479. // }
  36480. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  36481. // var dat map[string]interface{}
  36482. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36483. // fmt.Println(dat)
  36484. // } else {
  36485. // fmt.Println(err)
  36486. // }
  36487. // var res Result2001
  36488. // var res10265 Result2001Org10265
  36489. // if miConfig.Code == "H15049901371" {
  36490. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36491. // utils.ErrorLog("解析失败:%v", err)
  36492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36493. // return
  36494. // }
  36495. // res.ErrMsg = res10265.ErrMsg
  36496. // res.Output = res10265.Output
  36497. // res.InfRefmsgid = res10265.InfRefmsgid
  36498. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36499. // res.Infcode = infocode
  36500. // } else {
  36501. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  36502. // utils.ErrorLog("解析失败:%v", err)
  36503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36504. // return
  36505. // }
  36506. // }
  36507. // if res.Infcode == 0 {
  36508. // c.ServeSuccessJSON(map[string]interface{}{
  36509. // "msg": res.Output.Trtinfo,
  36510. // })
  36511. // }
  36512. // }
  36513. // }
  36514. //}
  36515. //func (c *HisApiController) PutRecord() {
  36516. // id, _ := c.GetInt64("id")
  36517. // record_time := c.GetString("record_time")
  36518. // timeLayout := "2006-01-02"
  36519. // loc, _ := time.LoadLocation("Local")
  36520. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36521. // if err != nil {
  36522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36523. // return
  36524. // }
  36525. // recordDateTime := theTime.Unix()
  36526. //
  36527. // adminInfo := c.GetAdminUserInfo()
  36528. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  36529. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36530. //
  36531. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  36532. //
  36533. // fmt.Println(miConfig.SecretKey)
  36534. //
  36535. // if patient == nil {
  36536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36537. // return
  36538. // }
  36539. // if len(patient.IdCardNo) == 0 {
  36540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  36541. // return
  36542. // }
  36543. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  36544. // if config.IsOpen == 1 {
  36545. // 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
  36546. // resp, requestErr := http.Get(api)
  36547. // if requestErr != nil {
  36548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36549. // return
  36550. // }
  36551. // defer resp.Body.Close()
  36552. // body, ioErr := ioutil.ReadAll(resp.Body)
  36553. // if ioErr != nil {
  36554. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36556. // return
  36557. // }
  36558. // var respJSON map[string]interface{}
  36559. //
  36560. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36561. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36563. // return
  36564. // }
  36565. //
  36566. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36567. // userJSONBytes, _ := json.Marshal(userJSON)
  36568. // var res ResultTwo
  36569. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36570. // utils.ErrorLog("解析失败:%v", err)
  36571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36572. // return
  36573. // }
  36574. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36575. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36576. // infoStr := string(Iinfos)
  36577. // idetinfoStr := string(Idetinfos)
  36578. //
  36579. // if res.Infcode == 0 {
  36580. // his := models.VMHisPatient{
  36581. // Status: 1,
  36582. // Ctime: time.Now().Unix(),
  36583. // Mtime: time.Now().Unix(),
  36584. // PsnNo: res.Output.Baseinfo.PsnNo,
  36585. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  36586. // Certno: res.Output.Baseinfo.Certno,
  36587. // PsnName: res.Output.Baseinfo.PsnName,
  36588. // Gend: res.Output.Baseinfo.Gend,
  36589. // Naty: res.Output.Baseinfo.Naty,
  36590. // Brdy: res.Output.Baseinfo.Brdy,
  36591. // Age: res.Output.Baseinfo.Age,
  36592. // Iinfo: infoStr,
  36593. // Idetinfo: idetinfoStr,
  36594. // PatientId: patient.ID,
  36595. // RecordDate: theTime.Unix(),
  36596. // UserOrgId: adminInfo.CurrentOrgId,
  36597. // AdminUserId: adminInfo.AdminUser.Id,
  36598. // IsReturn: 1,
  36599. // }
  36600. //
  36601. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  36602. // //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")
  36603. // //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")
  36604. //
  36605. // //var dat map[string]interface{}
  36606. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36607. // // fmt.Println(dat)
  36608. // //} else {
  36609. // // fmt.Println(err)
  36610. // //}
  36611. //
  36612. // var dat2 map[string]interface{}
  36613. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36614. // fmt.Println(dat2)
  36615. // } else {
  36616. // fmt.Println(err)
  36617. // }
  36618. //
  36619. // } else {
  36620. // adminUser := c.GetAdminUserInfo()
  36621. // errlog := &models.HisOrderError{
  36622. // UserOrgId: adminUser.CurrentOrgId,
  36623. // Ctime: time.Now().Unix(),
  36624. // Mtime: time.Now().Unix(),
  36625. // ErrMsg: res.ErrMsg,
  36626. // Status: 1,
  36627. // PatientId: id,
  36628. // RecordTime: recordDateTime,
  36629. // Stage: 1,
  36630. // }
  36631. // service.CreateErrMsgLog(errlog)
  36632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  36633. // return
  36634. // }
  36635. // }
  36636. //
  36637. //}
  36638. //func (c *HisApiController) GetUploadDiag() {
  36639. // id, _ := c.GetInt64("id")
  36640. // record_time := c.GetString("record_time")
  36641. //
  36642. // diagnosis_id, _ := c.GetInt64("diagnosis")
  36643. // sick_type, _ := c.GetInt64("sick_type")
  36644. // reg_type, _ := c.GetInt64("reg_type")
  36645. //
  36646. // timeLayout := "2006-01-02"
  36647. // loc, _ := time.LoadLocation("Local")
  36648. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36649. // if err != nil {
  36650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36651. // return
  36652. // }
  36653. //
  36654. // var patientPrescription models.HisPrescriptionInfo
  36655. // recordDateTime := theTime.Unix()
  36656. // adminInfo := c.GetAdminUserInfo()
  36657. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36658. //
  36659. // if patientPrescription.ID == 0 {
  36660. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36661. // }
  36662. //
  36663. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  36664. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  36665. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36666. // sickConfig, _ := service.FindSickById(sick_type)
  36667. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36668. //
  36669. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  36670. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  36671. // "&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 +
  36672. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  36673. // resp2, requestErr2 := http.Get(api2)
  36674. // if requestErr2 != nil {
  36675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36676. // return
  36677. // }
  36678. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  36679. // if ioErr2 != nil {
  36680. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  36681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36682. // return
  36683. // }
  36684. // var respJSON2 map[string]interface{}
  36685. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  36686. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36688. // return
  36689. // }
  36690. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36691. // userJSONBytes2, _ := json.Marshal(respJSON2)
  36692. //
  36693. // var res2 ResultSix
  36694. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36695. // utils.ErrorLog("解析失败:%v", err)
  36696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36697. // return
  36698. // }
  36699. // if res2.Infcode != 0 {
  36700. // adminUser := c.GetAdminUserInfo()
  36701. // errlog := &models.HisOrderError{
  36702. // UserOrgId: adminUser.CurrentOrgId,
  36703. // Ctime: time.Now().Unix(),
  36704. // Mtime: time.Now().Unix(),
  36705. // ErrMsg: res2.ErrMsg,
  36706. // Status: 1,
  36707. // PatientId: id,
  36708. // RecordTime: recordDateTime,
  36709. // Stage: 3,
  36710. // }
  36711. // service.CreateErrMsgLog(errlog)
  36712. //
  36713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  36714. // return
  36715. // }
  36716. //
  36717. // c.ServeSuccessJSON(map[string]interface{}{
  36718. // "msg": "上传成功",
  36719. // })
  36720. //
  36721. //}
  36722. type QueryResult struct {
  36723. ID int64
  36724. Name string
  36725. Code string
  36726. List_type_code string
  36727. }
  36728. func (c *HisApiController) GetCheckCode() {
  36729. ids_str := c.GetString("ids")
  36730. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36731. ids_arr := strings.Split(ids_str, ",")
  36732. var queryResult []QueryResult
  36733. ids := make([]int64, 0)
  36734. for _, item := range ids_arr {
  36735. id, _ := strconv.ParseInt(item, 10, 64)
  36736. ids = append(ids, id)
  36737. }
  36738. if record_type == 1 {
  36739. drugs, _ := service.GetBatchDrugList(ids)
  36740. for _, item := range drugs {
  36741. result := QueryResult{
  36742. ID: item.ID,
  36743. Name: item.DrugName,
  36744. Code: item.MedicalInsuranceNumber,
  36745. List_type_code: "101",
  36746. }
  36747. queryResult = append(queryResult, result)
  36748. }
  36749. } else if record_type == 2 {
  36750. goods, _ := service.GetBatchGoodInformationList(ids)
  36751. fmt.Println(goods)
  36752. for _, item := range goods {
  36753. result := QueryResult{
  36754. ID: item.ID,
  36755. Name: item.GoodName,
  36756. Code: item.SocialSecurityDirectoryCode,
  36757. List_type_code: "301",
  36758. }
  36759. queryResult = append(queryResult, result)
  36760. }
  36761. } else if record_type == 3 {
  36762. projects, _ := service.GetBathchMyPorjecgList(ids)
  36763. for _, item := range projects {
  36764. result := QueryResult{
  36765. ID: item.ID,
  36766. Name: item.ProjectName,
  36767. Code: item.MedicalCode,
  36768. List_type_code: "201",
  36769. }
  36770. queryResult = append(queryResult, result)
  36771. }
  36772. }
  36773. admin_user_id, _ := c.GetInt64("admin_user_id")
  36774. adminUser := c.GetAdminUserInfo()
  36775. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36776. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36777. var user_name string
  36778. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36779. if role.ID == 0 {
  36780. user_name = "管理员"
  36781. } else {
  36782. user_name = role.UserName
  36783. }
  36784. baseParams := models.BaseParams{
  36785. SecretKey: miConfig.SecretKey,
  36786. FixmedinsCode: miConfig.Code,
  36787. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36788. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36789. OrgName: miConfig.OrgName,
  36790. Doctor: user_name,
  36791. }
  36792. var result string
  36793. if miConfig.MdtrtareaAdmvs == "430800" {
  36794. for _, item := range queryResult {
  36795. if record_type == 1 {
  36796. 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)
  36797. } else if record_type == 2 {
  36798. fmt.Println(item.Code)
  36799. 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)
  36800. } else if record_type == 3 {
  36801. 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)
  36802. }
  36803. var dat map[string]interface{}
  36804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36805. fmt.Println(dat)
  36806. } else {
  36807. fmt.Println(err)
  36808. }
  36809. userJSONBytes, _ := json.Marshal(dat)
  36810. var res ResultSix
  36811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36812. utils.ErrorLog("解析失败:%v", err)
  36813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36814. return
  36815. }
  36816. if res.Infcode == 0 {
  36817. if record_type == 1 {
  36818. service.UpdateBaseDrugById(item.ID)
  36819. } else if record_type == 2 {
  36820. service.UpdateGoodInformaitonByDetail(item.ID)
  36821. } else if record_type == 3 {
  36822. service.UpdateProjectById(item.ID)
  36823. }
  36824. c.ServeSuccessJSON(map[string]interface{}{
  36825. "failed_code": 0,
  36826. "msg": "目录对照成功",
  36827. })
  36828. } else {
  36829. c.ServeSuccessJSON(map[string]interface{}{
  36830. "failed_code": -10,
  36831. "msg": res.ErrMsg,
  36832. })
  36833. }
  36834. }
  36835. } else {
  36836. for _, item := range queryResult {
  36837. var result string
  36838. if record_type == 1 {
  36839. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36840. } else if record_type == 2 {
  36841. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36842. } else if record_type == 3 {
  36843. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36844. }
  36845. var dat map[string]interface{}
  36846. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36847. fmt.Println(dat)
  36848. } else {
  36849. fmt.Println(err)
  36850. }
  36851. userJSONBytes, _ := json.Marshal(dat)
  36852. var res ResultSix
  36853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36854. utils.ErrorLog("解析失败:%v", err)
  36855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36856. return
  36857. }
  36858. if res.Infcode == 0 {
  36859. if record_type == 1 {
  36860. service.UpdateBaseDrugById(item.ID)
  36861. } else if record_type == 2 {
  36862. service.UpdateGoodInformaitonByDetail(item.ID)
  36863. } else if record_type == 3 {
  36864. service.UpdateProjectById(item.ID)
  36865. }
  36866. c.ServeSuccessJSON(map[string]interface{}{
  36867. "failed_code": 0,
  36868. "msg": "目录对照成功",
  36869. })
  36870. } else {
  36871. c.ServeSuccessJSON(map[string]interface{}{
  36872. "failed_code": -10,
  36873. "msg": res.ErrMsg,
  36874. })
  36875. }
  36876. }
  36877. }
  36878. }
  36879. func (c *HisApiController) UnCheckCode() {
  36880. ids_str := c.GetString("ids")
  36881. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36882. admin_user_id, _ := c.GetInt64("admin_user_id")
  36883. ids_arr := strings.Split(ids_str, ",")
  36884. var queryResult []QueryResult
  36885. ids := make([]int64, 0)
  36886. for _, item := range ids_arr {
  36887. id, _ := strconv.ParseInt(item, 10, 64)
  36888. ids = append(ids, id)
  36889. }
  36890. if record_type == 1 {
  36891. drugs, _ := service.GetBatchDrugList(ids)
  36892. for _, item := range drugs {
  36893. result := QueryResult{
  36894. ID: item.ID,
  36895. Name: item.DrugName,
  36896. Code: item.MedicalInsuranceNumber,
  36897. List_type_code: "101",
  36898. }
  36899. queryResult = append(queryResult, result)
  36900. }
  36901. } else if record_type == 2 {
  36902. goods, _ := service.GetBatchGoodInformationList(ids)
  36903. for _, item := range goods {
  36904. result := QueryResult{
  36905. ID: item.ID,
  36906. Name: item.GoodName,
  36907. Code: item.SocialSecurityDirectoryCode,
  36908. List_type_code: "301",
  36909. }
  36910. queryResult = append(queryResult, result)
  36911. }
  36912. } else if record_type == 3 {
  36913. projects, _ := service.GetBathchMyPorjecgList(ids)
  36914. for _, item := range projects {
  36915. result := QueryResult{
  36916. ID: item.ID,
  36917. Name: item.ProjectName,
  36918. Code: item.MedicalCode,
  36919. List_type_code: "201",
  36920. }
  36921. queryResult = append(queryResult, result)
  36922. }
  36923. }
  36924. adminUser := c.GetAdminUserInfo()
  36925. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36926. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36927. var user_name string
  36928. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36929. if role.ID == 0 {
  36930. user_name = "xxx"
  36931. } else {
  36932. user_name = role.UserName
  36933. }
  36934. baseParams := &models.BaseParams{
  36935. SecretKey: miConfig.SecretKey,
  36936. FixmedinsCode: miConfig.Code,
  36937. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36938. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36939. OrgName: miConfig.OrgName,
  36940. Doctor: user_name,
  36941. }
  36942. if config.IsOpen == 1 {
  36943. if miConfig.MdtrtareaAdmvs == "430800" {
  36944. for _, item := range queryResult {
  36945. var result string
  36946. if record_type == 1 {
  36947. 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)
  36948. } else if record_type == 2 {
  36949. fmt.Println(item.Code)
  36950. 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)
  36951. } else if record_type == 3 {
  36952. 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)
  36953. }
  36954. var dat map[string]interface{}
  36955. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36956. fmt.Println(dat)
  36957. } else {
  36958. fmt.Println(err)
  36959. }
  36960. userJSONBytes, _ := json.Marshal(dat)
  36961. var res ResultSix
  36962. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36963. utils.ErrorLog("解析失败:%v", err)
  36964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36965. return
  36966. }
  36967. if res.Infcode == 0 {
  36968. if record_type == 1 {
  36969. service.UpdateBaseDrugById(item.ID)
  36970. } else if record_type == 2 {
  36971. service.UpdateGoodInformaitonByDetail(item.ID)
  36972. } else if record_type == 3 {
  36973. service.UpdateProjectById(item.ID)
  36974. }
  36975. c.ServeSuccessJSON(map[string]interface{}{
  36976. "failed_code": 0,
  36977. "msg": "目录对照成功",
  36978. })
  36979. } else {
  36980. c.ServeSuccessJSON(map[string]interface{}{
  36981. "failed_code": -10,
  36982. "msg": res.ErrMsg,
  36983. })
  36984. }
  36985. }
  36986. } else {
  36987. for _, item := range queryResult {
  36988. var result string
  36989. if record_type == 1 {
  36990. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36991. } else if record_type == 2 {
  36992. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36993. } else if record_type == 3 {
  36994. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36995. }
  36996. var dat2 map[string]interface{}
  36997. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36998. fmt.Println(dat2)
  36999. } else {
  37000. fmt.Println(err)
  37001. }
  37002. userJSONBytes, _ := json.Marshal(dat2)
  37003. var res ResultSix
  37004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37005. utils.ErrorLog("解析失败:%v", err)
  37006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37007. return
  37008. }
  37009. if res.Infcode == 0 {
  37010. if record_type == 1 {
  37011. service.UpdateDrugByIdDetail(item.ID)
  37012. } else if record_type == 2 {
  37013. service.UpdateGoodInfoById(item.ID)
  37014. } else if record_type == 3 {
  37015. service.UpdateMyProjectById(item.ID)
  37016. }
  37017. c.ServeSuccessJSON(map[string]interface{}{
  37018. "failed_code": 0,
  37019. "msg": "撤销目录对照成功",
  37020. })
  37021. } else {
  37022. c.ServeSuccessJSON(map[string]interface{}{
  37023. "failed_code": -10,
  37024. "msg": res.ErrMsg,
  37025. })
  37026. }
  37027. }
  37028. }
  37029. }
  37030. }
  37031. func (c *HisApiController) GetPatientInfo() {
  37032. id_card_no := c.GetString("id_card_no")
  37033. admin_user_id, _ := c.GetInt64("admin_user_id")
  37034. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  37035. if patient.ID == 0 {
  37036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37037. return
  37038. }
  37039. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  37040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37041. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  37042. var res ResultTwo
  37043. var res10265 ResultTwo10265
  37044. if config.IsOpen == 1 {
  37045. if miConfig.MdtrtareaAdmvs == "150499" {
  37046. //请求内网数据
  37047. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  37048. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37049. "&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
  37050. resp, requestErr := http.Get(api)
  37051. if requestErr != nil {
  37052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37053. return
  37054. }
  37055. body, ioErr := ioutil.ReadAll(resp.Body)
  37056. if ioErr != nil {
  37057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37059. return
  37060. }
  37061. var respJSON map[string]interface{}
  37062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37065. return
  37066. }
  37067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37068. result_byte, _ := json.Marshal(respJSON)
  37069. result := string(result_byte)
  37070. var dat map[string]interface{}
  37071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37072. fmt.Println(dat)
  37073. } else {
  37074. fmt.Println(err)
  37075. }
  37076. userJSONBytes, _ := json.Marshal(dat)
  37077. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37078. utils.ErrorLog("解析失败:%v", err)
  37079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37080. return
  37081. }
  37082. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37083. res.Infcode = Infcode
  37084. res.ErrMsg = res10265.ErrMsg
  37085. res.Output = res10265.Output
  37086. res.InfRefmsgid = res10265.InfRefmsgid
  37087. res.RespondTime = res10265.RespondTime
  37088. res.WarnInfo = res10265.WarnInfo
  37089. } else {
  37090. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37091. var dat map[string]interface{}
  37092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37093. fmt.Println(dat)
  37094. } else {
  37095. fmt.Println(err)
  37096. }
  37097. userJSONBytes, _ := json.Marshal(dat)
  37098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37099. utils.ErrorLog("解析失败:%v", err)
  37100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37101. return
  37102. }
  37103. }
  37104. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37105. // utils.ErrorLog("解析失败:%v", err)
  37106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37107. // return
  37108. //}
  37109. for index, item := range res.Output.Iinfo {
  37110. if item.PsnInsuStas == "2" {
  37111. fmt.Println("--------")
  37112. res.Output.Iinfo[index].Insutype = "300"
  37113. res.Output.Iinfo[index].PsnInsuStas = "1"
  37114. }
  37115. }
  37116. fmt.Println(res.Output.Iinfo)
  37117. if res.Infcode != 0 {
  37118. c.ServeSuccessJSON(map[string]interface{}{
  37119. "failed_code": -10,
  37120. "msg": res.ErrMsg,
  37121. })
  37122. } else {
  37123. c.ServeSuccessJSON(map[string]interface{}{
  37124. "failed_code": 0,
  37125. "info": res,
  37126. })
  37127. }
  37128. }
  37129. }
  37130. func (c *HisApiController) PsnPutOnRecord() {
  37131. record_type, _ := c.GetInt64("type")
  37132. patient_id, _ := c.GetInt64("patient_id")
  37133. admin_user_id, _ := c.GetInt64("admin_user_id")
  37134. start_time := c.GetString("start_time")
  37135. end_time := c.GetString("end_time")
  37136. adminUser := c.GetAdminUserInfo()
  37137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37139. var patients []*models.Patients
  37140. if record_type == 1 { //全部备案
  37141. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  37142. patients = append(patients, patient...)
  37143. } else { //单个备案
  37144. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37145. patients = append(patients, patient)
  37146. }
  37147. var user_name string
  37148. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37149. if role.ID == 0 {
  37150. user_name = "xxx"
  37151. } else {
  37152. user_name = role.UserName
  37153. }
  37154. if config.IsOpen == 1 {
  37155. for _, item := range patients {
  37156. 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
  37157. resp, requestErr := http.Get(api)
  37158. if requestErr != nil {
  37159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37160. return
  37161. }
  37162. defer resp.Body.Close()
  37163. body, ioErr := ioutil.ReadAll(resp.Body)
  37164. if ioErr != nil {
  37165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37167. return
  37168. }
  37169. var respJSON map[string]interface{}
  37170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37173. return
  37174. }
  37175. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37176. userJSONBytes, _ := json.Marshal(userJSON)
  37177. var res ResultTwo
  37178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37179. utils.ErrorLog("解析失败:%v", err)
  37180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37181. return
  37182. }
  37183. if res.Infcode == 0 {
  37184. 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)
  37185. var dat map[string]interface{}
  37186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37187. fmt.Println(dat)
  37188. } else {
  37189. fmt.Println(err)
  37190. }
  37191. userJSONBytes, _ := json.Marshal(dat)
  37192. var res2 ResultThirteen
  37193. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  37194. utils.ErrorLog("解析失败:%v", err)
  37195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37196. return
  37197. }
  37198. if res2.Infcode == 0 {
  37199. psnResult := &models.GdybPsnRecord{
  37200. UserOrgId: adminUser.CurrentOrgId,
  37201. PatientId: item.ID,
  37202. PsnNo: res.Output.Baseinfo.PsnNo,
  37203. Ctime: time.Now().Unix(),
  37204. Mtime: time.Now().Unix(),
  37205. Status: 1,
  37206. IsCancel: 1,
  37207. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  37208. }
  37209. service.CreatePsnRecord(psnResult)
  37210. } else {
  37211. c.ServeSuccessJSON(map[string]interface{}{
  37212. "failed_code": -10,
  37213. "msg": res2.ErrMsg,
  37214. })
  37215. return
  37216. }
  37217. }
  37218. }
  37219. }
  37220. }
  37221. func (c *HisApiController) PsnUnPutOnRecord() {
  37222. id, _ := c.GetInt64("id")
  37223. //record_type, _ := c.GetInt64("type")
  37224. admin_user_id, _ := c.GetInt64("admin_user_id")
  37225. adminUser := c.GetAdminUserInfo()
  37226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37227. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37228. var user_name string
  37229. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37230. if role.ID == 0 {
  37231. user_name = "xxx"
  37232. } else {
  37233. user_name = role.UserName
  37234. }
  37235. psn_record, _ := service.GetPsnRecordById(id)
  37236. if psn_record.ID == 0 {
  37237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  37238. return
  37239. }
  37240. if config.IsOpen == 1 {
  37241. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  37242. var dat map[string]interface{}
  37243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37244. fmt.Println(dat)
  37245. } else {
  37246. fmt.Println(err)
  37247. }
  37248. userJSONBytes, _ := json.Marshal(dat)
  37249. var res ResultFourteen
  37250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37251. utils.ErrorLog("解析失败:%v", err)
  37252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37253. return
  37254. }
  37255. if res.Infcode == 0 {
  37256. psn_record.IsCancel = 2
  37257. service.CreatePsnRecord(&psn_record)
  37258. } else {
  37259. c.ServeSuccessJSON(map[string]interface{}{
  37260. "failed_code": -10,
  37261. "msg": res.ErrMsg,
  37262. })
  37263. return
  37264. }
  37265. }
  37266. }
  37267. func (c *HisApiController) PsnPutNCDSOnRecord() {
  37268. patient_id, _ := c.GetInt64("patient_id")
  37269. insutype_two := c.GetString("insutype")
  37270. psn_no := c.GetString("psn_no")
  37271. doctor_id, _ := c.GetInt64("doctor_id")
  37272. sick_id, _ := c.GetInt64("sick_id")
  37273. department_id, _ := c.GetInt64("department_id")
  37274. start_time := c.GetString("start_time")
  37275. end_time := c.GetString("end_time")
  37276. check_time := c.GetString("check_time")
  37277. hospital_code := c.GetString("hospital_code")
  37278. hospital_name := c.GetString("hospital_name")
  37279. adminUser := c.GetAdminUserInfo()
  37280. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37281. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37282. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37283. sick, _ := service.FindSickById(sick_id)
  37284. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37285. if len(hospital_code) == 0 {
  37286. hospital_code = miConfig.Code
  37287. }
  37288. if len(hospital_name) == 0 {
  37289. hospital_name = miConfig.OrgName
  37290. }
  37291. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37292. var res ResultTwo
  37293. var res10265 ResultTwo10265
  37294. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37295. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  37296. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  37297. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37298. "&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
  37299. resp, requestErr := http.Get(api)
  37300. if requestErr != nil {
  37301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37302. return
  37303. }
  37304. body, ioErr := ioutil.ReadAll(resp.Body)
  37305. if ioErr != nil {
  37306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37308. return
  37309. }
  37310. var respJSON map[string]interface{}
  37311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37314. return
  37315. }
  37316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37317. result, _ := json.Marshal(respJSON)
  37318. fmt.Println("log")
  37319. fmt.Println(string(result))
  37320. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37321. utils.ErrorLog("解析失败:%v", err)
  37322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37323. return
  37324. }
  37325. res.ErrMsg = res10265.ErrMsg
  37326. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37327. res.Infcode = infocode
  37328. res.Output = res10265.Output
  37329. res.InfRefmsgid = res10265.InfRefmsgid
  37330. } else {
  37331. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  37332. if miConfig.Code == "H15049901371" {
  37333. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37334. utils.ErrorLog("解析失败:%v", err)
  37335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37336. return
  37337. }
  37338. res.ErrMsg = res10265.ErrMsg
  37339. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37340. res.Infcode = infocode
  37341. res.Output = res10265.Output
  37342. res.InfRefmsgid = res10265.InfRefmsgid
  37343. } else {
  37344. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37345. utils.ErrorLog("解析失败:%v", err)
  37346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37347. return
  37348. }
  37349. }
  37350. }
  37351. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37352. infoStr := string(Iinfos)
  37353. var rf []*ResultFive
  37354. json.Unmarshal([]byte(infoStr), &rf)
  37355. var insuplc_admdvs string
  37356. var insutype string
  37357. var is390 int = 0
  37358. var is310 int = 0
  37359. var insutypes []*ResultFive
  37360. for _, item := range rf {
  37361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  37362. insutypes = append(insutypes, item)
  37363. }
  37364. }
  37365. if len(insutypes) == 1 {
  37366. insutype = insutypes[0].Insutype
  37367. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  37368. } else {
  37369. for _, i := range insutypes {
  37370. if i.Insutype == "390" {
  37371. is390 = 1
  37372. }
  37373. if i.Insutype == "310" {
  37374. is310 = 1
  37375. }
  37376. }
  37377. }
  37378. if is390 == 1 {
  37379. insutype = "390"
  37380. }
  37381. if is310 == 1 {
  37382. insutype = "310"
  37383. }
  37384. if len(insutypes) == 2 {
  37385. insutype = insutype_two
  37386. }
  37387. if len(insutypes) == 0 {
  37388. insutype = "310"
  37389. }
  37390. insutype = insutype_two
  37391. fmt.Println(insutype)
  37392. for _, item := range rf {
  37393. fmt.Println(item.Insutype)
  37394. fmt.Println(insutype)
  37395. if item.Insutype == insutype {
  37396. fmt.Println(item.Insutype)
  37397. fmt.Println(insutype)
  37398. insuplc_admdvs = item.InsuplcAdmdvs
  37399. }
  37400. }
  37401. fmt.Println(insuplc_admdvs)
  37402. var res2 ResultThirteen
  37403. var res10265_2 ResultThirteen10265
  37404. if config.IsOpen == 1 {
  37405. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37406. } else {
  37407. if miConfig.MdtrtareaAdmvs == "150499" {
  37408. //
  37409. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  37410. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37411. // "&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
  37412. //resp, requestErr := http.Get(api)
  37413. //if requestErr != nil {
  37414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37415. // return
  37416. //}
  37417. //
  37418. //body, ioErr := ioutil.ReadAll(resp.Body)
  37419. //if ioErr != nil {
  37420. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37422. // return
  37423. //}
  37424. //var respJSON map[string]interface{}
  37425. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37426. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37428. // return
  37429. //}
  37430. //
  37431. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37432. //result, _ := json.Marshal(respJSON)
  37433. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  37434. // utils.ErrorLog("解析失败:%v", err)
  37435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37436. // return
  37437. //}
  37438. //infocode = resThree.Infcode
  37439. //result, _ := json.Marshal(respJSON)
  37440. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  37441. // utils.ErrorLog("解析失败:%v", err)
  37442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37443. // return
  37444. //}
  37445. //
  37446. //resThree.ErrMsg = resThree10265.ErrMsg
  37447. //
  37448. //resThree.Output = resThree10265.Output
  37449. //
  37450. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  37451. //
  37452. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  37453. //
  37454. } else {
  37455. 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)
  37456. var dat map[string]interface{}
  37457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37458. fmt.Println(dat)
  37459. } else {
  37460. fmt.Println(err)
  37461. }
  37462. userJSONBytes, _ := json.Marshal(dat)
  37463. if miConfig.Code == "H15049901371" {
  37464. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  37465. utils.ErrorLog("解析失败:%v", err)
  37466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37467. return
  37468. }
  37469. res2.ErrMsg = res10265_2.ErrMsg
  37470. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  37471. res2.Infcode = infocode
  37472. res2.Output = res10265_2.Output
  37473. res2.InfRefmsgid = res10265_2.InfRefmsgid
  37474. } else {
  37475. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  37476. utils.ErrorLog("解析失败:%v", err)
  37477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37478. return
  37479. }
  37480. }
  37481. }
  37482. }
  37483. if res2.Infcode == 0 {
  37484. psnResult := &models.GdybPsnNcdsRecord{
  37485. UserOrgId: adminUser.CurrentOrgId,
  37486. PatientId: patient.ID,
  37487. PsnNo: psn_no,
  37488. DoctorId: doctor.AdminUserId,
  37489. DepartmentId: department_id,
  37490. SickType: sick_id,
  37491. Insutype: insutype,
  37492. Ctime: time.Now().Unix(),
  37493. Mtime: time.Now().Unix(),
  37494. Status: 1,
  37495. IsCancel: 1,
  37496. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  37497. }
  37498. service.CreatePsnNCDSRecord(psnResult)
  37499. c.ServeSuccessJSON(map[string]interface{}{
  37500. "failed_code": 0,
  37501. "msg": "备案成功",
  37502. "result": psnResult,
  37503. })
  37504. } else {
  37505. c.ServeSuccessJSON(map[string]interface{}{
  37506. "failed_code": -10,
  37507. "msg": res2.ErrMsg,
  37508. })
  37509. return
  37510. }
  37511. }
  37512. }
  37513. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  37514. id, _ := c.GetInt64("id")
  37515. admin_user_id, _ := c.GetInt64("admin_user_id")
  37516. adminUser := c.GetAdminUserInfo()
  37517. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37518. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37519. //config, _ := service.Ge(adminUser.CurrentOrgId)
  37520. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  37521. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37522. //var user_name string
  37523. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37524. //if role.ID == 0 {
  37525. // user_name = "xxx"
  37526. //} else {
  37527. // user_name = role.UserName
  37528. //}
  37529. psn_record, _ := service.GetPsnNCDSRecordById(id)
  37530. if psn_record.ID == 0 {
  37531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  37532. return
  37533. }
  37534. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  37535. var res ResultTwo
  37536. var res10265 ResultTwo10265
  37537. if miConfig.Code == "H15049901371" {
  37538. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37539. utils.ErrorLog("解析失败:%v", err)
  37540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37541. return
  37542. }
  37543. res.ErrMsg = res10265.ErrMsg
  37544. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37545. res.Infcode = infocode
  37546. res.Output = res10265.Output
  37547. res.InfRefmsgid = res10265.InfRefmsgid
  37548. } else {
  37549. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37550. utils.ErrorLog("解析失败:%v", err)
  37551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37552. return
  37553. }
  37554. }
  37555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37556. infoStr := string(Iinfos)
  37557. var rf []*ResultFive
  37558. json.Unmarshal([]byte(infoStr), &rf)
  37559. var insuplc_admdvs string
  37560. var insutype string
  37561. var is390 int = 0
  37562. var is310 int = 0
  37563. var insutypes []*ResultFive
  37564. for _, item := range rf {
  37565. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  37566. insutypes = append(insutypes, item)
  37567. }
  37568. }
  37569. if len(insutypes) == 1 {
  37570. insutype = insutypes[0].Insutype
  37571. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  37572. } else {
  37573. for _, i := range insutypes {
  37574. if i.Insutype == "390" {
  37575. is390 = 1
  37576. }
  37577. if i.Insutype == "310" {
  37578. is310 = 1
  37579. }
  37580. }
  37581. }
  37582. if is390 == 1 {
  37583. insutype = "390"
  37584. }
  37585. if is310 == 1 {
  37586. insutype = "310"
  37587. }
  37588. if len(insutypes) == 0 {
  37589. insutype = "310"
  37590. }
  37591. insutype = psn_record.Insutype
  37592. for _, item := range rf {
  37593. if item.Insutype == insutype {
  37594. insuplc_admdvs = item.InsuplcAdmdvs
  37595. }
  37596. }
  37597. if config.IsOpen == 1 {
  37598. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  37599. var dat map[string]interface{}
  37600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37601. fmt.Println(dat)
  37602. } else {
  37603. fmt.Println(err)
  37604. }
  37605. userJSONBytes, _ := json.Marshal(dat)
  37606. var res ResultFourteen
  37607. var res10265 ResultFourteen10265
  37608. if miConfig.Code == "H15049901371" {
  37609. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37610. utils.ErrorLog("解析失败:%v", err)
  37611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37612. return
  37613. }
  37614. res.ErrMsg = res10265.ErrMsg
  37615. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37616. res.Infcode = infocode
  37617. res.Output = res10265.Output
  37618. res.InfRefmsgid = res10265.InfRefmsgid
  37619. } else {
  37620. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37621. utils.ErrorLog("解析失败:%v", err)
  37622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37623. return
  37624. }
  37625. }
  37626. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37627. // utils.ErrorLog("解析失败:%v", err)
  37628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37629. // return
  37630. //}
  37631. if res.Infcode == 0 {
  37632. psn_record.IsCancel = 2
  37633. service.CreatePsnNCDSRecord(&psn_record)
  37634. c.ServeSuccessJSON(map[string]interface{}{
  37635. "failed_code": 0,
  37636. "msg": "撤销备案成功",
  37637. })
  37638. } else {
  37639. c.ServeSuccessJSON(map[string]interface{}{
  37640. "failed_code": -10,
  37641. "msg": res.ErrMsg,
  37642. })
  37643. return
  37644. }
  37645. }
  37646. }
  37647. func (c *HisApiController) TestTest() {
  37648. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  37649. fmt.Println(patient.Iinfo)
  37650. }
  37651. type CustomData struct {
  37652. MsgId string
  37653. PsnNo string
  37654. Info string
  37655. }
  37656. func (c *HisApiController) ReversalData() {
  37657. var customData []*CustomData
  37658. custom := &CustomData{
  37659. MsgId: "H44022900158202103301714472004",
  37660. PsnNo: "44020000001101329945",
  37661. Info: "2207",
  37662. }
  37663. customData = append(customData, custom)
  37664. custom1 := &CustomData{
  37665. MsgId: "H4402290015820210330172057803",
  37666. PsnNo: "44020000001101161813",
  37667. Info: "2207",
  37668. }
  37669. customData = append(customData, custom1)
  37670. custom2 := &CustomData{
  37671. MsgId: "H44022900158202103301705198813",
  37672. PsnNo: "44190000133097375417",
  37673. Info: "2207",
  37674. }
  37675. customData = append(customData, custom2)
  37676. custom3 := &CustomData{
  37677. MsgId: "H44022900158202103301715524756",
  37678. PsnNo: "44020000001100187221",
  37679. Info: "2207",
  37680. }
  37681. customData = append(customData, custom3)
  37682. custom4 := &CustomData{
  37683. MsgId: "H44022900158202103301730376224",
  37684. PsnNo: "44020000001101959155",
  37685. Info: "2207",
  37686. }
  37687. customData = append(customData, custom4)
  37688. custom5 := &CustomData{
  37689. MsgId: "H44022900158202103301748008725",
  37690. PsnNo: "44020000001104246641",
  37691. Info: "2207",
  37692. }
  37693. customData = append(customData, custom5)
  37694. custom6 := &CustomData{
  37695. MsgId: "H44022900158202103301718096755",
  37696. PsnNo: "44020000001102211860",
  37697. Info: "2207",
  37698. }
  37699. customData = append(customData, custom6)
  37700. custom7 := &CustomData{
  37701. MsgId: "H44022900158202103301736551640",
  37702. PsnNo: "44020000001102687718",
  37703. Info: "2207",
  37704. }
  37705. customData = append(customData, custom7)
  37706. custom8 := &CustomData{
  37707. MsgId: "H44022900158202103301743097676",
  37708. PsnNo: "44020000001102127785",
  37709. Info: "2207",
  37710. }
  37711. customData = append(customData, custom8)
  37712. custom9 := &CustomData{
  37713. MsgId: "H44022900158202103301712304203",
  37714. PsnNo: "44020000001101518097",
  37715. Info: "2207",
  37716. }
  37717. customData = append(customData, custom9)
  37718. custom10 := &CustomData{
  37719. MsgId: "H44022900158202103301738448785",
  37720. PsnNo: "44020000001100500813",
  37721. Info: "2207",
  37722. }
  37723. customData = append(customData, custom10)
  37724. custom11 := &CustomData{
  37725. MsgId: "H44022900158202103301732455843",
  37726. PsnNo: "44020000001102690557",
  37727. Info: "2207",
  37728. }
  37729. customData = append(customData, custom11)
  37730. custom12 := &CustomData{
  37731. MsgId: "H44022900158202103301745421708",
  37732. PsnNo: "44020000001102211928",
  37733. Info: "2207",
  37734. }
  37735. customData = append(customData, custom12)
  37736. custom1212 := &CustomData{
  37737. MsgId: "H440229001582021033017351627",
  37738. PsnNo: "44020000001102481733",
  37739. Info: "2207",
  37740. }
  37741. customData = append(customData, custom1212)
  37742. custom13 := &CustomData{
  37743. MsgId: "H44022900158202103301740327951",
  37744. PsnNo: "44020000001103174866",
  37745. Info: "2207",
  37746. }
  37747. customData = append(customData, custom13)
  37748. custom14 := &CustomData{
  37749. MsgId: "H4402290015820210330174922668",
  37750. PsnNo: "44020000001102927272",
  37751. Info: "2207",
  37752. }
  37753. customData = append(customData, custom14)
  37754. custom15 := &CustomData{
  37755. MsgId: "H44022900158202103301752362273",
  37756. PsnNo: "44020000001102942890",
  37757. Info: "2207",
  37758. }
  37759. customData = append(customData, custom15)
  37760. custom16 := &CustomData{
  37761. MsgId: "H44022900158202103301751082917",
  37762. PsnNo: "44020000001101662162",
  37763. Info: "2207",
  37764. }
  37765. customData = append(customData, custom16)
  37766. custom17 := &CustomData{
  37767. MsgId: "H44022900158202103301754147728",
  37768. PsnNo: "44020000000229014511",
  37769. Info: "2207",
  37770. }
  37771. customData = append(customData, custom17)
  37772. adminUser := c.GetAdminUserInfo()
  37773. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37774. for _, item := range customData {
  37775. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37776. fmt.Println(result)
  37777. }
  37778. }
  37779. func (c *HisApiController) GetAllopatry() {
  37780. year := c.GetString("year")
  37781. month := c.GetString("month")
  37782. admin_user_id, _ := c.GetInt64("admin_user_id")
  37783. adminUser := c.GetAdminUserInfo()
  37784. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37785. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37786. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37787. var dat map[string]interface{}
  37788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37789. fmt.Println(dat)
  37790. } else {
  37791. fmt.Println(err)
  37792. }
  37793. userJSONBytes, _ := json.Marshal(dat)
  37794. var res models.Result9001
  37795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37796. utils.ErrorLog("解析失败:%v", err)
  37797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37798. return
  37799. }
  37800. fmt.Println(res.Output.Signinoutb)
  37801. fmt.Println(res.Output.Signinoutb.SignNo)
  37802. fmt.Println(string(userJSONBytes))
  37803. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37804. var dat3 map[string]interface{}
  37805. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37806. fmt.Println(dat3)
  37807. } else {
  37808. fmt.Println(err)
  37809. }
  37810. userJSONBytes3, _ := json.Marshal(dat3)
  37811. var res3 models.Result3260
  37812. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37813. utils.ErrorLog("解析失败:%v", err)
  37814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37815. return
  37816. }
  37817. var curpage int
  37818. var pagesize int = 100
  37819. var start int = 1
  37820. //var stop int
  37821. //pagecount := 10
  37822. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37823. var res22 []models.Result3260
  37824. for curpage = 1; curpage <= pagecount; curpage++ {
  37825. if curpage == 1 {
  37826. start = 0
  37827. } else {
  37828. start = (curpage-1)*pagesize + 1
  37829. }
  37830. fmt.Println(start)
  37831. //stop = curpage * pagesize
  37832. //if stop > int(res3.Output.Totalrow) {
  37833. // stop =int(res3.Output.Totalrow)
  37834. //}
  37835. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37836. var dat2 map[string]interface{}
  37837. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37838. fmt.Println(dat)
  37839. } else {
  37840. fmt.Println(err)
  37841. }
  37842. userJSONBytes2, _ := json.Marshal(dat2)
  37843. var res2 models.Result3260
  37844. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37845. utils.ErrorLog("解析失败:%v", err)
  37846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37847. return
  37848. }
  37849. if res2.Infcode == 0 {
  37850. res22 = append(res22, res2)
  37851. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37852. //var dat2 map[string]interface{}
  37853. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37854. // fmt.Println(dat)
  37855. //} else {
  37856. // fmt.Println(err)
  37857. //}
  37858. //c.ServeSuccessJSON(map[string]interface{}{
  37859. // "list": res2.Output.Data,
  37860. //})
  37861. //continue
  37862. }
  37863. }
  37864. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37865. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37866. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37867. //var dat2 map[string]interface{}
  37868. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37869. // fmt.Println(dat)
  37870. //} else {
  37871. // fmt.Println(err)
  37872. //}
  37873. //userJSONBytes2, _ := json.Marshal(dat2)
  37874. //var res2 models.Result3260
  37875. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37876. // utils.ErrorLog("解析失败:%v", err)
  37877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37878. // return
  37879. //}
  37880. //if res2.Infcode == 0 {
  37881. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37882. // var dat2 map[string]interface{}
  37883. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37884. // fmt.Println(dat)
  37885. // } else {
  37886. // fmt.Println(err)
  37887. // }
  37888. // c.ServeSuccessJSON(map[string]interface{}{
  37889. // "list": res2.Output.Data,
  37890. // })
  37891. //}
  37892. }
  37893. func (c *HisApiController) ComfirmAllopatry() {
  37894. year := c.GetString("year")
  37895. month := c.GetString("month")
  37896. admin_user_id, _ := c.GetInt64("admin_user_id")
  37897. adminUser := c.GetAdminUserInfo()
  37898. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37899. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37900. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37901. var dat map[string]interface{}
  37902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37903. fmt.Println(dat)
  37904. } else {
  37905. fmt.Println(err)
  37906. }
  37907. userJSONBytes, _ := json.Marshal(dat)
  37908. var res models.Result9001
  37909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37910. utils.ErrorLog("解析失败:%v", err)
  37911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37912. return
  37913. }
  37914. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37915. var dat2 map[string]interface{}
  37916. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37917. fmt.Println(dat)
  37918. } else {
  37919. fmt.Println(err)
  37920. }
  37921. userJSONBytes2, _ := json.Marshal(dat2)
  37922. var res2 models.Result3260
  37923. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37924. utils.ErrorLog("解析失败:%v", err)
  37925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37926. return
  37927. }
  37928. //if res2.Infcode == 0 {
  37929. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37930. // var dat map[string]interface{}
  37931. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37932. // fmt.Println(dat)
  37933. // } else {
  37934. // fmt.Println(err)
  37935. // }
  37936. // userJSONBytes, _ := json.Marshal(dat)
  37937. // var res3 models.Result3261
  37938. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37939. // utils.ErrorLog("解析失败:%v", err)
  37940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37941. // return
  37942. // }
  37943. //
  37944. // if res3.Infcode == 0 {
  37945. // record := &models.HisYidiClearRecord{
  37946. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37947. // Ctime: time.Now().Unix(),
  37948. // Mtime: time.Now().Unix(),
  37949. // Status: 1,
  37950. // MsgId: msgId,
  37951. // }
  37952. // service.SaveClearRecord(record)
  37953. // c.ServeSuccessJSON(map[string]interface{}{
  37954. // "msg": "提取成功",
  37955. // })
  37956. // }
  37957. //}
  37958. }
  37959. func (c *HisApiController) RefundAllopatry() {
  37960. year := c.GetString("year")
  37961. month := c.GetString("month")
  37962. //id, _ := c.GetInt64("id")
  37963. admin_user_id, _ := c.GetInt64("admin_user_id")
  37964. adminUser := c.GetAdminUserInfo()
  37965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37966. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37967. //record, _ := service.GetClearRecordById(id)
  37968. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37969. var dat map[string]interface{}
  37970. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37971. fmt.Println(dat)
  37972. } else {
  37973. fmt.Println(err)
  37974. }
  37975. userJSONBytes, _ := json.Marshal(dat)
  37976. var res models.Result9001
  37977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37978. utils.ErrorLog("解析失败:%v", err)
  37979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37980. return
  37981. }
  37982. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37983. var dat2 map[string]interface{}
  37984. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37985. fmt.Println(dat)
  37986. } else {
  37987. fmt.Println(err)
  37988. }
  37989. userJSONBytes2, _ := json.Marshal(dat2)
  37990. var empty ResultFourteen
  37991. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37992. utils.ErrorLog("解析失败:%v", err)
  37993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37994. return
  37995. }
  37996. if empty.Infcode == 0 {
  37997. c.ServeSuccessJSON(map[string]interface{}{
  37998. "msg": "撤销成功",
  37999. })
  38000. return
  38001. }
  38002. }
  38003. func (c *HisApiController) ReversalOtherData() {
  38004. var customData []*CustomData
  38005. custom := &CustomData{
  38006. MsgId: "H44022900158202103301714472004",
  38007. PsnNo: "44020000001101329945",
  38008. Info: "2208",
  38009. }
  38010. customData = append(customData, custom)
  38011. custom1 := &CustomData{
  38012. MsgId: "H4402290015820210330172057803",
  38013. PsnNo: "44020000001101161813",
  38014. Info: "2208",
  38015. }
  38016. customData = append(customData, custom1)
  38017. custom2 := &CustomData{
  38018. MsgId: "H44022900158202103301705198813",
  38019. PsnNo: "44190000133097375417",
  38020. Info: "2208",
  38021. }
  38022. customData = append(customData, custom2)
  38023. custom3 := &CustomData{
  38024. MsgId: "H44022900158202103301715524756",
  38025. PsnNo: "44020000001100187221",
  38026. Info: "2208",
  38027. }
  38028. customData = append(customData, custom3)
  38029. custom4 := &CustomData{
  38030. MsgId: "H44022900158202103301730376224",
  38031. PsnNo: "44020000001101959155",
  38032. Info: "2208",
  38033. }
  38034. customData = append(customData, custom4)
  38035. custom5 := &CustomData{
  38036. MsgId: "H44022900158202103301748008725",
  38037. PsnNo: "44020000001104246641",
  38038. Info: "2208",
  38039. }
  38040. customData = append(customData, custom5)
  38041. custom6 := &CustomData{
  38042. MsgId: "H44022900158202103301718096755",
  38043. PsnNo: "44020000001102211860",
  38044. Info: "2208",
  38045. }
  38046. customData = append(customData, custom6)
  38047. custom7 := &CustomData{
  38048. MsgId: "H44022900158202103301736551640",
  38049. PsnNo: "44020000001102687718",
  38050. Info: "2208",
  38051. }
  38052. customData = append(customData, custom7)
  38053. custom8 := &CustomData{
  38054. MsgId: "H44022900158202103301743097676",
  38055. PsnNo: "44020000001102127785",
  38056. Info: "2208",
  38057. }
  38058. customData = append(customData, custom8)
  38059. custom9 := &CustomData{
  38060. MsgId: "H44022900158202103301712304203",
  38061. PsnNo: "44020000001101518097",
  38062. Info: "2208",
  38063. }
  38064. customData = append(customData, custom9)
  38065. custom10 := &CustomData{
  38066. MsgId: "H44022900158202103301738448785",
  38067. PsnNo: "44020000001100500813",
  38068. Info: "2208",
  38069. }
  38070. customData = append(customData, custom10)
  38071. custom11 := &CustomData{
  38072. MsgId: "H44022900158202103301732455843",
  38073. PsnNo: "44020000001102690557",
  38074. Info: "2208",
  38075. }
  38076. customData = append(customData, custom11)
  38077. custom12 := &CustomData{
  38078. MsgId: "H44022900158202103301745421708",
  38079. PsnNo: "44020000001102211928",
  38080. Info: "2208",
  38081. }
  38082. customData = append(customData, custom12)
  38083. custom1212 := &CustomData{
  38084. MsgId: "H440229001582021033017351627",
  38085. PsnNo: "44020000001102481733",
  38086. Info: "2208",
  38087. }
  38088. customData = append(customData, custom1212)
  38089. custom13 := &CustomData{
  38090. MsgId: "H44022900158202103301740327951",
  38091. PsnNo: "44020000001103174866",
  38092. Info: "2208",
  38093. }
  38094. customData = append(customData, custom13)
  38095. custom14 := &CustomData{
  38096. MsgId: "H4402290015820210330174922668",
  38097. PsnNo: "44020000001102927272",
  38098. Info: "2208",
  38099. }
  38100. customData = append(customData, custom14)
  38101. custom15 := &CustomData{
  38102. MsgId: "H44022900158202103301752362273",
  38103. PsnNo: "44020000001102942890",
  38104. Info: "2208",
  38105. }
  38106. customData = append(customData, custom15)
  38107. custom16 := &CustomData{
  38108. MsgId: "H44022900158202103301751082917",
  38109. PsnNo: "44020000001101662162",
  38110. Info: "2208",
  38111. }
  38112. customData = append(customData, custom16)
  38113. custom17 := &CustomData{
  38114. MsgId: "H44022900158202103301754147728",
  38115. PsnNo: "44020000000229014511",
  38116. Info: "2208",
  38117. }
  38118. customData = append(customData, custom17)
  38119. adminUser := c.GetAdminUserInfo()
  38120. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38121. for _, item := range customData {
  38122. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38123. fmt.Println(result)
  38124. }
  38125. }
  38126. func PathExists(path string) (bool, error) {
  38127. _, err := os.Stat(path)
  38128. if err == nil {
  38129. return true, nil
  38130. }
  38131. if os.IsNotExist(err) {
  38132. return false, nil
  38133. }
  38134. return false, err
  38135. }
  38136. // 创建文件夹
  38137. func Mkdir(dir string) {
  38138. // 创建文件夹
  38139. exist, err := PathExists(dir)
  38140. if err != nil {
  38141. fmt.Println(err.Error())
  38142. } else {
  38143. if exist {
  38144. fmt.Println(dir + "文件夹已存在!")
  38145. } else {
  38146. // 文件夹名称,权限
  38147. err := os.Mkdir(dir, os.ModePerm)
  38148. if err != nil {
  38149. fmt.Println(dir+"文件夹创建失败:", err.Error())
  38150. } else {
  38151. fmt.Println(dir + "文件夹创建成功!")
  38152. }
  38153. }
  38154. }
  38155. }
  38156. // 压缩文件
  38157. func Zip(srcFile string, destZip string) error {
  38158. zipfile, err := os.Create(destZip)
  38159. if err != nil {
  38160. return err
  38161. }
  38162. defer zipfile.Close()
  38163. archive := zip.NewWriter(zipfile)
  38164. defer archive.Close()
  38165. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  38166. if err != nil {
  38167. return err
  38168. }
  38169. header, err := zip.FileInfoHeader(info)
  38170. if err != nil {
  38171. return err
  38172. }
  38173. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  38174. // header.Name = path
  38175. if info.IsDir() {
  38176. header.Name += "/"
  38177. } else {
  38178. header.Method = zip.Deflate
  38179. }
  38180. writer, err := archive.CreateHeader(header)
  38181. if err != nil {
  38182. return err
  38183. }
  38184. if !info.IsDir() {
  38185. file, err := os.Open(path)
  38186. if err != nil {
  38187. return err
  38188. }
  38189. defer file.Close()
  38190. _, err = io.Copy(writer, file)
  38191. }
  38192. return err
  38193. })
  38194. return err
  38195. }
  38196. func ReadFile(filePath string) []byte {
  38197. f, err := os.Open(filePath)
  38198. if err != nil {
  38199. fmt.Println("read file fail", err)
  38200. return nil
  38201. }
  38202. defer f.Close()
  38203. fd, err := ioutil.ReadAll(f)
  38204. if err != nil {
  38205. fmt.Println("read to fd fail", err)
  38206. return nil
  38207. }
  38208. return fd
  38209. }
  38210. func saveLogq(result string, request string, infno string, desc string) {
  38211. dir := "日志"
  38212. utils.Mkdir(dir)
  38213. month := time.Unix(1557042972, 0).Format("1")
  38214. year := time.Now().Format("2006")
  38215. month = time.Now().Format("01")
  38216. day := time.Now().Format("02")
  38217. hour := time.Now().Format("15")
  38218. min := time.Now().Format("04")
  38219. sec := time.Now().Format("05")
  38220. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38221. file := year + month + day + "_log"
  38222. file_name := file + ".txt"
  38223. file_path := "日志" + "/" + file_name
  38224. exist, _ := utils.PathExists(file_path)
  38225. if exist { //存在
  38226. fmt.Println("存在")
  38227. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38228. if err != nil {
  38229. fmt.Println("read fail")
  38230. }
  38231. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38232. n, _ := f.Seek(0, 2)
  38233. _, err = f.WriteAt([]byte(content), n)
  38234. } else { //不存在
  38235. fmt.Println("文件不存在,创建文件")
  38236. f, err := os.Create("日志" + "/" + file_name)
  38237. defer f.Close()
  38238. if err != nil {
  38239. } else {
  38240. _, err = f.Write([]byte("记录日志"))
  38241. }
  38242. }
  38243. }
  38244. func saveLog(result string, request string, infno string, desc string) {
  38245. org_id, _ := beego.AppConfig.Int64("org_id")
  38246. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38247. dir := miConfig.OrgName + "日志"
  38248. utils.Mkdir(dir)
  38249. month := time.Unix(1557042972, 0).Format("1")
  38250. year := time.Now().Format("2006")
  38251. month = time.Now().Format("01")
  38252. day := time.Now().Format("02")
  38253. hour := time.Now().Format("15")
  38254. min := time.Now().Format("04")
  38255. sec := time.Now().Format("05")
  38256. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38257. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  38258. file_name := file + ".txt"
  38259. file_path := miConfig.OrgName + "日志" + "/" + file_name
  38260. exist, _ := utils.PathExists(file_path)
  38261. if exist { //存在
  38262. fmt.Println("存在")
  38263. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38264. if err != nil {
  38265. fmt.Println("read fail")
  38266. }
  38267. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38268. n, _ := f.Seek(0, 2)
  38269. _, err = f.WriteAt([]byte(content), n)
  38270. } else { //不存在
  38271. fmt.Println("文件不存在,创建文件")
  38272. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  38273. defer f.Close()
  38274. if err != nil {
  38275. } else {
  38276. _, err = f.Write([]byte("记录日志"))
  38277. }
  38278. }
  38279. }
  38280. type Charset string
  38281. const (
  38282. UTF8 = Charset("UTF-8")
  38283. GB18030 = Charset("GB18030")
  38284. )
  38285. func ConvertToString(src string, srcCode string, tagCode string) string {
  38286. srcCoder := mahonia.NewDecoder(srcCode)
  38287. srcResult := srcCoder.ConvertString(src)
  38288. tagCoder := mahonia.NewDecoder(tagCode)
  38289. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  38290. result := string(cdata)
  38291. return result
  38292. }
  38293. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  38294. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38295. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38296. var token string
  38297. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38298. var api string
  38299. if miConfig.MdtrtareaAdmvs == "320921" {
  38300. 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 +
  38301. "&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
  38302. fmt.Println(api)
  38303. } else {
  38304. 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 +
  38305. "&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
  38306. }
  38307. resp, requestErr := http.Get(api)
  38308. if requestErr != nil {
  38309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38310. return ""
  38311. }
  38312. body, ioErr := ioutil.ReadAll(resp.Body)
  38313. if ioErr != nil {
  38314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38316. return ""
  38317. }
  38318. var respJSON map[string]interface{}
  38319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38322. return ""
  38323. }
  38324. var status string
  38325. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38326. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38327. var res ResultTwo //1101结果
  38328. var res10265 ResultTwo10265 //1101结果
  38329. if status == "0" { //读卡成功
  38330. var card_info string //卡信息
  38331. var busi_card_info string
  38332. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38333. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38334. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38335. fmt.Println(card_info)
  38336. fmt.Println(busi_card_info)
  38337. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38338. result, _ := json.Marshal(respJSON)
  38339. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38340. utils.ErrorLog("解析失败:%v", err)
  38341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38342. return ""
  38343. }
  38344. res.ErrMsg = res10265.ErrMsg
  38345. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38346. res.Infcode = infocode
  38347. res.Output = res10265.Output
  38348. res.InfRefmsgid = res10265.InfRefmsgid
  38349. if res.Infcode == 0 {
  38350. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38351. if err == gorm.ErrRecordNotFound {
  38352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38353. return ""
  38354. } else if err != nil {
  38355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38356. return ""
  38357. } else {
  38358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38360. infoStr := string(Iinfos)
  38361. idetinfoStr := string(Idetinfos)
  38362. psn := &models.HisPsn{
  38363. PsnNo: res.Output.Baseinfo.PsnNo,
  38364. PatientId: patient.ID,
  38365. Certno: res.Output.Baseinfo.Certno,
  38366. Gend: res.Output.Baseinfo.Gend,
  38367. Naty: res.Output.Baseinfo.Naty,
  38368. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38369. PsnName: res.Output.Baseinfo.PsnName,
  38370. Idetinfo: idetinfoStr,
  38371. Insuinfo: infoStr,
  38372. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38373. CardInfo: card_info,
  38374. VerifyNumber: token,
  38375. }
  38376. service.CreateHisPsn(psn)
  38377. return token
  38378. }
  38379. }
  38380. } else {
  38381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38382. return ""
  38383. }
  38384. } else { //读卡失败
  38385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38386. return ""
  38387. }
  38388. return token
  38389. }
  38390. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  38391. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38392. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38393. var token string
  38394. var api string
  38395. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  38396. "&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
  38397. fmt.Println(api)
  38398. resp, requestErr := http.Get(api)
  38399. if requestErr != nil {
  38400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38401. return ""
  38402. }
  38403. body, ioErr := ioutil.ReadAll(resp.Body)
  38404. if ioErr != nil {
  38405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38407. return ""
  38408. }
  38409. var respJSON map[string]interface{}
  38410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38413. return ""
  38414. }
  38415. var status string
  38416. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38417. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38418. var res ResultTwo //1101结果
  38419. if status == "1" { //读卡成功
  38420. var card_info string //卡信息
  38421. var busi_card_info string
  38422. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38423. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38424. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38425. fmt.Println(card_info)
  38426. fmt.Println(busi_card_info)
  38427. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38428. result, _ := json.Marshal(respJSON)
  38429. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38430. utils.ErrorLog("解析失败:%v", err)
  38431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38432. return ""
  38433. }
  38434. if res.Infcode == 0 {
  38435. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38436. if err == gorm.ErrRecordNotFound {
  38437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38438. return ""
  38439. } else if err != nil {
  38440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38441. return ""
  38442. } else {
  38443. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38444. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38445. infoStr := string(Iinfos)
  38446. idetinfoStr := string(Idetinfos)
  38447. psn := &models.HisPsn{
  38448. PsnNo: res.Output.Baseinfo.PsnNo,
  38449. PatientId: patient.ID,
  38450. Certno: res.Output.Baseinfo.Certno,
  38451. Gend: res.Output.Baseinfo.Gend,
  38452. Naty: res.Output.Baseinfo.Naty,
  38453. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38454. PsnName: res.Output.Baseinfo.PsnName,
  38455. Idetinfo: idetinfoStr,
  38456. Insuinfo: infoStr,
  38457. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38458. CardInfo: card_info,
  38459. VerifyNumber: token,
  38460. }
  38461. service.CreateHisPsn(psn)
  38462. return token
  38463. }
  38464. }
  38465. } else {
  38466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38467. return ""
  38468. }
  38469. return token
  38470. }
  38471. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  38472. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38473. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38474. var token string
  38475. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38476. var api string
  38477. if miConfig.MdtrtareaAdmvs == "320921" {
  38478. 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 +
  38479. "&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
  38480. fmt.Println(api)
  38481. } else {
  38482. 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 +
  38483. "&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
  38484. }
  38485. resp, requestErr := http.Get(api)
  38486. if requestErr != nil {
  38487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38488. return ""
  38489. }
  38490. body, ioErr := ioutil.ReadAll(resp.Body)
  38491. if ioErr != nil {
  38492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38494. return ""
  38495. }
  38496. var respJSON map[string]interface{}
  38497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38500. return ""
  38501. }
  38502. var status string
  38503. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38504. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38505. var res ResultTwo //1101结果
  38506. var res10265 ResultTwo10265 //1101结果
  38507. if status == "0" { //读卡成功
  38508. var card_info string //卡信息
  38509. var busi_card_info string
  38510. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38511. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38512. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38513. fmt.Println(card_info)
  38514. fmt.Println(busi_card_info)
  38515. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38516. result, _ := json.Marshal(respJSON)
  38517. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38518. utils.ErrorLog("解析失败:%v", err)
  38519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38520. return ""
  38521. }
  38522. res.ErrMsg = res10265.ErrMsg
  38523. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38524. res.Infcode = infocode
  38525. res.Output = res10265.Output
  38526. res.InfRefmsgid = res10265.InfRefmsgid
  38527. if res.Infcode == 0 {
  38528. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38529. if err == gorm.ErrRecordNotFound {
  38530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38531. return ""
  38532. } else if err != nil {
  38533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38534. return ""
  38535. } else {
  38536. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38537. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38538. infoStr := string(Iinfos)
  38539. idetinfoStr := string(Idetinfos)
  38540. psn := &models.HisPsn{
  38541. PsnNo: res.Output.Baseinfo.PsnNo,
  38542. PatientId: patient.ID,
  38543. Certno: res.Output.Baseinfo.Certno,
  38544. Gend: res.Output.Baseinfo.Gend,
  38545. Naty: res.Output.Baseinfo.Naty,
  38546. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38547. PsnName: res.Output.Baseinfo.PsnName,
  38548. Idetinfo: idetinfoStr,
  38549. Insuinfo: infoStr,
  38550. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38551. CardInfo: card_info,
  38552. VerifyNumber: token,
  38553. }
  38554. service.CreateHisPsn(psn)
  38555. return token
  38556. }
  38557. }
  38558. } else {
  38559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38560. return ""
  38561. }
  38562. } else { //读卡失败
  38563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38564. return ""
  38565. }
  38566. return token
  38567. }
  38568. func DeleteExtraSpaceTwo(s string) string {
  38569. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  38570. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  38571. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  38572. reg, _ := regexp.Compile(regstr) //编译正则表达式
  38573. s2 := make([]byte, len(s1)) //定义字符数组切片
  38574. copy(s2, s1) //将字符串复制到切片
  38575. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  38576. for len(spc_index) > 0 { //找到适配项
  38577. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  38578. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  38579. }
  38580. return string(s2)
  38581. }
  38582. func Remove0000(s string) string {
  38583. str := make([]rune, 0, len(s))
  38584. for _, v := range []rune(s) {
  38585. if v == 0 {
  38586. continue
  38587. }
  38588. str = append(str, v)
  38589. }
  38590. return string(str)
  38591. }
  38592. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  38593. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  38594. readCard := DllDef.MustFindProc("EcQuery")
  38595. pCardInfo := make([]byte, 8192)
  38596. pBusiCardInfo := make([]byte, 8192)
  38597. data := make(map[string]interface{})
  38598. //pData := make(map[string]interface{})
  38599. inputData := make(map[string]interface{})
  38600. inputData["orgId"] = code
  38601. inputData["businessType"] = "01101"
  38602. inputData["operatorId"] = operator_id
  38603. inputData["operatorName"] = operator_name
  38604. inputData["officeId"] = "001"
  38605. inputData["officeName"] = "血透室"
  38606. //
  38607. data["data"] = inputData
  38608. data["transType"] = "ec.query"
  38609. data["orgId"] = code
  38610. bytesData, _ := json.Marshal(data)
  38611. pCardInfo = bytesData
  38612. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  38613. fmt.Println(ret2)
  38614. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  38615. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  38616. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  38617. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  38618. if ret2 != 0 {
  38619. return "", ""
  38620. }
  38621. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  38622. }
  38623. func DeleteExtraSpace(s string) string {
  38624. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  38625. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  38626. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  38627. reg, _ := regexp.Compile(regstr) //编译正则表达式
  38628. s2 := make([]byte, len(s1)) //定义字符数组切片
  38629. copy(s2, s1) //将字符串复制到切片
  38630. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  38631. for len(spc_index) > 0 { //找到适配项
  38632. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  38633. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  38634. }
  38635. return string(s2)
  38636. }
  38637. // 对账
  38638. func (c *HisApiController) Post3202() {
  38639. start_time := c.GetString("start_time")
  38640. end_time := c.GetString("end_time")
  38641. //insutype := c.GetString("insutype")
  38642. clr_type := c.GetString("clr_type")
  38643. clr_org := c.GetString("clr_optins")
  38644. admin_user_id, _ := c.GetInt64("admin_user_id")
  38645. adminUser := c.GetAdminUserInfo()
  38646. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38647. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38648. if len(clr_org) == 0 {
  38649. clr_org = miConfig.MdtrtareaAdmvs
  38650. }
  38651. timeLayout := "2006-01-02"
  38652. loc, _ := time.LoadLocation("Local")
  38653. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38654. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38655. var orders []*models.HisOrder
  38656. if clr_org == "421300" {
  38657. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38658. } else if clr_org == "420902" {
  38659. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38660. } else {
  38661. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38662. }
  38663. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38664. //fixmedins_setl_cnt := int64(len(orders))
  38665. var medfee_sumamt float64
  38666. var acct_pay float64
  38667. var fund_pay_sumamt float64
  38668. for _, item := range orders {
  38669. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38670. acct_pay = acct_pay + item.AcctPay
  38671. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38672. }
  38673. //var medfee_sumamt_two float64
  38674. //var acct_pay_two float64
  38675. //var fund_pay_sumamt_two float64
  38676. //for _, item := range orders_two {
  38677. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38678. // acct_pay_two = acct_pay_two + item.AcctPay
  38679. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38680. //}
  38681. //var user_name string
  38682. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38683. //if role.ID == 0 {
  38684. // user_name = "xxx"
  38685. //} else {
  38686. // user_name = role.UserName
  38687. //}
  38688. var res ResultSix
  38689. if config.IsOpen == 1 {
  38690. var bps []*models.BusinessParamsTwo
  38691. var bp models.BusinessParamsTwo
  38692. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38693. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38694. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38695. bp.MedfeeSumamt = medfee_sumamt_str
  38696. bp.AcctPay = acct_pay_str
  38697. bp.FundPaySumamt = fund_pay_sumamt_str
  38698. bp.Insutype = ""
  38699. bp.StmtBegndate = start_time
  38700. bp.ClrType = clr_type
  38701. bp.SetlOptins = clr_org
  38702. bp.StmtEnddate = end_time
  38703. bps = append(bps, &bp)
  38704. data := make(map[string]interface{})
  38705. data["bps"] = bps
  38706. data["org_name"] = miConfig.OrgName
  38707. data["doctor"] = role.UserName
  38708. data["fixmedins_code"] = miConfig.Code
  38709. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38710. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38711. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38712. if miConfig.MdtrtareaAdmvs == "421300" {
  38713. client := &http.Client{}
  38714. bytesData, _ := json.Marshal(data)
  38715. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38716. resp, _ := client.Do(req)
  38717. defer resp.Body.Close()
  38718. body, ioErr := ioutil.ReadAll(resp.Body)
  38719. if ioErr != nil {
  38720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38722. return
  38723. }
  38724. var respJSON map[string]interface{}
  38725. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38728. return
  38729. }
  38730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38731. userJSONBytes, _ := json.Marshal(respJSON)
  38732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38733. utils.ErrorLog("解析失败:%v", err)
  38734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38735. return
  38736. }
  38737. }
  38738. if miConfig.MdtrtareaAdmvs == "420200" {
  38739. client := &http.Client{}
  38740. bytesData, _ := json.Marshal(data)
  38741. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38742. resp, _ := client.Do(req)
  38743. defer resp.Body.Close()
  38744. body, ioErr := ioutil.ReadAll(resp.Body)
  38745. if ioErr != nil {
  38746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38748. return
  38749. }
  38750. var respJSON map[string]interface{}
  38751. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38754. return
  38755. }
  38756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38757. userJSONBytes, _ := json.Marshal(respJSON)
  38758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38759. utils.ErrorLog("解析失败:%v", err)
  38760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38761. return
  38762. }
  38763. }
  38764. if miConfig.MdtrtareaAdmvs == "421182" {
  38765. client := &http.Client{}
  38766. bytesData, _ := json.Marshal(data)
  38767. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38768. resp, _ := client.Do(req)
  38769. defer resp.Body.Close()
  38770. body, ioErr := ioutil.ReadAll(resp.Body)
  38771. if ioErr != nil {
  38772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38774. return
  38775. }
  38776. var respJSON map[string]interface{}
  38777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38780. return
  38781. }
  38782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38783. userJSONBytes, _ := json.Marshal(respJSON)
  38784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38785. utils.ErrorLog("解析失败:%v", err)
  38786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38787. return
  38788. }
  38789. }
  38790. if miConfig.MdtrtareaAdmvs == "420902" {
  38791. client := &http.Client{}
  38792. bytesData, _ := json.Marshal(data)
  38793. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38794. resp, _ := client.Do(req)
  38795. defer resp.Body.Close()
  38796. body, ioErr := ioutil.ReadAll(resp.Body)
  38797. if ioErr != nil {
  38798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38800. return
  38801. }
  38802. var respJSON map[string]interface{}
  38803. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38806. return
  38807. }
  38808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38809. userJSONBytes, _ := json.Marshal(respJSON)
  38810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38811. utils.ErrorLog("解析失败:%v", err)
  38812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38813. return
  38814. }
  38815. }
  38816. if res.Infcode == 0 {
  38817. c.ServeSuccessJSON(map[string]interface{}{
  38818. "msg": "发起成功",
  38819. })
  38820. } else {
  38821. c.ServeSuccessJSON(map[string]interface{}{
  38822. "failed_code": -10,
  38823. "msg": res.ErrMsg,
  38824. })
  38825. }
  38826. }
  38827. }
  38828. func (c *HisApiController) Post3204a() {
  38829. start_time := c.GetString("start_time")
  38830. end_time := c.GetString("end_time")
  38831. //insutype := c.GetString("insutype")
  38832. clr_type := c.GetString("clr_type")
  38833. clr_org := c.GetString("clr_optins")
  38834. admin_user_id, _ := c.GetInt64("admin_user_id")
  38835. adminUser := c.GetAdminUserInfo()
  38836. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38837. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38838. if len(clr_org) == 0 {
  38839. clr_org = miConfig.MdtrtareaAdmvs
  38840. }
  38841. timeLayout := "2006-01-02"
  38842. loc, _ := time.LoadLocation("Local")
  38843. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38844. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38845. var orders []*models.HisOrder
  38846. if clr_org == "421300" {
  38847. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38848. } else if clr_org == "420902" {
  38849. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38850. } else {
  38851. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38852. }
  38853. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38854. //fixmedins_setl_cnt := int64(len(orders))
  38855. var medfee_sumamt float64
  38856. var acct_pay float64
  38857. var fund_pay_sumamt float64
  38858. for _, item := range orders {
  38859. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38860. acct_pay = acct_pay + item.AcctPay
  38861. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38862. }
  38863. //var medfee_sumamt_two float64
  38864. //var acct_pay_two float64
  38865. //var fund_pay_sumamt_two float64
  38866. //for _, item := range orders_two {
  38867. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38868. // acct_pay_two = acct_pay_two + item.AcctPay
  38869. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38870. //}
  38871. //var user_name string
  38872. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38873. //if role.ID == 0 {
  38874. // user_name = "xxx"
  38875. //} else {
  38876. // user_name = role.UserName
  38877. //}
  38878. var res ResultSix
  38879. if config.IsOpen == 1 {
  38880. var bps []*models.BusinessParamsTwo
  38881. var bp models.BusinessParamsTwo
  38882. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38883. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38884. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38885. bp.MedfeeSumamt = medfee_sumamt_str
  38886. bp.AcctPay = acct_pay_str
  38887. bp.FundPaySumamt = fund_pay_sumamt_str
  38888. bp.Insutype = ""
  38889. bp.StmtBegndate = start_time
  38890. bp.ClrType = clr_type
  38891. bp.SetlOptins = clr_org
  38892. bp.StmtEnddate = end_time
  38893. bps = append(bps, &bp)
  38894. data := make(map[string]interface{})
  38895. data["bps"] = bps
  38896. data["org_name"] = miConfig.OrgName
  38897. data["doctor"] = role.UserName
  38898. data["fixmedins_code"] = miConfig.Code
  38899. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38900. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38901. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38902. if miConfig.MdtrtareaAdmvs == "421300" {
  38903. client := &http.Client{}
  38904. bytesData, _ := json.Marshal(data)
  38905. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38906. resp, _ := client.Do(req)
  38907. defer resp.Body.Close()
  38908. body, ioErr := ioutil.ReadAll(resp.Body)
  38909. if ioErr != nil {
  38910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38912. return
  38913. }
  38914. var respJSON map[string]interface{}
  38915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38918. return
  38919. }
  38920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38921. userJSONBytes, _ := json.Marshal(respJSON)
  38922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38923. utils.ErrorLog("解析失败:%v", err)
  38924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38925. return
  38926. }
  38927. }
  38928. if miConfig.MdtrtareaAdmvs == "420200" {
  38929. client := &http.Client{}
  38930. bytesData, _ := json.Marshal(data)
  38931. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38932. resp, _ := client.Do(req)
  38933. defer resp.Body.Close()
  38934. body, ioErr := ioutil.ReadAll(resp.Body)
  38935. if ioErr != nil {
  38936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38938. return
  38939. }
  38940. var respJSON map[string]interface{}
  38941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38944. return
  38945. }
  38946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38947. userJSONBytes, _ := json.Marshal(respJSON)
  38948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38949. utils.ErrorLog("解析失败:%v", err)
  38950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38951. return
  38952. }
  38953. }
  38954. if miConfig.MdtrtareaAdmvs == "421182" {
  38955. client := &http.Client{}
  38956. bytesData, _ := json.Marshal(data)
  38957. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38958. resp, _ := client.Do(req)
  38959. defer resp.Body.Close()
  38960. body, ioErr := ioutil.ReadAll(resp.Body)
  38961. if ioErr != nil {
  38962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38964. return
  38965. }
  38966. var respJSON map[string]interface{}
  38967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38970. return
  38971. }
  38972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38973. userJSONBytes, _ := json.Marshal(respJSON)
  38974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38975. utils.ErrorLog("解析失败:%v", err)
  38976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38977. return
  38978. }
  38979. }
  38980. if miConfig.MdtrtareaAdmvs == "420902" {
  38981. client := &http.Client{}
  38982. bytesData, _ := json.Marshal(data)
  38983. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38984. resp, _ := client.Do(req)
  38985. defer resp.Body.Close()
  38986. body, ioErr := ioutil.ReadAll(resp.Body)
  38987. if ioErr != nil {
  38988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38990. return
  38991. }
  38992. var respJSON map[string]interface{}
  38993. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38996. return
  38997. }
  38998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38999. userJSONBytes, _ := json.Marshal(respJSON)
  39000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39001. utils.ErrorLog("解析失败:%v", err)
  39002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39003. return
  39004. }
  39005. }
  39006. if res.Infcode == 0 {
  39007. c.ServeSuccessJSON(map[string]interface{}{
  39008. "msg": "撤销成功",
  39009. })
  39010. } else {
  39011. c.ServeSuccessJSON(map[string]interface{}{
  39012. "failed_code": -10,
  39013. "msg": res.ErrMsg,
  39014. })
  39015. }
  39016. }
  39017. }
  39018. func (c *HisApiController) Post3204() {
  39019. admin_user_id, _ := c.GetInt64("admin_user_id")
  39020. id := c.GetString("id")
  39021. adminUser := c.GetAdminUserInfo()
  39022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39024. //clr_org := miConfig.MdtrtareaAdmvs
  39025. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39026. var res ResultSix
  39027. if config.IsOpen == 1 {
  39028. data := make(map[string]interface{})
  39029. data["id"] = id
  39030. data["org_name"] = miConfig.OrgName
  39031. data["doctor"] = role.UserName
  39032. data["fixmedins_code"] = miConfig.Code
  39033. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39034. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39035. client := &http.Client{}
  39036. bytesData, _ := json.Marshal(data)
  39037. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  39038. resp, _ := client.Do(req)
  39039. defer resp.Body.Close()
  39040. body, ioErr := ioutil.ReadAll(resp.Body)
  39041. if ioErr != nil {
  39042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39044. return
  39045. }
  39046. var respJSON map[string]interface{}
  39047. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39050. return
  39051. }
  39052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39053. userJSONBytes, _ := json.Marshal(respJSON)
  39054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39055. utils.ErrorLog("解析失败:%v", err)
  39056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39057. return
  39058. }
  39059. if res.Infcode == 0 {
  39060. c.ServeSuccessJSON(map[string]interface{}{
  39061. "msg": "发起成功",
  39062. })
  39063. } else {
  39064. c.ServeSuccessJSON(map[string]interface{}{
  39065. "failed_code": -10,
  39066. "msg": res.ErrMsg,
  39067. })
  39068. }
  39069. }
  39070. }
  39071. func (c *HisApiController) Post8404() {
  39072. admin_user_id, _ := c.GetInt64("admin_user_id")
  39073. month := c.GetString("month")
  39074. adminUser := c.GetAdminUserInfo()
  39075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39076. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39077. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39078. var res ResultSix
  39079. if config.IsOpen == 1 {
  39080. data := make(map[string]interface{})
  39081. data["month"] = month
  39082. data["org_name"] = miConfig.OrgName
  39083. data["doctor"] = role.UserName
  39084. data["fixmedins_code"] = miConfig.Code
  39085. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39086. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39087. client := &http.Client{}
  39088. bytesData, _ := json.Marshal(data)
  39089. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  39090. resp, _ := client.Do(req)
  39091. defer resp.Body.Close()
  39092. body, ioErr := ioutil.ReadAll(resp.Body)
  39093. if ioErr != nil {
  39094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39096. return
  39097. }
  39098. var respJSON map[string]interface{}
  39099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39102. return
  39103. }
  39104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39105. userJSONBytes, _ := json.Marshal(respJSON)
  39106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39107. utils.ErrorLog("解析失败:%v", err)
  39108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39109. return
  39110. }
  39111. if res.Infcode == 0 {
  39112. c.ServeSuccessJSON(map[string]interface{}{
  39113. "msg": "查询成功",
  39114. })
  39115. } else {
  39116. c.ServeSuccessJSON(map[string]interface{}{
  39117. "failed_code": -10,
  39118. "msg": res.ErrMsg,
  39119. })
  39120. }
  39121. }
  39122. }
  39123. func (c *HisApiController) Post3202b() {
  39124. start_time := c.GetString("start_time")
  39125. end_time := c.GetString("end_time")
  39126. //insutype := c.GetString("insutype")
  39127. clr_type := c.GetString("clr_type")
  39128. clr_org := c.GetString("clr_optins")
  39129. admin_user_id, _ := c.GetInt64("admin_user_id")
  39130. adminUser := c.GetAdminUserInfo()
  39131. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39132. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39133. if len(clr_org) == 0 {
  39134. clr_org = miConfig.MdtrtareaAdmvs
  39135. }
  39136. timeLayout := "2006-01-02"
  39137. loc, _ := time.LoadLocation("Local")
  39138. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39139. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39140. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39141. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39142. //fixmedins_setl_cnt := int64(len(orders))
  39143. var medfee_sumamt float64
  39144. var acct_pay float64
  39145. var fund_pay_sumamt float64
  39146. for _, item := range orders {
  39147. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39148. acct_pay = acct_pay + item.AcctPay
  39149. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39150. }
  39151. //var medfee_sumamt_two float64
  39152. //var acct_pay_two float64
  39153. //var fund_pay_sumamt_two float64
  39154. //for _, item := range orders_two {
  39155. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39156. // acct_pay_two = acct_pay_two + item.AcctPay
  39157. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39158. //}
  39159. //var user_name string
  39160. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39161. //if role.ID == 0 {
  39162. // user_name = "xxx"
  39163. //} else {
  39164. // user_name = role.UserName
  39165. //}
  39166. var res ResultSix
  39167. if config.IsOpen == 1 {
  39168. var bps []*models.BusinessParamsTwo
  39169. var bp models.BusinessParamsTwo
  39170. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39171. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39172. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39173. bp.MedfeeSumamt = medfee_sumamt_str
  39174. bp.AcctPay = acct_pay_str
  39175. bp.FundPaySumamt = fund_pay_sumamt_str
  39176. bp.Insutype = "390"
  39177. bp.StmtBegndate = start_time
  39178. bp.ClrType = clr_type
  39179. bp.SetlOptins = clr_org
  39180. bp.StmtEnddate = end_time
  39181. bps = append(bps, &bp)
  39182. data := make(map[string]interface{})
  39183. data["bps"] = bps
  39184. data["org_name"] = miConfig.OrgName
  39185. data["doctor"] = role.UserName
  39186. data["fixmedins_code"] = miConfig.Code
  39187. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39188. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39189. if miConfig.MdtrtareaAdmvs == "421300" {
  39190. client := &http.Client{}
  39191. bytesData, _ := json.Marshal(data)
  39192. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39193. resp, _ := client.Do(req)
  39194. defer resp.Body.Close()
  39195. body, ioErr := ioutil.ReadAll(resp.Body)
  39196. if ioErr != nil {
  39197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39199. return
  39200. }
  39201. var respJSON map[string]interface{}
  39202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39205. return
  39206. }
  39207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39208. userJSONBytes, _ := json.Marshal(respJSON)
  39209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39210. utils.ErrorLog("解析失败:%v", err)
  39211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39212. return
  39213. }
  39214. }
  39215. if miConfig.MdtrtareaAdmvs == "420200" {
  39216. client := &http.Client{}
  39217. bytesData, _ := json.Marshal(data)
  39218. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39219. resp, _ := client.Do(req)
  39220. defer resp.Body.Close()
  39221. body, ioErr := ioutil.ReadAll(resp.Body)
  39222. if ioErr != nil {
  39223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39225. return
  39226. }
  39227. var respJSON map[string]interface{}
  39228. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39231. return
  39232. }
  39233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39234. userJSONBytes, _ := json.Marshal(respJSON)
  39235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39236. utils.ErrorLog("解析失败:%v", err)
  39237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39238. return
  39239. }
  39240. }
  39241. if miConfig.MdtrtareaAdmvs == "421182" {
  39242. client := &http.Client{}
  39243. bytesData, _ := json.Marshal(data)
  39244. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  39245. resp, _ := client.Do(req)
  39246. defer resp.Body.Close()
  39247. body, ioErr := ioutil.ReadAll(resp.Body)
  39248. if ioErr != nil {
  39249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39251. return
  39252. }
  39253. var respJSON map[string]interface{}
  39254. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39257. return
  39258. }
  39259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39260. userJSONBytes, _ := json.Marshal(respJSON)
  39261. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39262. utils.ErrorLog("解析失败:%v", err)
  39263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39264. return
  39265. }
  39266. }
  39267. if res.Infcode == 0 {
  39268. c.ServeSuccessJSON(map[string]interface{}{
  39269. "msg": "发起成功",
  39270. })
  39271. } else {
  39272. c.ServeSuccessJSON(map[string]interface{}{
  39273. "failed_code": -10,
  39274. "msg": res.ErrMsg,
  39275. })
  39276. }
  39277. }
  39278. }
  39279. func (c *HisApiController) Post1608() {
  39280. start_time := c.GetString("start_time")
  39281. end_time := c.GetString("end_time")
  39282. admin_user_id, _ := c.GetInt64("admin_user_id")
  39283. adminUser := c.GetAdminUserInfo()
  39284. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39285. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39286. timeLayout := "2006-01-02"
  39287. loc, _ := time.LoadLocation("Local")
  39288. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39289. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39290. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39291. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39292. fixmedins_setl_cnt := int64(len(orders))
  39293. var medfee_sumamt float64
  39294. var func_smamt float64
  39295. for _, item := range orders {
  39296. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39297. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  39298. }
  39299. times := strings.Split(start_time, "-")
  39300. time_tows := strings.Split(end_time, "-")
  39301. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39302. var res ResultSix
  39303. if config.IsOpen == 1 {
  39304. //var bps []*models.BusinessParamsTwo
  39305. //var bp models.BusinessParamsTwo
  39306. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39307. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  39308. data := make(map[string]interface{})
  39309. data["org_name"] = miConfig.OrgName
  39310. data["doctor"] = role.UserName
  39311. data["func_smamt"] = func_smamt_str
  39312. data["fixmedins_code"] = miConfig.Code
  39313. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39314. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39315. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  39316. data["medfee_sumamt"] = medfee_sumamt_str
  39317. data["start_time"] = times[0] + times[1] + times[2]
  39318. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  39319. if miConfig.MdtrtareaAdmvs == "421300" {
  39320. client := &http.Client{}
  39321. bytesData, _ := json.Marshal(data)
  39322. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  39323. resp, _ := client.Do(req)
  39324. defer resp.Body.Close()
  39325. body, ioErr := ioutil.ReadAll(resp.Body)
  39326. if ioErr != nil {
  39327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39329. return
  39330. }
  39331. var respJSON map[string]interface{}
  39332. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39335. return
  39336. }
  39337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39338. userJSONBytes, _ := json.Marshal(respJSON)
  39339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39340. utils.ErrorLog("解析失败:%v", err)
  39341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39342. return
  39343. }
  39344. }
  39345. if miConfig.MdtrtareaAdmvs == "420200" {
  39346. client := &http.Client{}
  39347. bytesData, _ := json.Marshal(data)
  39348. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  39349. resp, _ := client.Do(req)
  39350. defer resp.Body.Close()
  39351. body, ioErr := ioutil.ReadAll(resp.Body)
  39352. if ioErr != nil {
  39353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39355. return
  39356. }
  39357. var respJSON map[string]interface{}
  39358. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39361. return
  39362. }
  39363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39364. userJSONBytes, _ := json.Marshal(respJSON)
  39365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39366. utils.ErrorLog("解析失败:%v", err)
  39367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39368. return
  39369. }
  39370. }
  39371. if miConfig.MdtrtareaAdmvs == "421182" {
  39372. client := &http.Client{}
  39373. bytesData, _ := json.Marshal(data)
  39374. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  39375. resp, _ := client.Do(req)
  39376. defer resp.Body.Close()
  39377. body, ioErr := ioutil.ReadAll(resp.Body)
  39378. if ioErr != nil {
  39379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39381. return
  39382. }
  39383. var respJSON map[string]interface{}
  39384. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39387. return
  39388. }
  39389. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39390. userJSONBytes, _ := json.Marshal(respJSON)
  39391. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39392. utils.ErrorLog("解析失败:%v", err)
  39393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39394. return
  39395. }
  39396. }
  39397. if res.Infcode == 0 {
  39398. c.ServeSuccessJSON(map[string]interface{}{
  39399. "msg": "发起成功",
  39400. })
  39401. } else {
  39402. c.ServeSuccessJSON(map[string]interface{}{
  39403. "failed_code": -10,
  39404. "msg": res.ErrMsg,
  39405. })
  39406. }
  39407. }
  39408. }
  39409. // 5.11.1.1【5262】结算信息按时间段查询
  39410. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  39411. admin_user_id, _ := c.GetInt64("admin_user_id")
  39412. adminUser := c.GetAdminUserInfo()
  39413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39414. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39415. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39416. var res Result5262
  39417. if config.IsOpen == 1 {
  39418. if miConfig.MdtrtareaAdmvs == "421300" {
  39419. data := make(map[string]interface{})
  39420. data["bps"] = bp
  39421. data["org_name"] = miConfig.OrgName
  39422. data["doctor"] = role.UserName
  39423. data["fixmedins_code"] = miConfig.Code
  39424. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39425. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39426. data["page"] = strconv.FormatInt(page, 10)
  39427. data["limit"] = strconv.FormatInt(limit, 10)
  39428. fmt.Println(data)
  39429. client := &http.Client{}
  39430. bytesData, _ := json.Marshal(data)
  39431. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  39432. resp, _ := client.Do(req)
  39433. defer resp.Body.Close()
  39434. body, ioErr := ioutil.ReadAll(resp.Body)
  39435. if ioErr != nil {
  39436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39438. return
  39439. }
  39440. var respJSON map[string]interface{}
  39441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39444. return
  39445. }
  39446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39447. userJSONBytes, _ := json.Marshal(respJSON)
  39448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39449. utils.ErrorLog("解析失败:%v", err)
  39450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39451. return
  39452. }
  39453. }
  39454. if miConfig.MdtrtareaAdmvs == "420200" {
  39455. data := make(map[string]interface{})
  39456. data["bps"] = bp
  39457. data["org_name"] = miConfig.OrgName
  39458. data["doctor"] = role.UserName
  39459. data["fixmedins_code"] = miConfig.Code
  39460. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39461. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39462. data["page"] = strconv.FormatInt(page, 10)
  39463. data["limit"] = strconv.FormatInt(limit, 10)
  39464. fmt.Println(data)
  39465. client := &http.Client{}
  39466. bytesData, _ := json.Marshal(data)
  39467. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  39468. resp, _ := client.Do(req)
  39469. defer resp.Body.Close()
  39470. body, ioErr := ioutil.ReadAll(resp.Body)
  39471. if ioErr != nil {
  39472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39474. return
  39475. }
  39476. var respJSON map[string]interface{}
  39477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39480. return
  39481. }
  39482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39483. userJSONBytes, _ := json.Marshal(respJSON)
  39484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39485. utils.ErrorLog("解析失败:%v", err)
  39486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39487. return
  39488. }
  39489. }
  39490. if miConfig.MdtrtareaAdmvs == "421182" {
  39491. data := make(map[string]interface{})
  39492. data["bps"] = bp
  39493. data["org_name"] = miConfig.OrgName
  39494. data["doctor"] = role.UserName
  39495. data["fixmedins_code"] = miConfig.Code
  39496. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39497. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39498. data["page"] = strconv.FormatInt(page, 10)
  39499. data["limit"] = strconv.FormatInt(limit, 10)
  39500. fmt.Println(data)
  39501. client := &http.Client{}
  39502. bytesData, _ := json.Marshal(data)
  39503. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  39504. resp, _ := client.Do(req)
  39505. defer resp.Body.Close()
  39506. body, ioErr := ioutil.ReadAll(resp.Body)
  39507. if ioErr != nil {
  39508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39510. return
  39511. }
  39512. var respJSON map[string]interface{}
  39513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39516. return
  39517. }
  39518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39519. userJSONBytes, _ := json.Marshal(respJSON)
  39520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39521. utils.ErrorLog("解析失败:%v", err)
  39522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39523. return
  39524. }
  39525. }
  39526. if miConfig.MdtrtareaAdmvs == "420902" {
  39527. data := make(map[string]interface{})
  39528. data["bps"] = bp
  39529. data["org_name"] = miConfig.OrgName
  39530. data["doctor"] = role.UserName
  39531. data["fixmedins_code"] = miConfig.Code
  39532. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39533. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39534. data["page"] = strconv.FormatInt(page, 10)
  39535. data["limit"] = strconv.FormatInt(limit, 10)
  39536. fmt.Println(data)
  39537. client := &http.Client{}
  39538. bytesData, _ := json.Marshal(data)
  39539. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  39540. resp, _ := client.Do(req)
  39541. defer resp.Body.Close()
  39542. body, ioErr := ioutil.ReadAll(resp.Body)
  39543. if ioErr != nil {
  39544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39546. return
  39547. }
  39548. var respJSON map[string]interface{}
  39549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39552. return
  39553. }
  39554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39555. userJSONBytes, _ := json.Marshal(respJSON)
  39556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39557. utils.ErrorLog("解析失败:%v", err)
  39558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39559. return
  39560. }
  39561. }
  39562. if res.Infcode == 0 {
  39563. c.ServeSuccessJSON(map[string]interface{}{
  39564. "order": res.Output.Result,
  39565. "total": res.Output.PageInfo.RecordCounts,
  39566. })
  39567. } else {
  39568. c.ServeSuccessJSON(map[string]interface{}{
  39569. "failed_code": -10,
  39570. "msg": res.ErrMsg,
  39571. })
  39572. }
  39573. }
  39574. }
  39575. // 5.11.1.2【5267】异地结算信息时间段查询
  39576. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  39577. admin_user_id, _ := c.GetInt64("admin_user_id")
  39578. adminUser := c.GetAdminUserInfo()
  39579. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39580. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39581. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39582. var res Result5267
  39583. if config.IsOpen == 1 {
  39584. if miConfig.MdtrtareaAdmvs == "421300" {
  39585. data := make(map[string]interface{})
  39586. data["bps"] = bp
  39587. data["org_name"] = miConfig.OrgName
  39588. data["doctor"] = role.UserName
  39589. data["fixmedins_code"] = miConfig.Code
  39590. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39591. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39592. data["page"] = page
  39593. data["limit"] = limit
  39594. fmt.Println(data)
  39595. client := &http.Client{}
  39596. bytesData, _ := json.Marshal(data)
  39597. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  39598. resp, _ := client.Do(req)
  39599. defer resp.Body.Close()
  39600. body, ioErr := ioutil.ReadAll(resp.Body)
  39601. if ioErr != nil {
  39602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39604. return
  39605. }
  39606. var respJSON map[string]interface{}
  39607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39610. return
  39611. }
  39612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39613. userJSONBytes, _ := json.Marshal(respJSON)
  39614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39615. utils.ErrorLog("解析失败:%v", err)
  39616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39617. return
  39618. }
  39619. }
  39620. if miConfig.MdtrtareaAdmvs == "420200" {
  39621. data := make(map[string]interface{})
  39622. data["bps"] = bp
  39623. data["org_name"] = miConfig.OrgName
  39624. data["doctor"] = role.UserName
  39625. data["fixmedins_code"] = miConfig.Code
  39626. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39627. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39628. data["page"] = page
  39629. data["limit"] = limit
  39630. fmt.Println(data)
  39631. client := &http.Client{}
  39632. bytesData, _ := json.Marshal(data)
  39633. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  39634. resp, _ := client.Do(req)
  39635. defer resp.Body.Close()
  39636. body, ioErr := ioutil.ReadAll(resp.Body)
  39637. if ioErr != nil {
  39638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39640. return
  39641. }
  39642. var respJSON map[string]interface{}
  39643. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39646. return
  39647. }
  39648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39649. userJSONBytes, _ := json.Marshal(respJSON)
  39650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39651. utils.ErrorLog("解析失败:%v", err)
  39652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39653. return
  39654. }
  39655. }
  39656. if miConfig.MdtrtareaAdmvs == "421182" {
  39657. data := make(map[string]interface{})
  39658. data["bps"] = bp
  39659. data["org_name"] = miConfig.OrgName
  39660. data["doctor"] = role.UserName
  39661. data["fixmedins_code"] = miConfig.Code
  39662. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39663. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39664. data["page"] = page
  39665. data["limit"] = limit
  39666. fmt.Println(data)
  39667. client := &http.Client{}
  39668. bytesData, _ := json.Marshal(data)
  39669. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  39670. resp, _ := client.Do(req)
  39671. defer resp.Body.Close()
  39672. body, ioErr := ioutil.ReadAll(resp.Body)
  39673. if ioErr != nil {
  39674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39676. return
  39677. }
  39678. var respJSON map[string]interface{}
  39679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39682. return
  39683. }
  39684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39685. userJSONBytes, _ := json.Marshal(respJSON)
  39686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39687. utils.ErrorLog("解析失败:%v", err)
  39688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39689. return
  39690. }
  39691. }
  39692. if res.Infcode == 0 {
  39693. c.ServeSuccessJSON(map[string]interface{}{
  39694. "order": res.Output.Result,
  39695. "total": res.Output.PageInfo.RecordCounts,
  39696. })
  39697. } else {
  39698. c.ServeSuccessJSON(map[string]interface{}{
  39699. "failed_code": -10,
  39700. "msg": res.ErrMsg,
  39701. })
  39702. }
  39703. }
  39704. }
  39705. func (c *HisApiController) Post3501() {
  39706. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39707. data := make(map[string]interface{})
  39708. var struct3501s []models.Struct3501
  39709. var struct3501 models.Struct3501
  39710. struct3501.OrgName = miConfig.OrgName
  39711. struct3501.AccessKey = miConfig.AccessKey
  39712. struct3501.RequestUrl = miConfig.Url
  39713. struct3501.SecretKey = miConfig.SecretKey
  39714. struct3501.ManuDate = "2022-08-17"
  39715. struct3501.FixmedinsBchno = ""
  39716. struct3501.ManuLotnum = ""
  39717. struct3501.RxFlag = "0"
  39718. struct3501.ExpyEnd = "2022-08-17"
  39719. struct3501.Invdate = "2022-08-17"
  39720. struct3501.InvCnt = "20.25"
  39721. struct3501.Memo = ""
  39722. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39723. struct3501.FixmedinsHilistId = miConfig.Code
  39724. struct3501.FixmedinsHilistName = miConfig.OrgName
  39725. struct3501s = append(struct3501s, struct3501)
  39726. data["struct_3501s"] = struct3501s
  39727. client := &http.Client{}
  39728. bytesData, _ := json.Marshal(data)
  39729. var req *http.Request
  39730. if miConfig.MdtrtareaAdmvs == "320921" {
  39731. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39732. } else {
  39733. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39734. }
  39735. resp, _ := client.Do(req)
  39736. defer resp.Body.Close()
  39737. body, ioErr := ioutil.ReadAll(resp.Body)
  39738. if ioErr != nil {
  39739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39741. return
  39742. }
  39743. var respJSON map[string]interface{}
  39744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39747. return
  39748. }
  39749. var res ResultSix
  39750. var resSix10265 ResultSix10265 //1101结果
  39751. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39752. result, _ := json.Marshal(respJSON)
  39753. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39754. utils.ErrorLog("解析失败:%v", err)
  39755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39756. return
  39757. }
  39758. res.InfRefmsgid = resSix10265.InfRefmsgid
  39759. res.Output = resSix10265.Output
  39760. res.ErrMsg = resSix10265.ErrMsg
  39761. res.Cainfo = resSix10265.Cainfo
  39762. res.WarnMsg = resSix10265.WarnMsg
  39763. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39764. res.Infcode = infocode
  39765. if infocode == 0 {
  39766. c.ServeSuccessJSON(map[string]interface{}{
  39767. "msg": "上传成功",
  39768. })
  39769. return
  39770. } else {
  39771. c.ServeSuccessJSON(map[string]interface{}{
  39772. "failed_code": -10,
  39773. "msg": res.ErrMsg,
  39774. })
  39775. return
  39776. }
  39777. }
  39778. func (c *HisApiController) Post3502() {
  39779. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39780. data := make(map[string]interface{})
  39781. var struct3502s []models.Struct3502
  39782. var struct3502 models.Struct3502
  39783. struct3502.OrgName = miConfig.OrgName
  39784. struct3502.AccessKey = miConfig.AccessKey
  39785. struct3502.RequestUrl = miConfig.Url
  39786. struct3502.SecretKey = miConfig.SecretKey
  39787. struct3502.ManuDate = "2022-08-15"
  39788. struct3502.FixmedinsBchno = ""
  39789. struct3502.ManuLotnum = ""
  39790. struct3502.RxFlag = "0"
  39791. struct3502.ExpyEnd = "2022-08-15"
  39792. struct3502.Invdate = "2022-08-15"
  39793. struct3502.InvCnt = "20.25"
  39794. struct3502.Memo = ""
  39795. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39796. struct3502.FixmedinsHilistId = miConfig.Code
  39797. struct3502.FixmedinsHilistName = miConfig.OrgName
  39798. struct3502s = append(struct3502s, struct3502)
  39799. data["struct_3502s"] = struct3502s
  39800. client := &http.Client{}
  39801. bytesData, _ := json.Marshal(data)
  39802. var req *http.Request
  39803. if miConfig.MdtrtareaAdmvs == "320921" {
  39804. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39805. } else {
  39806. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39807. }
  39808. resp, _ := client.Do(req)
  39809. defer resp.Body.Close()
  39810. body, ioErr := ioutil.ReadAll(resp.Body)
  39811. if ioErr != nil {
  39812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39814. return
  39815. }
  39816. var respJSON map[string]interface{}
  39817. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39820. return
  39821. }
  39822. var res ResultSix
  39823. var resSix10265 ResultSix10265 //1101结果
  39824. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39825. result, _ := json.Marshal(respJSON)
  39826. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39827. utils.ErrorLog("解析失败:%v", err)
  39828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39829. return
  39830. }
  39831. res.InfRefmsgid = resSix10265.InfRefmsgid
  39832. res.Output = resSix10265.Output
  39833. res.ErrMsg = resSix10265.ErrMsg
  39834. res.Cainfo = resSix10265.Cainfo
  39835. res.WarnMsg = resSix10265.WarnMsg
  39836. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39837. res.Infcode = infocode
  39838. if infocode == 0 {
  39839. c.ServeSuccessJSON(map[string]interface{}{
  39840. "msg": "上传成功",
  39841. })
  39842. return
  39843. } else {
  39844. c.ServeSuccessJSON(map[string]interface{}{
  39845. "failed_code": -10,
  39846. "msg": res.ErrMsg,
  39847. })
  39848. return
  39849. }
  39850. }
  39851. func (c *HisApiController) Post3503() {
  39852. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39853. data := make(map[string]interface{})
  39854. var struct3501s []models.Struct3501
  39855. var struct3501 models.Struct3501
  39856. struct3501.OrgName = miConfig.OrgName
  39857. struct3501.AccessKey = miConfig.AccessKey
  39858. struct3501.RequestUrl = miConfig.Url
  39859. struct3501.SecretKey = miConfig.SecretKey
  39860. struct3501.ManuDate = "2022-08-15"
  39861. struct3501.FixmedinsBchno = ""
  39862. struct3501.ManuLotnum = ""
  39863. struct3501.RxFlag = "0"
  39864. struct3501.ExpyEnd = "2022-08-15"
  39865. struct3501.Invdate = "2022-08-15"
  39866. struct3501.InvCnt = "20.25"
  39867. struct3501.Memo = ""
  39868. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39869. struct3501.FixmedinsHilistId = miConfig.Code
  39870. struct3501.FixmedinsHilistName = miConfig.OrgName
  39871. struct3501s = append(struct3501s, struct3501)
  39872. data["struct_3501s"] = struct3501s
  39873. client := &http.Client{}
  39874. bytesData, _ := json.Marshal(data)
  39875. var req *http.Request
  39876. if miConfig.MdtrtareaAdmvs == "320921" {
  39877. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39878. } else {
  39879. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39880. }
  39881. resp, _ := client.Do(req)
  39882. defer resp.Body.Close()
  39883. body, ioErr := ioutil.ReadAll(resp.Body)
  39884. if ioErr != nil {
  39885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39887. return
  39888. }
  39889. var respJSON map[string]interface{}
  39890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39893. return
  39894. }
  39895. var res ResultSix
  39896. var resSix10265 ResultSix10265 //1101结果
  39897. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39898. result, _ := json.Marshal(respJSON)
  39899. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39900. utils.ErrorLog("解析失败:%v", err)
  39901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39902. return
  39903. }
  39904. res.InfRefmsgid = resSix10265.InfRefmsgid
  39905. res.Output = resSix10265.Output
  39906. res.ErrMsg = resSix10265.ErrMsg
  39907. res.Cainfo = resSix10265.Cainfo
  39908. res.WarnMsg = resSix10265.WarnMsg
  39909. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39910. res.Infcode = infocode
  39911. if infocode == 0 {
  39912. c.ServeSuccessJSON(map[string]interface{}{
  39913. "msg": "上传成功",
  39914. })
  39915. return
  39916. } else {
  39917. c.ServeSuccessJSON(map[string]interface{}{
  39918. "failed_code": -10,
  39919. "msg": res.ErrMsg,
  39920. })
  39921. return
  39922. }
  39923. }
  39924. func (c *HisApiController) Post3504() {
  39925. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39926. data := make(map[string]interface{})
  39927. var struct3501s []models.Struct3501
  39928. var struct3501 models.Struct3501
  39929. struct3501.OrgName = miConfig.OrgName
  39930. struct3501.AccessKey = miConfig.AccessKey
  39931. struct3501.RequestUrl = miConfig.Url
  39932. struct3501.SecretKey = miConfig.SecretKey
  39933. struct3501.ManuDate = "2022-08-15"
  39934. struct3501.FixmedinsBchno = ""
  39935. struct3501.ManuLotnum = ""
  39936. struct3501.RxFlag = "0"
  39937. struct3501.ExpyEnd = "2022-08-15"
  39938. struct3501.Invdate = "2022-08-15"
  39939. struct3501.InvCnt = "20.25"
  39940. struct3501.Memo = ""
  39941. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39942. struct3501.FixmedinsHilistId = miConfig.Code
  39943. struct3501.FixmedinsHilistName = miConfig.OrgName
  39944. struct3501s = append(struct3501s, struct3501)
  39945. data["struct_3501s"] = struct3501s
  39946. client := &http.Client{}
  39947. bytesData, _ := json.Marshal(data)
  39948. var req *http.Request
  39949. if miConfig.MdtrtareaAdmvs == "320921" {
  39950. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39951. } else {
  39952. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39953. }
  39954. resp, _ := client.Do(req)
  39955. defer resp.Body.Close()
  39956. body, ioErr := ioutil.ReadAll(resp.Body)
  39957. if ioErr != nil {
  39958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39960. return
  39961. }
  39962. var respJSON map[string]interface{}
  39963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39966. return
  39967. }
  39968. var res ResultSix
  39969. var resSix10265 ResultSix10265 //1101结果
  39970. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39971. result, _ := json.Marshal(respJSON)
  39972. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39973. utils.ErrorLog("解析失败:%v", err)
  39974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39975. return
  39976. }
  39977. res.InfRefmsgid = resSix10265.InfRefmsgid
  39978. res.Output = resSix10265.Output
  39979. res.ErrMsg = resSix10265.ErrMsg
  39980. res.Cainfo = resSix10265.Cainfo
  39981. res.WarnMsg = resSix10265.WarnMsg
  39982. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39983. res.Infcode = infocode
  39984. if infocode == 0 {
  39985. c.ServeSuccessJSON(map[string]interface{}{
  39986. "msg": "上传成功",
  39987. })
  39988. return
  39989. } else {
  39990. c.ServeSuccessJSON(map[string]interface{}{
  39991. "failed_code": -10,
  39992. "msg": res.ErrMsg,
  39993. })
  39994. return
  39995. }
  39996. }
  39997. func (c *HisApiController) Post3505() {
  39998. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39999. data := make(map[string]interface{})
  40000. var struct3501s []models.Struct3501
  40001. var struct3501 models.Struct3501
  40002. struct3501.OrgName = miConfig.OrgName
  40003. struct3501.AccessKey = miConfig.AccessKey
  40004. struct3501.RequestUrl = miConfig.Url
  40005. struct3501.SecretKey = miConfig.SecretKey
  40006. struct3501.ManuDate = "2022-08-15"
  40007. struct3501.FixmedinsBchno = ""
  40008. struct3501.ManuLotnum = ""
  40009. struct3501.RxFlag = "0"
  40010. struct3501.ExpyEnd = "2022-08-15"
  40011. struct3501.Invdate = "2022-08-15"
  40012. struct3501.InvCnt = "20.25"
  40013. struct3501.Memo = ""
  40014. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40015. struct3501.FixmedinsHilistId = miConfig.Code
  40016. struct3501.FixmedinsHilistName = miConfig.OrgName
  40017. struct3501s = append(struct3501s, struct3501)
  40018. data["struct_3501s"] = struct3501s
  40019. client := &http.Client{}
  40020. bytesData, _ := json.Marshal(data)
  40021. var req *http.Request
  40022. if miConfig.MdtrtareaAdmvs == "320921" {
  40023. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40024. } else {
  40025. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40026. }
  40027. resp, _ := client.Do(req)
  40028. defer resp.Body.Close()
  40029. body, ioErr := ioutil.ReadAll(resp.Body)
  40030. if ioErr != nil {
  40031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40033. return
  40034. }
  40035. var respJSON map[string]interface{}
  40036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40039. return
  40040. }
  40041. var res ResultSix
  40042. var resSix10265 ResultSix10265 //1101结果
  40043. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40044. result, _ := json.Marshal(respJSON)
  40045. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40046. utils.ErrorLog("解析失败:%v", err)
  40047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40048. return
  40049. }
  40050. res.InfRefmsgid = resSix10265.InfRefmsgid
  40051. res.Output = resSix10265.Output
  40052. res.ErrMsg = resSix10265.ErrMsg
  40053. res.Cainfo = resSix10265.Cainfo
  40054. res.WarnMsg = resSix10265.WarnMsg
  40055. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40056. res.Infcode = infocode
  40057. if infocode == 0 {
  40058. c.ServeSuccessJSON(map[string]interface{}{
  40059. "msg": "上传成功",
  40060. })
  40061. return
  40062. } else {
  40063. c.ServeSuccessJSON(map[string]interface{}{
  40064. "failed_code": -10,
  40065. "msg": res.ErrMsg,
  40066. })
  40067. return
  40068. }
  40069. }
  40070. func (c *HisApiController) Post3506() {
  40071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40072. data := make(map[string]interface{})
  40073. var struct3501s []models.Struct3501
  40074. var struct3501 models.Struct3501
  40075. struct3501.OrgName = miConfig.OrgName
  40076. struct3501.AccessKey = miConfig.AccessKey
  40077. struct3501.RequestUrl = miConfig.Url
  40078. struct3501.SecretKey = miConfig.SecretKey
  40079. struct3501.ManuDate = "2022-08-15"
  40080. struct3501.FixmedinsBchno = ""
  40081. struct3501.ManuLotnum = ""
  40082. struct3501.RxFlag = "0"
  40083. struct3501.ExpyEnd = "2022-08-15"
  40084. struct3501.Invdate = "2022-08-15"
  40085. struct3501.InvCnt = "20.25"
  40086. struct3501.Memo = ""
  40087. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40088. struct3501.FixmedinsHilistId = miConfig.Code
  40089. struct3501.FixmedinsHilistName = miConfig.OrgName
  40090. struct3501s = append(struct3501s, struct3501)
  40091. data["struct_3501s"] = struct3501s
  40092. client := &http.Client{}
  40093. bytesData, _ := json.Marshal(data)
  40094. var req *http.Request
  40095. if miConfig.MdtrtareaAdmvs == "320921" {
  40096. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40097. } else {
  40098. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40099. }
  40100. resp, _ := client.Do(req)
  40101. defer resp.Body.Close()
  40102. body, ioErr := ioutil.ReadAll(resp.Body)
  40103. if ioErr != nil {
  40104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40106. return
  40107. }
  40108. var respJSON map[string]interface{}
  40109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40112. return
  40113. }
  40114. var res ResultSix
  40115. var resSix10265 ResultSix10265 //1101结果
  40116. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40117. result, _ := json.Marshal(respJSON)
  40118. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40119. utils.ErrorLog("解析失败:%v", err)
  40120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40121. return
  40122. }
  40123. res.InfRefmsgid = resSix10265.InfRefmsgid
  40124. res.Output = resSix10265.Output
  40125. res.ErrMsg = resSix10265.ErrMsg
  40126. res.Cainfo = resSix10265.Cainfo
  40127. res.WarnMsg = resSix10265.WarnMsg
  40128. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40129. res.Infcode = infocode
  40130. if infocode == 0 {
  40131. c.ServeSuccessJSON(map[string]interface{}{
  40132. "msg": "上传成功",
  40133. })
  40134. return
  40135. } else {
  40136. c.ServeSuccessJSON(map[string]interface{}{
  40137. "failed_code": -10,
  40138. "msg": res.ErrMsg,
  40139. })
  40140. return
  40141. }
  40142. }
  40143. func (c *HisApiController) Post3507() {
  40144. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40145. data := make(map[string]interface{})
  40146. var struct3501s []models.Struct3501
  40147. var struct3501 models.Struct3501
  40148. struct3501.OrgName = miConfig.OrgName
  40149. struct3501.AccessKey = miConfig.AccessKey
  40150. struct3501.RequestUrl = miConfig.Url
  40151. struct3501.SecretKey = miConfig.SecretKey
  40152. struct3501.ManuDate = "2022-08-15"
  40153. struct3501.FixmedinsBchno = ""
  40154. struct3501.ManuLotnum = ""
  40155. struct3501.RxFlag = "0"
  40156. struct3501.ExpyEnd = "2022-08-15"
  40157. struct3501.Invdate = "2022-08-15"
  40158. struct3501.InvCnt = "20.25"
  40159. struct3501.Memo = ""
  40160. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40161. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  40162. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  40163. struct3501s = append(struct3501s, struct3501)
  40164. data["struct_3501s"] = struct3501s
  40165. client := &http.Client{}
  40166. bytesData, _ := json.Marshal(data)
  40167. var req *http.Request
  40168. if miConfig.MdtrtareaAdmvs == "320921" {
  40169. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40170. } else {
  40171. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40172. }
  40173. resp, _ := client.Do(req)
  40174. defer resp.Body.Close()
  40175. body, ioErr := ioutil.ReadAll(resp.Body)
  40176. if ioErr != nil {
  40177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40179. return
  40180. }
  40181. var respJSON map[string]interface{}
  40182. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40185. return
  40186. }
  40187. var res ResultSix
  40188. var resSix10265 ResultSix10265 //1101结果
  40189. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40190. result, _ := json.Marshal(respJSON)
  40191. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40192. utils.ErrorLog("解析失败:%v", err)
  40193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40194. return
  40195. }
  40196. res.InfRefmsgid = resSix10265.InfRefmsgid
  40197. res.Output = resSix10265.Output
  40198. res.ErrMsg = resSix10265.ErrMsg
  40199. res.Cainfo = resSix10265.Cainfo
  40200. res.WarnMsg = resSix10265.WarnMsg
  40201. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40202. res.Infcode = infocode
  40203. if infocode == 0 {
  40204. c.ServeSuccessJSON(map[string]interface{}{
  40205. "msg": "上传成功",
  40206. })
  40207. return
  40208. } else {
  40209. c.ServeSuccessJSON(map[string]interface{}{
  40210. "failed_code": -10,
  40211. "msg": res.ErrMsg,
  40212. })
  40213. return
  40214. }
  40215. }
  40216. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  40217. // WebSocket服务器地址
  40218. serverURL := "ws://127.0.0.1:8899"
  40219. // 解析WebSocket服务器地址
  40220. u, err := url.Parse(serverURL)
  40221. if err != nil {
  40222. }
  40223. // 建立WebSocket连接
  40224. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40225. if err != nil {
  40226. }
  40227. defer conn.Close()
  40228. input2 := make(map[string]interface{})
  40229. input := make(map[string]interface{})
  40230. inputData := make(map[string]interface{})
  40231. inputData["orgId"] = code
  40232. inputData["businessType"] = "01101"
  40233. inputData["operatorId"] = operator_id
  40234. inputData["operatorName"] = operator_name
  40235. inputData["officeId"] = "001"
  40236. inputData["officeName"] = "血透室"
  40237. inputData["deviceType"] = ""
  40238. input["data"] = inputData
  40239. input["orgId"] = code
  40240. input["transType"] = "ec.query"
  40241. //if md == ""
  40242. if md[:4] == "4403" {
  40243. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40244. } else if md[:4] == "4401" {
  40245. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40246. } else {
  40247. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40248. }
  40249. input2["indata"] = input
  40250. fmt.Println(input2)
  40251. bytesData, _ := json.Marshal(input2)
  40252. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40253. if err != nil {
  40254. fmt.Println(err)
  40255. }
  40256. // 接收消息
  40257. _, receivedMessage, err := conn.ReadMessage()
  40258. if err != nil {
  40259. fmt.Println(err)
  40260. }
  40261. return "", string(receivedMessage)
  40262. }
  40263. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  40264. // WebSocket服务器地址
  40265. serverURL := "ws://127.0.0.1:8899"
  40266. // 解析WebSocket服务器地址
  40267. u, err := url.Parse(serverURL)
  40268. if err != nil {
  40269. }
  40270. // 建立WebSocket连接
  40271. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40272. if err != nil {
  40273. }
  40274. defer conn.Close()
  40275. input2 := make(map[string]interface{})
  40276. input := make(map[string]interface{})
  40277. inputData := make(map[string]interface{})
  40278. inputData["orgId"] = code
  40279. inputData["businessType"] = "01101"
  40280. inputData["operatorId"] = operator_id
  40281. inputData["operatorName"] = operator_name
  40282. inputData["officeId"] = "001"
  40283. inputData["officeName"] = "血透室"
  40284. inputData["deviceType"] = ""
  40285. input["data"] = inputData
  40286. input["orgId"] = code
  40287. input["transType"] = "ec.query"
  40288. //if md == ""
  40289. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40290. input2["indata"] = input
  40291. fmt.Println(input2)
  40292. bytesData, _ := json.Marshal(input2)
  40293. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40294. if err != nil {
  40295. fmt.Println(err)
  40296. }
  40297. // 接收消息
  40298. _, receivedMessage, err := conn.ReadMessage()
  40299. if err != nil {
  40300. fmt.Println(err)
  40301. }
  40302. return "", string(receivedMessage)
  40303. }
  40304. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  40305. // WebSocket服务器地址
  40306. serverURL := "ws://127.0.0.1:8899"
  40307. // 解析WebSocket服务器地址
  40308. u, err := url.Parse(serverURL)
  40309. if err != nil {
  40310. }
  40311. // 建立WebSocket连接
  40312. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40313. if err != nil {
  40314. }
  40315. defer conn.Close()
  40316. input2 := make(map[string]interface{})
  40317. input := make(map[string]interface{})
  40318. inputData := make(map[string]interface{})
  40319. inputData["orgId"] = code
  40320. inputData["businessType"] = "01301"
  40321. inputData["operatorId"] = operator_id
  40322. inputData["operatorName"] = operator_name
  40323. inputData["officeId"] = "001"
  40324. inputData["officeName"] = "血透室"
  40325. inputData["deviceType"] = ""
  40326. input["data"] = inputData
  40327. input["orgId"] = code
  40328. input["transType"] = "ec.query"
  40329. //if md == ""
  40330. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40331. input2["indata"] = input
  40332. fmt.Println(input2)
  40333. bytesData, _ := json.Marshal(input2)
  40334. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40335. if err != nil {
  40336. fmt.Println(err)
  40337. }
  40338. // 接收消息
  40339. _, receivedMessage, err := conn.ReadMessage()
  40340. if err != nil {
  40341. fmt.Println(err)
  40342. }
  40343. return "", string(receivedMessage)
  40344. }
  40345. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  40346. // WebSocket服务器地址
  40347. serverURL := "ws://127.0.0.1:8899"
  40348. // 解析WebSocket服务器地址
  40349. u, err := url.Parse(serverURL)
  40350. if err != nil {
  40351. }
  40352. // 建立WebSocket连接
  40353. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40354. if err != nil {
  40355. }
  40356. defer conn.Close()
  40357. input2 := make(map[string]interface{})
  40358. input := make(map[string]interface{})
  40359. inputData := make(map[string]interface{})
  40360. inputData["orgId"] = code
  40361. inputData["businessType"] = "01103"
  40362. inputData["operatorId"] = operator_id
  40363. inputData["operatorName"] = operator_name
  40364. inputData["officeId"] = "001"
  40365. inputData["officeName"] = "血透室"
  40366. inputData["deviceType"] = ""
  40367. input["data"] = inputData
  40368. input["orgId"] = code
  40369. input["transType"] = "ec.query"
  40370. //if md ==
  40371. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  40372. input2["indata"] = input
  40373. fmt.Println(input2)
  40374. bytesData, _ := json.Marshal(input2)
  40375. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40376. if err != nil {
  40377. fmt.Println(err)
  40378. }
  40379. // 接收消息
  40380. _, receivedMessage, err := conn.ReadMessage()
  40381. if err != nil {
  40382. fmt.Println(err)
  40383. }
  40384. return "", string(receivedMessage)
  40385. }
  40386. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  40387. // WebSocket服务器地址
  40388. serverURL := "ws://127.0.0.1:8899"
  40389. // 解析WebSocket服务器地址
  40390. u, err := url.Parse(serverURL)
  40391. if err != nil {
  40392. }
  40393. // 建立WebSocket连接
  40394. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40395. if err != nil {
  40396. }
  40397. defer conn.Close()
  40398. input2 := make(map[string]interface{})
  40399. input := make(map[string]interface{})
  40400. inputData := make(map[string]interface{})
  40401. inputData["orgId"] = code
  40402. inputData["businessType"] = "01101"
  40403. inputData["operatorId"] = operator_id
  40404. inputData["operatorName"] = operator_name
  40405. inputData["officeId"] = "001"
  40406. inputData["officeName"] = "血透室"
  40407. inputData["deviceType"] = ""
  40408. input["data"] = inputData
  40409. input["orgId"] = code
  40410. input["transType"] = "ec.query"
  40411. //if md == ""
  40412. if md[:4] == "4403" {
  40413. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40414. } else if md[:4] == "4401" {
  40415. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40416. } else {
  40417. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40418. }
  40419. input2["indata"] = input
  40420. fmt.Println(input2)
  40421. bytesData, _ := json.Marshal(input2)
  40422. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40423. if err != nil {
  40424. fmt.Println(err)
  40425. }
  40426. // 接收消息
  40427. _, receivedMessage, err := conn.ReadMessage()
  40428. if err != nil {
  40429. fmt.Println(err)
  40430. }
  40431. return "", string(receivedMessage)
  40432. }
  40433. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  40434. // WebSocket服务器地址
  40435. serverURL := "ws://127.0.0.1:8899"
  40436. // 解析WebSocket服务器地址
  40437. u, err := url.Parse(serverURL)
  40438. if err != nil {
  40439. }
  40440. // 建立WebSocket连接
  40441. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40442. if err != nil {
  40443. }
  40444. defer conn.Close()
  40445. input2 := make(map[string]interface{})
  40446. input := make(map[string]interface{})
  40447. inputData := make(map[string]interface{})
  40448. inputData["orgId"] = code
  40449. inputData["businessType"] = "01301"
  40450. inputData["operatorId"] = operator_id
  40451. inputData["operatorName"] = operator_name
  40452. inputData["officeId"] = "001"
  40453. inputData["officeName"] = "血透室"
  40454. inputData["deviceType"] = ""
  40455. input["data"] = inputData
  40456. input["orgId"] = code
  40457. input["transType"] = "ec.query"
  40458. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40459. input2["indata"] = input
  40460. bytesData, _ := json.Marshal(input2)
  40461. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40462. if err != nil {
  40463. fmt.Println(err)
  40464. }
  40465. // 接收消息
  40466. _, receivedMessage, err := conn.ReadMessage()
  40467. if err != nil {
  40468. fmt.Println(err)
  40469. }
  40470. return "", string(receivedMessage)
  40471. }
  40472. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  40473. newArr = make([]string, 0)
  40474. for i := 0; i < len(arr); i++ {
  40475. repeat := false
  40476. for j := i + 1; j < len(arr); j++ {
  40477. if arr[i] == arr[j] {
  40478. repeat = true
  40479. break
  40480. }
  40481. }
  40482. if !repeat {
  40483. newArr = append(newArr, arr[i])
  40484. }
  40485. }
  40486. return
  40487. }
  40488. func getBirthdateAndAge(idNumber string) (string, int, error) {
  40489. if len(idNumber) != 18 {
  40490. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  40491. }
  40492. // 提取出生日期
  40493. year, err := strconv.Atoi(idNumber[6:10])
  40494. if err != nil {
  40495. return "", 0, err
  40496. }
  40497. month, err := strconv.Atoi(idNumber[10:12])
  40498. if err != nil {
  40499. return "", 0, err
  40500. }
  40501. day, err := strconv.Atoi(idNumber[12:14])
  40502. if err != nil {
  40503. return "", 0, err
  40504. }
  40505. // 格式化生日字符串
  40506. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  40507. birthdateFormatted := birthdate.Format("2006-01-02")
  40508. // 计算年龄
  40509. today := time.Now()
  40510. age := today.Year() - birthdate.Year()
  40511. if today.YearDay() < birthdate.YearDay() {
  40512. age--
  40513. }
  40514. return birthdateFormatted, age, nil
  40515. }
  40516. // 从身份证号码中提取出生年月日
  40517. func getBirthDateFromIDCard(idCard string) (string, error) {
  40518. // 身份证号码长度应为18位
  40519. if len(idCard) != 18 {
  40520. return "", fmt.Errorf("身份证号码长度应为18位")
  40521. }
  40522. // 提取出生日期部分 (YYYYMMDD)
  40523. birthDateStr := idCard[6:14]
  40524. // 解析出生日期
  40525. birthDate, err := time.Parse("20060102", birthDateStr)
  40526. if err != nil {
  40527. return "", fmt.Errorf("解析出生日期失败: %v", err)
  40528. }
  40529. // 格式化出生日期为 YYYY-MM-DD
  40530. formattedDate := birthDate.Format("2006-01-02")
  40531. return formattedDate, nil
  40532. }