his_api_controller.go 1.7MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  117. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  172. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  173. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  174. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  175. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  176. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  177. }
  178. func (c *HisApiController) Get5101() {
  179. adminUser := c.GetAdminUserInfo()
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. if miConfig.MdtrtareaAdmvs == "341203" {
  184. fmt.Println(miConfig.SecretKey)
  185. var res models.Result9001Two
  186. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  188. resp, requestErr := http.Get(api)
  189. if requestErr != nil {
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. body, ioErr := ioutil.ReadAll(resp.Body)
  194. if ioErr != nil {
  195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. status := respJSON["data"].(map[string]interface{})["status"].(string)
  206. if status == "0" {
  207. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": err_msg,
  211. })
  212. return
  213. }
  214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  215. result, _ := json.Marshal(respJSON)
  216. fmt.Println("log")
  217. fmt.Println(string(result))
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. sign := models.HisSignIn{
  225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  226. SignNo: res.Output.Signinoutb.SignNo,
  227. SignTime: "",
  228. Ctime: time.Now().Unix(),
  229. Mtime: time.Now().Unix(),
  230. Status: 1,
  231. InputLog: "",
  232. OutputLog: "",
  233. FixmedinsCode: miConfig.Code,
  234. }
  235. err := service.CreateSignIn(&sign)
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "签到成功",
  239. })
  240. }
  241. } else {
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "failed_code": -10,
  244. "msg": res.ErrMsg,
  245. })
  246. return
  247. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  248. //return
  249. }
  250. } else if miConfig.MdtrtareaAdmvs == "340699" {
  251. fmt.Println(miConfig.SecretKey)
  252. var res models.Result9001Two
  253. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  255. resp, requestErr := http.Get(api)
  256. if requestErr != nil {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. body, ioErr := ioutil.ReadAll(resp.Body)
  261. if ioErr != nil {
  262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. var respJSON map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  273. if status == "0" {
  274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  275. c.ServeSuccessJSON(map[string]interface{}{
  276. "failed_code": -10,
  277. "msg": err_msg,
  278. })
  279. return
  280. }
  281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  282. result, _ := json.Marshal(respJSON)
  283. fmt.Println("log")
  284. fmt.Println(string(result))
  285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  286. utils.ErrorLog("解析失败:%v", err)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. if res.Infcode == 0 {
  291. sign := models.HisSignIn{
  292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  293. SignNo: res.Output.Signinoutb.SignNo,
  294. SignTime: "",
  295. Ctime: time.Now().Unix(),
  296. Mtime: time.Now().Unix(),
  297. Status: 1,
  298. InputLog: "",
  299. OutputLog: "",
  300. FixmedinsCode: miConfig.Code,
  301. }
  302. err := service.CreateSignIn(&sign)
  303. if err == nil {
  304. c.ServeSuccessJSON(map[string]interface{}{
  305. "msg": "查询成功",
  306. })
  307. }
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "failed_code": -10,
  311. "msg": res.ErrMsg,
  312. })
  313. return
  314. }
  315. }
  316. }
  317. func (c *HisApiController) Get5102() {
  318. adminUser := c.GetAdminUserInfo()
  319. admin_user_id, _ := c.GetInt64("admin_user_id")
  320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  322. if miConfig.MdtrtareaAdmvs == "341203" {
  323. fmt.Println(miConfig.SecretKey)
  324. var res models.Result9001Two
  325. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  327. resp, requestErr := http.Get(api)
  328. if requestErr != nil {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. body, ioErr := ioutil.ReadAll(resp.Body)
  333. if ioErr != nil {
  334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. }
  338. var respJSON map[string]interface{}
  339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  342. return
  343. }
  344. status := respJSON["data"].(map[string]interface{})["status"].(string)
  345. if status == "0" {
  346. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": err_msg,
  350. })
  351. return
  352. }
  353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  354. result, _ := json.Marshal(respJSON)
  355. fmt.Println("log")
  356. fmt.Println(string(result))
  357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  358. utils.ErrorLog("解析失败:%v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. if res.Infcode == 0 {
  363. sign := models.HisSignIn{
  364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  365. SignNo: res.Output.Signinoutb.SignNo,
  366. SignTime: "",
  367. Ctime: time.Now().Unix(),
  368. Mtime: time.Now().Unix(),
  369. Status: 1,
  370. InputLog: "",
  371. OutputLog: "",
  372. FixmedinsCode: miConfig.Code,
  373. }
  374. err := service.CreateSignIn(&sign)
  375. if err == nil {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "msg": "签到成功",
  378. })
  379. }
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. return
  386. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  387. //return
  388. }
  389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  390. fmt.Println(miConfig.SecretKey)
  391. var res models.Result9001Two
  392. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  394. resp, requestErr := http.Get(api)
  395. if requestErr != nil {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. body, ioErr := ioutil.ReadAll(resp.Body)
  400. if ioErr != nil {
  401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  412. if status == "0" {
  413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "failed_code": -10,
  416. "msg": err_msg,
  417. })
  418. return
  419. }
  420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  421. result, _ := json.Marshal(respJSON)
  422. fmt.Println("log")
  423. fmt.Println(string(result))
  424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == 0 {
  430. sign := models.HisSignIn{
  431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  432. SignNo: res.Output.Signinoutb.SignNo,
  433. SignTime: "",
  434. Ctime: time.Now().Unix(),
  435. Mtime: time.Now().Unix(),
  436. Status: 1,
  437. InputLog: "",
  438. OutputLog: "",
  439. FixmedinsCode: miConfig.Code,
  440. }
  441. err := service.CreateSignIn(&sign)
  442. if err == nil {
  443. c.ServeSuccessJSON(map[string]interface{}{
  444. "msg": "查询成功",
  445. })
  446. }
  447. } else {
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "failed_code": -10,
  450. "msg": res.ErrMsg,
  451. })
  452. return
  453. }
  454. }
  455. }
  456. func (c *HisApiController) Get3201() {
  457. adminUser := c.GetAdminUserInfo()
  458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  459. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  460. var response Response
  461. if err := json.Unmarshal([]byte(result), &response); err != nil {
  462. fmt.Println("Error decoding JSON:", err)
  463. return
  464. }
  465. }
  466. func (c *HisApiController) TestNet() {
  467. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. //return
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "成功",
  471. })
  472. }
  473. func (c *HisApiController) Get3508() {
  474. admin_user_id, _ := c.GetInt64("admin_user_id")
  475. drug_id, _ := c.GetInt64("id")
  476. start_time := c.GetString("start_time")
  477. end_time := c.GetString("end_time")
  478. adminUser := c.GetAdminUserInfo()
  479. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  481. drug, _ := service.GetDrugByID(drug_id)
  482. var struct3508 models.Struct3508
  483. struct3508.OrgName = miConfig.OrgName
  484. struct3508.FixmedinsCode = miConfig.Code
  485. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  486. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  487. struct3508.AccessKey = miConfig.AccessKey
  488. struct3508.Opter = curRoles.UserName
  489. struct3508.RequestUrl = miConfig.Url
  490. struct3508.Url = miConfig.Url
  491. struct3508.AppId = miConfig.Cainfo
  492. struct3508.AppSecret = miConfig.AppSecret
  493. struct3508.Enckey = miConfig.EncKey
  494. struct3508.SignKey = miConfig.SignKey
  495. struct3508.SecretKey = miConfig.SecretKey
  496. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  497. struct3508.Begndate = start_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. struct3508.Enddate = end_time
  501. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  502. result1, result2 := service.Gdyb3508(struct3508,struct3508.SecretKey)
  503. saveLog(result1, result2, "3508", "3508")
  504. var res models.Result3508
  505. var respJSON2 map[string]interface{}
  506. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  509. return
  510. }
  511. userJSONBytes2, _ := json.Marshal(respJSON2)
  512. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  513. utils.ErrorLog("解析失败:%v", err)
  514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  515. return
  516. }
  517. if res.Infcode == -1 {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "failed_code": -10,
  520. "msg": res.ErrMsg,
  521. })
  522. } else {
  523. c.ServeSuccessJSON(map[string]interface{}{
  524. "info": res.Output,
  525. })
  526. }
  527. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //广东
  528. result1, result2, _ := service.FJyb3508(struct3508)
  529. saveLog(result1, result2, "3508", "3508")
  530. var res models.Result3508
  531. var respJSON2 map[string]interface{}
  532. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  535. return
  536. }
  537. userJSONBytes2, _ := json.Marshal(respJSON2)
  538. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  539. utils.ErrorLog("解析失败:%v", err)
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  541. return
  542. }
  543. if res.Infcode == -1 {
  544. c.ServeSuccessJSON(map[string]interface{}{
  545. "failed_code": -10,
  546. "msg": res.ErrMsg,
  547. })
  548. } else {
  549. c.ServeSuccessJSON(map[string]interface{}{
  550. "info": res.Output,
  551. })
  552. }
  553. }
  554. }
  555. func (c *HisApiController) Get3509() {
  556. admin_user_id, _ := c.GetInt64("admin_user_id")
  557. drug_id, _ := c.GetInt64("id")
  558. start_time := c.GetString("start_time")
  559. end_time := c.GetString("end_time")
  560. adminUser := c.GetAdminUserInfo()
  561. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  563. drug, _ := service.GetDrugByID(drug_id)
  564. var struct3508 models.Struct3509
  565. struct3508.OrgName = miConfig.OrgName
  566. struct3508.FixmedinsCode = miConfig.Code
  567. struct3508.AccessKey = miConfig.AccessKey
  568. struct3508.Opter = curRoles.UserName
  569. struct3508.RequestUrl = miConfig.Url
  570. struct3508.Url = miConfig.Url
  571. struct3508.AppId = miConfig.Cainfo
  572. struct3508.AppSecret = miConfig.AppSecret
  573. struct3508.Enckey = miConfig.EncKey
  574. struct3508.SignKey = miConfig.SignKey
  575. struct3508.SecretKey = miConfig.SecretKey
  576. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  577. struct3508.Begndate = start_time
  578. struct3508.Enddate = end_time
  579. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  580. result1, result2 := service.Gdyb3509(struct3508,struct3508.SecretKey)
  581. saveLog(result1, result2, "3509", "3509")
  582. var res models.Result3508
  583. var respJSON2 map[string]interface{}
  584. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  587. return
  588. }
  589. userJSONBytes2, _ := json.Marshal(respJSON2)
  590. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  591. utils.ErrorLog("解析失败:%v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. if res.Infcode == -1 {
  596. c.ServeSuccessJSON(map[string]interface{}{
  597. "failed_code": -10,
  598. "msg": res.ErrMsg,
  599. })
  600. } else {
  601. c.ServeSuccessJSON(map[string]interface{}{
  602. "info": res.Output,
  603. })
  604. }
  605. }
  606. result1, result2, _ := service.FJyb3509(struct3508)
  607. saveLog(result1, result2, "3509", "3509")
  608. var res models.Result3509
  609. var respJSON2 map[string]interface{}
  610. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. userJSONBytes2, _ := json.Marshal(respJSON2)
  616. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  617. utils.ErrorLog("解析失败:%v", err)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. if res.Infcode == -1 {
  622. c.ServeSuccessJSON(map[string]interface{}{
  623. "failed_code": -10,
  624. "msg": res.ErrMsg,
  625. })
  626. } else {
  627. c.ServeSuccessJSON(map[string]interface{}{
  628. "info": res.Output,
  629. })
  630. }
  631. }
  632. func (c *HisApiController) Get3510() {
  633. admin_user_id, _ := c.GetInt64("admin_user_id")
  634. drug_id, _ := c.GetInt64("id")
  635. start_time := c.GetString("start_time")
  636. end_time := c.GetString("end_time")
  637. adminUser := c.GetAdminUserInfo()
  638. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  640. drug, _ := service.GetDrugByID(drug_id)
  641. var struct3508 models.Struct3510
  642. struct3508.FixmedinsCode = miConfig.Code
  643. struct3508.OrgName = miConfig.OrgName
  644. struct3508.AccessKey = miConfig.AccessKey
  645. struct3508.Opter = curRoles.UserName
  646. struct3508.RequestUrl = miConfig.Url
  647. struct3508.Url = miConfig.Url
  648. struct3508.AppId = miConfig.Cainfo
  649. struct3508.AppSecret = miConfig.AppSecret
  650. struct3508.Enckey = miConfig.EncKey
  651. struct3508.SignKey = miConfig.SignKey
  652. struct3508.SecretKey = miConfig.SecretKey
  653. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  654. struct3508.Begndate = start_time
  655. struct3508.Enddate = end_time
  656. result1, result2, _ := service.FJyb3510(struct3508)
  657. saveLog(result1, result2, "3510", "3510")
  658. var res models.Result3510
  659. var respJSON2 map[string]interface{}
  660. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  663. return
  664. }
  665. userJSONBytes2, _ := json.Marshal(respJSON2)
  666. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  667. utils.ErrorLog("解析失败:%v", err)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return
  670. }
  671. if res.Infcode == -1 {
  672. c.ServeSuccessJSON(map[string]interface{}{
  673. "failed_code": -10,
  674. "msg": res.ErrMsg,
  675. })
  676. } else {
  677. c.ServeSuccessJSON(map[string]interface{}{
  678. "info": res.Output,
  679. })
  680. }
  681. }
  682. func (c *HisApiController) Get3511() {
  683. admin_user_id, _ := c.GetInt64("admin_user_id")
  684. drug_id, _ := c.GetInt64("id")
  685. start_time := c.GetString("start_time")
  686. end_time := c.GetString("end_time")
  687. adminUser := c.GetAdminUserInfo()
  688. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  690. drug, _ := service.GetDrugByID(drug_id)
  691. var struct3508 models.Struct3511
  692. struct3508.FixmedinsCode = miConfig.Code
  693. struct3508.OrgName = miConfig.OrgName
  694. struct3508.AccessKey = miConfig.AccessKey
  695. struct3508.Opter = curRoles.UserName
  696. struct3508.RequestUrl = miConfig.Url
  697. struct3508.Url = miConfig.Url
  698. struct3508.AppId = miConfig.Cainfo
  699. struct3508.AppSecret = miConfig.AppSecret
  700. struct3508.Enckey = miConfig.EncKey
  701. struct3508.SignKey = miConfig.SignKey
  702. struct3508.SecretKey = miConfig.SecretKey
  703. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  704. struct3508.Begndate = start_time
  705. struct3508.Enddate = end_time
  706. result1, result2, _ := service.FJyb3511(struct3508)
  707. saveLog(result1, result2, "3511", "3511")
  708. var res models.Result3511
  709. var respJSON2 map[string]interface{}
  710. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. userJSONBytes2, _ := json.Marshal(respJSON2)
  716. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  717. utils.ErrorLog("解析失败:%v", err)
  718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  719. return
  720. }
  721. if res.Infcode == -1 {
  722. c.ServeSuccessJSON(map[string]interface{}{
  723. "failed_code": -10,
  724. "msg": res.ErrMsg,
  725. })
  726. } else {
  727. c.ServeSuccessJSON(map[string]interface{}{
  728. "info": res.Output,
  729. })
  730. }
  731. }
  732. func (c *HisApiController) Get3512() {
  733. admin_user_id, _ := c.GetInt64("admin_user_id")
  734. drug_id, _ := c.GetInt64("id")
  735. start_time := c.GetString("start_time")
  736. end_time := c.GetString("end_time")
  737. adminUser := c.GetAdminUserInfo()
  738. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  740. drug, _ := service.GetDrugByID(drug_id)
  741. var struct3508 models.Struct3512
  742. struct3508.FixmedinsCode = miConfig.Code
  743. struct3508.OrgName = miConfig.OrgName
  744. struct3508.AccessKey = miConfig.AccessKey
  745. struct3508.Opter = curRoles.UserName
  746. struct3508.RequestUrl = miConfig.Url
  747. struct3508.Url = miConfig.Url
  748. struct3508.AppId = miConfig.Cainfo
  749. struct3508.AppSecret = miConfig.AppSecret
  750. struct3508.Enckey = miConfig.EncKey
  751. struct3508.SignKey = miConfig.SignKey
  752. struct3508.SecretKey = miConfig.SecretKey
  753. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  754. struct3508.Begndate = start_time
  755. struct3508.Enddate = end_time
  756. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  757. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  758. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  759. result1, result2 := service.Gdyb3512(struct3508,struct3508.SecretKey)
  760. saveLog(result1, result2, "3512", "3512")
  761. var res models.Result3512
  762. var respJSON2 map[string]interface{}
  763. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. userJSONBytes2, _ := json.Marshal(respJSON2)
  769. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. if res.Infcode == -1 {
  775. c.ServeSuccessJSON(map[string]interface{}{
  776. "failed_code": -10,
  777. "msg": res.ErrMsg,
  778. })
  779. } else {
  780. c.ServeSuccessJSON(map[string]interface{}{
  781. "info": res.Output,
  782. })
  783. }
  784. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350"){
  785. result1, result2, _ := service.FJyb3512(struct3508)
  786. saveLog(result1, result2, "3512", "3512")
  787. var res models.Result3512
  788. var respJSON2 map[string]interface{}
  789. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. userJSONBytes2, _ := json.Marshal(respJSON2)
  795. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  796. utils.ErrorLog("解析失败:%v", err)
  797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  798. return
  799. }
  800. if res.Infcode == -1 {
  801. c.ServeSuccessJSON(map[string]interface{}{
  802. "failed_code": -10,
  803. "msg": res.ErrMsg,
  804. })
  805. } else {
  806. c.ServeSuccessJSON(map[string]interface{}{
  807. "info": res.Output,
  808. })
  809. }
  810. }
  811. }
  812. func (c *HisApiController) Get3513() {
  813. admin_user_id, _ := c.GetInt64("admin_user_id")
  814. drug_id, _ := c.GetInt64("id")
  815. start_time := c.GetString("start_time")
  816. end_time := c.GetString("end_time")
  817. adminUser := c.GetAdminUserInfo()
  818. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  819. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  820. drug, _ := service.GetDrugByID(drug_id)
  821. var struct3508 models.Struct3513
  822. struct3508.FixmedinsCode = miConfig.Code
  823. struct3508.OrgName = miConfig.OrgName
  824. struct3508.AccessKey = miConfig.AccessKey
  825. struct3508.Opter = curRoles.UserName
  826. struct3508.RequestUrl = miConfig.Url
  827. struct3508.Url = miConfig.Url
  828. struct3508.AppId = miConfig.Cainfo
  829. struct3508.AppSecret = miConfig.AppSecret
  830. struct3508.Enckey = miConfig.EncKey
  831. struct3508.SignKey = miConfig.SignKey
  832. struct3508.SecretKey = miConfig.SecretKey
  833. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  834. struct3508.Begndate = start_time
  835. struct3508.Enddate = end_time
  836. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  837. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  838. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  839. result1, result2 := service.Gdyb3513(struct3508,struct3508.SecretKey)
  840. saveLog(result1, result2, "3513", "3513")
  841. var res models.Result3513
  842. var respJSON2 map[string]interface{}
  843. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  846. return
  847. }
  848. userJSONBytes2, _ := json.Marshal(respJSON2)
  849. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  850. utils.ErrorLog("解析失败:%v", err)
  851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  852. return
  853. }
  854. if res.Infcode == -1 {
  855. c.ServeSuccessJSON(map[string]interface{}{
  856. "failed_code": -10,
  857. "msg": res.ErrMsg,
  858. })
  859. } else {
  860. c.ServeSuccessJSON(map[string]interface{}{
  861. "info": res.Output,
  862. })
  863. }
  864. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350"){
  865. result1, result2, _ := service.FJyb3513(struct3508)
  866. saveLog(result1, result2, "3513", "3513")
  867. var res models.Result3513
  868. var respJSON2 map[string]interface{}
  869. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  872. return
  873. }
  874. userJSONBytes2, _ := json.Marshal(respJSON2)
  875. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  876. utils.ErrorLog("解析失败:%v", err)
  877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  878. return
  879. }
  880. if res.Infcode == -1 {
  881. c.ServeSuccessJSON(map[string]interface{}{
  882. "failed_code": -10,
  883. "msg": res.ErrMsg,
  884. })
  885. } else {
  886. c.ServeSuccessJSON(map[string]interface{}{
  887. "info": res.Output,
  888. })
  889. }
  890. }
  891. }
  892. func (c *HisApiController) Get35081() {
  893. admin_user_id, _ := c.GetInt64("admin_user_id")
  894. drug_id, _ := c.GetInt64("id")
  895. //start_time := c.GetString("start_time")
  896. //end_time := c.GetString("end_time")
  897. page, _ := c.GetInt("page")
  898. adminUser := c.GetAdminUserInfo()
  899. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  900. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  901. drug, _ := service.GetDrugByID(drug_id)
  902. var struct3508 models.Struct35081
  903. struct3508.FixmedinsCode = miConfig.Code
  904. struct3508.OrgName = miConfig.OrgName
  905. struct3508.AccessKey = miConfig.AccessKey
  906. struct3508.Opter = curRoles.UserName
  907. struct3508.RequestUrl = miConfig.Url
  908. struct3508.Url = miConfig.Url
  909. struct3508.AppId = miConfig.Cainfo
  910. struct3508.AppSecret = miConfig.AppSecret
  911. struct3508.Enckey = miConfig.EncKey
  912. struct3508.SignKey = miConfig.SignKey
  913. struct3508.SecretKey = miConfig.SecretKey
  914. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  915. struct3508.PageNum = page
  916. struct3508.PageSize = 10
  917. result1, result2, _ := service.FJyb35081(struct3508)
  918. saveLog(result1, result2, "35081", "35081")
  919. var res models.Result35081
  920. var respJSON2 map[string]interface{}
  921. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  924. return
  925. }
  926. userJSONBytes2, _ := json.Marshal(respJSON2)
  927. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  928. utils.ErrorLog("解析失败:%v", err)
  929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  930. return
  931. }
  932. if res.Infcode == -1 {
  933. c.ServeSuccessJSON(map[string]interface{}{
  934. "failed_code": -10,
  935. "msg": res.ErrMsg,
  936. })
  937. } else {
  938. c.ServeSuccessJSON(map[string]interface{}{
  939. "info": res.Output,
  940. })
  941. }
  942. }
  943. func (c *HisApiController) Get35082() {
  944. admin_user_id, _ := c.GetInt64("admin_user_id")
  945. drug_id, _ := c.GetInt64("id")
  946. //start_time := c.GetString("start_time")
  947. //end_time := c.GetString("end_time")
  948. page, _ := c.GetInt("page")
  949. adminUser := c.GetAdminUserInfo()
  950. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  951. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  952. drug, _ := service.GetDrugByID(drug_id)
  953. var struct3508 models.Struct35082
  954. struct3508.FixmedinsCode = miConfig.Code
  955. struct3508.OrgName = miConfig.OrgName
  956. struct3508.AccessKey = miConfig.AccessKey
  957. struct3508.Opter = curRoles.UserName
  958. struct3508.RequestUrl = miConfig.Url
  959. struct3508.Url = miConfig.Url
  960. struct3508.AppId = miConfig.Cainfo
  961. struct3508.AppSecret = miConfig.AppSecret
  962. struct3508.Enckey = miConfig.EncKey
  963. struct3508.SignKey = miConfig.SignKey
  964. struct3508.SecretKey = miConfig.SecretKey
  965. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  966. struct3508.PageNum = page
  967. struct3508.PageSize = 10
  968. result1, result2, _ := service.FJyb35082(struct3508)
  969. saveLog(result1, result2, "35082", "35082")
  970. var res models.Result35082
  971. var respJSON2 map[string]interface{}
  972. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  975. return
  976. }
  977. userJSONBytes2, _ := json.Marshal(respJSON2)
  978. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  979. utils.ErrorLog("解析失败:%v", err)
  980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  981. return
  982. }
  983. if res.Infcode == -1 {
  984. c.ServeSuccessJSON(map[string]interface{}{
  985. "failed_code": -10,
  986. "msg": res.ErrMsg,
  987. })
  988. } else {
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "info": res.Output,
  991. })
  992. }
  993. }
  994. func IsDigit(s string) bool {
  995. re := regexp.MustCompile("^[0-9]+$")
  996. return re.MatchString(s)
  997. }
  998. func (c *HisApiController) FJ3501AND3502() {
  999. ids := c.GetString("ids")
  1000. admin_user_id, _ := c.GetInt64("admin_user_id")
  1001. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1002. id_arr := strings.Split(ids, ",")
  1003. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1004. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1005. //规则判断
  1006. var errs []string
  1007. for _, drug := range drugs {
  1008. if drug.IsPc == 0 {
  1009. if len(drug.DrugCode) > 0{
  1010. codes := strings.Split(drug.DrugCode, ",")
  1011. for _, code := range codes{
  1012. if len(code) > 0 {
  1013. if len(code) != 20 {
  1014. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1015. }
  1016. if IsDigit(code) == false {
  1017. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1018. }
  1019. }
  1020. }
  1021. }
  1022. }
  1023. }
  1024. if len(errs) > 0 {
  1025. c.ServeSuccessJSON(map[string]interface{}{
  1026. "failed_code": -10,
  1027. "msg": errs,
  1028. })
  1029. return
  1030. }
  1031. //库盘
  1032. for _, drug := range drugs {
  1033. if drug.IsPc == 0 {
  1034. var res2 ResultSix
  1035. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1036. var struct3501 models.Struct3501
  1037. struct3501.Code = miConfig.Code
  1038. struct3501.OrgName = miConfig.OrgName
  1039. struct3501.AccessKey = miConfig.AccessKey
  1040. struct3501.Opter = roles.UserName
  1041. struct3501.RequestUrl = miConfig.Url
  1042. struct3501.Url = miConfig.Url
  1043. struct3501.AppId = miConfig.Cainfo
  1044. struct3501.AppSecret = miConfig.AppSecret
  1045. struct3501.Enckey = miConfig.EncKey
  1046. struct3501.SignKey = miConfig.SignKey
  1047. struct3501.SecretKey = miConfig.SecretKey
  1048. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1049. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1050. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1051. struct3501.RxFlag = "1"
  1052. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1053. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1054. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1055. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1056. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1057. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1058. struct3501.FixmedinsBchno = number
  1059. struct3501.DrugTracCodg = drug.DrugCode
  1060. memo := make(map[string]interface{})
  1061. memo["pric"] = drug.Price
  1062. bytesData, _ := json.Marshal(memo)
  1063. struct3501.Memo = string(bytesData)
  1064. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1065. result1, result2, _ := service.FJyb3501(struct3501)
  1066. saveLog(result1, result2, "3501", "3501")
  1067. //saveLog(result, requestLog, "2201", "挂号")
  1068. var respJSON2 map[string]interface{}
  1069. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1072. return
  1073. }
  1074. userJSONBytes2, _ := json.Marshal(respJSON2)
  1075. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1076. utils.ErrorLog("解析失败:%v", err)
  1077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1078. return
  1079. }
  1080. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1081. data := make(map[string]interface{})
  1082. data["struct_3501s"] = struct3501
  1083. client := &http.Client{}
  1084. bytesData, _ := json.Marshal(data)
  1085. var req *http.Request
  1086. if miConfig.MdtrtareaAdmvs == "320830" {
  1087. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1088. } else {
  1089. if miConfig.MdtrtareaAdmvs == "320921" {
  1090. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1091. } else {
  1092. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1093. }
  1094. }
  1095. resp, _ := client.Do(req)
  1096. defer resp.Body.Close()
  1097. body, ioErr := ioutil.ReadAll(resp.Body)
  1098. if ioErr != nil {
  1099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1100. }
  1101. var respJSON map[string]interface{}
  1102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1105. return
  1106. }
  1107. var resSix10265 ResultSix10265 //1101结果
  1108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1109. result, _ := json.Marshal(respJSON)
  1110. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1111. utils.ErrorLog("解析失败:%v", err)
  1112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1113. return
  1114. }
  1115. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1116. res2.Output = resSix10265.Output
  1117. res2.ErrMsg = resSix10265.ErrMsg
  1118. res2.Cainfo = resSix10265.Cainfo
  1119. res2.WarnMsg = resSix10265.WarnMsg
  1120. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1121. res2.Infcode = infocode
  1122. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1123. data := make(map[string]interface{})
  1124. data["struct_3501s"] = struct3501
  1125. client := &http.Client{}
  1126. bytesData, _ := json.Marshal(data)
  1127. var req *http.Request
  1128. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1129. resp, _ := client.Do(req)
  1130. defer resp.Body.Close()
  1131. body, ioErr := ioutil.ReadAll(resp.Body)
  1132. if ioErr != nil {
  1133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1134. }
  1135. var respJSON map[string]interface{}
  1136. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. var resSix10265 ResultSix10265 //1101结果
  1142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1143. result, _ := json.Marshal(respJSON)
  1144. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1145. utils.ErrorLog("解析失败:%v", err)
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1147. return
  1148. }
  1149. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1150. res2.Output = resSix10265.Output
  1151. res2.ErrMsg = resSix10265.ErrMsg
  1152. res2.Cainfo = resSix10265.Cainfo
  1153. res2.WarnMsg = resSix10265.WarnMsg
  1154. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1155. res2.Infcode = infocode
  1156. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1157. data := make(map[string]interface{})
  1158. data["struct_3501s"] = struct3501
  1159. client := &http.Client{}
  1160. bytesData, _ := json.Marshal(data)
  1161. var req *http.Request
  1162. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1163. resp, _ := client.Do(req)
  1164. defer resp.Body.Close()
  1165. body, ioErr := ioutil.ReadAll(resp.Body)
  1166. if ioErr != nil {
  1167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1168. }
  1169. var respJSON map[string]interface{}
  1170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1173. return
  1174. }
  1175. var resSix10265 ResultSix10265 //1101结果
  1176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1177. result, _ := json.Marshal(respJSON)
  1178. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1179. utils.ErrorLog("解析失败:%v", err)
  1180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1181. return
  1182. }
  1183. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1184. res2.Output = resSix10265.Output
  1185. res2.ErrMsg = resSix10265.ErrMsg
  1186. res2.Cainfo = resSix10265.Cainfo
  1187. res2.WarnMsg = resSix10265.WarnMsg
  1188. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1189. res2.Infcode = infocode
  1190. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1191. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1192. saveLog(result1, result2, "3501", "3501")
  1193. //saveLog(result, requestLog, "2201", "挂号")
  1194. var respJSON2 map[string]interface{}
  1195. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1198. return
  1199. }
  1200. userJSONBytes2, _ := json.Marshal(respJSON2)
  1201. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1202. utils.ErrorLog("解析失败:%v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. }
  1207. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1208. if res2.Infcode != -1 {
  1209. drug.IsPc = 1
  1210. drug.Bchno = number
  1211. drug.PcDate = time.Now().Unix()
  1212. service.SaveW(drug)
  1213. //if err == nil {
  1214. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1215. // var struct3502 models.Struct3502
  1216. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1217. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1218. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1219. // struct3502.FixmedinsCode = miConfig.Code
  1220. // struct3502.Code = miConfig.Code
  1221. //
  1222. // struct3502.RxFlag = "0"
  1223. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1224. // struct3502.OrgName = miConfig.OrgName
  1225. // struct3502.Opter = roles.UserName
  1226. // struct3502.AccessKey = miConfig.AccessKey
  1227. // struct3502.RequestUrl = miConfig.Url
  1228. // struct3502.SecretKey = miConfig.SecretKey
  1229. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1230. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1231. // struct3502.Url = miConfig.Url
  1232. // struct3502.AppId = miConfig.Cainfo
  1233. // struct3502.AppSecret = miConfig.AppSecret
  1234. // struct3502.Enckey = miConfig.EncKey
  1235. // struct3502.SignKey = miConfig.SignKey
  1236. // struct3502.SecretKey = miConfig.SecretKey
  1237. // struct3502.DrugTracCodg = drug.DrugCode
  1238. //
  1239. // struct3502.Memo = ""
  1240. // struct3502.InvChgType = "108"
  1241. // struct3502.FixmedinsBchno = bg_number
  1242. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1243. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1244. //
  1245. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1246. // result11, result22, _ := service.FJyb3502(struct3502)
  1247. // saveLog(result11, result22, "3502", "3502")
  1248. //
  1249. // var respJSON3 map[string]interface{}
  1250. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1251. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1253. // return
  1254. // }
  1255. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1256. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1257. // utils.ErrorLog("解析失败:%v", err)
  1258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1259. // return
  1260. // }
  1261. //
  1262. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1263. // data := make(map[string]interface{})
  1264. // data["struct_3502s"] = struct3502
  1265. // client := &http.Client{}
  1266. // bytesData, _ := json.Marshal(data)
  1267. // var req *http.Request
  1268. // if miConfig.MdtrtareaAdmvs == "320830" {
  1269. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1270. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1271. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1272. // } else {
  1273. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1274. // }
  1275. //
  1276. // resp, _ := client.Do(req)
  1277. // defer resp.Body.Close()
  1278. // body, ioErr := ioutil.ReadAll(resp.Body)
  1279. // if ioErr != nil {
  1280. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1281. // }
  1282. // var respJSON map[string]interface{}
  1283. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1284. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. // return
  1287. // }
  1288. // var resSix10265 ResultSix10265 //1101结果
  1289. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1290. // result, _ := json.Marshal(respJSON)
  1291. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1292. // utils.ErrorLog("解析失败:%v", err)
  1293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1294. // return
  1295. // }
  1296. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1297. // res3.Output = resSix10265.Output
  1298. // res3.ErrMsg = resSix10265.ErrMsg
  1299. // res3.Cainfo = resSix10265.Cainfo
  1300. // res3.WarnMsg = resSix10265.WarnMsg
  1301. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1302. // res3.Infcode = infocode
  1303. //
  1304. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1305. //
  1306. // data := make(map[string]interface{})
  1307. // data["struct_3502s"] = struct3502
  1308. // client := &http.Client{}
  1309. // bytesData, _ := json.Marshal(data)
  1310. // var req *http.Request
  1311. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1312. // resp, _ := client.Do(req)
  1313. // defer resp.Body.Close()
  1314. // body, ioErr := ioutil.ReadAll(resp.Body)
  1315. // if ioErr != nil {
  1316. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1317. // }
  1318. // var respJSON map[string]interface{}
  1319. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1320. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1322. // return
  1323. // }
  1324. // var resSix10265 ResultSix10265 //1101结果
  1325. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1326. // result, _ := json.Marshal(respJSON)
  1327. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1328. // utils.ErrorLog("解析失败:%v", err)
  1329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1330. // return
  1331. // }
  1332. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1333. // res3.Output = resSix10265.Output
  1334. // res3.ErrMsg = resSix10265.ErrMsg
  1335. // res3.Cainfo = resSix10265.Cainfo
  1336. // res3.WarnMsg = resSix10265.WarnMsg
  1337. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1338. // res3.Infcode = infocode
  1339. //
  1340. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1341. //
  1342. // data := make(map[string]interface{})
  1343. // data["struct_3501s"] = struct3501
  1344. // client := &http.Client{}
  1345. // bytesData, _ := json.Marshal(data)
  1346. // var req *http.Request
  1347. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1348. // resp, _ := client.Do(req)
  1349. // defer resp.Body.Close()
  1350. // body, ioErr := ioutil.ReadAll(resp.Body)
  1351. // if ioErr != nil {
  1352. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1353. // }
  1354. // var respJSON map[string]interface{}
  1355. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1356. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1358. // return
  1359. // }
  1360. // var resSix10265 ResultSix10265 //1101结果
  1361. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1362. // result, _ := json.Marshal(respJSON)
  1363. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1364. // utils.ErrorLog("解析失败:%v", err)
  1365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1366. // return
  1367. // }
  1368. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1369. // res2.Output = resSix10265.Output
  1370. // res2.ErrMsg = resSix10265.ErrMsg
  1371. // res2.Cainfo = resSix10265.Cainfo
  1372. // res2.WarnMsg = resSix10265.WarnMsg
  1373. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1374. // res2.Infcode = infocode
  1375. //
  1376. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1377. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1378. // saveLog(result11, result22, "3502", "3502")
  1379. //
  1380. // var respJSON3 map[string]interface{}
  1381. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1382. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1384. // return
  1385. // }
  1386. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1387. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1388. // utils.ErrorLog("解析失败:%v", err)
  1389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1390. // return
  1391. // }
  1392. // }
  1393. // if res3.Infcode == -1 {
  1394. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1395. // c.ServeSuccessJSON(map[string]interface{}{
  1396. // "failed_code": -10,
  1397. // "msg": res3.ErrMsg,
  1398. // })
  1399. // } else {
  1400. // drug.IsBg = 1
  1401. // drug.BgBchno = bg_number
  1402. // service.SaveW(drug)
  1403. // }
  1404. //}
  1405. //} else {
  1406. }else{
  1407. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1408. }
  1409. }
  1410. //变更
  1411. }
  1412. if len(errs) == 0 {
  1413. c.ServeSuccessJSON(map[string]interface{}{
  1414. "msg": "盘存变更成功",
  1415. })
  1416. } else {
  1417. c.ServeSuccessJSON(map[string]interface{}{
  1418. "failed_code": -10,
  1419. "msg": errs,
  1420. })
  1421. }
  1422. }
  1423. func (c *HisApiController) DeletePCandBG() {
  1424. ids := c.GetString("ids")
  1425. id_arr := strings.Split(ids, ",")
  1426. admin_user_id, _ := c.GetInt64("admin_user_id")
  1427. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1428. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1429. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1430. var err []string
  1431. for _, item := range drugs {
  1432. if item.IsPc == 1 {
  1433. var res FJ3507Result
  1434. var struct3507 models.Struct3507
  1435. struct3507.FixmedinsBchno = item.Bchno
  1436. struct3507.InvDataType = "1"
  1437. struct3507.Opter = roles.UserName
  1438. struct3507.OrgName = miConfig.OrgName
  1439. struct3507.AccessKey = miConfig.AccessKey
  1440. struct3507.RequestUrl = miConfig.Url
  1441. struct3507.FixmedinsCode = miConfig.Code
  1442. struct3507.Code = miConfig.Code
  1443. struct3507.SecretKey = miConfig.SecretKey
  1444. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1445. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1446. struct3507.Url = miConfig.Url
  1447. struct3507.AppId = miConfig.Cainfo
  1448. struct3507.AppSecret = miConfig.AppSecret
  1449. struct3507.Enckey = miConfig.EncKey
  1450. struct3507.SignKey = miConfig.SignKey
  1451. struct3507.SecretKey = miConfig.SecretKey
  1452. if miConfig.MdtrtareaAdmvs == "350500" {
  1453. result, result1, _ := service.FJyb3507(struct3507)
  1454. saveLog(result, result1, "3507", "3507")
  1455. var respJSON2 map[string]interface{}
  1456. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1459. return
  1460. }
  1461. userJSONBytes2, _ := json.Marshal(respJSON2)
  1462. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1463. utils.ErrorLog("解析失败:%v", err)
  1464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1465. return
  1466. }
  1467. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1468. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1469. saveLog(result2, result1, "3507", "3507")
  1470. var respJSON2 map[string]interface{}
  1471. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. userJSONBytes2, _ := json.Marshal(respJSON2)
  1477. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1478. utils.ErrorLog("解析失败:%v", err)
  1479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1480. return
  1481. }
  1482. } else {
  1483. data := make(map[string]interface{})
  1484. data["struct_3507s"] = struct3507
  1485. client := &http.Client{}
  1486. bytesData, _ := json.Marshal(data)
  1487. var req *http.Request
  1488. if miConfig.MdtrtareaAdmvs == "320830" {
  1489. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1490. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1491. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1492. } else {
  1493. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1494. }
  1495. resp, _ := client.Do(req)
  1496. defer resp.Body.Close()
  1497. body, ioErr := ioutil.ReadAll(resp.Body)
  1498. if ioErr != nil {
  1499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1500. }
  1501. var respJSON map[string]interface{}
  1502. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1505. return
  1506. }
  1507. var resSix10265 ResultSix10265 //1101结果
  1508. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1509. result, _ := json.Marshal(respJSON)
  1510. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1511. utils.ErrorLog("解析失败:%v", err)
  1512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1513. return
  1514. }
  1515. res.InfRefmsgid = resSix10265.InfRefmsgid
  1516. //res.Output = resSix10265.Output
  1517. res.ErrMsg = resSix10265.ErrMsg
  1518. res.Cainfo = resSix10265.Cainfo
  1519. res.WarnMsg = resSix10265.WarnMsg
  1520. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1521. res.Infcode = infocode
  1522. }
  1523. if res.Infcode == 0 {
  1524. item.IsPc = 0
  1525. service.SaveW(item)
  1526. } else {
  1527. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1528. }
  1529. }
  1530. }
  1531. if len(err) == 0 {
  1532. c.ServeSuccessJSON(map[string]interface{}{
  1533. "msg": "删除盘存变更成功",
  1534. })
  1535. } else {
  1536. c.ServeSuccessJSON(map[string]interface{}{
  1537. "failed_code": -10,
  1538. "msg": err,
  1539. })
  1540. }
  1541. }
  1542. func (c *HisApiController) DeleteXSandBG() {
  1543. ids := c.GetString("ids")
  1544. id_arr := strings.Split(ids, ",")
  1545. admin_user_id, _ := c.GetInt64("admin_user_id")
  1546. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1547. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1549. var err []string
  1550. for _, item := range flows {
  1551. if item.IsSale == 1 && item.IsChange == 1 {
  1552. var res FJ3507Result
  1553. var res2 FJ3507Result
  1554. var struct3507 models.Struct3507
  1555. struct3507.FixmedinsBchno = item.Bchno
  1556. struct3507.InvDataType = "4"
  1557. struct3507.Opter = roles.UserName
  1558. struct3507.OrgName = miConfig.OrgName
  1559. struct3507.AccessKey = miConfig.AccessKey
  1560. struct3507.RequestUrl = miConfig.Url
  1561. struct3507.FixmedinsCode = miConfig.Code
  1562. struct3507.SecretKey = miConfig.SecretKey
  1563. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1564. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1565. struct3507.Url = miConfig.Url
  1566. struct3507.AppId = miConfig.Cainfo
  1567. struct3507.AppSecret = miConfig.AppSecret
  1568. struct3507.Enckey = miConfig.EncKey
  1569. struct3507.SignKey = miConfig.SignKey
  1570. struct3507.SecretKey = miConfig.SecretKey
  1571. //result, result1, _ := service.FJyb3507(struct3507)
  1572. //saveLog(result, result1, "3507", "3507")
  1573. if miConfig.MdtrtareaAdmvs == "350500" {
  1574. result, result1, _ := service.FJyb3507(struct3507)
  1575. saveLog(result, result1, "3507", "3507")
  1576. var respJSON2 map[string]interface{}
  1577. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1580. return
  1581. }
  1582. userJSONBytes2, _ := json.Marshal(respJSON2)
  1583. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1584. utils.ErrorLog("解析失败:%v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. } else {
  1589. data := make(map[string]interface{})
  1590. data["struct_3507s"] = struct3507
  1591. client := &http.Client{}
  1592. bytesData, _ := json.Marshal(data)
  1593. var req *http.Request
  1594. if miConfig.MdtrtareaAdmvs == "320830" {
  1595. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1596. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1597. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1598. } else {
  1599. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1600. }
  1601. resp, _ := client.Do(req)
  1602. defer resp.Body.Close()
  1603. body, ioErr := ioutil.ReadAll(resp.Body)
  1604. if ioErr != nil {
  1605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1606. }
  1607. var respJSON map[string]interface{}
  1608. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1611. return
  1612. }
  1613. var resSix10265 ResultSix10265 //1101结果
  1614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1615. result, _ := json.Marshal(respJSON)
  1616. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1617. utils.ErrorLog("解析失败:%v", err)
  1618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1619. return
  1620. }
  1621. res.InfRefmsgid = resSix10265.InfRefmsgid
  1622. //res.Output = resSix10265.Output
  1623. res.ErrMsg = resSix10265.ErrMsg
  1624. res.Cainfo = resSix10265.Cainfo
  1625. res.WarnMsg = resSix10265.WarnMsg
  1626. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1627. res.Infcode = infocode
  1628. }
  1629. if res.Infcode == 0 {
  1630. item.IsSale = 0
  1631. item.SaleDate = ""
  1632. item.Bchno = ""
  1633. err2 := service.SaveDF(item)
  1634. if err2 == nil {
  1635. var struct3507_2 models.Struct3507
  1636. struct3507_2.OrgName = miConfig.OrgName
  1637. struct3507_2.AccessKey = miConfig.AccessKey
  1638. struct3507_2.RequestUrl = miConfig.Url
  1639. struct3507_2.Opter = roles.UserName
  1640. struct3507_2.FixmedinsCode = miConfig.Code
  1641. struct3507_2.Code = miConfig.Code
  1642. struct3507_2.SecretKey = miConfig.SecretKey
  1643. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1644. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1645. struct3507_2.Url = miConfig.Url
  1646. struct3507_2.AppId = miConfig.Cainfo
  1647. struct3507_2.AppSecret = miConfig.AppSecret
  1648. struct3507_2.Enckey = miConfig.EncKey
  1649. struct3507_2.SignKey = miConfig.SignKey
  1650. struct3507_2.SecretKey = miConfig.SecretKey
  1651. struct3507_2.FixmedinsBchno = item.BgBchno
  1652. struct3507_2.InvDataType = "2"
  1653. if miConfig.MdtrtareaAdmvs == "350500" {
  1654. result11, result22, _ := service.FJyb3507(struct3507_2)
  1655. saveLog(result11, result22, "3507", "3507")
  1656. var respJSON3 map[string]interface{}
  1657. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1660. return
  1661. }
  1662. userJSONBytes3, _ := json.Marshal(respJSON3)
  1663. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1664. utils.ErrorLog("解析失败:%v", err)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. } else {
  1669. data := make(map[string]interface{})
  1670. data["struct_3507s"] = struct3507_2
  1671. client := &http.Client{}
  1672. bytesData, _ := json.Marshal(data)
  1673. var req *http.Request
  1674. if miConfig.MdtrtareaAdmvs == "320830" {
  1675. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1676. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1677. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1678. } else {
  1679. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1680. }
  1681. resp, _ := client.Do(req)
  1682. defer resp.Body.Close()
  1683. body, ioErr := ioutil.ReadAll(resp.Body)
  1684. if ioErr != nil {
  1685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1686. }
  1687. var respJSON map[string]interface{}
  1688. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1691. return
  1692. }
  1693. var resSix10265 ResultSix10265 //1101结果
  1694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1695. result, _ := json.Marshal(respJSON)
  1696. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1697. utils.ErrorLog("解析失败:%v", err)
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1699. return
  1700. }
  1701. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1702. //res.Output = resSix10265.Output
  1703. res2.ErrMsg = resSix10265.ErrMsg
  1704. res2.Cainfo = resSix10265.Cainfo
  1705. res2.WarnMsg = resSix10265.WarnMsg
  1706. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1707. res2.Infcode = infocode
  1708. }
  1709. if res2.Infcode == 0 {
  1710. item.IsChange = 0
  1711. item.BgBchno = ""
  1712. service.SaveDF2(item)
  1713. } else {
  1714. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1715. }
  1716. }
  1717. } else {
  1718. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1719. }
  1720. }
  1721. if item.IsSale == 2 && item.IsChange == 1 {
  1722. var res FJ3507Result
  1723. var res2 FJ3507Result
  1724. var struct3507 models.Struct3507
  1725. struct3507.FixmedinsBchno = item.Bchno
  1726. struct3507.InvDataType = "4"
  1727. struct3507.Opter = roles.UserName
  1728. struct3507.OrgName = miConfig.OrgName
  1729. struct3507.AccessKey = miConfig.AccessKey
  1730. struct3507.RequestUrl = miConfig.Url
  1731. struct3507.FixmedinsCode = miConfig.Code
  1732. struct3507.Code = miConfig.Code
  1733. struct3507.SecretKey = miConfig.SecretKey
  1734. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1735. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1736. struct3507.Url = miConfig.Url
  1737. struct3507.AppId = miConfig.Cainfo
  1738. struct3507.AppSecret = miConfig.AppSecret
  1739. struct3507.Enckey = miConfig.EncKey
  1740. struct3507.SignKey = miConfig.SignKey
  1741. struct3507.SecretKey = miConfig.SecretKey
  1742. //result, result1, _ := service.FJyb3507(struct3507)
  1743. //saveLog(result, result1, "3507", "3507")
  1744. //
  1745. //var respJSON2 map[string]interface{}
  1746. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1747. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1749. // return
  1750. //}
  1751. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1752. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1753. // utils.ErrorLog("解析失败:%v", err)
  1754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1755. // return
  1756. //}
  1757. if miConfig.MdtrtareaAdmvs == "350500" {
  1758. result, result1, _ := service.FJyb3507(struct3507)
  1759. saveLog(result, result1, "3507", "3507")
  1760. var respJSON2 map[string]interface{}
  1761. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1764. return
  1765. }
  1766. userJSONBytes2, _ := json.Marshal(respJSON2)
  1767. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1768. utils.ErrorLog("解析失败:%v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. } else {
  1773. data := make(map[string]interface{})
  1774. data["struct_3507s"] = struct3507
  1775. client := &http.Client{}
  1776. bytesData, _ := json.Marshal(data)
  1777. var req *http.Request
  1778. if miConfig.MdtrtareaAdmvs == "320830" {
  1779. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1780. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1781. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1782. } else {
  1783. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1784. }
  1785. resp, _ := client.Do(req)
  1786. defer resp.Body.Close()
  1787. body, ioErr := ioutil.ReadAll(resp.Body)
  1788. if ioErr != nil {
  1789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1790. }
  1791. var respJSON map[string]interface{}
  1792. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1795. return
  1796. }
  1797. var resSix10265 ResultSix10265 //1101结果
  1798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1799. result, _ := json.Marshal(respJSON)
  1800. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1801. utils.ErrorLog("解析失败:%v", err)
  1802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1803. return
  1804. }
  1805. res.InfRefmsgid = resSix10265.InfRefmsgid
  1806. //res.Output = resSix10265.Output
  1807. res.ErrMsg = resSix10265.ErrMsg
  1808. res.Cainfo = resSix10265.Cainfo
  1809. res.WarnMsg = resSix10265.WarnMsg
  1810. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1811. res.Infcode = infocode
  1812. }
  1813. if res.Infcode == 0 {
  1814. item.IsSale = 0
  1815. item.SaleDate = ""
  1816. item.Bchno = ""
  1817. err2 := service.SaveDF(item)
  1818. if err2 == nil {
  1819. var struct3507_2 models.Struct3507
  1820. struct3507_2.OrgName = miConfig.OrgName
  1821. struct3507_2.AccessKey = miConfig.AccessKey
  1822. struct3507_2.RequestUrl = miConfig.Url
  1823. struct3507_2.Opter = roles.UserName
  1824. struct3507_2.FixmedinsCode = miConfig.Code
  1825. struct3507_2.Code = miConfig.Code
  1826. struct3507_2.SecretKey = miConfig.SecretKey
  1827. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1828. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1829. struct3507_2.Url = miConfig.Url
  1830. struct3507_2.AppId = miConfig.Cainfo
  1831. struct3507_2.AppSecret = miConfig.AppSecret
  1832. struct3507_2.Enckey = miConfig.EncKey
  1833. struct3507_2.SignKey = miConfig.SignKey
  1834. struct3507_2.SecretKey = miConfig.SecretKey
  1835. struct3507_2.FixmedinsBchno = item.BgBchno
  1836. struct3507_2.InvDataType = "2"
  1837. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1838. //saveLog(result11, result22, "3507", "3507")
  1839. //var respJSON3 map[string]interface{}
  1840. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. // return
  1844. //}
  1845. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1846. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1847. // utils.ErrorLog("解析失败:%v", err)
  1848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1849. // return
  1850. //}
  1851. if miConfig.MdtrtareaAdmvs == "350500" {
  1852. result11, result22, _ := service.FJyb3507(struct3507_2)
  1853. saveLog(result11, result22, "3507", "3507")
  1854. var respJSON3 map[string]interface{}
  1855. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1858. return
  1859. }
  1860. userJSONBytes3, _ := json.Marshal(respJSON3)
  1861. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1862. utils.ErrorLog("解析失败:%v", err)
  1863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1864. return
  1865. }
  1866. } else {
  1867. data := make(map[string]interface{})
  1868. data["struct_3507s"] = struct3507_2
  1869. client := &http.Client{}
  1870. bytesData, _ := json.Marshal(data)
  1871. var req *http.Request
  1872. if miConfig.MdtrtareaAdmvs == "320830" {
  1873. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1874. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1875. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1876. } else {
  1877. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1878. }
  1879. resp, _ := client.Do(req)
  1880. defer resp.Body.Close()
  1881. body, ioErr := ioutil.ReadAll(resp.Body)
  1882. if ioErr != nil {
  1883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1884. }
  1885. var respJSON map[string]interface{}
  1886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1889. return
  1890. }
  1891. var resSix10265 ResultSix10265 //1101结果
  1892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1893. result, _ := json.Marshal(respJSON)
  1894. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1895. utils.ErrorLog("解析失败:%v", err)
  1896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1897. return
  1898. }
  1899. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1900. //res.Output = resSix10265.Output
  1901. res2.ErrMsg = resSix10265.ErrMsg
  1902. res2.Cainfo = resSix10265.Cainfo
  1903. res2.WarnMsg = resSix10265.WarnMsg
  1904. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1905. res2.Infcode = infocode
  1906. }
  1907. if res2.Infcode == 0 {
  1908. item.IsChange = 0
  1909. item.BgBchno = ""
  1910. service.SaveDF2(item)
  1911. } else {
  1912. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1913. }
  1914. }
  1915. } else {
  1916. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1917. }
  1918. }
  1919. if item.IsSale == 1 && item.IsChange == 0 {
  1920. var res FJ3507Result
  1921. var struct3507 models.Struct3507
  1922. struct3507.FixmedinsBchno = item.Bchno
  1923. struct3507.InvDataType = "4"
  1924. struct3507.Opter = roles.UserName
  1925. struct3507.FixmedinsCode = miConfig.Code
  1926. struct3507.Code = miConfig.Code
  1927. struct3507.OrgName = miConfig.OrgName
  1928. struct3507.AccessKey = miConfig.AccessKey
  1929. struct3507.RequestUrl = miConfig.Url
  1930. struct3507.SecretKey = miConfig.SecretKey
  1931. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1932. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1933. struct3507.Url = miConfig.Url
  1934. struct3507.AppId = miConfig.Cainfo
  1935. struct3507.AppSecret = miConfig.AppSecret
  1936. struct3507.Enckey = miConfig.EncKey
  1937. struct3507.SignKey = miConfig.SignKey
  1938. struct3507.SecretKey = miConfig.SecretKey
  1939. //result, result1, _ := service.FJyb3507(struct3507)
  1940. //saveLog(result, result1, "3507", "3507")
  1941. //
  1942. //var respJSON3 map[string]interface{}
  1943. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1944. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1946. // return
  1947. //}
  1948. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1949. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1950. // utils.ErrorLog("解析失败:%v", err)
  1951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1952. // return
  1953. //}
  1954. if miConfig.MdtrtareaAdmvs == "350500" {
  1955. result, result1, _ := service.FJyb3507(struct3507)
  1956. saveLog(result, result1, "3507", "3507")
  1957. var respJSON2 map[string]interface{}
  1958. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1961. return
  1962. }
  1963. userJSONBytes2, _ := json.Marshal(respJSON2)
  1964. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1965. utils.ErrorLog("解析失败:%v", err)
  1966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1967. return
  1968. }
  1969. } else {
  1970. data := make(map[string]interface{})
  1971. data["struct_3507s"] = struct3507
  1972. client := &http.Client{}
  1973. bytesData, _ := json.Marshal(data)
  1974. var req *http.Request
  1975. if miConfig.MdtrtareaAdmvs == "320830" {
  1976. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1977. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1978. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1979. } else {
  1980. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1981. }
  1982. resp, _ := client.Do(req)
  1983. defer resp.Body.Close()
  1984. body, ioErr := ioutil.ReadAll(resp.Body)
  1985. if ioErr != nil {
  1986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1987. }
  1988. var respJSON map[string]interface{}
  1989. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1992. return
  1993. }
  1994. var resSix10265 ResultSix10265 //1101结果
  1995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1996. result, _ := json.Marshal(respJSON)
  1997. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1998. utils.ErrorLog("解析失败:%v", err)
  1999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2000. return
  2001. }
  2002. res.InfRefmsgid = resSix10265.InfRefmsgid
  2003. //res.Output = resSix10265.Output
  2004. res.ErrMsg = resSix10265.ErrMsg
  2005. res.Cainfo = resSix10265.Cainfo
  2006. res.WarnMsg = resSix10265.WarnMsg
  2007. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2008. res.Infcode = infocode
  2009. }
  2010. if res.Infcode == 0 {
  2011. item.IsSale = 0
  2012. item.SaleDate = ""
  2013. service.SaveDF(item)
  2014. } else {
  2015. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2016. }
  2017. }
  2018. if item.IsSale == 2 && item.IsChange == 0 {
  2019. var res FJ3507Result
  2020. var struct3507 models.Struct3507
  2021. struct3507.FixmedinsBchno = item.Bchno
  2022. struct3507.InvDataType = "4"
  2023. struct3507.Opter = roles.UserName
  2024. struct3507.FixmedinsCode = miConfig.Code
  2025. struct3507.Code = miConfig.Code
  2026. struct3507.OrgName = miConfig.OrgName
  2027. struct3507.AccessKey = miConfig.AccessKey
  2028. struct3507.RequestUrl = miConfig.Url
  2029. struct3507.SecretKey = miConfig.SecretKey
  2030. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2031. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2032. struct3507.Url = miConfig.Url
  2033. struct3507.AppId = miConfig.Cainfo
  2034. struct3507.AppSecret = miConfig.AppSecret
  2035. struct3507.Enckey = miConfig.EncKey
  2036. struct3507.SignKey = miConfig.SignKey
  2037. struct3507.SecretKey = miConfig.SecretKey
  2038. //result, result1, _ := service.FJyb3507(struct3507)
  2039. //saveLog(result, result1, "3507", "3507")
  2040. //
  2041. //var respJSON3 map[string]interface{}
  2042. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2043. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2045. // return
  2046. //}
  2047. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2048. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2049. // utils.ErrorLog("解析失败:%v", err)
  2050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. // return
  2052. //}
  2053. if miConfig.MdtrtareaAdmvs == "350500" {
  2054. result, result1, _ := service.FJyb3507(struct3507)
  2055. saveLog(result, result1, "3507", "3507")
  2056. var respJSON2 map[string]interface{}
  2057. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2060. return
  2061. }
  2062. userJSONBytes2, _ := json.Marshal(respJSON2)
  2063. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2064. utils.ErrorLog("解析失败:%v", err)
  2065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. return
  2067. }
  2068. } else {
  2069. data := make(map[string]interface{})
  2070. data["struct_3507s"] = struct3507
  2071. client := &http.Client{}
  2072. bytesData, _ := json.Marshal(data)
  2073. var req *http.Request
  2074. if miConfig.MdtrtareaAdmvs == "320830" {
  2075. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2076. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2077. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2078. } else {
  2079. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2080. }
  2081. resp, _ := client.Do(req)
  2082. defer resp.Body.Close()
  2083. body, ioErr := ioutil.ReadAll(resp.Body)
  2084. if ioErr != nil {
  2085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2086. }
  2087. var respJSON map[string]interface{}
  2088. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2091. return
  2092. }
  2093. var resSix10265 ResultSix10265 //1101结果
  2094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2095. result, _ := json.Marshal(respJSON)
  2096. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2097. utils.ErrorLog("解析失败:%v", err)
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. return
  2100. }
  2101. res.InfRefmsgid = resSix10265.InfRefmsgid
  2102. //res.Output = resSix10265.Output
  2103. res.ErrMsg = resSix10265.ErrMsg
  2104. res.Cainfo = resSix10265.Cainfo
  2105. res.WarnMsg = resSix10265.WarnMsg
  2106. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2107. res.Infcode = infocode
  2108. }
  2109. if res.Infcode == 0 {
  2110. item.IsSale = 0
  2111. item.SaleDate = ""
  2112. item.Bchno = ""
  2113. service.SaveDF(item)
  2114. } else {
  2115. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2116. }
  2117. }
  2118. if item.IsSale == 0 && item.IsChange == 1 {
  2119. var res FJ3507Result
  2120. var struct3507 models.Struct3507
  2121. struct3507.FixmedinsBchno = item.BgBchno
  2122. struct3507.InvDataType = "2"
  2123. struct3507.Opter = roles.UserName
  2124. struct3507.FixmedinsCode = miConfig.Code
  2125. struct3507.Code = miConfig.Code
  2126. struct3507.OrgName = miConfig.OrgName
  2127. struct3507.AccessKey = miConfig.AccessKey
  2128. struct3507.RequestUrl = miConfig.Url
  2129. struct3507.SecretKey = miConfig.SecretKey
  2130. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2131. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2132. struct3507.Url = miConfig.Url
  2133. struct3507.AppId = miConfig.Cainfo
  2134. struct3507.AppSecret = miConfig.AppSecret
  2135. struct3507.Enckey = miConfig.EncKey
  2136. struct3507.SignKey = miConfig.SignKey
  2137. struct3507.SecretKey = miConfig.SecretKey
  2138. //result, result1, _ := service.FJyb3507(struct3507)
  2139. //saveLog(result, result1, "3507", "3507")
  2140. //
  2141. //var respJSON3 map[string]interface{}
  2142. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. // return
  2146. //}
  2147. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2148. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2149. // utils.ErrorLog("解析失败:%v", err)
  2150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. // return
  2152. //}
  2153. if miConfig.MdtrtareaAdmvs == "350500" {
  2154. result, result1, _ := service.FJyb3507(struct3507)
  2155. saveLog(result, result1, "3507", "3507")
  2156. var respJSON2 map[string]interface{}
  2157. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2160. return
  2161. }
  2162. userJSONBytes2, _ := json.Marshal(respJSON2)
  2163. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2164. utils.ErrorLog("解析失败:%v", err)
  2165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2166. return
  2167. }
  2168. } else {
  2169. data := make(map[string]interface{})
  2170. data["struct_3507s"] = struct3507
  2171. client := &http.Client{}
  2172. bytesData, _ := json.Marshal(data)
  2173. var req *http.Request
  2174. if miConfig.MdtrtareaAdmvs == "320830" {
  2175. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2176. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2177. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2178. } else {
  2179. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2180. }
  2181. resp, _ := client.Do(req)
  2182. defer resp.Body.Close()
  2183. body, ioErr := ioutil.ReadAll(resp.Body)
  2184. if ioErr != nil {
  2185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2186. }
  2187. var respJSON map[string]interface{}
  2188. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2191. return
  2192. }
  2193. var resSix10265 ResultSix10265 //1101结果
  2194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2195. result, _ := json.Marshal(respJSON)
  2196. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2197. utils.ErrorLog("解析失败:%v", err)
  2198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2199. return
  2200. }
  2201. res.InfRefmsgid = resSix10265.InfRefmsgid
  2202. //res.Output = resSix10265.Output
  2203. res.ErrMsg = resSix10265.ErrMsg
  2204. res.Cainfo = resSix10265.Cainfo
  2205. res.WarnMsg = resSix10265.WarnMsg
  2206. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2207. res.Infcode = infocode
  2208. }
  2209. if res.Infcode == 0 {
  2210. item.IsChange = 0
  2211. item.BgBchno = ""
  2212. service.SaveDF2(item)
  2213. } else {
  2214. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2215. }
  2216. }
  2217. }
  2218. if len(err) == 0 {
  2219. c.ServeSuccessJSON(map[string]interface{}{
  2220. "msg": "删除销售变更成功",
  2221. })
  2222. } else {
  2223. c.ServeSuccessJSON(map[string]interface{}{
  2224. "failed_code": -10,
  2225. "msg": err,
  2226. })
  2227. }
  2228. }
  2229. //func (c *HisApiController) BatchFJ3501AND3502() {
  2230. // //ids := c.GetString("ids")
  2231. // start_time := c.GetString("start_time")
  2232. // end_time := c.GetString("end_time")
  2233. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2234. //
  2235. //
  2236. // timeLayout := "2006-01-02"
  2237. // loc, _ := time.LoadLocation("Local")
  2238. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2239. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2240. //
  2241. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2242. // //id_arr := strings.Split(ids, ",")
  2243. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2244. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2245. // //库盘
  2246. // var errs []string
  2247. // for _, drug := range drugs {
  2248. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2249. // var res2 ResultSix
  2250. // var res3 ResultSix
  2251. //
  2252. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2253. // var struct3501 models.Struct3501
  2254. // struct3501.Code = miConfig.Code
  2255. // struct3501.OrgName = miConfig.OrgName
  2256. // struct3501.AccessKey = miConfig.AccessKey
  2257. // struct3501.Opter = roles.UserName
  2258. // struct3501.RequestUrl = miConfig.Url
  2259. // struct3501.Url = miConfig.Url
  2260. // struct3501.AppId = miConfig.Cainfo
  2261. // struct3501.AppSecret = miConfig.AppSecret
  2262. // struct3501.Enckey = miConfig.EncKey
  2263. // struct3501.SignKey = miConfig.SignKey
  2264. // struct3501.SecretKey = miConfig.SecretKey
  2265. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2266. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2267. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2268. // struct3501.RxFlag = "1"
  2269. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2270. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2271. //
  2272. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2273. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2274. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2275. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2276. // struct3501.FixmedinsBchno = number
  2277. // struct3501.DrugTracCodg = drug.DrugCode
  2278. // memo := make(map[string]interface{})
  2279. // memo["pric"] = drug.Price
  2280. // bytesData, _ := json.Marshal(memo)
  2281. // struct3501.Memo = string(bytesData)
  2282. //
  2283. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2284. //
  2285. // result1, result2, _ := service.FJyb3501(struct3501)
  2286. // saveLog(result1, result2, "3501", "3501")
  2287. // //saveLog(result, requestLog, "2201", "挂号")
  2288. //
  2289. // var respJSON2 map[string]interface{}
  2290. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2291. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2293. // return
  2294. // }
  2295. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2296. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2297. // utils.ErrorLog("解析失败:%v", err)
  2298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2299. // return
  2300. // }
  2301. //
  2302. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2303. // data := make(map[string]interface{})
  2304. // data["struct_3501s"] = struct3501
  2305. // client := &http.Client{}
  2306. // bytesData, _ := json.Marshal(data)
  2307. // var req *http.Request
  2308. // if miConfig.MdtrtareaAdmvs == "320921" {
  2309. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2310. // } else {
  2311. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2312. // }
  2313. //
  2314. // resp, _ := client.Do(req)
  2315. // defer resp.Body.Close()
  2316. // body, ioErr := ioutil.ReadAll(resp.Body)
  2317. // if ioErr != nil {
  2318. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2319. // }
  2320. // var respJSON map[string]interface{}
  2321. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2322. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2324. // return
  2325. // }
  2326. // var resSix10265 ResultSix10265 //1101结果
  2327. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2328. // result, _ := json.Marshal(respJSON)
  2329. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2330. // utils.ErrorLog("解析失败:%v", err)
  2331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2332. // return
  2333. // }
  2334. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2335. // res2.Output = resSix10265.Output
  2336. // res2.ErrMsg = resSix10265.ErrMsg
  2337. // res2.Cainfo = resSix10265.Cainfo
  2338. // res2.WarnMsg = resSix10265.WarnMsg
  2339. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2340. // res2.Infcode = infocode
  2341. //
  2342. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2343. // data := make(map[string]interface{})
  2344. // data["struct_3501s"] = struct3501
  2345. // client := &http.Client{}
  2346. // bytesData, _ := json.Marshal(data)
  2347. // var req *http.Request
  2348. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2349. // resp, _ := client.Do(req)
  2350. // defer resp.Body.Close()
  2351. // body, ioErr := ioutil.ReadAll(resp.Body)
  2352. // if ioErr != nil {
  2353. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2354. // }
  2355. // var respJSON map[string]interface{}
  2356. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2357. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2359. // return
  2360. // }
  2361. // var resSix10265 ResultSix10265 //1101结果
  2362. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2363. // result, _ := json.Marshal(respJSON)
  2364. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2365. // utils.ErrorLog("解析失败:%v", err)
  2366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2367. // return
  2368. // }
  2369. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2370. // res2.Output = resSix10265.Output
  2371. // res2.ErrMsg = resSix10265.ErrMsg
  2372. // res2.Cainfo = resSix10265.Cainfo
  2373. // res2.WarnMsg = resSix10265.WarnMsg
  2374. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2375. // res2.Infcode = infocode
  2376. //
  2377. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2378. // data := make(map[string]interface{})
  2379. // data["struct_3501s"] = struct3501
  2380. // client := &http.Client{}
  2381. // bytesData, _ := json.Marshal(data)
  2382. // var req *http.Request
  2383. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2384. // resp, _ := client.Do(req)
  2385. // defer resp.Body.Close()
  2386. // body, ioErr := ioutil.ReadAll(resp.Body)
  2387. // if ioErr != nil {
  2388. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2389. // }
  2390. // var respJSON map[string]interface{}
  2391. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2392. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2394. // return
  2395. // }
  2396. // var resSix10265 ResultSix10265 //1101结果
  2397. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2398. // result, _ := json.Marshal(respJSON)
  2399. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2400. // utils.ErrorLog("解析失败:%v", err)
  2401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2402. // return
  2403. // }
  2404. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2405. // res2.Output = resSix10265.Output
  2406. // res2.ErrMsg = resSix10265.ErrMsg
  2407. // res2.Cainfo = resSix10265.Cainfo
  2408. // res2.WarnMsg = resSix10265.WarnMsg
  2409. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2410. // res2.Infcode = infocode
  2411. //
  2412. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2413. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2414. // saveLog(result1, result2, "3501", "3501")
  2415. // //saveLog(result, requestLog, "2201", "挂号")
  2416. //
  2417. // var respJSON2 map[string]interface{}
  2418. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2419. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2421. // return
  2422. // }
  2423. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2424. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2425. // utils.ErrorLog("解析失败:%v", err)
  2426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2427. // return
  2428. // }
  2429. //
  2430. // }
  2431. //
  2432. // if res2.Infcode != -1 {
  2433. // drug.IsPc = 1
  2434. // drug.Bchno = number
  2435. // drug.PcDate = time.Now().Unix()
  2436. // err := service.SaveW(drug)
  2437. // if err == nil {
  2438. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2439. // var struct3502 models.Struct3502
  2440. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2441. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2442. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2443. // struct3502.FixmedinsCode = miConfig.Code
  2444. // struct3502.Code = miConfig.Code
  2445. //
  2446. // struct3502.RxFlag = "0"
  2447. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2448. // struct3502.OrgName = miConfig.OrgName
  2449. // struct3502.Opter = roles.UserName
  2450. // struct3502.AccessKey = miConfig.AccessKey
  2451. // struct3502.RequestUrl = miConfig.Url
  2452. // struct3502.SecretKey = miConfig.SecretKey
  2453. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2454. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2455. // struct3502.Url = miConfig.Url
  2456. // struct3502.AppId = miConfig.Cainfo
  2457. // struct3502.AppSecret = miConfig.AppSecret
  2458. // struct3502.Enckey = miConfig.EncKey
  2459. // struct3502.SignKey = miConfig.SignKey
  2460. // struct3502.SecretKey = miConfig.SecretKey
  2461. // struct3502.DrugTracCodg = drug.DrugCode
  2462. //
  2463. // struct3502.Memo = ""
  2464. // struct3502.InvChgType = "108"
  2465. // struct3502.FixmedinsBchno = bg_number
  2466. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2467. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2468. //
  2469. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2470. // result11, result22, _ := service.FJyb3502(struct3502)
  2471. // saveLog(result11, result22, "3502", "3502")
  2472. //
  2473. // var respJSON3 map[string]interface{}
  2474. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. // return
  2478. // }
  2479. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2480. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. //
  2486. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2487. // data := make(map[string]interface{})
  2488. // data["struct_3502s"] = struct3502
  2489. // client := &http.Client{}
  2490. // bytesData, _ := json.Marshal(data)
  2491. // var req *http.Request
  2492. // if miConfig.MdtrtareaAdmvs == "320921" {
  2493. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2494. // } else {
  2495. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2496. // }
  2497. //
  2498. // resp, _ := client.Do(req)
  2499. // defer resp.Body.Close()
  2500. // body, ioErr := ioutil.ReadAll(resp.Body)
  2501. // if ioErr != nil {
  2502. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2503. // }
  2504. // var respJSON map[string]interface{}
  2505. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2508. // return
  2509. // }
  2510. // var resSix10265 ResultSix10265 //1101结果
  2511. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2512. // result, _ := json.Marshal(respJSON)
  2513. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2514. // utils.ErrorLog("解析失败:%v", err)
  2515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2516. // return
  2517. // }
  2518. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2519. // res3.Output = resSix10265.Output
  2520. // res3.ErrMsg = resSix10265.ErrMsg
  2521. // res3.Cainfo = resSix10265.Cainfo
  2522. // res3.WarnMsg = resSix10265.WarnMsg
  2523. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2524. // res3.Infcode = infocode
  2525. //
  2526. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2527. //
  2528. // data := make(map[string]interface{})
  2529. // data["struct_3502s"] = struct3502
  2530. // client := &http.Client{}
  2531. // bytesData, _ := json.Marshal(data)
  2532. // var req *http.Request
  2533. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2534. // resp, _ := client.Do(req)
  2535. // defer resp.Body.Close()
  2536. // body, ioErr := ioutil.ReadAll(resp.Body)
  2537. // if ioErr != nil {
  2538. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2539. // }
  2540. // var respJSON map[string]interface{}
  2541. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2542. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2544. // return
  2545. // }
  2546. // var resSix10265 ResultSix10265 //1101结果
  2547. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2548. // result, _ := json.Marshal(respJSON)
  2549. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2550. // utils.ErrorLog("解析失败:%v", err)
  2551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2552. // return
  2553. // }
  2554. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2555. // res3.Output = resSix10265.Output
  2556. // res3.ErrMsg = resSix10265.ErrMsg
  2557. // res3.Cainfo = resSix10265.Cainfo
  2558. // res3.WarnMsg = resSix10265.WarnMsg
  2559. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2560. // res3.Infcode = infocode
  2561. //
  2562. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2563. //
  2564. // data := make(map[string]interface{})
  2565. // data["struct_3501s"] = struct3501
  2566. // client := &http.Client{}
  2567. // bytesData, _ := json.Marshal(data)
  2568. // var req *http.Request
  2569. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2570. // resp, _ := client.Do(req)
  2571. // defer resp.Body.Close()
  2572. // body, ioErr := ioutil.ReadAll(resp.Body)
  2573. // if ioErr != nil {
  2574. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2575. // }
  2576. // var respJSON map[string]interface{}
  2577. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2578. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2580. // return
  2581. // }
  2582. // var resSix10265 ResultSix10265 //1101结果
  2583. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2584. // result, _ := json.Marshal(respJSON)
  2585. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2586. // utils.ErrorLog("解析失败:%v", err)
  2587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2588. // return
  2589. // }
  2590. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2591. // res2.Output = resSix10265.Output
  2592. // res2.ErrMsg = resSix10265.ErrMsg
  2593. // res2.Cainfo = resSix10265.Cainfo
  2594. // res2.WarnMsg = resSix10265.WarnMsg
  2595. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2596. // res2.Infcode = infocode
  2597. //
  2598. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2599. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2600. // saveLog(result11, result22, "3502", "3502")
  2601. //
  2602. // var respJSON3 map[string]interface{}
  2603. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2604. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2606. // return
  2607. // }
  2608. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2609. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2610. // utils.ErrorLog("解析失败:%v", err)
  2611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2612. // return
  2613. // }
  2614. // }
  2615. // if res3.Infcode == -1 {
  2616. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2617. // c.ServeSuccessJSON(map[string]interface{}{
  2618. // "failed_code": -10,
  2619. // "msg": res3.ErrMsg,
  2620. // })
  2621. // } else {
  2622. // drug.IsBg = 1
  2623. // drug.BgBchno = bg_number
  2624. // service.SaveW(drug)
  2625. // }
  2626. // }
  2627. // } else {
  2628. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2629. // }
  2630. // }
  2631. // //变更
  2632. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2633. // var res3 ResultSix
  2634. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2635. //
  2636. // var struct3502 models.Struct3502
  2637. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2638. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2639. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2640. // struct3502.FixmedinsCode = miConfig.Code
  2641. // struct3502.Code = miConfig.Code
  2642. //
  2643. // struct3502.Opter = roles.UserName
  2644. // struct3502.RxFlag = "0"
  2645. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2646. // struct3502.OrgName = miConfig.OrgName
  2647. // struct3502.AccessKey = miConfig.AccessKey
  2648. // struct3502.RequestUrl = miConfig.Url
  2649. // struct3502.SecretKey = miConfig.SecretKey
  2650. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2651. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2652. // struct3502.InvChgType = "108"
  2653. // struct3502.DrugTracCodg = drug.DrugCode
  2654. //
  2655. // struct3502.Url = miConfig.Url
  2656. // struct3502.AppId = miConfig.Cainfo
  2657. // struct3502.AppSecret = miConfig.AppSecret
  2658. // struct3502.Enckey = miConfig.EncKey
  2659. // struct3502.SignKey = miConfig.SignKey
  2660. // struct3502.SecretKey = miConfig.SecretKey
  2661. //
  2662. // struct3502.FixmedinsBchno = bg_number
  2663. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2664. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2665. //
  2666. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2667. // result1, result2, _ := service.FJyb3502(struct3502)
  2668. // saveLog(result1, result2, "3502", "3502")
  2669. // var respJSON3 map[string]interface{}
  2670. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2671. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. // return
  2674. // }
  2675. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2676. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2677. // utils.ErrorLog("解析失败:%v", err)
  2678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. // return
  2680. // }
  2681. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2682. // data := make(map[string]interface{})
  2683. // data["struct_3502s"] = struct3502
  2684. // client := &http.Client{}
  2685. // bytesData, _ := json.Marshal(data)
  2686. // var req *http.Request
  2687. // if miConfig.MdtrtareaAdmvs == "320921" {
  2688. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2689. // } else {
  2690. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2691. // }
  2692. // resp, _ := client.Do(req)
  2693. // defer resp.Body.Close()
  2694. // body, ioErr := ioutil.ReadAll(resp.Body)
  2695. // if ioErr != nil {
  2696. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2697. // }
  2698. // var respJSON map[string]interface{}
  2699. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2700. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2702. // return
  2703. // }
  2704. // var resSix10265 ResultSix10265 //1101结果
  2705. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2706. // result, _ := json.Marshal(respJSON)
  2707. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2708. // utils.ErrorLog("解析失败:%v", err)
  2709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2710. // return
  2711. // }
  2712. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2713. // res3.Output = resSix10265.Output
  2714. // res3.ErrMsg = resSix10265.ErrMsg
  2715. // res3.Cainfo = resSix10265.Cainfo
  2716. // res3.WarnMsg = resSix10265.WarnMsg
  2717. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2718. // res3.Infcode = infocode
  2719. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2720. //
  2721. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2722. //
  2723. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2724. //
  2725. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2726. //
  2727. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2728. // saveLog(result1, result2, "3501", "3501")
  2729. // //saveLog(result, requestLog, "2201", "挂号")
  2730. //
  2731. // var respJSON2 map[string]interface{}
  2732. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2733. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2735. // return
  2736. // }
  2737. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2738. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2739. // utils.ErrorLog("解析失败:%v", err)
  2740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2741. // return
  2742. // }
  2743. //
  2744. // }
  2745. // if res3.Infcode == -1 {
  2746. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2747. // } else {
  2748. // drug.IsBg = 1
  2749. // drug.BgBchno = bg_number
  2750. // service.SaveW(drug)
  2751. // }
  2752. // }
  2753. // }
  2754. //
  2755. // if len(errs) == 0 {
  2756. // c.ServeSuccessJSON(map[string]interface{}{
  2757. // "msg": "盘存变更成功",
  2758. // })
  2759. // } else {
  2760. // c.ServeSuccessJSON(map[string]interface{}{
  2761. // "failed_code": -10,
  2762. // "msg": errs,
  2763. // })
  2764. // }
  2765. //}
  2766. func (c *HisApiController) DeleteXSandBGTwo() {
  2767. patient_id, _ := c.GetInt64("patient_id")
  2768. admin_user_id, _ := c.GetInt64("admin_user_id")
  2769. times := c.GetString("time", "")
  2770. timeLayout := "2006-01-02"
  2771. loc, _ := time.LoadLocation("Local")
  2772. var stime, etime int64
  2773. if times == "" {
  2774. stime, etime = GetNowTime()
  2775. } else {
  2776. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2777. stime = stmp.Unix()
  2778. etime = stime + 86399
  2779. }
  2780. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2781. var flows []*models.DrugFlow
  2782. for _, item := range advicelist {
  2783. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2784. flows = append(flows, flow...)
  2785. }
  2786. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2787. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2788. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2789. var err []string
  2790. for _, item := range flows {
  2791. if item.IsSale == 1 {
  2792. var res FJ3507Result
  2793. var struct3507 models.Struct3507
  2794. struct3507.FixmedinsBchno = item.Bchno
  2795. struct3507.InvDataType = "4"
  2796. struct3507.Opter = roles.UserName
  2797. struct3507.OrgName = miConfig.OrgName
  2798. struct3507.AccessKey = miConfig.AccessKey
  2799. struct3507.RequestUrl = miConfig.Url
  2800. struct3507.FixmedinsCode = miConfig.Code
  2801. struct3507.SecretKey = miConfig.SecretKey
  2802. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2803. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2804. struct3507.Url = miConfig.Url
  2805. struct3507.AppId = miConfig.Cainfo
  2806. struct3507.AppSecret = miConfig.AppSecret
  2807. struct3507.Enckey = miConfig.EncKey
  2808. struct3507.SignKey = miConfig.SignKey
  2809. struct3507.SecretKey = miConfig.SecretKey
  2810. if miConfig.MdtrtareaAdmvs == "350500" {
  2811. result, result1, _ := service.FJyb3507(struct3507)
  2812. saveLog(result, result1, "3507", "3507")
  2813. var respJSON2 map[string]interface{}
  2814. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2817. return
  2818. }
  2819. userJSONBytes2, _ := json.Marshal(respJSON2)
  2820. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2821. utils.ErrorLog("解析失败:%v", err)
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2823. return
  2824. }
  2825. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  2826. data := make(map[string]interface{})
  2827. data["struct_3507s"] = struct3507
  2828. client := &http.Client{}
  2829. bytesData, _ := json.Marshal(data)
  2830. var req *http.Request
  2831. if miConfig.MdtrtareaAdmvs == "320830" {
  2832. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2833. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2834. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2835. } else {
  2836. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2837. }
  2838. resp, _ := client.Do(req)
  2839. defer resp.Body.Close()
  2840. body, ioErr := ioutil.ReadAll(resp.Body)
  2841. if ioErr != nil {
  2842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2843. }
  2844. var respJSON map[string]interface{}
  2845. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2848. return
  2849. }
  2850. var resSix10265 ResultSix10265 //1101结果
  2851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2852. result, _ := json.Marshal(respJSON)
  2853. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2854. utils.ErrorLog("解析失败:%v", err)
  2855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2856. return
  2857. }
  2858. res.InfRefmsgid = resSix10265.InfRefmsgid
  2859. //res.Output = resSix10265.Output
  2860. res.ErrMsg = resSix10265.ErrMsg
  2861. res.Cainfo = resSix10265.Cainfo
  2862. res.WarnMsg = resSix10265.WarnMsg
  2863. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2864. res.Infcode = infocode
  2865. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2866. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2867. saveLog(result2, result1, "3507", "3507")
  2868. var respJSON2 map[string]interface{}
  2869. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2872. return
  2873. }
  2874. userJSONBytes2, _ := json.Marshal(respJSON2)
  2875. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2876. utils.ErrorLog("解析失败:%v", err)
  2877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2878. return
  2879. }
  2880. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2881. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2882. saveLog(result2, result1, "3507", "3507")
  2883. var respJSON2 map[string]interface{}
  2884. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2887. return
  2888. }
  2889. userJSONBytes2, _ := json.Marshal(respJSON2)
  2890. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2891. utils.ErrorLog("解析失败:%v", err)
  2892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2893. return
  2894. }
  2895. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2896. result1, result2 := service.Jxyb3507(struct3507)
  2897. saveLog(result2, result1, "3507", "3507")
  2898. var respJSON2 map[string]interface{}
  2899. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. return
  2903. }
  2904. userJSONBytes2, _ := json.Marshal(respJSON2)
  2905. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2906. utils.ErrorLog("解析失败:%v", err)
  2907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2908. return
  2909. }
  2910. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2911. result1, result2 := service.AHyb3507(struct3507)
  2912. saveLog(result2, result1, "3507", "3507")
  2913. var respJSON2 map[string]interface{}
  2914. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2917. return
  2918. }
  2919. userJSONBytes2, _ := json.Marshal(respJSON2)
  2920. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2921. utils.ErrorLog("解析失败:%v", err)
  2922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2923. return
  2924. }
  2925. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2926. data := make(map[string]interface{})
  2927. data["struct_3507s"] = struct3507
  2928. client := &http.Client{}
  2929. bytesData, _ := json.Marshal(data)
  2930. var req *http.Request
  2931. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2932. resp, _ := client.Do(req)
  2933. defer resp.Body.Close()
  2934. body, ioErr := ioutil.ReadAll(resp.Body)
  2935. if ioErr != nil {
  2936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2937. }
  2938. var respJSON map[string]interface{}
  2939. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2941. }
  2942. var resSix10265 ResultSix10265 //1101结果
  2943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2944. result, _ := json.Marshal(respJSON)
  2945. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2946. utils.ErrorLog("解析失败:%v", err)
  2947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2948. return
  2949. }
  2950. res.InfRefmsgid = resSix10265.InfRefmsgid
  2951. res.ErrMsg = resSix10265.ErrMsg
  2952. res.Cainfo = resSix10265.Cainfo
  2953. res.WarnMsg = resSix10265.WarnMsg
  2954. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2955. res.Infcode = infocode
  2956. }
  2957. if res.Infcode == 0 {
  2958. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2959. item.IsSale = 0
  2960. item.SaleDate = ""
  2961. item.Bchno = ""
  2962. service.SaveDF(item)
  2963. } else {
  2964. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2965. }
  2966. }
  2967. }
  2968. c.ServeSuccessJSON(map[string]interface{}{
  2969. "msg": "删除销售数据成功",
  2970. })
  2971. }
  2972. // 删除
  2973. func (c *HisApiController) DeleteXSandBGThree() {
  2974. id, _ := c.GetInt64("id")
  2975. admin_user_id, _ := c.GetInt64("admin_user_id")
  2976. advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  2977. var flows []*models.DrugFlow
  2978. for _, item := range advicelist {
  2979. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2980. flows = append(flows, flow...)
  2981. }
  2982. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2983. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2984. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2985. var err []string
  2986. for _, item := range flows {
  2987. if item.IsSale == 1 {
  2988. var res FJ3507Result
  2989. var struct3507 models.Struct3507
  2990. struct3507.FixmedinsBchno = item.Bchno
  2991. struct3507.InvDataType = "4"
  2992. struct3507.Opter = roles.UserName
  2993. struct3507.OrgName = miConfig.OrgName
  2994. struct3507.AccessKey = miConfig.AccessKey
  2995. struct3507.RequestUrl = miConfig.Url
  2996. struct3507.FixmedinsCode = miConfig.Code
  2997. struct3507.SecretKey = miConfig.SecretKey
  2998. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2999. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3000. struct3507.Url = miConfig.Url
  3001. struct3507.AppId = miConfig.Cainfo
  3002. struct3507.AppSecret = miConfig.AppSecret
  3003. struct3507.Enckey = miConfig.EncKey
  3004. struct3507.SignKey = miConfig.SignKey
  3005. struct3507.SecretKey = miConfig.SecretKey
  3006. if miConfig.MdtrtareaAdmvs == "350500" {
  3007. result, result1, _ := service.FJyb3507(struct3507)
  3008. saveLog(result, result1, "3507", "3507")
  3009. var respJSON2 map[string]interface{}
  3010. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3013. return
  3014. }
  3015. userJSONBytes2, _ := json.Marshal(respJSON2)
  3016. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3017. utils.ErrorLog("解析失败:%v", err)
  3018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3019. return
  3020. }
  3021. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3022. data := make(map[string]interface{})
  3023. data["struct_3507s"] = struct3507
  3024. client := &http.Client{}
  3025. bytesData, _ := json.Marshal(data)
  3026. var req *http.Request
  3027. if miConfig.MdtrtareaAdmvs == "320830" {
  3028. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3029. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3030. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3031. } else {
  3032. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3033. }
  3034. resp, _ := client.Do(req)
  3035. defer resp.Body.Close()
  3036. body, ioErr := ioutil.ReadAll(resp.Body)
  3037. if ioErr != nil {
  3038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3039. }
  3040. var respJSON map[string]interface{}
  3041. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3044. return
  3045. }
  3046. var resSix10265 ResultSix10265 //1101结果
  3047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3048. result, _ := json.Marshal(respJSON)
  3049. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3050. utils.ErrorLog("解析失败:%v", err)
  3051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3052. return
  3053. }
  3054. res.InfRefmsgid = resSix10265.InfRefmsgid
  3055. //res.Output = resSix10265.Output
  3056. res.ErrMsg = resSix10265.ErrMsg
  3057. res.Cainfo = resSix10265.Cainfo
  3058. res.WarnMsg = resSix10265.WarnMsg
  3059. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3060. res.Infcode = infocode
  3061. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3062. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3063. saveLog(result2, result1, "3507", "3507")
  3064. var respJSON2 map[string]interface{}
  3065. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3068. return
  3069. }
  3070. userJSONBytes2, _ := json.Marshal(respJSON2)
  3071. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3072. utils.ErrorLog("解析失败:%v", err)
  3073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3074. return
  3075. }
  3076. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3077. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3078. saveLog(result2, result1, "3507", "3507")
  3079. var respJSON2 map[string]interface{}
  3080. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3083. return
  3084. }
  3085. userJSONBytes2, _ := json.Marshal(respJSON2)
  3086. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3087. utils.ErrorLog("解析失败:%v", err)
  3088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3089. return
  3090. }
  3091. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3092. result1, result2 := service.Jxyb3507(struct3507)
  3093. saveLog(result2, result1, "3507", "3507")
  3094. var respJSON2 map[string]interface{}
  3095. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3098. return
  3099. }
  3100. userJSONBytes2, _ := json.Marshal(respJSON2)
  3101. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3102. utils.ErrorLog("解析失败:%v", err)
  3103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3104. return
  3105. }
  3106. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3107. result1, result2 := service.AHyb3507(struct3507)
  3108. saveLog(result2, result1, "3507", "3507")
  3109. var respJSON2 map[string]interface{}
  3110. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3113. return
  3114. }
  3115. userJSONBytes2, _ := json.Marshal(respJSON2)
  3116. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3117. utils.ErrorLog("解析失败:%v", err)
  3118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3119. return
  3120. }
  3121. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3122. data := make(map[string]interface{})
  3123. data["struct_3507s"] = struct3507
  3124. client := &http.Client{}
  3125. bytesData, _ := json.Marshal(data)
  3126. var req *http.Request
  3127. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3128. resp, _ := client.Do(req)
  3129. defer resp.Body.Close()
  3130. body, ioErr := ioutil.ReadAll(resp.Body)
  3131. if ioErr != nil {
  3132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3133. }
  3134. var respJSON map[string]interface{}
  3135. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3137. }
  3138. var resSix10265 ResultSix10265 //1101结果
  3139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3140. result, _ := json.Marshal(respJSON)
  3141. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3142. utils.ErrorLog("解析失败:%v", err)
  3143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. return
  3145. }
  3146. res.InfRefmsgid = resSix10265.InfRefmsgid
  3147. res.ErrMsg = resSix10265.ErrMsg
  3148. res.Cainfo = resSix10265.Cainfo
  3149. res.WarnMsg = resSix10265.WarnMsg
  3150. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3151. res.Infcode = infocode
  3152. }
  3153. if res.Infcode == 0 {
  3154. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3155. item.IsSale = 0
  3156. item.SaleDate = ""
  3157. item.Bchno = ""
  3158. service.SaveDF(item)
  3159. } else {
  3160. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3161. }
  3162. }
  3163. }
  3164. c.ServeSuccessJSON(map[string]interface{}{
  3165. "msg": "删除销售数据成功",
  3166. })
  3167. }
  3168. // 获取当天起止时间戳
  3169. func GetNowTime() (int64, int64) {
  3170. t := time.Now()
  3171. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3172. timesamp := addTime.Unix()
  3173. return timesamp, timesamp + 86399
  3174. }
  3175. func (c *HisApiController) ChangeDrugfour() {
  3176. patient_id, _ := c.GetInt64("patient_id")
  3177. admin_user_id, _ := c.GetInt64("admin_user_id")
  3178. times := c.GetString("time", "")
  3179. timeLayout := "2006-01-02"
  3180. loc, _ := time.LoadLocation("Local")
  3181. var stime, etime int64
  3182. if times == "" {
  3183. stime, etime = GetNowTime()
  3184. } else {
  3185. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3186. stime = stmp.Unix()
  3187. etime = stime + 86399
  3188. }
  3189. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3190. var flows []*models.DrugFlow
  3191. for _, item := range advicelist {
  3192. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3193. flows = append(flows, flow...)
  3194. }
  3195. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3196. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3197. var err []string
  3198. for _, item := range flows {
  3199. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3200. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3201. if prescription.OrderStatus == 2 {
  3202. if item.IsSale == 0 {
  3203. var res FJ3507Result
  3204. var res3507for10188 FJ3507ResultFor10188
  3205. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3206. //进行商品销售接口
  3207. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3208. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3209. var respJSON3 map[string]interface{}
  3210. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3213. return
  3214. }
  3215. userJSONBytes3, _ := json.Marshal(respJSON3)
  3216. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3217. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3218. utils.ErrorLog("解析失败:%v", err)
  3219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3220. return
  3221. }
  3222. //if res3507for10188.Infcode
  3223. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3224. //res.Output = resSix10265.Output
  3225. res.ErrMsg = res3507for10188.ErrMsg
  3226. res.Cainfo = res3507for10188.Cainfo
  3227. res.WarnMsg = res3507for10188.WarnMsg
  3228. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3229. res.Infcode = infocode
  3230. } else {
  3231. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3232. utils.ErrorLog("解析失败:%v", err)
  3233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3234. return
  3235. }
  3236. }
  3237. if res.Infcode == 0 {
  3238. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3239. item.IsSale = 1
  3240. item.Bchno = number
  3241. item.SaleDate = time.Now().Format("2006-01-02")
  3242. service.SaveDF(item)
  3243. } else {
  3244. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3245. }
  3246. }
  3247. } else { //还没结,提示用户去结算,并药品追溯上传
  3248. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3249. }
  3250. }
  3251. }
  3252. str := strings.Join(err, " ")
  3253. saveLog(str, str, "3505", "3505自动上传日志")
  3254. c.ServeSuccessJSON(map[string]interface{}{
  3255. "status": "1",
  3256. "msg": err,
  3257. })
  3258. }
  3259. func (c *HisApiController) ChangeDrugFive() {
  3260. id := c.GetString("id")
  3261. ids := strings.Split(id, ",")
  3262. admin_user_id, _ := c.GetInt64("admin_user_id")
  3263. var errs []string
  3264. //校验gui'ge
  3265. for _, value := range ids {
  3266. intValue, _ := strconv.ParseInt(value, 10, 64)
  3267. //file := strconv.FormatInt(int64(num), 10)
  3268. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3269. var flows []*models.DrugFlow
  3270. for _, item := range advicelist {
  3271. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3272. flows = append(flows, flow...)
  3273. }
  3274. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3275. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3276. for _, item := range flows {
  3277. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3278. if prescription.OrderStatus != 2 {
  3279. // 将时间戳转换为time.Time类型
  3280. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3281. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3282. errs = append(errs, patient.Name + "的" + t.Format("2006-01-02") +" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"医嘱没结算无法上传")
  3283. }
  3284. if len(item.HisDoctorAdviceInfo.DrugCode) > 0{
  3285. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3286. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3287. codes := strings.Split(item.HisDoctorAdviceInfo.DrugCode, ",")
  3288. for _, code := range codes{
  3289. if len(code) > 0 {
  3290. if len(code) != 20 {
  3291. errs = append(errs,patient.Name + "的" + t.Format("2006-01-02") +" 的" + item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  3292. }
  3293. if IsDigit(code) == false {
  3294. errs = append(errs,patient.Name + "的" + t.Format("2006-01-02") +" 的" + item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  3295. }
  3296. }
  3297. }
  3298. }
  3299. }
  3300. }
  3301. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3302. if len(errs) > 0 {
  3303. c.ServeSuccessJSON(map[string]interface{}{
  3304. "failed_code": -10,
  3305. "msg": errs,
  3306. })
  3307. return
  3308. }
  3309. for _, value := range ids {
  3310. intValue, _ := strconv.ParseInt(value, 10, 64)
  3311. //file := strconv.FormatInt(int64(num), 10)
  3312. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3313. var flows []*models.DrugFlow
  3314. for _, item := range advicelist {
  3315. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3316. flows = append(flows, flow...)
  3317. }
  3318. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3319. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3320. for _, item := range flows {
  3321. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3322. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3323. if prescription.OrderStatus == 2 {
  3324. if item.IsSale == 0 {
  3325. var res FJ3507Result
  3326. var res3507for10188 FJ3507ResultFor10188
  3327. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3328. //进行商品销售接口
  3329. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3330. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3331. var respJSON3 map[string]interface{}
  3332. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3335. return
  3336. }
  3337. userJSONBytes3, _ := json.Marshal(respJSON3)
  3338. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3339. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3340. utils.ErrorLog("解析失败:%v", err)
  3341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3342. return
  3343. }
  3344. //if res3507for10188.Infcode
  3345. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3346. //res.Output = resSix10265.Output
  3347. res.ErrMsg = res3507for10188.ErrMsg
  3348. res.Cainfo = res3507for10188.Cainfo
  3349. res.WarnMsg = res3507for10188.WarnMsg
  3350. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3351. res.Infcode = infocode
  3352. } else {
  3353. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3354. utils.ErrorLog("解析失败:%v", err)
  3355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3356. return
  3357. }
  3358. }
  3359. if res.Infcode == 0 {
  3360. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3361. item.IsSale = 1
  3362. item.Bchno = number
  3363. item.SaleDate = time.Now().Format("2006-01-02")
  3364. service.SaveDF(item)
  3365. } else {
  3366. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3367. }
  3368. }
  3369. } else { //还没结,提示用户去结算,并药品追溯上传
  3370. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3371. }
  3372. }
  3373. }
  3374. str := strings.Join(errs, " ")
  3375. saveLog(str, str, "3505", "3505自动上传日志")
  3376. }
  3377. c.ServeSuccessJSON(map[string]interface{}{
  3378. "status": "1",
  3379. "msg": errs,
  3380. })
  3381. }
  3382. //func (c *HisApiController) ChangeDrugfour() {
  3383. // patient_id, _ := c.GetInt64("patient_id")
  3384. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3385. // //id_arr := strings.Split(ids, ",")
  3386. // times := c.GetString("time", "")
  3387. // timeLayout := "2006-01-02"
  3388. // loc, _ := time.LoadLocation("Local")
  3389. // var stime, etime int64
  3390. // if times == "" {
  3391. // stime, etime = GetNowTime()
  3392. // } else {
  3393. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3394. // stime = stmp.Unix()
  3395. // etime = stime + 86399
  3396. // }
  3397. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3398. // var flows []*models.DrugFlow
  3399. // for _, item := range advicelist {
  3400. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3401. // flows = append(flows, flow...)
  3402. // }
  3403. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3404. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3405. // var err []string
  3406. //
  3407. // for _, item := range flows {
  3408. // var res3 ResultSix
  3409. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3410. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3411. // if prescription.OrderStatus == 2 {
  3412. // //已经结算
  3413. // //判断是否已经销售
  3414. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3415. // //是否已经变更 1是 0否
  3416. // if item.IsChange == 0 { //没变更,进行变更操作
  3417. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3418. //
  3419. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3420. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3421. // var respJSON3 map[string]interface{}
  3422. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3423. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3425. // return
  3426. // }
  3427. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3428. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3429. // utils.ErrorLog("解析失败:%v", err)
  3430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3431. // return
  3432. // }
  3433. // if res3.Infcode == 0 {
  3434. // item.IsChange = 1
  3435. // item.BgBchno = bg_number
  3436. // service.SaveDF2(item)
  3437. // } else {
  3438. //
  3439. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3440. // }
  3441. // }
  3442. // } else { //没销售,
  3443. // var res FJ3507Result
  3444. // var res3507for10188 FJ3507ResultFor10188
  3445. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3446. //
  3447. // //进行商品销售接口
  3448. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3449. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3450. // var respJSON3 map[string]interface{}
  3451. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3452. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3454. // return
  3455. // }
  3456. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3457. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3458. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3459. // utils.ErrorLog("解析失败:%v", err)
  3460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. // return
  3462. // }
  3463. // //if res3507for10188.Infcode
  3464. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3465. // //res.Output = resSix10265.Output
  3466. // res.ErrMsg = res3507for10188.ErrMsg
  3467. // res.Cainfo = res3507for10188.Cainfo
  3468. // res.WarnMsg = res3507for10188.WarnMsg
  3469. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3470. // res.Infcode = infocode
  3471. // } else {
  3472. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3473. // utils.ErrorLog("解析失败:%v", err)
  3474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3475. // return
  3476. // }
  3477. //
  3478. // }
  3479. // if res.Infcode == 0 {
  3480. // item.IsSale = 1
  3481. // item.Bchno = number
  3482. // item.SaleDate = time.Now().Format("2006-01-02")
  3483. //
  3484. // err5 := service.SaveDF(item)
  3485. // if err5 == nil {
  3486. // if item.IsChange == 0 { //没变更,进行变更操作
  3487. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3488. //
  3489. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3490. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3491. //
  3492. // var respJSON3 map[string]interface{}
  3493. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3494. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3496. // return
  3497. // }
  3498. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3499. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3500. // utils.ErrorLog("解析失败:%v", err)
  3501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3502. // return
  3503. // }
  3504. // //if res3507for10188.Infcode
  3505. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3506. // //res.Output = resSix10265.Output
  3507. // res3.ErrMsg = res3507for10188.ErrMsg
  3508. // res3.Cainfo = res3507for10188.Cainfo
  3509. // res3.WarnMsg = res3507for10188.WarnMsg
  3510. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3511. // res3.Infcode = infocode
  3512. // } else {
  3513. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3514. // utils.ErrorLog("解析失败:%v", err)
  3515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3516. // return
  3517. // }
  3518. // }
  3519. // if res3.Infcode == 0 {
  3520. // item.IsChange = 1
  3521. // item.BgBchno = bg_number
  3522. // service.SaveDF2(item)
  3523. // } else {
  3524. //
  3525. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3526. // }
  3527. // }
  3528. // }
  3529. // } else {
  3530. //
  3531. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3532. // }
  3533. // }
  3534. //
  3535. // } else { //还没结,提示用户去结算,并药品追溯上传
  3536. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3537. // }
  3538. // }
  3539. // }
  3540. // if len(err) == 0 {
  3541. // c.ServeSuccessJSON(map[string]interface{}{
  3542. // "msg": "销售变更成功",
  3543. // })
  3544. // } else {
  3545. // c.ServeSuccessJSON(map[string]interface{}{
  3546. // "failed_code": -10,
  3547. // "msg": err,
  3548. // })
  3549. // }
  3550. //}
  3551. func (c *HisApiController) ChangeDrug() {
  3552. ids := c.GetString("ids")
  3553. id_arr := strings.Split(ids, ",")
  3554. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3555. admin_user_id, _ := c.GetInt64("admin_user_id")
  3556. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3557. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3558. var err []string
  3559. for _, item := range flows {
  3560. var res3 ResultSix
  3561. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3562. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3563. if prescription.OrderStatus == 2 {
  3564. //已经结算
  3565. //判断是否已经销售
  3566. if item.IsSale == 1 { //是否已经销售,1是 0否
  3567. //是否已经变更 1是 0否
  3568. if item.IsChange == 0 { //没变更,进行变更操作
  3569. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3570. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3571. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3572. var respJSON3 map[string]interface{}
  3573. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3576. return
  3577. }
  3578. userJSONBytes3, _ := json.Marshal(respJSON3)
  3579. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3580. utils.ErrorLog("解析失败:%v", err)
  3581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3582. return
  3583. }
  3584. if res3.Infcode == 0 {
  3585. item.IsChange = 1
  3586. item.BgBchno = bg_number
  3587. service.SaveDF2(item)
  3588. } else {
  3589. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3590. }
  3591. }
  3592. } else { //没销售,
  3593. var res FJ3507Result
  3594. var res3507for10188 FJ3507ResultFor10188
  3595. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3596. //进行商品销售接口
  3597. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3598. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3599. var respJSON3 map[string]interface{}
  3600. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3603. return
  3604. }
  3605. userJSONBytes3, _ := json.Marshal(respJSON3)
  3606. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3607. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3608. utils.ErrorLog("解析失败:%v", err)
  3609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3610. return
  3611. }
  3612. //if res3507for10188.Infcode
  3613. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3614. //res.Output = resSix10265.Output
  3615. res.ErrMsg = res3507for10188.ErrMsg
  3616. res.Cainfo = res3507for10188.Cainfo
  3617. res.WarnMsg = res3507for10188.WarnMsg
  3618. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3619. res.Infcode = infocode
  3620. } else {
  3621. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3622. utils.ErrorLog("解析失败:%v", err)
  3623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3624. return
  3625. }
  3626. }
  3627. if res.Infcode == 0 {
  3628. item.IsSale = 1
  3629. item.Bchno = number
  3630. item.SaleDate = time.Now().Format("2006-01-02")
  3631. err5 := service.SaveDF(item)
  3632. if err5 == nil {
  3633. if item.IsChange == 0 { //没变更,进行变更操作
  3634. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3635. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3636. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3637. var respJSON3 map[string]interface{}
  3638. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3641. return
  3642. }
  3643. userJSONBytes3, _ := json.Marshal(respJSON3)
  3644. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3645. utils.ErrorLog("解析失败:%v", err)
  3646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3647. return
  3648. }
  3649. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3650. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3651. utils.ErrorLog("解析失败:%v", err)
  3652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3653. return
  3654. }
  3655. //if res3507for10188.Infcode
  3656. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3657. //res.Output = resSix10265.Output
  3658. res3.ErrMsg = res3507for10188.ErrMsg
  3659. res3.Cainfo = res3507for10188.Cainfo
  3660. res3.WarnMsg = res3507for10188.WarnMsg
  3661. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3662. res3.Infcode = infocode
  3663. } else {
  3664. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3665. utils.ErrorLog("解析失败:%v", err)
  3666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3667. return
  3668. }
  3669. }
  3670. if res3.Infcode == 0 {
  3671. item.IsChange = 1
  3672. item.BgBchno = bg_number
  3673. service.SaveDF2(item)
  3674. } else {
  3675. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3676. }
  3677. }
  3678. }
  3679. } else {
  3680. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3681. }
  3682. }
  3683. } else { //还没结算
  3684. var res3507for10188 FJ3507ResultFor10188
  3685. if item.IsChange == 0 { //没变更,进行变更操作
  3686. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3687. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3688. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3689. var respJSON3 map[string]interface{}
  3690. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3693. return
  3694. }
  3695. userJSONBytes3, _ := json.Marshal(respJSON3)
  3696. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3697. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3698. utils.ErrorLog("解析失败:%v", err)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. //if res3507for10188.Infcode
  3703. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3704. //res.Output = resSix10265.Output
  3705. res3.ErrMsg = res3507for10188.ErrMsg
  3706. res3.Cainfo = res3507for10188.Cainfo
  3707. res3.WarnMsg = res3507for10188.WarnMsg
  3708. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3709. res3.Infcode = infocode
  3710. } else {
  3711. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3712. utils.ErrorLog("解析失败:%v", err)
  3713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3714. return
  3715. }
  3716. }
  3717. if res3.Infcode == 0 {
  3718. item.IsChange = 1
  3719. item.BgBchno = bg_number
  3720. service.SaveDF2(item)
  3721. } else {
  3722. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3723. }
  3724. }
  3725. }
  3726. } else if item.ConsumableType == 7 {
  3727. var res3507for10188 FJ3507ResultFor10188
  3728. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3729. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3730. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3731. //判断是否已经销售
  3732. if item.IsSale == 2 { //是否已经销售,1是 0否
  3733. //是否已经变更 1是 0否
  3734. if item.IsChange == 0 { //没变更,进行变更操作
  3735. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3736. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3737. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3738. var respJSON3 map[string]interface{}
  3739. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3742. return
  3743. }
  3744. userJSONBytes3, _ := json.Marshal(respJSON3)
  3745. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3746. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3747. utils.ErrorLog("解析失败:%v", err)
  3748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3749. return
  3750. }
  3751. //if res3507for10188.Infcode
  3752. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3753. //res.Output = resSix10265.Output
  3754. res3.ErrMsg = res3507for10188.ErrMsg
  3755. res3.Cainfo = res3507for10188.Cainfo
  3756. res3.WarnMsg = res3507for10188.WarnMsg
  3757. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3758. res3.Infcode = infocode
  3759. } else {
  3760. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3761. utils.ErrorLog("解析失败:%v", err)
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. return
  3764. }
  3765. }
  3766. if res3.Infcode == 0 {
  3767. item.IsChange = 1
  3768. item.BgBchno = bg_number
  3769. service.SaveDF2(item)
  3770. } else {
  3771. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3772. }
  3773. }
  3774. } else { //没销售,
  3775. //进行商品销售退货接口
  3776. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3777. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3778. saveLog(result111, result222, "3506", "销售退货")
  3779. var res7 FJ3507Result
  3780. //进行商品销售接口
  3781. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3782. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3783. var respJSON3 map[string]interface{}
  3784. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3787. return
  3788. }
  3789. userJSONBytes3, _ := json.Marshal(respJSON3)
  3790. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3791. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3792. utils.ErrorLog("解析失败:%v", err)
  3793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3794. return
  3795. }
  3796. //if res3507for10188.Infcode
  3797. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3798. //res.Output = resSix10265.Output
  3799. res7.ErrMsg = res3507for10188.ErrMsg
  3800. res7.Cainfo = res3507for10188.Cainfo
  3801. res7.WarnMsg = res3507for10188.WarnMsg
  3802. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3803. res7.Infcode = infocode
  3804. } else {
  3805. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3806. utils.ErrorLog("解析失败:%v", err)
  3807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3808. return
  3809. }
  3810. }
  3811. if res7.Infcode == 0 {
  3812. item.IsSale = 2
  3813. item.SaleDate = item.SaleDate
  3814. item.Bchno = number
  3815. service.SaveDF(item)
  3816. if item.IsChange == 0 { //没变更,进行变更操作
  3817. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3818. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3819. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3820. var respJSON3 map[string]interface{}
  3821. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3824. return
  3825. }
  3826. userJSONBytes3, _ := json.Marshal(respJSON3)
  3827. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3828. // utils.ErrorLog("解析失败:%v", err)
  3829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3830. // return
  3831. //}
  3832. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3833. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3834. utils.ErrorLog("解析失败:%v", err)
  3835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3836. return
  3837. }
  3838. //if res3507for10188.Infcode
  3839. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3840. //res.Output = resSix10265.Output
  3841. res3.ErrMsg = res3507for10188.ErrMsg
  3842. res3.Cainfo = res3507for10188.Cainfo
  3843. res3.WarnMsg = res3507for10188.WarnMsg
  3844. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3845. res3.Infcode = infocode
  3846. } else {
  3847. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3848. utils.ErrorLog("解析失败:%v", err)
  3849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. return
  3851. }
  3852. }
  3853. if res3.Infcode == 0 {
  3854. item.IsChange = 1
  3855. item.BgBchno = bg_number
  3856. service.SaveDF2(item)
  3857. } else {
  3858. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3859. }
  3860. }
  3861. } else {
  3862. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3863. }
  3864. }
  3865. } else { //还没结算
  3866. if item.IsChange == 0 { //没变更,进行变更操作
  3867. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3868. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3869. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3870. var respJSON3 map[string]interface{}
  3871. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3874. return
  3875. }
  3876. userJSONBytes3, _ := json.Marshal(respJSON3)
  3877. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3878. // utils.ErrorLog("解析失败:%v", err)
  3879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. // return
  3881. //}
  3882. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3883. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3884. utils.ErrorLog("解析失败:%v", err)
  3885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. return
  3887. }
  3888. //if res3507for10188.Infcode
  3889. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3890. //res.Output = resSix10265.Output
  3891. res3.ErrMsg = res3507for10188.ErrMsg
  3892. res3.Cainfo = res3507for10188.Cainfo
  3893. res3.WarnMsg = res3507for10188.WarnMsg
  3894. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3895. res3.Infcode = infocode
  3896. } else {
  3897. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3898. utils.ErrorLog("解析失败:%v", err)
  3899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3900. return
  3901. }
  3902. }
  3903. if res3.Infcode == 0 {
  3904. item.IsChange = 1
  3905. item.BgBchno = bg_number
  3906. service.SaveDF2(item)
  3907. } else {
  3908. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3909. }
  3910. }
  3911. }
  3912. }
  3913. }
  3914. if len(err) == 0 {
  3915. c.ServeSuccessJSON(map[string]interface{}{
  3916. "msg": "销售变更成功",
  3917. })
  3918. } else {
  3919. c.ServeSuccessJSON(map[string]interface{}{
  3920. "failed_code": -10,
  3921. "msg": err,
  3922. })
  3923. }
  3924. }
  3925. func (c *HisApiController) ChangeDrugtwo() {
  3926. //ids := c.GetString("ids")
  3927. //id_arr := strings.Split(ids, ",")
  3928. flows, _ := service.GetNewDrugFlowInfothree123()
  3929. admin_user_id, _ := c.GetInt64("admin_user_id")
  3930. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3931. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3932. var err []string
  3933. for _, item := range flows {
  3934. var res3 ResultSix
  3935. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3936. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3937. if prescription.OrderStatus == 2 {
  3938. //已经结算
  3939. //判断是否已经销售
  3940. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3941. // //是否已经变更 1是 0否
  3942. // if item.IsChange == 0 { //没变更,进行变更操作
  3943. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3944. //
  3945. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3946. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3947. // var respJSON3 map[string]interface{}
  3948. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3949. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3951. // return
  3952. // }
  3953. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3954. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3955. // utils.ErrorLog("解析失败:%v", err)
  3956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3957. // return
  3958. // }
  3959. // if res3.Infcode == 0 {
  3960. // item.IsChange = 1
  3961. // item.BgBchno = bg_number
  3962. // service.SaveDF2(item)
  3963. // } else {
  3964. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3965. // }
  3966. // }
  3967. //}
  3968. //else
  3969. { //没销售,
  3970. var res FJ3507Result
  3971. var res3507for10188 FJ3507ResultFor10188
  3972. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3973. //进行商品销售接口
  3974. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3975. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3976. var respJSON3 map[string]interface{}
  3977. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3980. return
  3981. }
  3982. userJSONBytes3, _ := json.Marshal(respJSON3)
  3983. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3984. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3985. utils.ErrorLog("解析失败:%v", err)
  3986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3987. return
  3988. }
  3989. //if res3507for10188.Infcode
  3990. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3991. //res.Output = resSix10265.Output
  3992. res.ErrMsg = res3507for10188.ErrMsg
  3993. res.Cainfo = res3507for10188.Cainfo
  3994. res.WarnMsg = res3507for10188.WarnMsg
  3995. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3996. res.Infcode = infocode
  3997. } else {
  3998. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3999. utils.ErrorLog("解析失败:%v", err)
  4000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4001. return
  4002. }
  4003. }
  4004. if res.Infcode == 0 {
  4005. item.IsSale = 1
  4006. item.Bchno = number
  4007. item.SaleDate = time.Now().Format("2006-01-02")
  4008. service.SaveDF(item)
  4009. //if err5 == nil {
  4010. // if item.IsChange == 0 { //没变更,进行变更操作
  4011. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4012. //
  4013. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4014. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4015. //
  4016. // var respJSON3 map[string]interface{}
  4017. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4018. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. // return
  4021. // }
  4022. //
  4023. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4024. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4025. // utils.ErrorLog("解析失败:%v", err)
  4026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4027. // return
  4028. // }
  4029. // //if res3507for10188.Infcode
  4030. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4031. // //res.Output = resSix10265.Output
  4032. // res3.ErrMsg = res3507for10188.ErrMsg
  4033. // res3.Cainfo = res3507for10188.Cainfo
  4034. // res3.WarnMsg = res3507for10188.WarnMsg
  4035. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4036. // res3.Infcode = infocode
  4037. // } else {
  4038. //
  4039. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4040. // utils.ErrorLog("解析失败:%v", err)
  4041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4042. // return
  4043. // }
  4044. //
  4045. // }
  4046. //
  4047. // if res3.Infcode == 0 {
  4048. // item.IsChange = 1
  4049. // item.BgBchno = bg_number
  4050. // service.SaveDF2(item)
  4051. // } else {
  4052. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4053. // }
  4054. // }
  4055. //}
  4056. } else {
  4057. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4058. }
  4059. }
  4060. } else { //还没结算
  4061. var res3507for10188 FJ3507ResultFor10188
  4062. if item.IsChange == 0 { //没变更,进行变更操作
  4063. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4064. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4065. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4066. var respJSON3 map[string]interface{}
  4067. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4070. return
  4071. }
  4072. userJSONBytes3, _ := json.Marshal(respJSON3)
  4073. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4074. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4075. utils.ErrorLog("解析失败:%v", err)
  4076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4077. return
  4078. }
  4079. //if res3507for10188.Infcode
  4080. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4081. //res.Output = resSix10265.Output
  4082. res3.ErrMsg = res3507for10188.ErrMsg
  4083. res3.Cainfo = res3507for10188.Cainfo
  4084. res3.WarnMsg = res3507for10188.WarnMsg
  4085. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4086. res3.Infcode = infocode
  4087. } else {
  4088. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4089. utils.ErrorLog("解析失败:%v", err)
  4090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4091. return
  4092. }
  4093. }
  4094. if res3.Infcode == 0 {
  4095. item.IsChange = 1
  4096. item.BgBchno = bg_number
  4097. service.SaveDF2(item)
  4098. } else {
  4099. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4100. }
  4101. }
  4102. }
  4103. }
  4104. //if item.ConsumableType == 7 {
  4105. // var res3507for10188 FJ3507ResultFor10188
  4106. //
  4107. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4108. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4109. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4110. // //判断是否已经销售
  4111. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4112. // //是否已经变更 1是 0否
  4113. // if item.IsChange == 0 { //没变更,进行变更操作
  4114. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4115. //
  4116. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4117. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4118. //
  4119. // var respJSON3 map[string]interface{}
  4120. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4121. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4122. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4123. // return
  4124. // }
  4125. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4126. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4127. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4128. // utils.ErrorLog("解析失败:%v", err)
  4129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4130. // return
  4131. // }
  4132. // //if res3507for10188.Infcode
  4133. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4134. // //res.Output = resSix10265.Output
  4135. // res3.ErrMsg = res3507for10188.ErrMsg
  4136. // res3.Cainfo = res3507for10188.Cainfo
  4137. // res3.WarnMsg = res3507for10188.WarnMsg
  4138. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4139. // res3.Infcode = infocode
  4140. // } else {
  4141. //
  4142. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4143. // utils.ErrorLog("解析失败:%v", err)
  4144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4145. // return
  4146. // }
  4147. //
  4148. // }
  4149. // if res3.Infcode == 0 {
  4150. // item.IsChange = 1
  4151. // item.BgBchno = bg_number
  4152. // service.SaveDF2(item)
  4153. // } else {
  4154. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4155. // }
  4156. // }
  4157. // } else { //没销售,
  4158. // //进行商品销售退货接口
  4159. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4160. //
  4161. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4162. // saveLog(result111, result222, "3506", "销售退货")
  4163. // var res7 FJ3507Result
  4164. //
  4165. // //进行商品销售接口
  4166. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4167. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4168. // var respJSON3 map[string]interface{}
  4169. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4170. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4172. // return
  4173. // }
  4174. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4175. //
  4176. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4177. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4178. // utils.ErrorLog("解析失败:%v", err)
  4179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4180. // return
  4181. // }
  4182. // //if res3507for10188.Infcode
  4183. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4184. // //res.Output = resSix10265.Output
  4185. // res7.ErrMsg = res3507for10188.ErrMsg
  4186. // res7.Cainfo = res3507for10188.Cainfo
  4187. // res7.WarnMsg = res3507for10188.WarnMsg
  4188. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4189. // res7.Infcode = infocode
  4190. // } else {
  4191. //
  4192. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4193. // utils.ErrorLog("解析失败:%v", err)
  4194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4195. // return
  4196. // }
  4197. //
  4198. // }
  4199. // if res7.Infcode == 0 {
  4200. // item.IsSale = 2
  4201. // item.SaleDate = item.SaleDate
  4202. // item.Bchno = number
  4203. // service.SaveDF(item)
  4204. // if item.IsChange == 0 { //没变更,进行变更操作
  4205. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4206. //
  4207. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4208. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4209. //
  4210. // var respJSON3 map[string]interface{}
  4211. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4212. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. // return
  4215. // }
  4216. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4217. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4218. // // utils.ErrorLog("解析失败:%v", err)
  4219. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4220. // // return
  4221. // //}
  4222. //
  4223. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4224. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4225. // utils.ErrorLog("解析失败:%v", err)
  4226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. // return
  4228. // }
  4229. // //if res3507for10188.Infcode
  4230. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4231. // //res.Output = resSix10265.Output
  4232. // res3.ErrMsg = res3507for10188.ErrMsg
  4233. // res3.Cainfo = res3507for10188.Cainfo
  4234. // res3.WarnMsg = res3507for10188.WarnMsg
  4235. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4236. // res3.Infcode = infocode
  4237. // } else {
  4238. //
  4239. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4240. // utils.ErrorLog("解析失败:%v", err)
  4241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4242. // return
  4243. // }
  4244. //
  4245. // }
  4246. // if res3.Infcode == 0 {
  4247. // item.IsChange = 1
  4248. // item.BgBchno = bg_number
  4249. // service.SaveDF2(item)
  4250. // } else {
  4251. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4252. // }
  4253. // }
  4254. // } else {
  4255. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4256. // }
  4257. // }
  4258. // } else { //还没结算
  4259. // if item.IsChange == 0 { //没变更,进行变更操作
  4260. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4261. //
  4262. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4263. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4264. //
  4265. // var respJSON3 map[string]interface{}
  4266. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4267. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4269. // return
  4270. // }
  4271. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4272. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4273. // // utils.ErrorLog("解析失败:%v", err)
  4274. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4275. // // return
  4276. // //}
  4277. //
  4278. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4279. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4280. // utils.ErrorLog("解析失败:%v", err)
  4281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4282. // return
  4283. // }
  4284. // //if res3507for10188.Infcode
  4285. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4286. // //res.Output = resSix10265.Output
  4287. // res3.ErrMsg = res3507for10188.ErrMsg
  4288. // res3.Cainfo = res3507for10188.Cainfo
  4289. // res3.WarnMsg = res3507for10188.WarnMsg
  4290. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4291. // res3.Infcode = infocode
  4292. // } else {
  4293. //
  4294. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4295. // utils.ErrorLog("解析失败:%v", err)
  4296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4297. // return
  4298. // }
  4299. //
  4300. // }
  4301. // if res3.Infcode == 0 {
  4302. // item.IsChange = 1
  4303. // item.BgBchno = bg_number
  4304. // service.SaveDF2(item)
  4305. // } else {
  4306. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4307. // }
  4308. // }
  4309. // }
  4310. //}
  4311. }
  4312. if len(err) == 0 {
  4313. c.ServeSuccessJSON(map[string]interface{}{
  4314. "msg": "销售变更成功",
  4315. })
  4316. } else {
  4317. c.ServeSuccessJSON(map[string]interface{}{
  4318. "failed_code": -10,
  4319. "msg": err,
  4320. })
  4321. }
  4322. }
  4323. func (c *HisApiController) ChangeDrugthree() {
  4324. //ids := c.GetString("ids")
  4325. //id_arr := strings.Split(ids, ",")
  4326. flows, _ := service.GetNewDrugFlowInfothree()
  4327. admin_user_id, _ := c.GetInt64("admin_user_id")
  4328. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4329. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4330. var err []string
  4331. for _, item := range flows {
  4332. var res3 ResultSix
  4333. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4334. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4335. if prescription.OrderStatus == 2 {
  4336. //已经结算
  4337. //判断是否已经销售
  4338. if item.IsSale == 1 { //是否已经销售,1是 0否
  4339. //是否已经变更 1是 0否
  4340. if item.IsChange == 0 { //没变更,进行变更操作
  4341. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4342. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4343. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4344. var respJSON3 map[string]interface{}
  4345. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4348. return
  4349. }
  4350. userJSONBytes3, _ := json.Marshal(respJSON3)
  4351. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4352. utils.ErrorLog("解析失败:%v", err)
  4353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4354. return
  4355. }
  4356. if res3.Infcode == 0 {
  4357. item.IsChange = 1
  4358. item.BgBchno = bg_number
  4359. service.SaveDF2(item)
  4360. } else {
  4361. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4362. }
  4363. }
  4364. } else { //没销售,
  4365. var res FJ3507Result
  4366. var res3507for10188 FJ3507ResultFor10188
  4367. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4368. //进行商品销售接口
  4369. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4370. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4371. var respJSON3 map[string]interface{}
  4372. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4375. return
  4376. }
  4377. userJSONBytes3, _ := json.Marshal(respJSON3)
  4378. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4379. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4380. utils.ErrorLog("解析失败:%v", err)
  4381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4382. return
  4383. }
  4384. //if res3507for10188.Infcode
  4385. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4386. //res.Output = resSix10265.Output
  4387. res.ErrMsg = res3507for10188.ErrMsg
  4388. res.Cainfo = res3507for10188.Cainfo
  4389. res.WarnMsg = res3507for10188.WarnMsg
  4390. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4391. res.Infcode = infocode
  4392. } else {
  4393. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4394. utils.ErrorLog("解析失败:%v", err)
  4395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4396. return
  4397. }
  4398. }
  4399. if res.Infcode == 0 {
  4400. item.IsSale = 1
  4401. item.Bchno = number
  4402. item.SaleDate = time.Now().Format("2006-01-02")
  4403. err5 := service.SaveDF(item)
  4404. if err5 == nil {
  4405. if item.IsChange == 0 { //没变更,进行变更操作
  4406. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4407. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4408. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4409. var respJSON3 map[string]interface{}
  4410. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4416. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4417. utils.ErrorLog("解析失败:%v", err)
  4418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4419. return
  4420. }
  4421. //if res3507for10188.Infcode
  4422. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4423. //res.Output = resSix10265.Output
  4424. res3.ErrMsg = res3507for10188.ErrMsg
  4425. res3.Cainfo = res3507for10188.Cainfo
  4426. res3.WarnMsg = res3507for10188.WarnMsg
  4427. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4428. res3.Infcode = infocode
  4429. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4430. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4431. utils.ErrorLog("解析失败:%v", err)
  4432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4433. return
  4434. }
  4435. //if res3507for10188.Infcode
  4436. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4437. //res.Output = resSix10265.Output
  4438. res3.ErrMsg = res3507for10188.ErrMsg
  4439. res3.Cainfo = res3507for10188.Cainfo
  4440. res3.WarnMsg = res3507for10188.WarnMsg
  4441. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4442. res3.Infcode = infocode
  4443. } else {
  4444. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4445. utils.ErrorLog("解析失败:%v", err)
  4446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4447. return
  4448. }
  4449. }
  4450. if res3.Infcode == 0 {
  4451. item.IsChange = 1
  4452. item.BgBchno = bg_number
  4453. service.SaveDF2(item)
  4454. } else {
  4455. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4456. }
  4457. }
  4458. }
  4459. } else {
  4460. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4461. }
  4462. }
  4463. } else { //还没结算
  4464. var res3507for10188 FJ3507ResultFor10188
  4465. if item.IsChange == 0 { //没变更,进行变更操作
  4466. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4467. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4468. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4469. var respJSON3 map[string]interface{}
  4470. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4473. return
  4474. }
  4475. userJSONBytes3, _ := json.Marshal(respJSON3)
  4476. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4477. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4478. utils.ErrorLog("解析失败:%v", err)
  4479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. return
  4481. }
  4482. //if res3507for10188.Infcode
  4483. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4484. //res.Output = resSix10265.Output
  4485. res3.ErrMsg = res3507for10188.ErrMsg
  4486. res3.Cainfo = res3507for10188.Cainfo
  4487. res3.WarnMsg = res3507for10188.WarnMsg
  4488. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4489. res3.Infcode = infocode
  4490. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4491. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4492. utils.ErrorLog("解析失败:%v", err)
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4494. return
  4495. }
  4496. //if res3507for10188.Infcode
  4497. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4498. //res.Output = resSix10265.Output
  4499. res3.ErrMsg = res3507for10188.ErrMsg
  4500. res3.Cainfo = res3507for10188.Cainfo
  4501. res3.WarnMsg = res3507for10188.WarnMsg
  4502. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4503. res3.Infcode = infocode
  4504. } else {
  4505. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4506. utils.ErrorLog("解析失败:%v", err)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. }
  4511. if res3.Infcode == 0 {
  4512. item.IsChange = 1
  4513. item.BgBchno = bg_number
  4514. service.SaveDF2(item)
  4515. } else {
  4516. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4517. }
  4518. }
  4519. }
  4520. } else if item.ConsumableType == 7 {
  4521. var res3507for10188 FJ3507ResultFor10188
  4522. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4523. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4524. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4525. //判断是否已经销售
  4526. if item.IsSale == 2 { //是否已经销售,1是 0否
  4527. //是否已经变更 1是 0否
  4528. if item.IsChange == 0 { //没变更,进行变更操作
  4529. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4530. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4531. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4532. var respJSON3 map[string]interface{}
  4533. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4536. return
  4537. }
  4538. userJSONBytes3, _ := json.Marshal(respJSON3)
  4539. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4540. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4541. utils.ErrorLog("解析失败:%v", err)
  4542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4543. return
  4544. }
  4545. //if res3507for10188.Infcode
  4546. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4547. //res.Output = resSix10265.Output
  4548. res3.ErrMsg = res3507for10188.ErrMsg
  4549. res3.Cainfo = res3507for10188.Cainfo
  4550. res3.WarnMsg = res3507for10188.WarnMsg
  4551. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4552. res3.Infcode = infocode
  4553. } else {
  4554. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4555. utils.ErrorLog("解析失败:%v", err)
  4556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. return
  4558. }
  4559. }
  4560. if res3.Infcode == 0 {
  4561. item.IsChange = 1
  4562. item.BgBchno = bg_number
  4563. service.SaveDF2(item)
  4564. } else {
  4565. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4566. }
  4567. }
  4568. } else { //没销售,
  4569. //进行商品销售退货接口
  4570. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4571. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4572. saveLog(result111, result222, "3506", "销售退货")
  4573. var res7 FJ3507Result
  4574. //进行商品销售接口
  4575. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4576. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4577. var respJSON3 map[string]interface{}
  4578. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4581. return
  4582. }
  4583. userJSONBytes3, _ := json.Marshal(respJSON3)
  4584. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4585. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4586. utils.ErrorLog("解析失败:%v", err)
  4587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. return
  4589. }
  4590. //if res3507for10188.Infcode
  4591. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4592. //res.Output = resSix10265.Output
  4593. res7.ErrMsg = res3507for10188.ErrMsg
  4594. res7.Cainfo = res3507for10188.Cainfo
  4595. res7.WarnMsg = res3507for10188.WarnMsg
  4596. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4597. res7.Infcode = infocode
  4598. } else {
  4599. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4600. utils.ErrorLog("解析失败:%v", err)
  4601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4602. return
  4603. }
  4604. }
  4605. if res7.Infcode == 0 {
  4606. item.IsSale = 2
  4607. item.SaleDate = item.SaleDate
  4608. item.Bchno = number
  4609. service.SaveDF(item)
  4610. if item.IsChange == 0 { //没变更,进行变更操作
  4611. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4612. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4613. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4614. var respJSON3 map[string]interface{}
  4615. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4618. return
  4619. }
  4620. userJSONBytes3, _ := json.Marshal(respJSON3)
  4621. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4622. // utils.ErrorLog("解析失败:%v", err)
  4623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4624. // return
  4625. //}
  4626. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4627. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4628. utils.ErrorLog("解析失败:%v", err)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. //if res3507for10188.Infcode
  4633. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4634. //res.Output = resSix10265.Output
  4635. res3.ErrMsg = res3507for10188.ErrMsg
  4636. res3.Cainfo = res3507for10188.Cainfo
  4637. res3.WarnMsg = res3507for10188.WarnMsg
  4638. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4639. res3.Infcode = infocode
  4640. } else {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. }
  4647. if res3.Infcode == 0 {
  4648. item.IsChange = 1
  4649. item.BgBchno = bg_number
  4650. service.SaveDF2(item)
  4651. } else {
  4652. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4653. }
  4654. }
  4655. } else {
  4656. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4657. }
  4658. }
  4659. } else { //还没结算
  4660. if item.IsChange == 0 { //没变更,进行变更操作
  4661. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4662. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4663. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4664. var respJSON3 map[string]interface{}
  4665. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4668. return
  4669. }
  4670. userJSONBytes3, _ := json.Marshal(respJSON3)
  4671. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4672. // utils.ErrorLog("解析失败:%v", err)
  4673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4674. // return
  4675. //}
  4676. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4677. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4678. utils.ErrorLog("解析失败:%v", err)
  4679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4680. return
  4681. }
  4682. //if res3507for10188.Infcode
  4683. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4684. //res.Output = resSix10265.Output
  4685. res3.ErrMsg = res3507for10188.ErrMsg
  4686. res3.Cainfo = res3507for10188.Cainfo
  4687. res3.WarnMsg = res3507for10188.WarnMsg
  4688. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4689. res3.Infcode = infocode
  4690. } else {
  4691. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4692. utils.ErrorLog("解析失败:%v", err)
  4693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4694. return
  4695. }
  4696. }
  4697. if res3.Infcode == 0 {
  4698. item.IsChange = 1
  4699. item.BgBchno = bg_number
  4700. service.SaveDF2(item)
  4701. } else {
  4702. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4703. }
  4704. }
  4705. }
  4706. }
  4707. }
  4708. if len(err) == 0 {
  4709. c.ServeSuccessJSON(map[string]interface{}{
  4710. "msg": "销售变更成功",
  4711. })
  4712. } else {
  4713. c.ServeSuccessJSON(map[string]interface{}{
  4714. "failed_code": -10,
  4715. "msg": err,
  4716. })
  4717. }
  4718. }
  4719. func (c *HisApiController) ChangeDrugTen() {
  4720. start_time_str := c.GetString("start_time")
  4721. end_time_str := c.GetString("end_time")
  4722. //ids := c.GetString("ids")
  4723. //id_arr := strings.Split(ids, ",")
  4724. timeLayout := "2006-01-02"
  4725. loc, _ := time.LoadLocation("Local")
  4726. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4727. recordStartTime := theStartTime.Unix()
  4728. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4729. recordEndTime := theEndTime.Unix()
  4730. //timestamp := int64(1729612800)
  4731. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4732. admin_user_id, _ := c.GetInt64("admin_user_id")
  4733. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4734. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4735. var err []string
  4736. for _, item := range flows {
  4737. var res3 ResultSix
  4738. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4739. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4740. continue
  4741. }
  4742. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4743. continue
  4744. }
  4745. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4746. if prescription.OrderStatus == 2 {
  4747. //已经结算
  4748. //判断 是否已经销售
  4749. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4750. ////是否已经变更 1是 0否
  4751. //if item.IsChange == 0 { //没变更,进行变更操作
  4752. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4753. //
  4754. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4755. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4756. // var respJSON3 map[string]interface{}
  4757. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4758. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. // return
  4761. // }
  4762. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4763. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4764. // utils.ErrorLog("解析失败:%v", err)
  4765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. // return
  4767. // }
  4768. // if res3.Infcode == 0 {
  4769. // item.IsChange = 1
  4770. // item.BgBchno = bg_number
  4771. // service.SaveDF2(item)
  4772. // } else {
  4773. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4774. // }
  4775. //}
  4776. //} else
  4777. if item.IsSale == 0 { //没销售,
  4778. var res FJ3507Result
  4779. var res3507for10188 FJ3507ResultFor10188
  4780. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4781. //进行商品销售接口
  4782. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4783. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4784. var respJSON3 map[string]interface{}
  4785. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4788. return
  4789. }
  4790. userJSONBytes3, _ := json.Marshal(respJSON3)
  4791. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4792. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4793. utils.ErrorLog("解析失败:%v", err)
  4794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4795. return
  4796. }
  4797. //if res3507for10188.Infcode
  4798. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4799. //res.Output = resSix10265.Output
  4800. res.ErrMsg = res3507for10188.ErrMsg
  4801. res.Cainfo = res3507for10188.Cainfo
  4802. res.WarnMsg = res3507for10188.WarnMsg
  4803. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4804. res.Infcode = infocode
  4805. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4806. } else {
  4807. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4808. utils.ErrorLog("解析失败:%v", err)
  4809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4810. return
  4811. }
  4812. }
  4813. if res.Infcode == 0 {
  4814. item.IsSale = 1
  4815. item.Bchno = number
  4816. item.SaleDate = time.Now().Format("2006-01-02")
  4817. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  4818. err5 := service.SaveDF(item)
  4819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4820. //if err5 == nil {
  4821. //
  4822. // if item.IsChange == 1 { //没变更,进行变更操作
  4823. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4824. //
  4825. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4826. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4827. //
  4828. // var respJSON3 map[string]interface{}
  4829. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4830. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4832. // return
  4833. // }
  4834. //
  4835. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4836. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4837. // utils.ErrorLog("解析失败:%v", err)
  4838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4839. // return
  4840. // }
  4841. // //if res3507for10188.Infcode
  4842. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4843. // //res.Output = resSix10265.Output
  4844. // res3.ErrMsg = res3507for10188.ErrMsg
  4845. // res3.Cainfo = res3507for10188.Cainfo
  4846. // res3.WarnMsg = res3507for10188.WarnMsg
  4847. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4848. // res3.Infcode = infocode
  4849. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4850. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4851. // utils.ErrorLog("解析失败:%v", err)
  4852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4853. // return
  4854. // }
  4855. // //if res3507for10188.Infcode
  4856. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4857. // //res.Output = resSix10265.Output
  4858. // res3.ErrMsg = res3507for10188.ErrMsg
  4859. // res3.Cainfo = res3507for10188.Cainfo
  4860. // res3.WarnMsg = res3507for10188.WarnMsg
  4861. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4862. // res3.Infcode = infocode
  4863. //
  4864. // } else {
  4865. //
  4866. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4867. // utils.ErrorLog("解析失败:%v", err)
  4868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4869. // return
  4870. // }
  4871. //
  4872. // }
  4873. //
  4874. // if res3.Infcode == 0 {
  4875. // item.IsChange = 1
  4876. // item.BgBchno = bg_number
  4877. // service.SaveDF2(item)
  4878. // return
  4879. // } else {
  4880. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4881. // }
  4882. // }
  4883. //}
  4884. } else {
  4885. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4886. }
  4887. }
  4888. }
  4889. } else if item.ConsumableType == 7 {
  4890. var res3507for10188 FJ3507ResultFor10188
  4891. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4892. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4893. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4894. //判断是否已经销售
  4895. if item.IsSale == 2 { //是否已经销售,1是 0否
  4896. //是否已经变更 1是 0否
  4897. if item.IsChange == 0 { //没变更,进行变更操作
  4898. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4899. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4900. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4901. var respJSON3 map[string]interface{}
  4902. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4905. return
  4906. }
  4907. userJSONBytes3, _ := json.Marshal(respJSON3)
  4908. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4909. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4910. utils.ErrorLog("解析失败:%v", err)
  4911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4912. return
  4913. }
  4914. //if res3507for10188.Infcode
  4915. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4916. //res.Output = resSix10265.Output
  4917. res3.ErrMsg = res3507for10188.ErrMsg
  4918. res3.Cainfo = res3507for10188.Cainfo
  4919. res3.WarnMsg = res3507for10188.WarnMsg
  4920. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4921. res3.Infcode = infocode
  4922. } else {
  4923. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4924. utils.ErrorLog("解析失败:%v", err)
  4925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4926. return
  4927. }
  4928. }
  4929. if res3.Infcode == 0 {
  4930. item.IsChange = 1
  4931. item.BgBchno = bg_number
  4932. service.SaveDF2(item)
  4933. } else {
  4934. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4935. }
  4936. }
  4937. } else { //没销售,
  4938. //进行商品销售退货接口
  4939. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4940. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4941. saveLog(result111, result222, "3506", "销售退货")
  4942. var res7 FJ3507Result
  4943. //进行商品销售接口
  4944. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4945. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4946. var respJSON3 map[string]interface{}
  4947. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. return
  4951. }
  4952. userJSONBytes3, _ := json.Marshal(respJSON3)
  4953. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4954. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4955. utils.ErrorLog("解析失败:%v", err)
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4957. return
  4958. }
  4959. //if res3507for10188.Infcode
  4960. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4961. //res.Output = resSix10265.Output
  4962. res7.ErrMsg = res3507for10188.ErrMsg
  4963. res7.Cainfo = res3507for10188.Cainfo
  4964. res7.WarnMsg = res3507for10188.WarnMsg
  4965. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4966. res7.Infcode = infocode
  4967. } else {
  4968. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4969. utils.ErrorLog("解析失败:%v", err)
  4970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4971. return
  4972. }
  4973. }
  4974. if res7.Infcode == 0 {
  4975. item.IsSale = 2
  4976. item.SaleDate = item.SaleDate
  4977. item.Bchno = number
  4978. service.SaveDF(item)
  4979. if item.IsChange == 0 { //没变更,进行变更操作
  4980. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4981. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4982. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4983. var respJSON3 map[string]interface{}
  4984. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4987. return
  4988. }
  4989. userJSONBytes3, _ := json.Marshal(respJSON3)
  4990. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4991. // utils.ErrorLog("解析失败:%v", err)
  4992. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4993. // return
  4994. //}
  4995. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4996. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4997. utils.ErrorLog("解析失败:%v", err)
  4998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4999. return
  5000. }
  5001. //if res3507for10188.Infcode
  5002. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5003. //res.Output = resSix10265.Output
  5004. res3.ErrMsg = res3507for10188.ErrMsg
  5005. res3.Cainfo = res3507for10188.Cainfo
  5006. res3.WarnMsg = res3507for10188.WarnMsg
  5007. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5008. res3.Infcode = infocode
  5009. } else {
  5010. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5011. utils.ErrorLog("解析失败:%v", err)
  5012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5013. return
  5014. }
  5015. }
  5016. if res3.Infcode == 0 {
  5017. item.IsChange = 1
  5018. item.BgBchno = bg_number
  5019. service.SaveDF2(item)
  5020. } else {
  5021. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5022. }
  5023. }
  5024. } else {
  5025. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5026. }
  5027. }
  5028. } else { //还没结算
  5029. if item.IsChange == 0 { //没变更,进行变更操作
  5030. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5031. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5032. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5033. var respJSON3 map[string]interface{}
  5034. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5037. return
  5038. }
  5039. userJSONBytes3, _ := json.Marshal(respJSON3)
  5040. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5041. // utils.ErrorLog("解析失败:%v", err)
  5042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5043. // return
  5044. //}
  5045. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5046. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5047. utils.ErrorLog("解析失败:%v", err)
  5048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5049. return
  5050. }
  5051. //if res3507for10188.Infcode
  5052. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5053. //res.Output = resSix10265.Output
  5054. res3.ErrMsg = res3507for10188.ErrMsg
  5055. res3.Cainfo = res3507for10188.Cainfo
  5056. res3.WarnMsg = res3507for10188.WarnMsg
  5057. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5058. res3.Infcode = infocode
  5059. } else {
  5060. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5061. utils.ErrorLog("解析失败:%v", err)
  5062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5063. return
  5064. }
  5065. }
  5066. if res3.Infcode == 0 {
  5067. item.IsChange = 1
  5068. item.BgBchno = bg_number
  5069. service.SaveDF2(item)
  5070. } else {
  5071. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5072. }
  5073. }
  5074. }
  5075. }
  5076. }
  5077. if len(err) == 0 {
  5078. c.ServeSuccessJSON(map[string]interface{}{
  5079. "msg": "销售变更成功",
  5080. })
  5081. } else {
  5082. c.ServeSuccessJSON(map[string]interface{}{
  5083. "failed_code": -10,
  5084. "msg": err,
  5085. })
  5086. }
  5087. }
  5088. func ChangeDrugTenone() {
  5089. //ids := c.GetString("ids")
  5090. //id_arr := strings.Split(ids, ",")
  5091. now := time.Now()
  5092. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5093. //timestamp := int64(1729612800)
  5094. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5095. admin_user_id := int64(2463)
  5096. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5097. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5098. var err []string
  5099. for _, item := range flows {
  5100. var res3 ResultSix
  5101. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5102. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5103. continue
  5104. }
  5105. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5106. continue
  5107. }
  5108. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5109. if prescription.OrderStatus == 2 {
  5110. //已经结算
  5111. //判断是否已经销售
  5112. if item.IsSale == 1 { //是否已经销售,1是 0否
  5113. //是否已经变更 1是 0否
  5114. if item.IsChange == 0 { //没变更,进行变更操作
  5115. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5116. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5117. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5118. var respJSON3 map[string]interface{}
  5119. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5121. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5122. return
  5123. }
  5124. userJSONBytes3, _ := json.Marshal(respJSON3)
  5125. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5126. utils.ErrorLog("解析失败:%v", err)
  5127. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5128. return
  5129. }
  5130. if res3.Infcode == 0 {
  5131. item.IsChange = 1
  5132. item.BgBchno = bg_number
  5133. service.SaveDF2(item)
  5134. } else {
  5135. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5136. }
  5137. }
  5138. } else { //没销售,
  5139. var res FJ3507Result
  5140. var res3507for10188 FJ3507ResultFor10188
  5141. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5142. //进行商品销售接口
  5143. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5144. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5145. var respJSON3 map[string]interface{}
  5146. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5148. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5149. return
  5150. }
  5151. userJSONBytes3, _ := json.Marshal(respJSON3)
  5152. {
  5153. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5154. utils.ErrorLog("解析失败:%v", err)
  5155. return
  5156. }
  5157. //if res3507for10188.Infcode
  5158. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5159. //res.Output = resSix10265.Output
  5160. res.ErrMsg = res3507for10188.ErrMsg
  5161. res.Cainfo = res3507for10188.Cainfo
  5162. res.WarnMsg = res3507for10188.WarnMsg
  5163. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5164. res.Infcode = infocode
  5165. }
  5166. if res.Infcode == 0 {
  5167. item.IsSale = 1
  5168. item.Bchno = number
  5169. item.SaleDate = time.Now().Format("2006-01-02")
  5170. err5 := service.SaveDF(item)
  5171. if err5 == nil {
  5172. if item.IsChange == 1 { //没变更,进行变更操作
  5173. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5174. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5175. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5176. var respJSON3 map[string]interface{}
  5177. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5179. return
  5180. }
  5181. {
  5182. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5183. utils.ErrorLog("解析失败:%v", err)
  5184. return
  5185. }
  5186. //if res3507for10188.Infcode
  5187. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5188. //res.Output = resSix10265.Output
  5189. res3.ErrMsg = res3507for10188.ErrMsg
  5190. res3.Cainfo = res3507for10188.Cainfo
  5191. res3.WarnMsg = res3507for10188.WarnMsg
  5192. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5193. res3.Infcode = infocode
  5194. }
  5195. if res3.Infcode == 0 {
  5196. item.IsChange = 1
  5197. item.BgBchno = bg_number
  5198. service.SaveDF2(item)
  5199. } else {
  5200. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5201. }
  5202. }
  5203. }
  5204. } else {
  5205. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5206. }
  5207. }
  5208. }
  5209. }
  5210. }
  5211. }
  5212. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5213. var struct3502 models.Struct3502
  5214. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5215. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5216. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5217. struct3502.FixmedinsCode = miConfig.Code
  5218. struct3502.Code = miConfig.Code
  5219. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5220. struct3502.Opter = role.UserName
  5221. struct3502.RxFlag = "1"
  5222. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5223. struct3502.OrgName = miConfig.OrgName
  5224. struct3502.AccessKey = miConfig.AccessKey
  5225. struct3502.RequestUrl = miConfig.Url
  5226. struct3502.SecretKey = miConfig.SecretKey
  5227. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5228. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5229. struct3502.Url = miConfig.Url
  5230. struct3502.AppId = miConfig.Cainfo
  5231. struct3502.AppSecret = miConfig.AppSecret
  5232. struct3502.Enckey = miConfig.EncKey
  5233. struct3502.SignKey = miConfig.SignKey
  5234. struct3502.SecretKey = miConfig.SecretKey
  5235. struct3502.InvChgType = chgType
  5236. struct3502.FixmedinsBchno = number
  5237. struct3502.Cnt = strconv.FormatInt(count, 10)
  5238. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5239. //result1, result2, _ := service.FJyb3502(struct3502)
  5240. if miConfig.MdtrtareaAdmvs == "350500" {
  5241. result1, result2, _ := service.FJyb3502(struct3502)
  5242. //saveLog(result1, result2, "3502", "3502")
  5243. return result1, result2
  5244. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5245. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5246. return result1, result2
  5247. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5248. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5249. return result1, result2
  5250. } else {
  5251. data := make(map[string]interface{})
  5252. data["struct_3502s"] = struct3502
  5253. client := &http.Client{}
  5254. bytesData, _ := json.Marshal(data)
  5255. var req *http.Request
  5256. if miConfig.MdtrtareaAdmvs == "320830" {
  5257. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5258. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5259. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5260. } else {
  5261. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5262. }
  5263. resp, _ := client.Do(req)
  5264. defer resp.Body.Close()
  5265. body, ioErr := ioutil.ReadAll(resp.Body)
  5266. if ioErr != nil {
  5267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5268. }
  5269. var respJSON map[string]interface{}
  5270. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5272. }
  5273. //var resSix10265 ResultSix10265 //1101结果
  5274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5275. result, _ := json.Marshal(respJSON)
  5276. return string(result), ""
  5277. }
  5278. }
  5279. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5280. var struct3505 models.Struct3505
  5281. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5282. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5283. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5284. struct3505.FixmedinsBchno = number
  5285. struct3505.Opter = role.UserName
  5286. struct3505.Bchno = "---"
  5287. struct3505.FixmedinsCode = miConfig.Code
  5288. struct3505.Code = miConfig.Code
  5289. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5290. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5291. struct3505.PrscDrName = roles.UserName
  5292. if org_id == 10191 {
  5293. struct3505.PharName = "刘水山"
  5294. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5295. }
  5296. if org_id == 10188 {
  5297. struct3505.PharName = "李汉清"
  5298. struct3505.PharPracCertNo = "30220200932022010034"
  5299. }
  5300. if org_id == 10217 {
  5301. struct3505.PharName = "张敏"
  5302. struct3505.PharPracCertNo = "30220230432090100108"
  5303. }
  5304. if org_id == 10318 {
  5305. struct3505.PharName = "邹刘阳"
  5306. struct3505.PharPracCertNo = "210441200001378"
  5307. }
  5308. if org_id == 10402 {
  5309. struct3505.PharName = "刘韶健"
  5310. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5311. }
  5312. if org_id == 9919 {
  5313. struct3505.PharName = "周君权"
  5314. struct3505.PharPracCertNo = "089644396094401375"
  5315. }
  5316. if org_id == 10644 {
  5317. struct3505.PharName = "陈金娣"
  5318. struct3505.PharPracCertNo = "20181441500320100066"
  5319. }
  5320. if org_id == 10567 {
  5321. struct3505.PharName = "范小兰"
  5322. struct3505.PharPracCertNo = "0200102079485"
  5323. }
  5324. if org_id == 10721 {
  5325. struct3505.PharName = "孙莉侠"
  5326. struct3505.PharPracCertNo = "060399"
  5327. }
  5328. if org_id == 10726 {
  5329. struct3505.PharName = "彭建福"
  5330. struct3505.PharPracCertNo = "D445281006261"
  5331. }
  5332. if org_id == 10697 {
  5333. struct3505.PharName = "陶海兰"
  5334. struct3505.PharPracCertNo = "0010933"
  5335. }
  5336. if org_id == 10265 {
  5337. struct3505.PharName = "李彩星"
  5338. struct3505.PharPracCertNo = "20171110600110100019"
  5339. }
  5340. if org_id == 10028 {
  5341. struct3505.PharName = "曾细平"
  5342. struct3505.PharPracCertNo = "D440307022134"
  5343. }
  5344. if org_id == 10138 {
  5345. struct3505.PharName = "彭斯遥"
  5346. struct3505.PharPracCertNo = "30220200943042010052"
  5347. }
  5348. if org_id == 10278 {
  5349. struct3505.PharName = "彭斯遥"
  5350. struct3505.PharPracCertNo = "30220200943042010052"
  5351. }
  5352. if org_id == 10610 {
  5353. struct3505.PharName = "彭斯遥"
  5354. struct3505.PharPracCertNo = "30220200943042010052"
  5355. }
  5356. if org_id == 10537 {
  5357. struct3505.PharName = "彭斯遥"
  5358. struct3505.PharPracCertNo = "30220200943042010052"
  5359. }
  5360. if org_id == 9504 {
  5361. struct3505.PharName = "资美红"
  5362. struct3505.PharPracCertNo = "D440904006635"
  5363. }
  5364. if org_id == 10480 {
  5365. struct3505.PharName = "陈思"
  5366. struct3505.PharPracCertNo = "30220240434110010470"
  5367. }
  5368. if org_id == 10653 {
  5369. struct3505.PharName = "邓树英"
  5370. struct3505.PharPracCertNo = "201910026440004734"
  5371. }
  5372. if org_id == 10571 {
  5373. struct3505.PharName = "廖志平"
  5374. struct3505.PharPracCertNo = "0136425"
  5375. }
  5376. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5377. struct3505.SetlId = order.SetlId
  5378. struct3505.MdtrtSn = order.MdtrtId
  5379. struct3505.ManuLotnum = drug.BatchNumber
  5380. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5381. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5382. struct3505.RxFlag = "1"
  5383. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5384. struct3505.TrdnFlag = "0"
  5385. } else {
  5386. struct3505.TrdnFlag = "1"
  5387. }
  5388. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5389. struct3505.TrdnFlag = "1"
  5390. }
  5391. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5392. struct3505.TrdnFlag = "0"
  5393. }
  5394. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 {
  5395. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5396. struct3505.TrdnFlag = "1"
  5397. }
  5398. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5399. struct3505.TrdnFlag = "0"
  5400. }
  5401. }
  5402. struct3505.RtalDocno = order.Number
  5403. struct3505.PsnCertType = "01"
  5404. struct3505.CertNo = order.Certno
  5405. struct3505.PsnNo = order.PsnNo
  5406. struct3505.PsnName = order.PsnName
  5407. struct3505.Url = miConfig.Url
  5408. struct3505.AppId = miConfig.Cainfo
  5409. struct3505.AppSecret = miConfig.AppSecret
  5410. struct3505.Enckey = miConfig.EncKey
  5411. struct3505.SignKey = miConfig.SignKey
  5412. struct3505.SecretKey = miConfig.SecretKey
  5413. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5414. struct3505.SelRetnCnt = strValue
  5415. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5416. struct3505.SelRetnOpterName = role.UserName
  5417. if order.IsMedicineInsurance == 1 {
  5418. struct3505.MdtrtSetlType = "1"
  5419. } else {
  5420. struct3505.MdtrtSetlType = "2"
  5421. }
  5422. struct3505.OrgName = miConfig.OrgName
  5423. struct3505.AccessKey = miConfig.AccessKey
  5424. struct3505.RequestUrl = miConfig.Url
  5425. struct3505.SecretKey = miConfig.SecretKey
  5426. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5427. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5428. struct3505.Cainfo = miConfig.Cainfo
  5429. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5430. if miConfig.MdtrtareaAdmvs == "350500" {
  5431. result1, result2, _ := service.FJyb3505(struct3505)
  5432. return result1, result2
  5433. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5434. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5435. return result1, result2
  5436. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5437. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5438. return result1, result2
  5439. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5440. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5441. return result1, result2
  5442. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5443. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5444. return result1, result2
  5445. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5446. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5447. return result1, result2
  5448. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5449. data := make(map[string]interface{})
  5450. data["struct_3505s"] = struct3505
  5451. client := &http.Client{}
  5452. bytesData, _ := json.Marshal(data)
  5453. var req *http.Request
  5454. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5455. resp, _ := client.Do(req)
  5456. defer resp.Body.Close()
  5457. body, ioErr := ioutil.ReadAll(resp.Body)
  5458. if ioErr != nil {
  5459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5460. }
  5461. var respJSON map[string]interface{}
  5462. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5464. }
  5465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5466. result, _ := json.Marshal(respJSON)
  5467. return string(result), ""
  5468. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5469. data := make(map[string]interface{})
  5470. data["struct_3505s"] = struct3505
  5471. client := &http.Client{}
  5472. bytesData, _ := json.Marshal(data)
  5473. var req *http.Request
  5474. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5475. resp, _ := client.Do(req)
  5476. defer resp.Body.Close()
  5477. body, ioErr := ioutil.ReadAll(resp.Body)
  5478. if ioErr != nil {
  5479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5480. }
  5481. var respJSON map[string]interface{}
  5482. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5484. }
  5485. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5486. if status == "0" {
  5487. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5488. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5489. }
  5490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5491. result, _ := json.Marshal(respJSON)
  5492. return string(result), ""
  5493. } else {
  5494. data := make(map[string]interface{})
  5495. data["struct_3505s"] = struct3505
  5496. client := &http.Client{}
  5497. bytesData, _ := json.Marshal(data)
  5498. var req *http.Request
  5499. if miConfig.MdtrtareaAdmvs == "320830" {
  5500. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5501. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5502. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5503. } else {
  5504. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5505. }
  5506. resp, _ := client.Do(req)
  5507. defer resp.Body.Close()
  5508. body, ioErr := ioutil.ReadAll(resp.Body)
  5509. if ioErr != nil {
  5510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5511. }
  5512. var respJSON map[string]interface{}
  5513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5515. }
  5516. //var resSix10265 ResultSix10265 //1101结果
  5517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5518. result, _ := json.Marshal(respJSON)
  5519. return string(result), ""
  5520. }
  5521. }
  5522. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5523. var struct3505 models.Struct3505
  5524. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5525. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5526. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5527. struct3505.FixmedinsBchno = number
  5528. struct3505.Opter = role.UserName
  5529. struct3505.FixmedinsCode = miConfig.Code
  5530. struct3505.Code = miConfig.Code
  5531. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5532. struct3505.PrscDrName = roles.UserName
  5533. if org_id == 10191 {
  5534. struct3505.PharName = "刘水山"
  5535. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5536. }
  5537. if org_id == 10188 {
  5538. struct3505.PharName = "李汉清"
  5539. struct3505.PharPracCertNo = "30220200932022010034"
  5540. }
  5541. if org_id == 10217 {
  5542. struct3505.PharName = "张敏"
  5543. struct3505.PharPracCertNo = "30220230432090100108"
  5544. }
  5545. if org_id == 10318 {
  5546. struct3505.PharName = "邹刘阳"
  5547. struct3505.PharPracCertNo = "210441200001378"
  5548. }
  5549. if org_id == 10402 {
  5550. struct3505.PharName = "刘韶健"
  5551. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5552. }
  5553. if org_id == 9919 {
  5554. struct3505.PharName = "周君权"
  5555. struct3505.PharPracCertNo = "089644396094401375"
  5556. }
  5557. if org_id == 10644 {
  5558. struct3505.PharName = "陈金娣"
  5559. struct3505.PharPracCertNo = "20181441500320100066"
  5560. }
  5561. if org_id == 10567 {
  5562. struct3505.PharName = "范小兰"
  5563. struct3505.PharPracCertNo = "0200102079485"
  5564. }
  5565. if org_id == 10721 {
  5566. struct3505.PharName = "孙莉侠"
  5567. struct3505.PharPracCertNo = "060399"
  5568. }
  5569. if org_id == 10726 {
  5570. struct3505.PharName = "彭建福"
  5571. struct3505.PharPracCertNo = "D445281006261"
  5572. }
  5573. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5574. struct3505.SetlId = order.SetlId
  5575. struct3505.MdtrtSn = order.MdtrtId
  5576. struct3505.ManuLotnum = drug.Number
  5577. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5578. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5579. struct3505.RxFlag = "1"
  5580. struct3505.TrdnFlag = "0"
  5581. struct3505.RtalDocno = order.Number
  5582. struct3505.PsnCertType = "01"
  5583. struct3505.CertNo = order.Certno
  5584. struct3505.PsnNo = order.PsnNo
  5585. struct3505.PsnName = order.PsnName
  5586. struct3505.Url = miConfig.Url
  5587. struct3505.AppId = miConfig.Cainfo
  5588. struct3505.AppSecret = miConfig.AppSecret
  5589. struct3505.Enckey = miConfig.EncKey
  5590. struct3505.SignKey = miConfig.SignKey
  5591. struct3505.SecretKey = miConfig.SecretKey
  5592. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5593. struct3505.SelRetnCnt = strValue
  5594. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5595. struct3505.SelRetnOpterName = role.UserName
  5596. if order.IsMedicineInsurance == 1 {
  5597. struct3505.MdtrtSetlType = "1"
  5598. } else {
  5599. struct3505.MdtrtSetlType = "2"
  5600. }
  5601. struct3505.OrgName = miConfig.OrgName
  5602. struct3505.AccessKey = miConfig.AccessKey
  5603. struct3505.RequestUrl = miConfig.Url
  5604. struct3505.SecretKey = miConfig.SecretKey
  5605. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5606. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5607. struct3505.Cainfo = miConfig.Cainfo
  5608. struct3505.DrugTracCodg = drug.DrugCode
  5609. if miConfig.MdtrtareaAdmvs == "350500" {
  5610. result1, result2, _ := service.FJyb3505(struct3505)
  5611. return result1, result2
  5612. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5613. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5614. return result1, result2
  5615. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5616. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5617. return result1, result2
  5618. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5619. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5620. return result1, result2
  5621. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5622. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5623. return result1, result2
  5624. } else {
  5625. data := make(map[string]interface{})
  5626. data["struct_3505s"] = struct3505
  5627. client := &http.Client{}
  5628. bytesData, _ := json.Marshal(data)
  5629. var req *http.Request
  5630. if miConfig.MdtrtareaAdmvs == "320830" {
  5631. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5632. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5633. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5634. } else {
  5635. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5636. }
  5637. resp, _ := client.Do(req)
  5638. defer resp.Body.Close()
  5639. body, ioErr := ioutil.ReadAll(resp.Body)
  5640. if ioErr != nil {
  5641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5642. }
  5643. var respJSON map[string]interface{}
  5644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5646. }
  5647. //var resSix10265 ResultSix10265 //1101结果
  5648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5649. result, _ := json.Marshal(respJSON)
  5650. return string(result), ""
  5651. }
  5652. }
  5653. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5654. var struct3506 models.Struct3506
  5655. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5656. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5657. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5658. struct3506.FixmedinsCode = miConfig.Code
  5659. struct3506.Code = miConfig.Code
  5660. struct3506.FixmedinsBchno = number
  5661. struct3506.Opter = role.UserName
  5662. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5663. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5664. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5665. struct3506.MdtrtSn = order.MdtrtId
  5666. struct3506.ExpyEnd = ""
  5667. struct3506.RxFlag = "0"
  5668. struct3506.TrdnFlag = "1"
  5669. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5670. struct3506.SelRetnCnt = strValue
  5671. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5672. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5673. struct3506.SelRetnOpterName = role.UserName
  5674. struct3506.OrgName = miConfig.OrgName
  5675. struct3506.AccessKey = miConfig.AccessKey
  5676. struct3506.RequestUrl = miConfig.Url
  5677. struct3506.SecretKey = miConfig.SecretKey
  5678. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5679. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5680. struct3506.Url = miConfig.Url
  5681. struct3506.AppId = miConfig.Cainfo
  5682. struct3506.AppSecret = miConfig.AppSecret
  5683. struct3506.Enckey = miConfig.EncKey
  5684. struct3506.SignKey = miConfig.SignKey
  5685. struct3506.SecretKey = miConfig.SecretKey
  5686. struct3506.DrugTracCodg = drug.DrugCode
  5687. if miConfig.MdtrtareaAdmvs == "350500" {
  5688. result1, result2, _ := service.FJyb3506(struct3506)
  5689. return result1, result2
  5690. } else {
  5691. data := make(map[string]interface{})
  5692. data["struct_3506s"] = struct3506
  5693. client := &http.Client{}
  5694. bytesData, _ := json.Marshal(data)
  5695. var req *http.Request
  5696. if miConfig.MdtrtareaAdmvs == "320830" {
  5697. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5698. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5699. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5700. } else {
  5701. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5702. }
  5703. resp, _ := client.Do(req)
  5704. defer resp.Body.Close()
  5705. body, ioErr := ioutil.ReadAll(resp.Body)
  5706. if ioErr != nil {
  5707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5708. }
  5709. var respJSON map[string]interface{}
  5710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5712. }
  5713. //var resSix10265 ResultSix10265 //1101结果
  5714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5715. result, _ := json.Marshal(respJSON)
  5716. return string(result), ""
  5717. }
  5718. }
  5719. func (c *HisApiController) Get1318() {
  5720. adminUser := c.GetAdminUserInfo()
  5721. admin_user_id, _ := c.GetInt64("admin_user_id")
  5722. code := c.GetString("code")
  5723. code = ""
  5724. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5725. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5726. api := ""
  5727. if miConfig.MdtrtareaAdmvs == "320830" {
  5728. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5729. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5730. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5731. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5732. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5733. } else {
  5734. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5735. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5736. }
  5737. resp, requestErr := http.Get(api)
  5738. if requestErr != nil {
  5739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5740. return
  5741. }
  5742. body, ioErr := ioutil.ReadAll(resp.Body)
  5743. if ioErr != nil {
  5744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5746. return
  5747. }
  5748. var respJSON map[string]interface{}
  5749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5752. return
  5753. }
  5754. //var res Result2406
  5755. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5756. result, _ := json.Marshal(respJSON)
  5757. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5758. utils.ErrorLog("解析失败:%v", err)
  5759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5760. return
  5761. }
  5762. if res.Infcode == "0" {
  5763. c.ServeSuccessJSON(map[string]interface{}{
  5764. "result": "",
  5765. })
  5766. } else {
  5767. c.ServeSuccessJSON(map[string]interface{}{
  5768. "failed_code": -10,
  5769. "msg": res.ErrMsg,
  5770. })
  5771. */return
  5772. //}
  5773. }
  5774. func (c *HisApiController) Get2503() {
  5775. adminUser := c.GetAdminUserInfo()
  5776. admin_user_id, _ := c.GetInt64("admin_user_id")
  5777. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5779. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5780. }
  5781. func (c *HisApiController) Get2406() {
  5782. id, _ := c.GetInt64("id")
  5783. record_time := c.GetString("record_time")
  5784. his_patient_id, _ := c.GetInt64("his_patient_id")
  5785. admin_user_id, _ := c.GetInt64("admin_user_id")
  5786. diagnosis_id := c.GetString("diagnosis")
  5787. timeLayout := "2006-01-02"
  5788. loc, _ := time.LoadLocation("Local")
  5789. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5790. if err != nil {
  5791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5792. return
  5793. }
  5794. recordDateTime := theTime.Unix()
  5795. adminUser := c.GetAdminUserInfo()
  5796. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5797. var config []*models.HisXtDiagnoseConfig
  5798. for _, item := range diagnosis_ids {
  5799. id, _ := strconv.ParseInt(item, 10, 64)
  5800. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5801. config = append(config, &diagnosisConfig)
  5802. }
  5803. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5804. fmt.Println(his_patient_id)
  5805. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5806. //timestamp := time.Now().Unix()
  5807. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5808. var patientPrescription models.HisPrescriptionInfo
  5809. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5810. if patientPrescription.ID == 0 {
  5811. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5812. }
  5813. var res2 Result2406
  5814. if miConfig.MdtrtareaAdmvs == "341203" {
  5815. data := make(map[string]interface{})
  5816. client := &http.Client{}
  5817. data["psn_no"] = his.PsnNo
  5818. data["mdtrt_id"] = his.Number
  5819. data["operator"] = roles.UserName
  5820. data["cert_no"] = his.IdCardNo
  5821. data["org_name"] = miConfig.OrgName
  5822. data["psn_name"] = his.Name
  5823. data["ipt_otp_no"] = his.IptOtpNo
  5824. data["ipt_psn_sp_flag_type"] = "0901"
  5825. data["ipt_psn_sp_flag"] = "1"
  5826. data["fixmedins_code"] = miConfig.Code
  5827. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5828. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5829. data["url"] = miConfig.Url
  5830. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5831. bytesData, _ := json.Marshal(data)
  5832. var req *http.Request
  5833. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5834. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5835. resp, _ := client.Do(req)
  5836. defer resp.Body.Close()
  5837. body, ioErr := ioutil.ReadAll(resp.Body)
  5838. if ioErr != nil {
  5839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5841. return
  5842. }
  5843. var respJSON map[string]interface{}
  5844. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5850. if status == "0" {
  5851. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5852. c.ServeSuccessJSON(map[string]interface{}{
  5853. "failed_code": -10,
  5854. "msg": err_msg,
  5855. })
  5856. return
  5857. }
  5858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5859. userJSONBytes, _ := json.Marshal(respJSON)
  5860. fmt.Println("log")
  5861. fmt.Println(string(userJSONBytes))
  5862. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5863. utils.ErrorLog("解析失败:%v", err)
  5864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5865. return
  5866. }
  5867. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5868. data := make(map[string]interface{})
  5869. client := &http.Client{}
  5870. data["psn_no"] = his.PsnNo
  5871. data["mdtrt_id"] = his.Number
  5872. data["operator"] = roles.UserName
  5873. data["cert_no"] = his.IdCardNo
  5874. data["org_name"] = miConfig.OrgName
  5875. data["psn_name"] = his.Name
  5876. data["ipt_otp_no"] = his.IptOtpNo
  5877. data["ipt_psn_sp_flag_type"] = "0901"
  5878. data["ipt_psn_sp_flag"] = "1"
  5879. data["fixmedins_code"] = miConfig.Code
  5880. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5881. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5882. data["url"] = miConfig.Url
  5883. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5884. bytesData, _ := json.Marshal(data)
  5885. var req *http.Request
  5886. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5887. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5888. resp, _ := client.Do(req)
  5889. defer resp.Body.Close()
  5890. body, ioErr := ioutil.ReadAll(resp.Body)
  5891. if ioErr != nil {
  5892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5894. return
  5895. }
  5896. var respJSON map[string]interface{}
  5897. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. return
  5901. }
  5902. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5903. if status == "0" {
  5904. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5905. c.ServeSuccessJSON(map[string]interface{}{
  5906. "failed_code": -10,
  5907. "msg": err_msg,
  5908. })
  5909. return
  5910. }
  5911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5912. userJSONBytes, _ := json.Marshal(respJSON)
  5913. fmt.Println("log")
  5914. fmt.Println(string(userJSONBytes))
  5915. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5916. utils.ErrorLog("解析失败:%v", err)
  5917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5918. return
  5919. }
  5920. }
  5921. if res2.Infcode != 0 {
  5922. adminUser := c.GetAdminUserInfo()
  5923. errlog := &models.HisOrderError{
  5924. UserOrgId: adminUser.CurrentOrgId,
  5925. Ctime: time.Now().Unix(),
  5926. Mtime: time.Now().Unix(),
  5927. ErrMsg: res2.ErrMsg,
  5928. Status: 1,
  5929. PatientId: id,
  5930. RecordTime: recordDateTime,
  5931. Stage: 3,
  5932. }
  5933. service.CreateErrMsgLog(errlog)
  5934. c.ServeSuccessJSON(map[string]interface{}{
  5935. "failed_code": -10,
  5936. "msg": res2.ErrMsg,
  5937. })
  5938. return
  5939. } else {
  5940. c.ServeSuccessJSON(map[string]interface{}{
  5941. "msg": "上传成功",
  5942. })
  5943. return
  5944. }
  5945. }
  5946. func (c *HisApiController) Get4105() {
  5947. }
  5948. func (c *HisApiController) Post5302() {
  5949. patient_id, _ := c.GetInt64("id")
  5950. admin_user_id, _ := c.GetInt64("admin_user_id")
  5951. p, _ := service.GetHisPatientById(patient_id)
  5952. adminUser := c.GetAdminUserInfo()
  5953. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5954. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5955. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5956. }
  5957. func (c *HisApiController) Get4104() {
  5958. }
  5959. type Output struct {
  5960. CertNo string `json:"certno"`
  5961. PsnName string `json:"psn_name"`
  5962. CardNo string `json:"card_no"`
  5963. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5964. CardSN string `json:"card_sn"`
  5965. PsnCertType string `json:"psn_cert_type"`
  5966. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5967. MdtrtCertType string `json:"mdtrt_cert_type"`
  5968. QRCode string `json:"qrCode"`
  5969. EcToken string `json:"ecToken"`
  5970. }
  5971. type AHResponse struct {
  5972. Body AHBody `json:"body"`
  5973. Code int `json:"code"`
  5974. CSBCode int `json:"csbCode"`
  5975. Message string `json:"message"`
  5976. RequestID string `json:"requestId"`
  5977. State struct{} `json:"state"`
  5978. }
  5979. type AHBody struct {
  5980. ErrMsg string `json:"err_msg"`
  5981. InfRefMsgID string `json:"inf_refmsgid"`
  5982. InfCode int `json:"infcode"`
  5983. Output struct {
  5984. Result []struct {
  5985. BasMednFlag string `json:"bas_medn_flag"`
  5986. ChldMedcFlag string `json:"chld_medc_flag"`
  5987. ChrgitmLv string `json:"chrgitm_lv"`
  5988. Cnt float64 `json:"cnt"`
  5989. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5990. DrtReimFlag string `json:"drt_reim_flag"`
  5991. FeedetlSn string `json:"feedetl_sn"`
  5992. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5993. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5994. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5995. ListSpItemFlag string `json:"list_sp_item_flag"`
  5996. LmtUsedFlag string `json:"lmt_used_flag"`
  5997. MedChrgitmType string `json:"med_chrgitm_type"`
  5998. Memo string `json:"memo"`
  5999. OverlmtAmt float64 `json:"overlmt_amt"`
  6000. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6001. Pric float64 `json:"pric"`
  6002. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6003. SelfpayProp float64 `json:"selfpay_prop"`
  6004. } `json:"result"`
  6005. } `json:"output"`
  6006. }
  6007. type Response struct {
  6008. Output Output `json:"output"`
  6009. Infcode int `json:"infcode"`
  6010. InfRefMsgID string `json:"inf_refmsgid"`
  6011. RefMsgTime string `json:"refmsg_time"`
  6012. RespondTime string `json:"respond_time"`
  6013. ErrMsg string `json:"err_msg"`
  6014. WarnMsg string `json:"warn_msg"`
  6015. SignType string `json:"signtype"`
  6016. CAInfo string `json:"cainfo"`
  6017. }
  6018. func (c *HisApiController) Getquerydata() {
  6019. query_type, _ := c.GetInt64("type")
  6020. refd_setl_flag := c.GetString("refd_setl_flag")
  6021. med_type := c.GetString("med_type")
  6022. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6023. cert_no := c.GetString("cert_no")
  6024. psn_no := c.GetString("psn_no")
  6025. start_time := c.GetString("start_time")
  6026. end_time := c.GetString("end_time")
  6027. page, _ := c.GetInt64("page")
  6028. limit, _ := c.GetInt64("limit")
  6029. var bp models.BusinessParams5262
  6030. bp.RefdSetlFlag = refd_setl_flag
  6031. bp.MedType = med_type
  6032. bp.Certno = cert_no
  6033. bp.Psnno = psn_no
  6034. bp.QBegntime = start_time
  6035. bp.QEndtime = end_time
  6036. if query_type == 1 { //本地
  6037. Post5262(c, bp, page, limit)
  6038. } else { //异地
  6039. Post5267(c, bp, page, limit)
  6040. }
  6041. }
  6042. func (c *HisApiController) Drugscheck() {
  6043. admin_user_id, _ := c.GetInt64("admin_user_id")
  6044. adminUser := c.GetAdminUserInfo()
  6045. var queryResult []QueryResult
  6046. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6047. for _, item := range drugs {
  6048. result := QueryResult{
  6049. ID: item.ID,
  6050. Name: item.DrugName,
  6051. Code: item.MedicalInsuranceNumber,
  6052. List_type_code: "101",
  6053. }
  6054. queryResult = append(queryResult, result)
  6055. }
  6056. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6057. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6058. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6059. for _, item := range queryResult {
  6060. 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)
  6061. }
  6062. }
  6063. func (c *HisApiController) Goodcheck() {
  6064. admin_user_id, _ := c.GetInt64("admin_user_id")
  6065. adminUser := c.GetAdminUserInfo()
  6066. var queryResult []QueryResult
  6067. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6068. for _, item := range goods {
  6069. result := QueryResult{
  6070. ID: item.ID,
  6071. Name: item.GoodName,
  6072. Code: item.SocialSecurityDirectoryCode,
  6073. List_type_code: "301",
  6074. }
  6075. queryResult = append(queryResult, result)
  6076. }
  6077. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6078. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6079. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6080. for _, item := range queryResult {
  6081. 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)
  6082. //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)
  6083. }
  6084. }
  6085. func (c *HisApiController) Projectcheck() {
  6086. admin_user_id, _ := c.GetInt64("admin_user_id")
  6087. adminUser := c.GetAdminUserInfo()
  6088. var queryResult []QueryResult
  6089. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6090. for _, item := range projects {
  6091. result := QueryResult{
  6092. ID: item.ID,
  6093. Name: item.ProjectName,
  6094. Code: item.MedicalCode,
  6095. List_type_code: "201",
  6096. }
  6097. queryResult = append(queryResult, result)
  6098. }
  6099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6100. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6101. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6102. for _, item := range queryResult {
  6103. 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)
  6104. }
  6105. }
  6106. //func (c *HisApiController)CancleDia(){
  6107. //
  6108. // id, _ := c.GetInt64("id")
  6109. // record_time := c.GetString("record_time")
  6110. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6111. //
  6112. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6113. //
  6114. // diagnosis_id := c.GetString("diagnosis")
  6115. // sick_type, _ := c.GetInt64("sick_type")
  6116. // reg_type, _ := c.GetInt64("p_type")
  6117. // begin_time := c.GetString("begin_time")
  6118. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6119. //
  6120. //
  6121. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6122. //
  6123. // fmt.Println(acct_used_flag)
  6124. //
  6125. //
  6126. // timeLayout := "2006-01-02"
  6127. // loc, _ := time.LoadLocation("Local")
  6128. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6129. // if err != nil {
  6130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6131. // return
  6132. // }
  6133. // recordDateTime := theTime.Unix()
  6134. // adminUser := c.GetAdminUserInfo()
  6135. //
  6136. //
  6137. //
  6138. //
  6139. //
  6140. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6141. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6142. // var patientPrescription models.HisPrescriptionInfo
  6143. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6144. // if patientPrescription.ID == 0 {
  6145. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6146. // }
  6147. // //if patientPrescription.Do
  6148. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6149. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6150. //
  6151. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6152. //
  6153. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6154. //
  6155. // var config []*models.HisXtDiagnoseConfig
  6156. // for _, item := range diagnosis_ids {
  6157. // id, _ := strconv.ParseInt(item, 10, 64)
  6158. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6159. // config = append(config, &diagnosisConfig)
  6160. // }
  6161. //
  6162. // sickConfig, _ := service.FindSickById(sick_type)
  6163. //
  6164. //
  6165. // data := make(map[string]interface{})
  6166. // client := &http.Client{}
  6167. // data["psn_no"] = his.PsnNo
  6168. // data["mdtrt_id"] = his.Number
  6169. // data["doctor"] = roles.UserName
  6170. // data["department"] = department.Name
  6171. // data["org_name"] = miConfig.OrgName
  6172. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6173. // data["doctor_id"] = doctor_info.DoctorNumber
  6174. // data["new_doctor_name"] = doctor_info.UserName
  6175. // data["fixmedins_code"] = miConfig.Code
  6176. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6177. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6178. // data["secret_key"] = miConfig.SecretKey
  6179. // data["sick_code"] = sickConfig.CountryCode
  6180. // data["sick_name"] = sickConfig.ClassName
  6181. // data["url"] = miConfig.Url
  6182. // data["ak"] = miConfig.AccessKey
  6183. // data["begin_time"] = begin_time
  6184. // data["cainfo"] = miConfig.Cainfo
  6185. // data["is_vaild"] = "0"
  6186. //
  6187. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6188. // data["config"] = config
  6189. // bytesData, _ := json.Marshal(data)
  6190. //
  6191. // var req *http.Request
  6192. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6193. // resp, _ := client.Do(req)
  6194. // defer resp.Body.Close()
  6195. // body, ioErr := ioutil.ReadAll(resp.Body)
  6196. // if ioErr != nil {
  6197. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6199. // return
  6200. // }
  6201. // var respJSON map[string]interface{}
  6202. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6203. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6205. // return
  6206. // }
  6207. //
  6208. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6209. // userJSONBytes, _ := json.Marshal(respJSON)
  6210. // fmt.Println("log")
  6211. // fmt.Println(string(userJSONBytes))
  6212. //
  6213. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6214. // utils.ErrorLog("解析失败:%v", err)
  6215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6216. // return
  6217. // }
  6218. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6219. // res2.Output = ressix10265.Output
  6220. // res2.ErrMsg = ressix10265.ErrMsg
  6221. // res2.Cainfo = ressix10265.Cainfo
  6222. // res2.WarnMsg = ressix10265.WarnMsg
  6223. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6224. // res2.Infcode = infocode
  6225. //
  6226. //}
  6227. func (c *HisApiController) Get4102() {
  6228. order_id, _ := c.GetInt64("order_id")
  6229. admin_user_id, _ := c.GetInt64("admin_user_id")
  6230. stas_type := c.GetString("stas_type")
  6231. order, _ := service.GetHisOrderByIDTwo(order_id)
  6232. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6233. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6234. var pp models.PublicParams
  6235. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6236. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6237. pp.FixmedinsName = miConfig.OrgName
  6238. pp.FixmedinsCode = miConfig.Code
  6239. pp.RequestUrl = miConfig.Url
  6240. pp.Cainfo = miConfig.Cainfo
  6241. pp.SecretKey = miConfig.SecretKey
  6242. pp.AccessKey = miConfig.AccessKey
  6243. pp.OpterName = curRoles.UserName
  6244. if miConfig.MdtrtareaAdmvs == "350500" {
  6245. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6246. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6247. saveLog(result, request, "4102", "清单确认")
  6248. var dat map[string]interface{}
  6249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6250. fmt.Println(dat)
  6251. } else {
  6252. fmt.Println(err)
  6253. }
  6254. var empty ResultFourteen
  6255. userJSONBytes, _ := json.Marshal(dat)
  6256. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6257. utils.ErrorLog("解析失败:%v", err)
  6258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6259. return
  6260. }
  6261. if empty.Infcode == 0 {
  6262. c.ServeSuccessJSON(map[string]interface{}{
  6263. "msg": "确认成功",
  6264. })
  6265. return
  6266. }
  6267. } else {
  6268. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6269. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6270. result3, request3 := service.Jxyb4105(pp)
  6271. saveLog(result, request, "4102", "清单确认")
  6272. saveLog(result2, request2, "4103", "清单确认")
  6273. saveLog(result3, request3, "4105", "清单统计")
  6274. var dat map[string]interface{}
  6275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6276. fmt.Println(dat)
  6277. } else {
  6278. fmt.Println(err)
  6279. }
  6280. var empty ResultFourteen
  6281. userJSONBytes, _ := json.Marshal(dat)
  6282. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6283. utils.ErrorLog("解析失败:%v", err)
  6284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6285. return
  6286. }
  6287. if empty.Infcode == 0 {
  6288. c.ServeSuccessJSON(map[string]interface{}{
  6289. "msg": "确认成功",
  6290. })
  6291. return
  6292. }
  6293. }
  6294. }
  6295. // 对账权限查询
  6296. func (c *HisApiController) Get3260() {
  6297. admin_user_id, _ := c.GetInt64("admin_user_id")
  6298. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6300. var api string
  6301. var res models.JSResult3260
  6302. if miConfig.MdtrtareaAdmvs == "320830" {
  6303. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6304. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6305. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6306. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6307. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6308. } else {
  6309. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6310. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6311. }
  6312. resp, requestErr := http.Get(api)
  6313. if requestErr != nil {
  6314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6315. return
  6316. }
  6317. body, ioErr := ioutil.ReadAll(resp.Body)
  6318. if ioErr != nil {
  6319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. return
  6322. }
  6323. var respJSON map[string]interface{}
  6324. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6327. return
  6328. }
  6329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6330. result, _ := json.Marshal(respJSON)
  6331. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6332. utils.ErrorLog("解析失败:%v", err)
  6333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6334. return
  6335. }
  6336. if res.Infcode == "0" {
  6337. c.ServeSuccessJSON(map[string]interface{}{
  6338. "result": res.Output.Data,
  6339. })
  6340. } else {
  6341. c.ServeSuccessJSON(map[string]interface{}{
  6342. "failed_code": -10,
  6343. "msg": res.ErrMsg,
  6344. })
  6345. return
  6346. }
  6347. }
  6348. func (c *HisApiController) Get3261() {
  6349. admin_user_id, _ := c.GetInt64("admin_user_id")
  6350. //month := c.GetString("month")
  6351. startTime := c.GetString("start_time")
  6352. //endTime, _ := c.GetString("end_time")
  6353. times := strings.Split(startTime, "-")
  6354. stmt_mon := times[0] + times[1]
  6355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6357. var api string
  6358. var res models.JSResult3261
  6359. //var res10265 Result5301For10265
  6360. if miConfig.MdtrtareaAdmvs == "320830" {
  6361. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6362. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6363. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6364. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6365. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6366. } else {
  6367. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6368. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6369. }
  6370. resp, requestErr := http.Get(api)
  6371. if requestErr != nil {
  6372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6373. return
  6374. }
  6375. body, ioErr := ioutil.ReadAll(resp.Body)
  6376. if ioErr != nil {
  6377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. return
  6380. }
  6381. var respJSON map[string]interface{}
  6382. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6385. return
  6386. }
  6387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6388. result, _ := json.Marshal(respJSON)
  6389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6390. utils.ErrorLog("解析失败:%v", err)
  6391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6392. return
  6393. }
  6394. if res.Infcode == "0" {
  6395. c.ServeSuccessJSON(map[string]interface{}{
  6396. "result": res.Output,
  6397. })
  6398. } else {
  6399. c.ServeSuccessJSON(map[string]interface{}{
  6400. "failed_code": -10,
  6401. "msg": res.ErrMsg,
  6402. })
  6403. return
  6404. }
  6405. }
  6406. type TempFun struct {
  6407. FundKey string
  6408. FundCode string
  6409. }
  6410. func (c *HisApiController) Get3262() {
  6411. admin_user_id, _ := c.GetInt64("admin_user_id")
  6412. startTime := c.GetString("start_time")
  6413. endTime := c.GetString("end_time")
  6414. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6415. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6416. //timeLayout := "2006-01-02"
  6417. //loc, _ := time.LoadLocation("Local")
  6418. //var theStartTIme int64
  6419. //if len(startTime) > 0 {
  6420. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6421. // if err != nil {
  6422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6423. // return
  6424. // }
  6425. // theStartTIme = theTime.Unix()
  6426. //}
  6427. //var theEndtTIme int64
  6428. //if len(endTime) > 0 {
  6429. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6430. // if err != nil {
  6431. // utils.ErrorLog(err.Error())
  6432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6433. // return
  6434. // }
  6435. // theEndtTIme = theTime.Unix()
  6436. //}
  6437. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6438. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6439. for _, team := range datas {
  6440. fmt.Println(team.PsnTime)
  6441. for _, team_two := range datas_two {
  6442. fmt.Println(team_two.PsnTime)
  6443. if team.FundKey == team_two.FundKey {
  6444. fmt.Println(team_two.PsnTime)
  6445. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6446. fmt.Println(team.PsnTime)
  6447. }
  6448. }
  6449. }
  6450. fmt.Println("1111")
  6451. fmt.Println(datas)
  6452. fmt.Println("1111")
  6453. var twos []models.FixMonRecDetailFileInTwo
  6454. for _, team := range datas {
  6455. var two models.FixMonRecDetailFileInTwo
  6456. two.MedType = team.MedType
  6457. two.Insutype = team.Insutype
  6458. two.PsnType = team.PsnType
  6459. two.MedType = team.MedType
  6460. two.FixBlngAdmdvs = "999999"
  6461. two.InsuAdmdvs = "555555"
  6462. two.PsnTime = team.PsnTime
  6463. two.PsnCnt = team.PsnCnt
  6464. two.FundKey = team.FundKey
  6465. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6466. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6467. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6468. two.MedfeeSumAmt = ms
  6469. two.InscpAmt = ia
  6470. two.FundPaySumAmt = fps
  6471. twos = append(twos, two)
  6472. }
  6473. //startTime := c.GetString("start_time")
  6474. //endTime, _ := c.GetString("end_time")
  6475. times := strings.Split(startTime, "-")
  6476. stmt_mon := times[0] + times[1]
  6477. var funs []models.FundDetail
  6478. for _, item := range datas {
  6479. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6480. funs = append(funs, fun...)
  6481. }
  6482. var funInfos []models.Fund
  6483. //for _, item := range funs {
  6484. // var rf []models.FundInfo
  6485. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6486. // for _, subitem := range rf {
  6487. // var fund models.Fund
  6488. // fund.FundCode = subitem.FundPayType
  6489. // fund.FundName = subitem.FundPayTypeName
  6490. // fund.FundAmt = subitem.FundPayAmt
  6491. // fund.FundKey = item.FundKey
  6492. // fund.InsuAdmdvs = "555555"
  6493. // fund.FixBlngAdmdvs = "999999"
  6494. // funInfos = append(funInfos, fund)
  6495. // }
  6496. //}
  6497. var tempFuns []TempFun
  6498. for _, funInfo := range funInfos {
  6499. var tempFun TempFun
  6500. tempFun.FundKey = funInfo.FundKey
  6501. tempFun.FundCode = funInfo.FundCode
  6502. tempFuns = append(tempFuns, tempFun)
  6503. }
  6504. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6505. fmt.Println(tempFuns)
  6506. var funInfosTwo []models.Fund
  6507. decimal.DivisionPrecision = 2
  6508. for _, item := range tempFuns {
  6509. var fund models.Fund
  6510. for _, subItem := range funInfos {
  6511. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6512. fund.FundKey = subItem.FundKey
  6513. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6514. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6515. fund.FundName = subItem.FundName
  6516. fund.FundCode = subItem.FundCode
  6517. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6518. }
  6519. }
  6520. funInfosTwo = append(funInfosTwo, fund)
  6521. }
  6522. fmt.Println("funInfosTwo")
  6523. fmt.Println(funInfosTwo)
  6524. var upld_btch string
  6525. var empty models.JSResultEmpty
  6526. data := make(map[string]interface{})
  6527. data["org_name"] = miConfig.OrgName
  6528. data["doctor"] = curRoles.UserName
  6529. data["doctor_name"] = curRoles.UserName
  6530. data["fixmedins_code"] = miConfig.Code
  6531. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6532. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6533. data["secret_key"] = miConfig.SecretKey
  6534. data["url"] = miConfig.Url
  6535. data["ak"] = miConfig.AccessKey
  6536. data["cainfo"] = miConfig.Cainfo
  6537. data["datas"] = twos
  6538. data["fund"] = funInfosTwo
  6539. fmt.Println(twos)
  6540. month := time.Unix(1557042972, 0).Format("1")
  6541. year := time.Now().Format("2006")
  6542. month = time.Now().Format("01")
  6543. day := time.Now().Format("02")
  6544. hour := time.Now().Format("15")
  6545. min := time.Now().Format("04")
  6546. sec := time.Now().Format("05")
  6547. fix_fill_date := year + month + day + hour + min + sec
  6548. data["fix_fill_dept"] = miConfig.OrgName
  6549. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6550. data["fix_fill_psn"] = curRoles.UserName
  6551. data["fix_fill_date"] = fix_fill_date
  6552. data["stmt_loc"] = "2"
  6553. data["setl_mon"] = stmt_mon
  6554. upld_btch = "0"
  6555. data["upld_btch"] = upld_btch
  6556. //fmt.Println(data)
  6557. client := &http.Client{}
  6558. bytesData, _ := json.Marshal(data)
  6559. var req *http.Request
  6560. if miConfig.MdtrtareaAdmvs == "320830" {
  6561. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6562. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6564. } else {
  6565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6566. }
  6567. resp, _ := client.Do(req)
  6568. defer resp.Body.Close()
  6569. body, ioErr := ioutil.ReadAll(resp.Body)
  6570. if ioErr != nil {
  6571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6573. }
  6574. var respJSON map[string]interface{}
  6575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6578. }
  6579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6580. //fmt.Println(respJSON)
  6581. result, _ := json.Marshal(respJSON)
  6582. //fmt.Println(result)
  6583. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6584. utils.ErrorLog("解析失败:%v", err)
  6585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6586. }
  6587. if empty.Infcode != "0" {
  6588. c.ServeSuccessJSON(map[string]interface{}{
  6589. "failed_code": -10,
  6590. "msg": empty.ErrMsg,
  6591. })
  6592. return
  6593. } else {
  6594. c.ServeSuccessJSON(map[string]interface{}{
  6595. "msg": "上传成功",
  6596. })
  6597. return
  6598. }
  6599. }
  6600. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6601. newArr = make([]TempFun, 0)
  6602. for i := 0; i < len(arr); i++ {
  6603. repeat := false
  6604. for j := i + 1; j < len(arr); j++ {
  6605. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6606. repeat = true
  6607. break
  6608. }
  6609. }
  6610. if !repeat {
  6611. newArr = append(newArr, arr[i])
  6612. }
  6613. }
  6614. return
  6615. }
  6616. func (c *HisApiController) Get3263() {
  6617. admin_user_id, _ := c.GetInt64("admin_user_id")
  6618. startTime := c.GetString("start_time")
  6619. //endTime, _ := c.GetString("end_time")
  6620. times := strings.Split(startTime, "-")
  6621. setl_mon := times[0] + times[1]
  6622. upld_btch := "0"
  6623. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6624. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6625. var result3263 models.JSResult3263
  6626. data := make(map[string]interface{})
  6627. data["org_name"] = miConfig.OrgName
  6628. data["doctor"] = curRoles.UserName
  6629. data["doctor_name"] = curRoles.UserName
  6630. data["fixmedins_code"] = miConfig.Code
  6631. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6632. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6633. data["secret_key"] = miConfig.SecretKey
  6634. data["url"] = miConfig.Url
  6635. data["ak"] = miConfig.AccessKey
  6636. data["cainfo"] = miConfig.Cainfo
  6637. data["setl_mon"] = setl_mon
  6638. data["stmt_loc"] = "2"
  6639. data["upld_btch"] = upld_btch
  6640. client := &http.Client{}
  6641. bytesData, _ := json.Marshal(data)
  6642. var req *http.Request
  6643. if miConfig.MdtrtareaAdmvs == "320830" {
  6644. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6645. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6646. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6647. } else {
  6648. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6649. }
  6650. resp, _ := client.Do(req)
  6651. defer resp.Body.Close()
  6652. body, ioErr := ioutil.ReadAll(resp.Body)
  6653. if ioErr != nil {
  6654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6656. }
  6657. var respJSON map[string]interface{}
  6658. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6661. }
  6662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6663. fmt.Println(respJSON)
  6664. result, _ := json.Marshal(respJSON)
  6665. fmt.Println(result)
  6666. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6667. utils.ErrorLog("解析失败:%v", err)
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. }
  6670. if result3263.Infcode != "0" {
  6671. c.ServeSuccessJSON(map[string]interface{}{
  6672. "failed_code": -10,
  6673. "msg": result3263.ErrMsg,
  6674. })
  6675. return
  6676. } else {
  6677. c.ServeSuccessJSON(map[string]interface{}{
  6678. "list": result3263.Output,
  6679. })
  6680. return
  6681. }
  6682. }
  6683. func (c *HisApiController) Get3264() {
  6684. admin_user_id, _ := c.GetInt64("admin_user_id")
  6685. startTime := c.GetString("start_time")
  6686. //endTime, _ := c.GetString("end_time")
  6687. times := strings.Split(startTime, "-")
  6688. setl_mon := times[0] + times[1]
  6689. upld_btch := "0"
  6690. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6692. //solidify_id := []
  6693. var result3263 models.JSResult3263
  6694. data := make(map[string]interface{})
  6695. data["org_name"] = miConfig.OrgName
  6696. data["doctor"] = curRoles.UserName
  6697. data["doctor_name"] = curRoles.UserName
  6698. data["fixmedins_code"] = miConfig.Code
  6699. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6701. data["secret_key"] = miConfig.SecretKey
  6702. data["url"] = miConfig.Url
  6703. data["ak"] = miConfig.AccessKey
  6704. data["cainfo"] = miConfig.Cainfo
  6705. data["setl_mon"] = setl_mon
  6706. data["stmt_loc"] = "2"
  6707. data["upld_btch"] = upld_btch
  6708. client := &http.Client{}
  6709. bytesData, _ := json.Marshal(data)
  6710. var req3263 *http.Request
  6711. if miConfig.MdtrtareaAdmvs == "320830" {
  6712. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6713. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6714. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6715. } else {
  6716. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6717. }
  6718. resp, _ := client.Do(req3263)
  6719. defer resp.Body.Close()
  6720. body, ioErr := ioutil.ReadAll(resp.Body)
  6721. if ioErr != nil {
  6722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. }
  6725. var respJSON3263 map[string]interface{}
  6726. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6729. }
  6730. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6731. fmt.Println(respJSON3263)
  6732. result, _ := json.Marshal(respJSON3263)
  6733. fmt.Println(result)
  6734. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6735. utils.ErrorLog("解析失败:%v", err)
  6736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6737. }
  6738. var ids []string
  6739. for _, item := range result3263.Output {
  6740. ids = append(ids, item.SolidifyID)
  6741. }
  6742. var empty models.JSResultEmpty
  6743. data2 := make(map[string]interface{})
  6744. data2["org_name"] = miConfig.OrgName
  6745. data2["doctor"] = curRoles.UserName
  6746. data2["doctor_name"] = curRoles.UserName
  6747. data2["fixmedins_code"] = miConfig.Code
  6748. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6749. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6750. data2["secret_key"] = miConfig.SecretKey
  6751. data2["url"] = miConfig.Url
  6752. data2["ak"] = miConfig.AccessKey
  6753. data2["cainfo"] = miConfig.Cainfo
  6754. data2["setl_mon"] = setl_mon
  6755. data2["stmt_loc"] = "2"
  6756. data2["upld_btch"] = upld_btch
  6757. data2["solidify_id"] = ids
  6758. client2 := &http.Client{}
  6759. bytesData2, _ := json.Marshal(data2)
  6760. var req *http.Request
  6761. if miConfig.MdtrtareaAdmvs == "320830" {
  6762. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6763. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6764. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6765. } else {
  6766. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6767. }
  6768. resp2, _ := client2.Do(req)
  6769. defer resp.Body.Close()
  6770. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6771. if ioErr2 != nil {
  6772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6774. }
  6775. var respJSON map[string]interface{}
  6776. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6779. }
  6780. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6781. fmt.Println(respJSON)
  6782. result2, _ := json.Marshal(respJSON)
  6783. fmt.Println(result2)
  6784. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6785. utils.ErrorLog("解析失败:%v", err)
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. }
  6788. if empty.Infcode != "0" {
  6789. c.ServeSuccessJSON(map[string]interface{}{
  6790. "failed_code": -10,
  6791. "msg": empty.ErrMsg,
  6792. })
  6793. return
  6794. } else {
  6795. c.ServeSuccessJSON(map[string]interface{}{
  6796. "msg": "",
  6797. })
  6798. return
  6799. }
  6800. }
  6801. func (c *HisApiController) Get3265() {
  6802. admin_user_id, _ := c.GetInt64("admin_user_id")
  6803. startTime := c.GetString("start_time")
  6804. //endTime, _ := c.GetString("end_time")
  6805. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6807. times := strings.Split(startTime, "-")
  6808. setl_mon := times[0] + times[1]
  6809. var upld_btch string
  6810. upld_btch = "0"
  6811. //var empty models.JSResultEmpty
  6812. var result3265 models.JSResult3264
  6813. var result3263 models.JSResult3263
  6814. data2 := make(map[string]interface{})
  6815. data2["org_name"] = miConfig.OrgName
  6816. data2["doctor"] = curRoles.UserName
  6817. data2["doctor_name"] = curRoles.UserName
  6818. data2["fixmedins_code"] = miConfig.Code
  6819. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6820. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6821. data2["secret_key"] = miConfig.SecretKey
  6822. data2["url"] = miConfig.Url
  6823. data2["ak"] = miConfig.AccessKey
  6824. data2["cainfo"] = miConfig.Cainfo
  6825. data2["setl_mon"] = setl_mon
  6826. data2["stmt_loc"] = "2"
  6827. data2["upld_btch"] = upld_btch
  6828. client2 := &http.Client{}
  6829. bytesData2, _ := json.Marshal(data2)
  6830. var req3263 *http.Request
  6831. if miConfig.MdtrtareaAdmvs == "320830" {
  6832. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  6833. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6834. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6835. } else {
  6836. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6837. }
  6838. resp2, _ := client2.Do(req3263)
  6839. defer resp2.Body.Close()
  6840. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6841. if ioErr2 != nil {
  6842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. }
  6845. var respJSON3263 map[string]interface{}
  6846. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6849. }
  6850. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6851. fmt.Println(respJSON3263)
  6852. result2, _ := json.Marshal(respJSON3263)
  6853. fmt.Println(result2)
  6854. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6855. utils.ErrorLog("解析失败:%v", err)
  6856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6857. }
  6858. var ids []string
  6859. for _, item := range result3263.Output {
  6860. ids = append(ids, item.SolidifyID)
  6861. }
  6862. data := make(map[string]interface{})
  6863. data["org_name"] = miConfig.OrgName
  6864. data["doctor"] = curRoles.UserName
  6865. data["doctor_name"] = curRoles.UserName
  6866. data["fixmedins_code"] = miConfig.Code
  6867. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6868. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6869. data["secret_key"] = miConfig.SecretKey
  6870. data["url"] = miConfig.Url
  6871. data["ak"] = miConfig.AccessKey
  6872. data["cainfo"] = miConfig.Cainfo
  6873. data["setl_mon"] = setl_mon
  6874. data["solidify_id"] = ids
  6875. month := time.Unix(1557042972, 0).Format("1")
  6876. year := time.Now().Format("2006")
  6877. month = time.Now().Format("01")
  6878. day := time.Now().Format("02")
  6879. hour := time.Now().Format("15")
  6880. min := time.Now().Format("04")
  6881. sec := time.Now().Format("05")
  6882. fix_fill_date := year + month + day + hour + min + sec
  6883. data["fix_fill_dept"] = miConfig.OrgName
  6884. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6885. data["fix_fill_psn"] = curRoles.UserName
  6886. data["fix_fill_date"] = fix_fill_date
  6887. data["stmt_loc"] = "2"
  6888. data["upld_btch"] = upld_btch
  6889. client := &http.Client{}
  6890. bytesData, _ := json.Marshal(data)
  6891. var req *http.Request
  6892. if miConfig.MdtrtareaAdmvs == "320830" {
  6893. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  6894. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6895. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6896. } else {
  6897. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6898. }
  6899. resp, _ := client.Do(req)
  6900. defer resp.Body.Close()
  6901. body, ioErr := ioutil.ReadAll(resp.Body)
  6902. if ioErr != nil {
  6903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6905. }
  6906. var respJSON map[string]interface{}
  6907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. }
  6911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6912. fmt.Println(respJSON)
  6913. result, _ := json.Marshal(respJSON)
  6914. fmt.Println(result)
  6915. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6916. utils.ErrorLog("解析失败:%v", err)
  6917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6918. }
  6919. if result3265.Infcode != "0" {
  6920. c.ServeSuccessJSON(map[string]interface{}{
  6921. "failed_code": -10,
  6922. "msg": result3265.ErrMsg,
  6923. })
  6924. return
  6925. } else {
  6926. c.ServeSuccessJSON(map[string]interface{}{
  6927. "info": result3265.Output,
  6928. })
  6929. return
  6930. }
  6931. }
  6932. func (c *HisApiController) Get3266() {
  6933. admin_user_id, _ := c.GetInt64("admin_user_id")
  6934. startTime := c.GetString("start_time")
  6935. //endTime, _ := c.GetString("end_time")
  6936. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6938. times := strings.Split(startTime, "-")
  6939. stmt_mon := times[0] + times[1]
  6940. var upld_btch string
  6941. //var empty models.JSResultEmpty
  6942. var result3265 models.JSResult3264
  6943. data := make(map[string]interface{})
  6944. data["org_name"] = miConfig.OrgName
  6945. data["doctor"] = curRoles.UserName
  6946. data["doctor_name"] = curRoles.UserName
  6947. data["fixmedins_code"] = miConfig.Code
  6948. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6949. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6950. data["secret_key"] = miConfig.SecretKey
  6951. data["url"] = miConfig.Url
  6952. data["ak"] = miConfig.AccessKey
  6953. data["cainfo"] = miConfig.Cainfo
  6954. data["setl_mon"] = stmt_mon
  6955. month := time.Unix(1557042972, 0).Format("1")
  6956. year := time.Now().Format("2006")
  6957. month = time.Now().Format("01")
  6958. day := time.Now().Format("02")
  6959. hour := time.Now().Format("15")
  6960. min := time.Now().Format("04")
  6961. sec := time.Now().Format("05")
  6962. fix_fill_date := year + month + day + hour + min + sec
  6963. data["fix_fill_dept"] = miConfig.OrgName
  6964. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6965. data["fix_fill_psn"] = curRoles.UserName
  6966. data["fix_fill_date"] = fix_fill_date
  6967. data["stmt_loc"] = "2"
  6968. upld_btch = "0"
  6969. data["upld_btch"] = upld_btch
  6970. client := &http.Client{}
  6971. bytesData, _ := json.Marshal(data)
  6972. var req *http.Request
  6973. if miConfig.MdtrtareaAdmvs == "320830" {
  6974. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  6975. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6976. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6977. } else {
  6978. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6979. }
  6980. resp, _ := client.Do(req)
  6981. defer resp.Body.Close()
  6982. body, ioErr := ioutil.ReadAll(resp.Body)
  6983. if ioErr != nil {
  6984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. }
  6987. var respJSON map[string]interface{}
  6988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6991. }
  6992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6993. fmt.Println(respJSON)
  6994. result, _ := json.Marshal(respJSON)
  6995. fmt.Println(result)
  6996. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6997. utils.ErrorLog("解析失败:%v", err)
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. }
  7000. if result3265.Infcode != "0" {
  7001. c.ServeSuccessJSON(map[string]interface{}{
  7002. "failed_code": -10,
  7003. "msg": result3265.ErrMsg,
  7004. })
  7005. return
  7006. } else {
  7007. c.ServeSuccessJSON(map[string]interface{}{
  7008. "info": result3265.Output,
  7009. })
  7010. return
  7011. }
  7012. }
  7013. func (c *HisApiController) Get3267() {
  7014. admin_user_id, _ := c.GetInt64("admin_user_id")
  7015. startTime := c.GetString("start_time")
  7016. //endTime, _ := c.GetString("end_time")
  7017. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7018. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7019. times := strings.Split(startTime, "-")
  7020. setl_mon := times[0] + times[1]
  7021. var upld_btch string
  7022. //var empty models.JSResultEmpty
  7023. var result3265 models.JSResult3264
  7024. upld_btch = "0"
  7025. data := make(map[string]interface{})
  7026. data["org_name"] = miConfig.OrgName
  7027. data["doctor"] = curRoles.UserName
  7028. data["doctor_name"] = curRoles.UserName
  7029. data["fixmedins_code"] = miConfig.Code
  7030. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7031. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7032. data["secret_key"] = miConfig.SecretKey
  7033. data["url"] = miConfig.Url
  7034. data["ak"] = miConfig.AccessKey
  7035. data["cainfo"] = miConfig.Cainfo
  7036. data["setl_mon"] = setl_mon
  7037. data["stmt_loc"] = "2"
  7038. data["upld_btch"] = upld_btch
  7039. client := &http.Client{}
  7040. bytesData, _ := json.Marshal(data)
  7041. var req *http.Request
  7042. if miConfig.MdtrtareaAdmvs == "320830" {
  7043. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7044. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7045. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7046. } else {
  7047. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7048. }
  7049. resp, _ := client.Do(req)
  7050. defer resp.Body.Close()
  7051. body, ioErr := ioutil.ReadAll(resp.Body)
  7052. if ioErr != nil {
  7053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. }
  7056. var respJSON map[string]interface{}
  7057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. }
  7061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7062. fmt.Println(respJSON)
  7063. result, _ := json.Marshal(respJSON)
  7064. fmt.Println(result)
  7065. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. }
  7069. if result3265.Infcode != "0" {
  7070. c.ServeSuccessJSON(map[string]interface{}{
  7071. "failed_code": -10,
  7072. "msg": result3265.ErrMsg,
  7073. })
  7074. return
  7075. } else {
  7076. c.ServeSuccessJSON(map[string]interface{}{
  7077. "info": result3265.Output.Data,
  7078. })
  7079. return
  7080. }
  7081. }
  7082. func (c *HisApiController) Get3268() {
  7083. admin_user_id, _ := c.GetInt64("admin_user_id")
  7084. startTime := c.GetString("start_time")
  7085. endTime := c.GetString("end_time")
  7086. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7087. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7088. times := strings.Split(startTime, "-")
  7089. setl_mon := times[0] + times[1]
  7090. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7091. var twos []models.FixMonRecDetailFileInTwo
  7092. var funs []models.FundDetail
  7093. for _, item := range datas {
  7094. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7095. funs = append(funs, fun...)
  7096. }
  7097. var funInfos []models.Fund
  7098. //for _, item := range funs {
  7099. // var rf []models.FundInfo
  7100. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7101. // for _, subitem := range rf {
  7102. // var fund models.Fund
  7103. // fund.FundCode = subitem.FundPayType
  7104. // fund.FundName = subitem.FundPayTypeName
  7105. // fund.FundAmt = subitem.FundPayAmt
  7106. // fund.FundKey = item.FundKey
  7107. // fund.InsuAdmdvs = "555555"
  7108. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7109. // funInfos = append(funInfos, fund)
  7110. // }
  7111. //}
  7112. for _, team := range datas {
  7113. var two models.FixMonRecDetailFileInTwo
  7114. two.SetlDate = time.Now().Format("2006-01-02")
  7115. two.MedType = team.MedType
  7116. two.Insutype = team.Insutype
  7117. two.PsnType = team.PsnType
  7118. two.MedType = team.MedType
  7119. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7120. two.InsuAdmdvs = team.InsuAdmdvs
  7121. two.PsnTime = team.PsnTime
  7122. two.PsnCnt = team.PsnCnt
  7123. two.FundKey = team.FundKey
  7124. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7125. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7126. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7127. two.MedfeeSumAmt = ms
  7128. two.InscpAmt = ia
  7129. two.FundPaySumAmt = fps
  7130. twos = append(twos, two)
  7131. }
  7132. var upld_btch string
  7133. upld_btch = "0"
  7134. var empty models.JSResultEmpty
  7135. data := make(map[string]interface{})
  7136. data["org_name"] = miConfig.OrgName
  7137. data["doctor"] = curRoles.UserName
  7138. data["doctor_name"] = curRoles.UserName
  7139. data["fixmedins_code"] = miConfig.Code
  7140. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7141. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7142. data["secret_key"] = miConfig.SecretKey
  7143. data["url"] = miConfig.Url
  7144. data["ak"] = miConfig.AccessKey
  7145. data["cainfo"] = miConfig.Cainfo
  7146. data["datas"] = twos
  7147. data["fund"] = funInfos
  7148. data["setl_mon"] = setl_mon
  7149. month := time.Unix(1557042972, 0).Format("1")
  7150. year := time.Now().Format("2006")
  7151. month = time.Now().Format("01")
  7152. day := time.Now().Format("02")
  7153. hour := time.Now().Format("15")
  7154. min := time.Now().Format("04")
  7155. sec := time.Now().Format("05")
  7156. fix_fill_date := year + month + day + hour + min + sec
  7157. data["fix_fill_dept"] = miConfig.OrgName
  7158. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7159. data["fix_fill_psn"] = curRoles.UserName
  7160. data["fix_fill_date"] = fix_fill_date
  7161. data["stmt_loc"] = "2"
  7162. data["upld_btch"] = upld_btch
  7163. client := &http.Client{}
  7164. bytesData, _ := json.Marshal(data)
  7165. var req *http.Request
  7166. if miConfig.MdtrtareaAdmvs == "320830" {
  7167. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7168. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7169. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7170. } else {
  7171. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7172. }
  7173. resp, _ := client.Do(req)
  7174. defer resp.Body.Close()
  7175. body, ioErr := ioutil.ReadAll(resp.Body)
  7176. if ioErr != nil {
  7177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. }
  7180. var respJSON map[string]interface{}
  7181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7184. }
  7185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7186. fmt.Println(respJSON)
  7187. result, _ := json.Marshal(respJSON)
  7188. fmt.Println(result)
  7189. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7190. utils.ErrorLog("解析失败:%v", err)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. }
  7193. if empty.Infcode != "0" {
  7194. c.ServeSuccessJSON(map[string]interface{}{
  7195. "failed_code": -10,
  7196. "msg": empty.ErrMsg,
  7197. })
  7198. return
  7199. } else {
  7200. c.ServeSuccessJSON(map[string]interface{}{
  7201. "msg": "上传成功",
  7202. })
  7203. return
  7204. }
  7205. }
  7206. func (c *HisApiController) Get3269() {
  7207. admin_user_id, _ := c.GetInt64("admin_user_id")
  7208. startTime := c.GetString("start_time")
  7209. //endTime, _ := c.GetString("end_time")
  7210. times := strings.Split(startTime, "-")
  7211. setl_mon := times[0] + times[1]
  7212. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7214. var result3263 models.JSResult3263
  7215. data := make(map[string]interface{})
  7216. data["org_name"] = miConfig.OrgName
  7217. data["doctor"] = curRoles.UserName
  7218. data["doctor_name"] = curRoles.UserName
  7219. data["fixmedins_code"] = miConfig.Code
  7220. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7221. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7222. data["secret_key"] = miConfig.SecretKey
  7223. data["url"] = miConfig.Url
  7224. data["ak"] = miConfig.AccessKey
  7225. data["cainfo"] = miConfig.Cainfo
  7226. data["setl_mon"] = setl_mon
  7227. data["stmt_loc"] = "2"
  7228. client := &http.Client{}
  7229. bytesData, _ := json.Marshal(data)
  7230. var req *http.Request
  7231. if miConfig.MdtrtareaAdmvs == "320830" {
  7232. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7233. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7234. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7235. } else {
  7236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7237. }
  7238. resp, _ := client.Do(req)
  7239. defer resp.Body.Close()
  7240. body, ioErr := ioutil.ReadAll(resp.Body)
  7241. if ioErr != nil {
  7242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7244. }
  7245. var respJSON map[string]interface{}
  7246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. }
  7250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7251. fmt.Println(respJSON)
  7252. result, _ := json.Marshal(respJSON)
  7253. fmt.Println(result)
  7254. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7255. utils.ErrorLog("解析失败:%v", err)
  7256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7257. }
  7258. if result3263.Infcode != "0" {
  7259. c.ServeSuccessJSON(map[string]interface{}{
  7260. "failed_code": -10,
  7261. "msg": result3263.ErrMsg,
  7262. })
  7263. return
  7264. } else {
  7265. c.ServeSuccessJSON(map[string]interface{}{
  7266. "msg": "上传成功",
  7267. })
  7268. return
  7269. }
  7270. }
  7271. func (c *HisApiController) Get3270() {
  7272. admin_user_id, _ := c.GetInt64("admin_user_id")
  7273. startTime := c.GetString("start_time")
  7274. //endTime, _ := c.GetString("end_time")
  7275. times := strings.Split(startTime, "-")
  7276. setl_mon := times[0] + times[1]
  7277. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7278. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7279. var result3263 models.JSResult3263
  7280. data2 := make(map[string]interface{})
  7281. data2["org_name"] = miConfig.OrgName
  7282. data2["doctor"] = curRoles.UserName
  7283. data2["doctor_name"] = curRoles.UserName
  7284. data2["fixmedins_code"] = miConfig.Code
  7285. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7286. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7287. data2["secret_key"] = miConfig.SecretKey
  7288. data2["url"] = miConfig.Url
  7289. data2["ak"] = miConfig.AccessKey
  7290. data2["cainfo"] = miConfig.Cainfo
  7291. data2["setl_mon"] = setl_mon
  7292. data2["stmt_loc"] = "2"
  7293. client2 := &http.Client{}
  7294. bytesData2, _ := json.Marshal(data2)
  7295. var req3263 *http.Request
  7296. if miConfig.MdtrtareaAdmvs == "320830" {
  7297. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7298. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7299. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7300. } else {
  7301. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7302. }
  7303. resp2, _ := client2.Do(req3263)
  7304. defer resp2.Body.Close()
  7305. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7306. if ioErr2 != nil {
  7307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7309. }
  7310. var respJSON3263 map[string]interface{}
  7311. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7314. }
  7315. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7316. fmt.Println(respJSON3263)
  7317. result2, _ := json.Marshal(respJSON3263)
  7318. fmt.Println(result2)
  7319. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7320. utils.ErrorLog("解析失败:%v", err)
  7321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7322. }
  7323. var ids []string
  7324. for _, item := range result3263.Output {
  7325. ids = append(ids, item.SolidifyID)
  7326. }
  7327. var result3264 models.JSResult3264
  7328. data := make(map[string]interface{})
  7329. data["org_name"] = miConfig.OrgName
  7330. data["doctor"] = curRoles.UserName
  7331. data["doctor_name"] = curRoles.UserName
  7332. data["fixmedins_code"] = miConfig.Code
  7333. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7334. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7335. data["secret_key"] = miConfig.SecretKey
  7336. data["url"] = miConfig.Url
  7337. data["ak"] = miConfig.AccessKey
  7338. data["cainfo"] = miConfig.Cainfo
  7339. data["setl_mon"] = setl_mon
  7340. data["stmt_loc"] = "2"
  7341. data["solidify_id"] = ids
  7342. client := &http.Client{}
  7343. bytesData, _ := json.Marshal(data)
  7344. var req *http.Request
  7345. if miConfig.MdtrtareaAdmvs == "320830" {
  7346. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7347. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7348. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7349. } else {
  7350. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7351. }
  7352. resp, _ := client.Do(req)
  7353. defer resp.Body.Close()
  7354. body, ioErr := ioutil.ReadAll(resp.Body)
  7355. if ioErr != nil {
  7356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. }
  7359. var respJSON map[string]interface{}
  7360. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. }
  7364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7365. fmt.Println(respJSON)
  7366. result, _ := json.Marshal(respJSON)
  7367. fmt.Println(result)
  7368. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7369. utils.ErrorLog("解析失败:%v", err)
  7370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. }
  7372. if result3264.Infcode != "0" {
  7373. c.ServeSuccessJSON(map[string]interface{}{
  7374. "failed_code": -10,
  7375. "msg": result3264.ErrMsg,
  7376. })
  7377. return
  7378. } else {
  7379. c.ServeSuccessJSON(map[string]interface{}{
  7380. "info": result3264.Output,
  7381. })
  7382. return
  7383. }
  7384. }
  7385. func (c *HisApiController) Get3271() {
  7386. admin_user_id, _ := c.GetInt64("admin_user_id")
  7387. startTime := c.GetString("start_time")
  7388. //endTime, _ := c.GetString("end_time")
  7389. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7390. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7391. times := strings.Split(startTime, "-")
  7392. setl_mon := times[0] + times[1]
  7393. //var empty models.JSResultEmpty
  7394. var result3265 models.JSResult3264
  7395. var result3263 models.JSResult3263
  7396. data2 := make(map[string]interface{})
  7397. data2["org_name"] = miConfig.OrgName
  7398. data2["doctor"] = curRoles.UserName
  7399. data2["doctor_name"] = curRoles.UserName
  7400. data2["fixmedins_code"] = miConfig.Code
  7401. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7402. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7403. data2["secret_key"] = miConfig.SecretKey
  7404. data2["url"] = miConfig.Url
  7405. data2["ak"] = miConfig.AccessKey
  7406. data2["cainfo"] = miConfig.Cainfo
  7407. data2["setl_mon"] = setl_mon
  7408. data2["stmt_loc"] = "2"
  7409. client2 := &http.Client{}
  7410. bytesData2, _ := json.Marshal(data2)
  7411. var req3263 *http.Request
  7412. if miConfig.MdtrtareaAdmvs == "320830" {
  7413. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7414. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7415. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7416. } else {
  7417. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7418. }
  7419. resp2, _ := client2.Do(req3263)
  7420. defer resp2.Body.Close()
  7421. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7422. if ioErr2 != nil {
  7423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7425. }
  7426. var respJSON3263 map[string]interface{}
  7427. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. }
  7431. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7432. fmt.Println(respJSON3263)
  7433. result2, _ := json.Marshal(respJSON3263)
  7434. fmt.Println(result2)
  7435. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7436. utils.ErrorLog("解析失败:%v", err)
  7437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7438. }
  7439. var ids []string
  7440. for _, item := range result3263.Output {
  7441. ids = append(ids, item.SolidifyID)
  7442. }
  7443. data := make(map[string]interface{})
  7444. data["org_name"] = miConfig.OrgName
  7445. data["doctor"] = curRoles.UserName
  7446. data["doctor_name"] = curRoles.UserName
  7447. data["fixmedins_code"] = miConfig.Code
  7448. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7450. data["secret_key"] = miConfig.SecretKey
  7451. data["url"] = miConfig.Url
  7452. data["ak"] = miConfig.AccessKey
  7453. data["cainfo"] = miConfig.Cainfo
  7454. data["setl_mon"] = setl_mon
  7455. data["solidify_id"] = ids
  7456. month := time.Unix(1557042972, 0).Format("1")
  7457. year := time.Now().Format("2006")
  7458. month = time.Now().Format("01")
  7459. day := time.Now().Format("02")
  7460. hour := time.Now().Format("15")
  7461. min := time.Now().Format("04")
  7462. sec := time.Now().Format("05")
  7463. fix_fill_date := year + month + day + hour + min + sec
  7464. data["fix_fill_dept"] = miConfig.OrgName
  7465. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7466. data["fix_fill_psn"] = curRoles.UserName
  7467. data["fix_fill_date"] = fix_fill_date
  7468. data["stmt_loc"] = "2"
  7469. client := &http.Client{}
  7470. bytesData, _ := json.Marshal(data)
  7471. var req *http.Request
  7472. if miConfig.MdtrtareaAdmvs == "320830" {
  7473. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7474. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7475. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7476. } else {
  7477. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7478. }
  7479. resp, _ := client.Do(req)
  7480. defer resp.Body.Close()
  7481. body, ioErr := ioutil.ReadAll(resp.Body)
  7482. if ioErr != nil {
  7483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7485. }
  7486. var respJSON map[string]interface{}
  7487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. }
  7491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7492. fmt.Println(respJSON)
  7493. result, _ := json.Marshal(respJSON)
  7494. fmt.Println(result)
  7495. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7496. utils.ErrorLog("解析失败:%v", err)
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7498. }
  7499. if result3265.Infcode != "0" {
  7500. c.ServeSuccessJSON(map[string]interface{}{
  7501. "failed_code": -10,
  7502. "msg": result3265.ErrMsg,
  7503. })
  7504. return
  7505. } else {
  7506. c.ServeSuccessJSON(map[string]interface{}{
  7507. "info": result3265.Output.Data,
  7508. })
  7509. return
  7510. }
  7511. }
  7512. func (c *HisApiController) Get3272() {
  7513. admin_user_id, _ := c.GetInt64("admin_user_id")
  7514. startTime := c.GetString("start_time")
  7515. //endTime, _ := c.GetString("end_time")
  7516. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7517. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7518. times := strings.Split(startTime, "-")
  7519. setl_mon := times[0] + times[1]
  7520. var upld_btch string
  7521. //var empty models.JSResultEmpty
  7522. var result3265 models.JSResult3264
  7523. data := make(map[string]interface{})
  7524. data["org_name"] = miConfig.OrgName
  7525. data["doctor"] = curRoles.UserName
  7526. data["doctor_name"] = curRoles.UserName
  7527. data["fixmedins_code"] = miConfig.Code
  7528. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7529. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7530. data["secret_key"] = miConfig.SecretKey
  7531. data["url"] = miConfig.Url
  7532. data["ak"] = miConfig.AccessKey
  7533. data["cainfo"] = miConfig.Cainfo
  7534. data["setl_mon"] = setl_mon
  7535. month := time.Unix(1557042972, 0).Format("1")
  7536. year := time.Now().Format("2006")
  7537. month = time.Now().Format("01")
  7538. day := time.Now().Format("02")
  7539. hour := time.Now().Format("15")
  7540. min := time.Now().Format("04")
  7541. sec := time.Now().Format("05")
  7542. fix_fill_date := year + month + day + hour + min + sec
  7543. data["fix_fill_dept"] = miConfig.OrgName
  7544. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7545. data["fix_fill_psn"] = curRoles.UserName
  7546. data["fix_fill_date"] = fix_fill_date
  7547. data["stmt_loc"] = "2"
  7548. data["upld_btch"] = upld_btch
  7549. client := &http.Client{}
  7550. bytesData, _ := json.Marshal(data)
  7551. var req *http.Request
  7552. if miConfig.MdtrtareaAdmvs == "320830" {
  7553. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7554. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7555. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7556. } else {
  7557. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7558. }
  7559. resp, _ := client.Do(req)
  7560. defer resp.Body.Close()
  7561. body, ioErr := ioutil.ReadAll(resp.Body)
  7562. if ioErr != nil {
  7563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. }
  7566. var respJSON map[string]interface{}
  7567. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7570. }
  7571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7572. fmt.Println(respJSON)
  7573. result, _ := json.Marshal(respJSON)
  7574. fmt.Println(result)
  7575. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7576. utils.ErrorLog("解析失败:%v", err)
  7577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7578. }
  7579. if result3265.Infcode != "0" {
  7580. c.ServeSuccessJSON(map[string]interface{}{
  7581. "failed_code": -10,
  7582. "msg": result3265.ErrMsg,
  7583. })
  7584. return
  7585. } else {
  7586. c.ServeSuccessJSON(map[string]interface{}{
  7587. "info": result3265.Output,
  7588. })
  7589. return
  7590. }
  7591. }
  7592. func (c *HisApiController) Get3273() {
  7593. admin_user_id, _ := c.GetInt64("admin_user_id")
  7594. startTime := c.GetString("start_time")
  7595. //endTime, _ := c.GetString("end_time")
  7596. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7598. times := strings.Split(startTime, "-")
  7599. setl_mon := times[0] + times[1]
  7600. var result3265 models.JSResult3264
  7601. data := make(map[string]interface{})
  7602. data["org_name"] = miConfig.OrgName
  7603. data["doctor"] = curRoles.UserName
  7604. data["doctor_name"] = curRoles.UserName
  7605. data["fixmedins_code"] = miConfig.Code
  7606. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7607. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7608. data["secret_key"] = miConfig.SecretKey
  7609. data["url"] = miConfig.Url
  7610. data["ak"] = miConfig.AccessKey
  7611. data["cainfo"] = miConfig.Cainfo
  7612. data["setl_mon"] = setl_mon
  7613. data["stmt_loc"] = "2"
  7614. client := &http.Client{}
  7615. bytesData, _ := json.Marshal(data)
  7616. var req *http.Request
  7617. if miConfig.MdtrtareaAdmvs == "320921" {
  7618. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7619. } else {
  7620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7621. }
  7622. resp, _ := client.Do(req)
  7623. defer resp.Body.Close()
  7624. body, ioErr := ioutil.ReadAll(resp.Body)
  7625. if ioErr != nil {
  7626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7628. }
  7629. var respJSON map[string]interface{}
  7630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7633. }
  7634. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7635. fmt.Println(respJSON)
  7636. result, _ := json.Marshal(respJSON)
  7637. fmt.Println(result)
  7638. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7639. utils.ErrorLog("解析失败:%v", err)
  7640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. }
  7642. if result3265.Infcode != "0" {
  7643. c.ServeSuccessJSON(map[string]interface{}{
  7644. "failed_code": -10,
  7645. "msg": result3265.ErrMsg,
  7646. })
  7647. return
  7648. } else {
  7649. c.ServeSuccessJSON(map[string]interface{}{
  7650. "info": result3265.Output.Data,
  7651. })
  7652. return
  7653. }
  7654. }
  7655. func (c *HisApiController) Get3274() {
  7656. //if miConfig.MdtrtareaAdmvs == "320921" {
  7657. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7658. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7659. // "&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
  7660. //
  7661. //} else {
  7662. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7663. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7664. // "&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
  7665. //
  7666. //}
  7667. }
  7668. func (c *HisApiController) Get3275() {
  7669. //if miConfig.MdtrtareaAdmvs == "320921" {
  7670. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7671. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7672. // "&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
  7673. //
  7674. //} else {
  7675. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7676. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7677. // "&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
  7678. //
  7679. //}
  7680. }
  7681. func (c *HisApiController) Get3276() {
  7682. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7683. //month := c.GetString("month")
  7684. //
  7685. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7686. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7687. //var api string
  7688. //var res Result5301
  7689. //
  7690. //if miConfig.MdtrtareaAdmvs == "320921" {
  7691. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7692. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7693. //} else {
  7694. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7695. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7696. //}
  7697. //
  7698. //resp, requestErr := http.Get(api)
  7699. //if requestErr != nil {
  7700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7701. // return
  7702. //}
  7703. //
  7704. //body, ioErr := ioutil.ReadAll(resp.Body)
  7705. //if ioErr != nil {
  7706. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7708. // return
  7709. //}
  7710. //var respJSON map[string]interface{}
  7711. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7712. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7714. // return
  7715. //}
  7716. //
  7717. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7718. //result, _ := json.Marshal(respJSON)
  7719. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7720. // utils.ErrorLog("解析失败:%v", err)
  7721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7722. // return
  7723. //}
  7724. }
  7725. func (c *HisApiController) Get3277() {
  7726. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7727. //month := c.GetString("month")
  7728. //
  7729. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7730. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7731. //var api string
  7732. //var res Result5301
  7733. //
  7734. //if miConfig.MdtrtareaAdmvs == "320921" {
  7735. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7736. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7737. //} else {
  7738. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7739. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7740. //}
  7741. //
  7742. //resp, requestErr := http.Get(api)
  7743. //if requestErr != nil {
  7744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7745. // return
  7746. //}
  7747. //
  7748. //body, ioErr := ioutil.ReadAll(resp.Body)
  7749. //if ioErr != nil {
  7750. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. // return
  7753. //}
  7754. //var respJSON map[string]interface{}
  7755. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. // return
  7759. //}
  7760. //
  7761. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7762. //result, _ := json.Marshal(respJSON)
  7763. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7764. // utils.ErrorLog("解析失败:%v", err)
  7765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7766. // return
  7767. //}
  7768. }
  7769. func (c *HisApiController) GetCFYLJG001() {
  7770. admin_user_id, _ := c.GetInt64("admin_user_id")
  7771. patient_id, _ := c.GetInt64("patient_id")
  7772. his_patient_id, _ := c.GetInt64("his_patient_id")
  7773. record_time := c.GetString("record_time")
  7774. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7775. psn, _ := service.GetPsnByPatientId(patient_id)
  7776. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7778. var cFYLJG001 models.CFYLJG001
  7779. timeLayout := "2006-01-02"
  7780. loc, _ := time.LoadLocation("Local")
  7781. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7782. if err != nil {
  7783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7784. return
  7785. }
  7786. recordDateTime := theTime.Unix()
  7787. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7788. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7789. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7790. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7791. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7792. for _, item := range prescriptions {
  7793. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7794. if his.IdCardType == 1 {
  7795. bas := strings.Split(psn.CardInfo, "|")
  7796. basNumber := bas[1]
  7797. fmt.Println(basNumber)
  7798. card_sn := bas[3]
  7799. card_no := bas[2]
  7800. cFYLJG001.MdtrtCertType = "03"
  7801. cFYLJG001.CardSn = card_sn
  7802. cFYLJG001.MdtrtCertNo = card_no
  7803. cFYLJG001.EcToken = ""
  7804. cFYLJG001.AuthNo = ""
  7805. } else if his.IdCardType == 2 {
  7806. cFYLJG001.MdtrtCertType = "02"
  7807. cFYLJG001.CardSn = ""
  7808. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7809. cFYLJG001.EcToken = ""
  7810. cFYLJG001.AuthNo = ""
  7811. } else if his.IdCardType == 4 {
  7812. cFYLJG001.MdtrtCertType = "01"
  7813. cFYLJG001.CardSn = ""
  7814. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7815. cFYLJG001.EcToken = psn.VerifyNumber
  7816. cFYLJG001.AuthNo = ""
  7817. }
  7818. cFYLJG001.BizTypeCode = "01"
  7819. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7820. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7821. cFYLJG001.RxTypeCode = "1"
  7822. tempTime := time.Unix(item.PreTime, 0)
  7823. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7824. cFYLJG001.PrscTime = timeFormatOne
  7825. var count float64
  7826. if item.Type == 1 {
  7827. for _, sumItem := range item.HisDoctorAdviceInfo {
  7828. count = count + sumItem.PrescribingNumber
  7829. }
  7830. }
  7831. cFYLJG001.RxDrugCnt = count
  7832. cFYLJG001.ValiDays = "2"
  7833. ts := time.Unix(item.PreTime, 0)
  7834. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7835. tempTime3 := time.Unix(record_time2, 0)
  7836. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7837. cFYLJG001.ValiEndTime = timeFormat3
  7838. cFYLJG001.RxCotnFlag = "0"
  7839. for _, subItem := range item.HisDoctorAdviceInfo {
  7840. var drug models.RxDrug
  7841. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7842. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7843. drug.RxItemTypeCode = "11"
  7844. drug.DrugDosform = "剂" //TODO
  7845. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7846. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7847. }
  7848. drug.MedcWayDscr = subItem.DeliveryWay
  7849. tempTime2 := time.Unix(subItem.StartTime, 0)
  7850. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7851. drug.MedcBegntime = timeFormatTwo
  7852. if subItem.Day > 0 {
  7853. ts := time.Unix(subItem.StartTime, 0)
  7854. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7855. tempTime4 := time.Unix(record_time, 0)
  7856. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7857. drug.MedcEndtime = timeFormat5
  7858. } else {
  7859. tempTime2 := time.Unix(subItem.StartTime, 0)
  7860. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7861. drug.MedcEndtime = timeFormatTwo
  7862. }
  7863. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7864. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7865. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7866. drug.DrugCnt = subItem.PrescribingNumber
  7867. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7868. drug.DrugGenname = subItem.AdviceName
  7869. drug.MedcWayCodg = subItem.DeliveryWay
  7870. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7871. drug.SinDoscnt = subItem.SingleDose
  7872. drug.SinDosunt = subItem.SingleDoseUnit
  7873. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7874. drug.UsedFrquName = subItem.ExecutionFrequency
  7875. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7876. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7877. drug.HospApprFlag = "1"
  7878. cFYLJG001.List = append(cFYLJG001.List, drug)
  7879. }
  7880. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7881. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7882. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7883. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7884. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7885. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7886. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7887. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7888. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7889. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7890. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7891. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7892. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7893. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7894. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7895. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7896. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7897. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7898. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7899. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7900. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7901. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7902. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7903. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7904. tempTime2 := time.Now().Unix()
  7905. tempTime6 := time.Unix(tempTime2, 0)
  7906. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7907. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7908. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  7909. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7910. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  7911. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  7912. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7913. var config []*models.HisXtDiagnoseConfig
  7914. for _, item := range diagnosis_ids {
  7915. id, _ := strconv.ParseInt(item, 10, 64)
  7916. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7917. config = append(config, &diagnosisConfig)
  7918. }
  7919. for index, subitem := range config {
  7920. if index == 0 {
  7921. var dia models.DiseInfo
  7922. dia.DiagType = "1"
  7923. dia.MaindiagFlag = "1"
  7924. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7925. dia.DiagCode = subitem.CountryCode
  7926. dia.DiagName = subitem.ClassName
  7927. dia.DiagDept = "肾内科"
  7928. dia.DiagDrNo = doctor.DoctorNumber
  7929. dia.DiagDrName = doctor.UserName
  7930. tempTime3 := time.Unix(item.PreTime, 0)
  7931. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7932. dia.DiagTime = timeFormatTwo
  7933. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7934. } else {
  7935. var dia models.DiseInfo
  7936. dia.DiagType = "1"
  7937. dia.MaindiagFlag = "0"
  7938. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7939. dia.DiagCode = subitem.CountryCode
  7940. dia.DiagName = subitem.ClassName
  7941. dia.DiagDept = "肾内科"
  7942. dia.DiagDrNo = doctor.DoctorNumber
  7943. dia.DiagDrName = doctor.UserName
  7944. tempTime3 := time.Unix(item.PreTime, 0)
  7945. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7946. dia.DiagTime = timeFormatTwo
  7947. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7948. }
  7949. }
  7950. if miConfig.MdtrtareaAdmvs == "340699" {
  7951. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  7952. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7953. var res ResultCFYLJG001AH
  7954. var respJSON2 map[string]interface{}
  7955. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. return
  7959. }
  7960. userJSONBytes2, _ := json.Marshal(respJSON2)
  7961. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7962. utils.ErrorLog("解析失败:%v", err)
  7963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7964. return
  7965. }
  7966. var flow models.HisPrescriptionFlow
  7967. flow.Ctime = time.Now().Unix()
  7968. flow.SignDigest = ""
  7969. flow.RxTraceCode = res.RxTraceCode
  7970. flow.HiRxno = res.HiRxno
  7971. flow.MID = his.Number
  7972. flow.Status = 1
  7973. flow.DCode = doctor_info.DoctorNumber
  7974. flow.OriginalRxFile = ""
  7975. flow.OriginalValue = ""
  7976. flow.SignCertDn = ""
  7977. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  7978. flow.SignCertSn = ""
  7979. flow.Mtime = time.Now().Unix()
  7980. service.Createflow(&flow)
  7981. c.ServeSuccessJSON(map[string]interface{}{
  7982. "msg": "上传成功",
  7983. })
  7984. } else {
  7985. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7986. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7987. var res ResultCFYLJG001
  7988. var respJSON2 map[string]interface{}
  7989. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7992. return
  7993. }
  7994. userJSONBytes2, _ := json.Marshal(respJSON2)
  7995. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7996. utils.ErrorLog("解析失败:%v", err)
  7997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7998. return
  7999. }
  8000. if res.Infcode == -1 {
  8001. c.ServeSuccessJSON(map[string]interface{}{
  8002. "failed_code": -10,
  8003. "msg": res.ErrMsg,
  8004. })
  8005. return
  8006. } else {
  8007. var flow models.HisPrescriptionFlow
  8008. flow.Ctime = time.Now().Unix()
  8009. flow.SignDigest = ""
  8010. flow.RxTraceCode = res.Output.RxTraceCode
  8011. flow.HiRxno = res.Output.HiRxno
  8012. flow.MID = his.Number
  8013. flow.Status = 1
  8014. flow.DCode = doctor_info.DoctorNumber
  8015. flow.OriginalRxFile = ""
  8016. flow.OriginalValue = ""
  8017. flow.SignCertDn = ""
  8018. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8019. flow.SignCertSn = ""
  8020. flow.Mtime = time.Now().Unix()
  8021. service.Createflow(&flow)
  8022. c.ServeSuccessJSON(map[string]interface{}{
  8023. "msg": "上传成功",
  8024. })
  8025. }
  8026. }
  8027. }
  8028. }
  8029. func (c *HisApiController) GetCFYLJG12() {
  8030. admin_user_id, _ := c.GetInt64("admin_user_id")
  8031. his_patient_id, _ := c.GetInt64("his_patient_id")
  8032. record_time := c.GetString("record_time")
  8033. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8034. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8035. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8036. flow, _ := service.Getflowtwo(his.Number)
  8037. patient_id, _ := c.GetInt64("patient_id")
  8038. timeLayout := "2006-01-02"
  8039. loc, _ := time.LoadLocation("Local")
  8040. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8041. if err != nil {
  8042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8043. return
  8044. }
  8045. recordDateTime := theTime.Unix()
  8046. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8047. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8048. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8049. dept, _ := service.GetDepartMentDetail(info.Departments)
  8050. inputData := make(map[string]interface{})
  8051. inputData["rxTraceCode"] = flow.RxTraceCode
  8052. inputData["hiRxno"] = flow.HiRxno
  8053. inputData["mdtrtId"] = flow.MID
  8054. inputData["patnName"] = his.PsnName
  8055. inputData["psnCertType"] = his.PsnCertType
  8056. inputData["certno"] = his.Certno
  8057. inputData["fixmedinsName"] = miConfig.OrgName
  8058. inputData["fixmedinsCode"] = miConfig.Code
  8059. inputData["drCode"] = doctor_info.DoctorNumber
  8060. inputData["prscDrName"] = doctor_info.UserName
  8061. inputData["pharDeptName"] = dept.Name
  8062. inputData["pharDeptCode"] = dept.Number
  8063. inputData["pharProfttlCodg"] = ""
  8064. inputData["pharProfttlName"] = ""
  8065. inputData["pharCode"] = "HY340621000425"
  8066. inputData["pharCertType"] = "01"
  8067. inputData["pharCertno"] = ""
  8068. inputData["pharName"] = "孙莉侠"
  8069. inputData["pharPracCertNo"] = ""
  8070. tempTime2 := time.Unix(info.Ctime, 0)
  8071. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8072. inputData["pharChkTime"] = timeFormatTwo
  8073. bytesData, _ := json.Marshal(inputData)
  8074. fmt.Println(string(bytesData))
  8075. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8076. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8077. if err != nil {
  8078. fmt.Println("Error reading PDF file:", err)
  8079. return
  8080. }
  8081. // 将 PDF 文件内容进行 Base64 编码
  8082. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8083. fmt.Println(err)
  8084. if miConfig.MdtrtareaAdmvs == "340699" {
  8085. data := make(map[string]interface{})
  8086. data["rx_encoded"] = rx_encoded
  8087. data["code"] = miConfig.Code
  8088. data["url"] = "http://10.66.149.64:8080/epc/api"
  8089. data["encoded"] = encoded
  8090. client := &http.Client{}
  8091. bytesData, _ := json.Marshal(data)
  8092. var req *http.Request
  8093. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8094. resp, _ := client.Do(req)
  8095. defer resp.Body.Close()
  8096. body, ioErr := ioutil.ReadAll(resp.Body)
  8097. if ioErr != nil {
  8098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8099. }
  8100. var respJSON map[string]interface{}
  8101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8104. return
  8105. }
  8106. var resSix10265 ResultSix10265 //1101结果
  8107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8108. result, _ := json.Marshal(respJSON)
  8109. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8110. utils.ErrorLog("解析失败:%v", err)
  8111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8112. return
  8113. }
  8114. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8115. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8116. } else {
  8117. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8118. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8119. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8120. var res2 AhResult002
  8121. var respJSON2 map[string]interface{}
  8122. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8125. return
  8126. }
  8127. userJSONBytes2, _ := json.Marshal(respJSON2)
  8128. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8129. utils.ErrorLog("解析失败:%v", err)
  8130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8131. return
  8132. }
  8133. flow.Ctime = time.Now().Unix()
  8134. flow.SignDigest = res2.SignDigest
  8135. flow.RxFile = res2.RxFile
  8136. flow.MID = his.Number
  8137. flow.Status = 1
  8138. flow.DCode = doctor_info.DoctorNumber
  8139. flow.OriginalRxFile = rx_encoded
  8140. flow.OriginalValue = encoded
  8141. flow.SignCertDn = res2.SignCertDn
  8142. flow.SignCertSn = res2.SignCertSn
  8143. flow.Mtime = time.Now().Unix()
  8144. service.Saveflow(flow)
  8145. c.ServeSuccessJSON(map[string]interface{}{
  8146. "msg": "预签名成功",
  8147. })
  8148. }
  8149. }
  8150. func (c *HisApiController) GetCFYLJG13() {
  8151. admin_user_id, _ := c.GetInt64("admin_user_id")
  8152. his_patient_id, _ := c.GetInt64("his_patient_id")
  8153. record_time := c.GetString("record_time")
  8154. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8155. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8157. flow, _ := service.Getflowtwo(his.Number)
  8158. patient_id, _ := c.GetInt64("patient_id")
  8159. timeLayout := "2006-01-02"
  8160. loc, _ := time.LoadLocation("Local")
  8161. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8162. if err != nil {
  8163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8164. return
  8165. }
  8166. recordDateTime := theTime.Unix()
  8167. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8168. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8169. dept, _ := service.GetDepartMentDetail(info.Departments)
  8170. var cFYLJG003 models.CFYLJG003
  8171. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8172. cFYLJG003.HiRxno = flow.HiRxno
  8173. cFYLJG003.MdtrtID = flow.MID
  8174. cFYLJG003.PatnName = his.Name
  8175. cFYLJG003.Certno = his.Certno
  8176. cFYLJG003.FixmedinsName = miConfig.OrgName
  8177. cFYLJG003.FixmedinsCode = miConfig.Code
  8178. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8179. cFYLJG003.PrscDrName = doctor_info.UserName
  8180. cFYLJG003.PharDeptName = dept.Name
  8181. cFYLJG003.PharDeptCode = dept.Number
  8182. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8183. cFYLJG003.PharName = "孙莉侠"
  8184. cFYLJG003.PharPracCertNo = "060399"
  8185. cFYLJG003.PharCode = "HY340621000425"
  8186. cFYLJG003.PharCertType = "01"
  8187. cFYLJG003.PharCertno = ""
  8188. } else {
  8189. cFYLJG003.PharName = "彭斯遥"
  8190. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8191. cFYLJG003.PharCode = "HY440309002107"
  8192. cFYLJG003.PharCertType = "01"
  8193. cFYLJG003.PharCertno = "430482199408260023"
  8194. }
  8195. cFYLJG003.PsnCertType = "01"
  8196. cFYLJG003.RxFile = flow.RxFile
  8197. cFYLJG003.SignDigest = flow.SignDigest
  8198. cFYLJG003.FixmedinsCode = miConfig.Code
  8199. cFYLJG003.PsnCertType = "01"
  8200. cFYLJG003.PharProfttlCodg = dept.Name
  8201. tempTime2 := time.Unix(info.Ctime, 0)
  8202. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8203. cFYLJG003.PharChkTime = timeFormatTwo
  8204. if miConfig.MdtrtareaAdmvs == "340699" {
  8205. data := make(map[string]interface{})
  8206. data["url"] = "http://10.66.149.64:8080/epc/api"
  8207. data["13"] = cFYLJG003
  8208. client := &http.Client{}
  8209. bytesData, _ := json.Marshal(data)
  8210. var req *http.Request
  8211. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8212. resp, _ := client.Do(req)
  8213. defer resp.Body.Close()
  8214. body, ioErr := ioutil.ReadAll(resp.Body)
  8215. if ioErr != nil {
  8216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8217. }
  8218. var respJSON map[string]interface{}
  8219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8222. return
  8223. }
  8224. var resSix10265 ResultSix10265 //1101结果
  8225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8226. result, _ := json.Marshal(respJSON)
  8227. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8228. utils.ErrorLog("解析失败:%v", err)
  8229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8230. return
  8231. }
  8232. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8233. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8234. } else {
  8235. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8236. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8237. var res ResultCFYLJG003
  8238. var respJSON2 map[string]interface{}
  8239. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8242. return
  8243. }
  8244. userJSONBytes2, _ := json.Marshal(respJSON2)
  8245. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8246. utils.ErrorLog("解析失败:%v", err)
  8247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8248. return
  8249. }
  8250. if res.Infcode == -1 {
  8251. c.ServeSuccessJSON(map[string]interface{}{
  8252. "failed_code": -10,
  8253. "msg": res.ErrMsg,
  8254. })
  8255. return
  8256. } else {
  8257. c.ServeSuccessJSON(map[string]interface{}{
  8258. "info": res.Output,
  8259. })
  8260. }
  8261. }
  8262. }
  8263. func (c *HisApiController) GetCFYLJG002() {
  8264. admin_user_id, _ := c.GetInt64("admin_user_id")
  8265. his_patient_id, _ := c.GetInt64("his_patient_id")
  8266. record_time := c.GetString("record_time")
  8267. admin_user_id = 3626
  8268. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8269. //id, _ := c.GetInt64("id")
  8270. admin_user_id = 3626
  8271. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8272. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8273. flow, _ := service.Getflowtwo(his.Number)
  8274. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8275. //record_time := c.GetString("record_time")
  8276. patient_id, _ := c.GetInt64("patient_id")
  8277. //patient_id = 23834
  8278. //record_time = "2023-09-18"
  8279. timeLayout := "2006-01-02"
  8280. loc, _ := time.LoadLocation("Local")
  8281. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8282. if err != nil {
  8283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8284. return
  8285. }
  8286. recordDateTime := theTime.Unix()
  8287. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8288. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8289. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8290. dept, _ := service.GetDepartMentDetail(info.Departments)
  8291. inputData := make(map[string]interface{})
  8292. inputData["rxTraceCode"] = flow.RxTraceCode
  8293. inputData["hiRxno"] = flow.HiRxno
  8294. inputData["mdtrtId"] = flow.MID
  8295. inputData["patnName"] = his.PsnName
  8296. inputData["psnCertType"] = his.PsnCertType
  8297. inputData["certno"] = his.Certno
  8298. inputData["fixmedinsName"] = miConfig.OrgName
  8299. inputData["fixmedinsCode"] = miConfig.Code
  8300. inputData["drCode"] = doctor_info.DoctorNumber
  8301. inputData["prscDrName"] = doctor_info.UserName
  8302. inputData["pharDeptName"] = dept.Name
  8303. inputData["pharDeptCode"] = dept.Number
  8304. inputData["pharProfttlCodg"] = ""
  8305. inputData["pharProfttlName"] = ""
  8306. inputData["pharCode"] = "HY340621000425"
  8307. inputData["pharCertType"] = "01"
  8308. inputData["pharCertno"] = ""
  8309. inputData["pharName"] = "孙莉侠"
  8310. inputData["pharPracCertNo"] = "060399"
  8311. tempTime2 := time.Unix(info.Ctime, 0)
  8312. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8313. inputData["pharChkTime"] = timeFormatTwo
  8314. bytesData, _ := json.Marshal(inputData)
  8315. fmt.Println(string(bytesData))
  8316. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8317. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8318. if err != nil {
  8319. fmt.Println("Error reading PDF file:", err)
  8320. return
  8321. }
  8322. // 将 PDF 文件内容进行 Base64 编码
  8323. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8324. fmt.Println(err)
  8325. if miConfig.MdtrtareaAdmvs == "340699" {
  8326. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8327. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8328. var res2 AhResult002
  8329. var respJSON2 map[string]interface{}
  8330. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8333. return
  8334. }
  8335. userJSONBytes2, _ := json.Marshal(respJSON2)
  8336. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8337. utils.ErrorLog("解析失败:%v", err)
  8338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8339. return
  8340. }
  8341. flow.Ctime = time.Now().Unix()
  8342. flow.SignDigest = res2.SignDigest
  8343. flow.RxFile = res2.RxFile
  8344. flow.MID = his.Number
  8345. flow.Status = 1
  8346. flow.DCode = doctor_info.DoctorNumber
  8347. flow.OriginalRxFile = rx_encoded
  8348. flow.OriginalValue = encoded
  8349. flow.SignCertDn = res2.SignCertDn
  8350. flow.SignCertSn = res2.SignCertSn
  8351. flow.Mtime = time.Now().Unix()
  8352. service.Saveflow(flow)
  8353. c.ServeSuccessJSON(map[string]interface{}{
  8354. "msg": "预签名成功",
  8355. })
  8356. } else {
  8357. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8358. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8359. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8360. var res2 Result002
  8361. var respJSON2 map[string]interface{}
  8362. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8365. return
  8366. }
  8367. userJSONBytes2, _ := json.Marshal(respJSON2)
  8368. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8369. utils.ErrorLog("解析失败:%v", err)
  8370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8371. return
  8372. }
  8373. if res2.Infcode == 0 {
  8374. flow.Ctime = time.Now().Unix()
  8375. flow.SignDigest = res2.Output.SignDigest
  8376. flow.RxFile = res2.Output.RxFile
  8377. flow.MID = his.Number
  8378. flow.Status = 1
  8379. flow.DCode = doctor_info.DoctorNumber
  8380. flow.OriginalRxFile = rx_encoded
  8381. flow.OriginalValue = encoded
  8382. flow.SignCertDn = res2.Output.SignCertDn
  8383. flow.SignCertSn = res2.Output.SignCertSn
  8384. flow.Mtime = time.Now().Unix()
  8385. service.Saveflow(flow)
  8386. c.ServeSuccessJSON(map[string]interface{}{
  8387. "msg": "预签名成功",
  8388. })
  8389. } else {
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8391. return
  8392. }
  8393. }
  8394. }
  8395. func (c *HisApiController) GetCFYLJG003() {
  8396. admin_user_id, _ := c.GetInt64("admin_user_id")
  8397. his_patient_id, _ := c.GetInt64("his_patient_id")
  8398. record_time := c.GetString("record_time")
  8399. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8400. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8401. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8402. flow, _ := service.Getflowtwo(his.Number)
  8403. patient_id, _ := c.GetInt64("patient_id")
  8404. timeLayout := "2006-01-02"
  8405. loc, _ := time.LoadLocation("Local")
  8406. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8407. if err != nil {
  8408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8409. return
  8410. }
  8411. recordDateTime := theTime.Unix()
  8412. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8413. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8414. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8415. dept, _ := service.GetDepartMentDetail(info.Departments)
  8416. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8417. var cFYLJG003 models.CFYLJG003
  8418. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8419. cFYLJG003.HiRxno = flow.HiRxno
  8420. cFYLJG003.MdtrtID = flow.MID
  8421. cFYLJG003.PatnName = his.PsnName
  8422. cFYLJG003.Certno = his.Certno
  8423. cFYLJG003.FixmedinsName = miConfig.OrgName
  8424. cFYLJG003.FixmedinsCode = miConfig.Code
  8425. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8426. cFYLJG003.PrscDrName = doctor_info.UserName
  8427. cFYLJG003.PharDeptName = dept.Name
  8428. cFYLJG003.PharDeptCode = dept.Number
  8429. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8430. cFYLJG003.PharName = "孙莉侠"
  8431. cFYLJG003.PharPracCertNo = "060399"
  8432. cFYLJG003.PharCode = "HY340621000425"
  8433. cFYLJG003.PharCertType = "01"
  8434. cFYLJG003.PharCertno = ""
  8435. } else {
  8436. cFYLJG003.PharName = "彭斯遥"
  8437. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8438. cFYLJG003.PharCode = "HY440309002107"
  8439. cFYLJG003.PharCertType = "01"
  8440. cFYLJG003.PharCertno = "430482199408260023"
  8441. }
  8442. cFYLJG003.RxFile = flow.RxFile
  8443. cFYLJG003.SignDigest = flow.SignDigest
  8444. cFYLJG003.FixmedinsCode = miConfig.Code
  8445. cFYLJG003.PsnCertType = his.PsnCertType
  8446. tempTime2 := time.Unix(info.Ctime, 0)
  8447. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8448. cFYLJG003.PharChkTime = timeFormatTwo
  8449. if miConfig.MdtrtareaAdmvs == "340699" {
  8450. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8451. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8452. var res AHResult003
  8453. var respJSON2 map[string]interface{}
  8454. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8457. return
  8458. }
  8459. userJSONBytes2, _ := json.Marshal(respJSON2)
  8460. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8461. utils.ErrorLog("解析失败:%v", err)
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8463. return
  8464. }
  8465. {
  8466. c.ServeSuccessJSON(map[string]interface{}{
  8467. "info": res,
  8468. })
  8469. }
  8470. } else {
  8471. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8472. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8473. var res ResultCFYLJG003
  8474. var respJSON2 map[string]interface{}
  8475. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. return
  8479. }
  8480. userJSONBytes2, _ := json.Marshal(respJSON2)
  8481. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8482. utils.ErrorLog("解析失败:%v", err)
  8483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8484. return
  8485. }
  8486. if res.Infcode == -1 {
  8487. c.ServeSuccessJSON(map[string]interface{}{
  8488. "failed_code": -10,
  8489. "msg": res.ErrMsg,
  8490. })
  8491. return
  8492. } else {
  8493. c.ServeSuccessJSON(map[string]interface{}{
  8494. "info": res.Output,
  8495. })
  8496. }
  8497. }
  8498. }
  8499. func (c *HisApiController) GetCFYLJG004() {
  8500. admin_user_id, _ := c.GetInt64("admin_user_id")
  8501. his_patient_id, _ := c.GetInt64("his_patient_id")
  8502. record_time := c.GetString("record_time")
  8503. admin_user_id = 3626
  8504. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8505. //id, _ := c.GetInt64("id")
  8506. admin_user_id = 3626
  8507. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8508. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8509. flow, _ := service.Getflowtwo(his.Number)
  8510. //id = 3
  8511. patient_id, _ := c.GetInt64("patient_id")
  8512. //patient_id = 23834
  8513. //record_time = "2023-09-18"
  8514. timeLayout := "2006-01-02"
  8515. loc, _ := time.LoadLocation("Local")
  8516. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8517. if err != nil {
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8519. return
  8520. }
  8521. recordDateTime := theTime.Unix()
  8522. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8523. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8524. var cFYLJG004 models.CFYLJG004
  8525. cFYLJG004.HiRxno = flow.HiRxno
  8526. cFYLJG004.FixmedinsCode = miConfig.Code
  8527. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8528. cFYLJG004.UndoDrCertType = "01"
  8529. cFYLJG004.UndoRea = "撤销处方"
  8530. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8531. cFYLJG004.UndoDrName = doctor_info.UserName
  8532. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8533. if miConfig.MdtrtareaAdmvs == "340699" {
  8534. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8535. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8536. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8537. } else {
  8538. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8539. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8540. var res ResultCFYLJG004
  8541. var respJSON2 map[string]interface{}
  8542. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. userJSONBytes2, _ := json.Marshal(respJSON2)
  8548. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8549. utils.ErrorLog("解析失败:%v", err)
  8550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8551. return
  8552. }
  8553. if res.Infcode == -1 {
  8554. c.ServeSuccessJSON(map[string]interface{}{
  8555. "failed_code": -10,
  8556. "msg": res.ErrMsg,
  8557. })
  8558. return
  8559. } else {
  8560. flow.Status = 0
  8561. service.Saveflow(flow)
  8562. c.ServeSuccessJSON(map[string]interface{}{
  8563. "msg": "撤销成功",
  8564. })
  8565. return
  8566. }
  8567. }
  8568. }
  8569. func (c *HisApiController) GetCFYLJG005() {
  8570. admin_user_id, _ := c.GetInt64("admin_user_id")
  8571. his_patient_id, _ := c.GetInt64("his_patient_id")
  8572. //record_time := c.GetString("record_time")
  8573. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8574. //id, _ := c.GetInt64("id")
  8575. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8577. flow, _ := service.Getflowtwo(his.Number)
  8578. //id = 3
  8579. var cFYLJG005 models.CFYLJG005
  8580. //patient_id, _ := c.GetInt64("patient_id")
  8581. cFYLJG005.HiRxno = flow.HiRxno
  8582. cFYLJG005.MdtrtID = flow.MID
  8583. cFYLJG005.EcToken = ""
  8584. cFYLJG005.PsnName = his.Name
  8585. cFYLJG005.PsnCertType = "01"
  8586. cFYLJG005.Certno = his.IdCardNo
  8587. if miConfig.MdtrtareaAdmvs == "340699" {
  8588. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8589. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8590. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8591. } else {
  8592. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8593. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8594. var res ResultCFYLJG005
  8595. var respJSON2 map[string]interface{}
  8596. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8599. return
  8600. }
  8601. userJSONBytes2, _ := json.Marshal(respJSON2)
  8602. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8603. utils.ErrorLog("解析失败:%v", err)
  8604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8605. return
  8606. }
  8607. if res.Infcode == -1 {
  8608. c.ServeSuccessJSON(map[string]interface{}{
  8609. "failed_code": -10,
  8610. "msg": res.ErrMsg,
  8611. })
  8612. return
  8613. } else {
  8614. c.ServeSuccessJSON(map[string]interface{}{
  8615. "info": res.Output,
  8616. })
  8617. return
  8618. }
  8619. }
  8620. }
  8621. func (c *HisApiController) GetCFYLJG006() {
  8622. admin_user_id, _ := c.GetInt64("admin_user_id")
  8623. his_patient_id, _ := c.GetInt64("his_patient_id")
  8624. admin_user_id = 3626
  8625. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8626. //id, _ := c.GetInt64("id")
  8627. admin_user_id = 3626
  8628. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8629. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8630. flow, _ := service.Getflowtwo(his.Number)
  8631. //id = 3
  8632. patient_id, _ := c.GetInt64("patient_id")
  8633. var cFYLJG006 models.CFYLJG006
  8634. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8635. cFYLJG006.HiRxno = flow.HiRxno
  8636. cFYLJG006.MdtrtID = flow.MID
  8637. cFYLJG006.PsnName = patient.Name
  8638. cFYLJG006.PsnCertType = "01"
  8639. cFYLJG006.Certno = patient.IdCardNo
  8640. if miConfig.MdtrtareaAdmvs == "340699" {
  8641. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8642. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8643. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8644. } else {
  8645. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8646. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8647. var res ResultCFYLJG006
  8648. var respJSON2 map[string]interface{}
  8649. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8652. return
  8653. }
  8654. userJSONBytes2, _ := json.Marshal(respJSON2)
  8655. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8656. utils.ErrorLog("解析失败:%v", err)
  8657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8658. return
  8659. }
  8660. if res.Infcode == -1 {
  8661. c.ServeSuccessJSON(map[string]interface{}{
  8662. "failed_code": -10,
  8663. "msg": res.ErrMsg,
  8664. })
  8665. return
  8666. } else {
  8667. c.ServeSuccessJSON(map[string]interface{}{
  8668. "info": res.Output,
  8669. })
  8670. return
  8671. }
  8672. }
  8673. }
  8674. func (c *HisApiController) GetCFYLJG007() {
  8675. admin_user_id, _ := c.GetInt64("admin_user_id")
  8676. his_patient_id, _ := c.GetInt64("his_patient_id")
  8677. admin_user_id = 3626
  8678. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8679. //id, _ := c.GetInt64("id")
  8680. admin_user_id = 3626
  8681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8683. flow, _ := service.Getflowtwo(his.Number)
  8684. //id = 3
  8685. patient_id, _ := c.GetInt64("patient_id")
  8686. var cFYLJG007 models.CFYLJG007
  8687. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8688. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8689. cFYLJG007.HiRxno = flow.HiRxno
  8690. cFYLJG007.MdtrtID = flow.MID
  8691. cFYLJG007.PsnNo = his.PsnNo
  8692. cFYLJG007.PsnCertType = "01"
  8693. cFYLJG007.Certno = patient.IdCardNo
  8694. cFYLJG007.PsnName = patient.Name
  8695. if miConfig.MdtrtareaAdmvs == "340699" {
  8696. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8697. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8698. } else {
  8699. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8700. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8701. var res ResultCFYLJG007
  8702. var respJSON2 map[string]interface{}
  8703. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8706. return
  8707. }
  8708. userJSONBytes2, _ := json.Marshal(respJSON2)
  8709. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8710. utils.ErrorLog("解析失败:%v", err)
  8711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8712. return
  8713. }
  8714. if res.Infcode == -1 {
  8715. c.ServeSuccessJSON(map[string]interface{}{
  8716. "failed_code": -10,
  8717. "msg": res.ErrMsg,
  8718. })
  8719. return
  8720. } else {
  8721. c.ServeSuccessJSON(map[string]interface{}{
  8722. "info": res,
  8723. })
  8724. return
  8725. }
  8726. }
  8727. }
  8728. func (c *HisApiController) GetCFYLJG008() {
  8729. admin_user_id, _ := c.GetInt64("admin_user_id")
  8730. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8731. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8732. var cFYLJG008 models.CFYLJG008
  8733. //id, _ := c.GetInt64("id")
  8734. patient_id, _ := c.GetInt64("patient_id")
  8735. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8736. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8737. //id = 3
  8738. //flow, _ := service.Getflow(id)
  8739. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8740. //
  8741. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8742. //patient_id, _ := c.GetInt64("patient_id")
  8743. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8744. record_time := c.GetString("record_time")
  8745. admin_user_id = 3626
  8746. patient_id = 19424
  8747. //his_patient_id = 263947
  8748. record_time = "2023-08-29"
  8749. timeLayout := "2006-01-02"
  8750. loc, _ := time.LoadLocation("Local")
  8751. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8752. if err != nil {
  8753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8754. return
  8755. }
  8756. recordDateTime := theTime.Unix()
  8757. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8758. cFYLJG008.FixmedinsName = ""
  8759. cFYLJG008.Lat = ""
  8760. cFYLJG008.Lng = ""
  8761. cFYLJG008.OrderType = "1"
  8762. cFYLJG008.PoolareaNo = ""
  8763. cFYLJG008.Lng = ""
  8764. cFYLJG008.PageNum = 1
  8765. cFYLJG008.PageSize = 10
  8766. var MPI models.MedinsProdInvChgDDTO
  8767. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8768. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8769. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8770. if miConfig.MdtrtareaAdmvs == "340699" {
  8771. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8772. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8773. } else {
  8774. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8775. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8776. var res ResultCFYLJG008
  8777. var respJSON2 map[string]interface{}
  8778. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8781. return
  8782. }
  8783. userJSONBytes2, _ := json.Marshal(respJSON2)
  8784. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8785. utils.ErrorLog("解析失败:%v", err)
  8786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8787. return
  8788. }
  8789. if res.Infcode == -1 {
  8790. c.ServeSuccessJSON(map[string]interface{}{
  8791. "failed_code": -10,
  8792. "msg": res.ErrMsg,
  8793. })
  8794. return
  8795. } else {
  8796. c.ServeSuccessJSON(map[string]interface{}{
  8797. "info": res.Output,
  8798. })
  8799. return
  8800. }
  8801. }
  8802. }
  8803. func (c *HisApiController) GetBL4201A() {
  8804. order_id, _ := c.GetInt64("order_id")
  8805. admin_user_id, _ := c.GetInt64("admin_user_id")
  8806. order, _ := service.GetHisOrderByIDTwo(order_id)
  8807. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8808. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8809. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8810. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8811. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8812. department, _ := service.GetDepartMentDetail(his.Departments)
  8813. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8814. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8815. if order.ID == 0 {
  8816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8817. return
  8818. }
  8819. var struct4201A models.Struct4201A
  8820. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8821. for _, items := range order_info {
  8822. memo := make(map[string]interface{})
  8823. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8824. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8825. fsiOPFLD.MedType = "14"
  8826. fsiOPFLD.BkkpSn = items.FeedetlSn
  8827. fsiOPFLD.FixmedinsCode = miConfig.Code
  8828. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8829. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8830. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8831. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8832. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8833. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8834. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8835. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8836. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8837. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8838. fsiOPFLD.BilgDeptName = department.Name
  8839. fsiOPFLD.BilgDeptCodg = department.Number
  8840. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8841. fsiOPFLD.BilgDrName = doctor.UserName
  8842. fsiOPFLD.MedChrgitmType = "09"
  8843. memo["hosp_appr_flag"] = "1"
  8844. memo["invoice_no"] = order.MdtrtId
  8845. memo["memo"] = "自费"
  8846. bytesData, _ := json.Marshal(memo)
  8847. fsiOPFLD.Memo = string(bytesData)
  8848. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8849. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8850. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8851. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8852. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8853. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8854. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8855. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8856. fsiOPFLD.BilgDeptName = department.Name
  8857. fsiOPFLD.BilgDeptCodg = department.Number
  8858. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8859. fsiOPFLD.BilgDrName = doctor.UserName
  8860. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8861. case 0:
  8862. break
  8863. case 1:
  8864. fsiOPFLD.MedChrgitmType = "14"
  8865. break
  8866. case 2:
  8867. fsiOPFLD.MedChrgitmType = "05"
  8868. break
  8869. case 3:
  8870. fsiOPFLD.MedChrgitmType = "03"
  8871. break
  8872. case 4:
  8873. fsiOPFLD.MedChrgitmType = "03"
  8874. break
  8875. case 5:
  8876. fsiOPFLD.MedChrgitmType = "08"
  8877. break
  8878. case 6:
  8879. fsiOPFLD.MedChrgitmType = "14"
  8880. break
  8881. case 7:
  8882. fsiOPFLD.MedChrgitmType = "14"
  8883. break
  8884. case 8:
  8885. fsiOPFLD.MedChrgitmType = "03"
  8886. break
  8887. case 9:
  8888. fsiOPFLD.MedChrgitmType = "14"
  8889. break
  8890. case 10:
  8891. fsiOPFLD.MedChrgitmType = "14"
  8892. break
  8893. case 11:
  8894. fsiOPFLD.MedChrgitmType = "06"
  8895. break
  8896. case 12:
  8897. fsiOPFLD.MedChrgitmType = "12"
  8898. break
  8899. case 13:
  8900. fsiOPFLD.MedChrgitmType = "01"
  8901. break
  8902. case 14:
  8903. fsiOPFLD.MedChrgitmType = "04"
  8904. break
  8905. case 15:
  8906. fsiOPFLD.MedChrgitmType = "14"
  8907. break
  8908. }
  8909. memo["hosp_appr_flag"] = "1"
  8910. memo["invoice_no"] = order.MdtrtId
  8911. memo["memo"] = "自费"
  8912. bytesData, _ := json.Marshal(memo)
  8913. fsiOPFLD.Memo = string(bytesData)
  8914. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8915. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8916. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8917. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8918. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8919. fsiOPFLD.BilgDeptName = department.Name
  8920. fsiOPFLD.BilgDeptCodg = department.Number
  8921. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8922. fsiOPFLD.BilgDrName = doctor.UserName
  8923. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8924. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8925. fsiOPFLD.MedChrgitmType = "08"
  8926. memo["hosp_appr_flag"] = "1"
  8927. memo["invoice_no"] = order.MdtrtId
  8928. memo["memo"] = "自费"
  8929. bytesData, _ := json.Marshal(memo)
  8930. fsiOPFLD.Memo = string(bytesData)
  8931. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8932. }
  8933. }
  8934. }
  8935. for _, items := range order_info_two {
  8936. memo := make(map[string]interface{})
  8937. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8938. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8939. fsiOPFLD.MedType = "14"
  8940. fsiOPFLD.BkkpSn = items.FeedetlSn
  8941. fsiOPFLD.FixmedinsCode = miConfig.Code
  8942. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8943. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8944. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8945. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8946. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8947. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8948. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8949. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8950. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8951. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8952. fsiOPFLD.BilgDeptName = department.Name
  8953. fsiOPFLD.BilgDeptCodg = department.Number
  8954. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8955. fsiOPFLD.BilgDrName = doctor.UserName
  8956. fsiOPFLD.MedChrgitmType = "09"
  8957. memo["hosp_appr_flag"] = "1"
  8958. memo["invoice_no"] = order.MdtrtId
  8959. memo["memo"] = "自费"
  8960. bytesData, _ := json.Marshal(memo)
  8961. fsiOPFLD.Memo = string(bytesData)
  8962. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8963. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8964. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8965. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8966. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8967. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8968. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8969. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8970. fsiOPFLD.BilgDeptName = department.Name
  8971. fsiOPFLD.BilgDeptCodg = department.Number
  8972. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8973. fsiOPFLD.BilgDrName = doctor.UserName
  8974. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8975. case 0:
  8976. break
  8977. case 1:
  8978. fsiOPFLD.MedChrgitmType = "14"
  8979. break
  8980. case 2:
  8981. fsiOPFLD.MedChrgitmType = "05"
  8982. break
  8983. case 3:
  8984. fsiOPFLD.MedChrgitmType = "03"
  8985. break
  8986. case 4:
  8987. fsiOPFLD.MedChrgitmType = "03"
  8988. break
  8989. case 5:
  8990. fsiOPFLD.MedChrgitmType = "08"
  8991. break
  8992. case 6:
  8993. fsiOPFLD.MedChrgitmType = "14"
  8994. break
  8995. case 7:
  8996. fsiOPFLD.MedChrgitmType = "14"
  8997. break
  8998. case 8:
  8999. fsiOPFLD.MedChrgitmType = "03"
  9000. break
  9001. case 9:
  9002. fsiOPFLD.MedChrgitmType = "14"
  9003. break
  9004. case 10:
  9005. fsiOPFLD.MedChrgitmType = "14"
  9006. break
  9007. case 11:
  9008. fsiOPFLD.MedChrgitmType = "06"
  9009. break
  9010. case 12:
  9011. fsiOPFLD.MedChrgitmType = "12"
  9012. break
  9013. case 13:
  9014. fsiOPFLD.MedChrgitmType = "01"
  9015. break
  9016. case 14:
  9017. fsiOPFLD.MedChrgitmType = "04"
  9018. break
  9019. case 15:
  9020. fsiOPFLD.MedChrgitmType = "14"
  9021. break
  9022. }
  9023. memo["hosp_appr_flag"] = "1"
  9024. memo["invoice_no"] = order.MdtrtId
  9025. memo["memo"] = "自费"
  9026. bytesData, _ := json.Marshal(memo)
  9027. fsiOPFLD.Memo = string(bytesData)
  9028. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9029. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9030. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9031. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9032. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9033. fsiOPFLD.BilgDeptName = department.Name
  9034. fsiOPFLD.BilgDeptCodg = department.Number
  9035. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9036. fsiOPFLD.BilgDrName = doctor.UserName
  9037. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9038. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9039. fsiOPFLD.MedChrgitmType = "08"
  9040. memo["hosp_appr_flag"] = "1"
  9041. memo["invoice_no"] = order.MdtrtId
  9042. memo["memo"] = "自费"
  9043. bytesData, _ := json.Marshal(memo)
  9044. fsiOPFLD.Memo = string(bytesData)
  9045. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9046. }
  9047. }
  9048. }
  9049. fmt.Println(fsiOPFLDs)
  9050. struct4201A.Fopfd = fsiOPFLDs
  9051. fmt.Println(struct4201A.Fopfd)
  9052. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9053. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9054. var res2 ResultSix
  9055. var respJSON2 map[string]interface{}
  9056. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9059. return
  9060. }
  9061. userJSONBytes2, _ := json.Marshal(respJSON2)
  9062. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9063. utils.ErrorLog("解析失败:%v", err)
  9064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9065. return
  9066. }
  9067. if res2.Infcode != 0 {
  9068. c.ServeSuccessJSON(map[string]interface{}{
  9069. "failed_code": -10,
  9070. "msg": res2.ErrMsg,
  9071. })
  9072. return
  9073. } else {
  9074. order.IsUploadOrderInfo = 1
  9075. service.UpdateOrder(order)
  9076. c.ServeSuccessJSON(map[string]interface{}{
  9077. "msg": "上传成功",
  9078. })
  9079. }
  9080. }
  9081. func (c *HisApiController) Get3103() {
  9082. admin_user_id, _ := c.GetInt64("admin_user_id")
  9083. warm_type, _ := c.GetInt64("warm_type")
  9084. fk_state, _ := c.GetInt64("fk_state")
  9085. warm_ids := c.GetString("warm_ids")
  9086. desc := c.GetString("desc")
  9087. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9088. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9089. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9090. saveLog(result, requestLog, "3103", "反馈")
  9091. var res2 ResultSix3103
  9092. var respJSON2 map[string]interface{}
  9093. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9096. return
  9097. }
  9098. userJSONBytes2, _ := json.Marshal(respJSON2)
  9099. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9100. utils.ErrorLog("解析失败:%v", err)
  9101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9102. return
  9103. }
  9104. if res2.Infcode != 0 {
  9105. c.ServeSuccessJSON(map[string]interface{}{
  9106. "failed_code": -10,
  9107. "msg": res2.ErrMsg,
  9108. })
  9109. return
  9110. } else {
  9111. c.ServeSuccessJSON(map[string]interface{}{
  9112. "msg": "反馈成功",
  9113. })
  9114. return
  9115. }
  9116. }
  9117. func (c *HisApiController) Get4201A() {
  9118. order_id, _ := c.GetInt64("order_id")
  9119. admin_user_id, _ := c.GetInt64("admin_user_id")
  9120. order, _ := service.GetHisOrderByIDTwo(order_id)
  9121. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9122. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9123. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9124. //order_info = append(order_info, order_info_two...)
  9125. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9126. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9127. department, _ := service.GetDepartMentDetail(his.Departments)
  9128. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9129. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9130. if order.ID == 0 {
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9132. return
  9133. }
  9134. var struct4201A models.Struct4201A
  9135. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9136. for _, items := range order_info {
  9137. memo := make(map[string]interface{})
  9138. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9139. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9140. fsiOPFLD.MedType = "14"
  9141. fsiOPFLD.BkkpSn = items.FeedetlSn
  9142. fsiOPFLD.FixmedinsCode = miConfig.Code
  9143. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9144. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9145. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9146. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9147. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9148. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9149. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9150. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9151. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9152. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9153. fsiOPFLD.BilgDeptName = department.Name
  9154. fsiOPFLD.BilgDeptCodg = department.Number
  9155. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9156. fsiOPFLD.BilgDrName = doctor.UserName
  9157. fsiOPFLD.MedChrgitmType = "09"
  9158. memo["hosp_appr_flag"] = "1"
  9159. memo["invoice_no"] = order.MdtrtId
  9160. memo["memo"] = "自费"
  9161. bytesData, _ := json.Marshal(memo)
  9162. fsiOPFLD.Memo = string(bytesData)
  9163. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9164. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9165. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9166. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9167. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9168. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9169. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9170. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9171. fsiOPFLD.BilgDeptName = department.Name
  9172. fsiOPFLD.BilgDeptCodg = department.Number
  9173. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9174. fsiOPFLD.BilgDrName = doctor.UserName
  9175. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9176. case 0:
  9177. break
  9178. case 1:
  9179. fsiOPFLD.MedChrgitmType = "14"
  9180. break
  9181. case 2:
  9182. fsiOPFLD.MedChrgitmType = "05"
  9183. break
  9184. case 3:
  9185. fsiOPFLD.MedChrgitmType = "03"
  9186. break
  9187. case 4:
  9188. fsiOPFLD.MedChrgitmType = "03"
  9189. break
  9190. case 5:
  9191. fsiOPFLD.MedChrgitmType = "08"
  9192. break
  9193. case 6:
  9194. fsiOPFLD.MedChrgitmType = "14"
  9195. break
  9196. case 7:
  9197. fsiOPFLD.MedChrgitmType = "14"
  9198. break
  9199. case 8:
  9200. fsiOPFLD.MedChrgitmType = "03"
  9201. break
  9202. case 9:
  9203. fsiOPFLD.MedChrgitmType = "14"
  9204. break
  9205. case 10:
  9206. fsiOPFLD.MedChrgitmType = "14"
  9207. break
  9208. case 11:
  9209. fsiOPFLD.MedChrgitmType = "06"
  9210. break
  9211. case 12:
  9212. fsiOPFLD.MedChrgitmType = "12"
  9213. break
  9214. case 13:
  9215. fsiOPFLD.MedChrgitmType = "01"
  9216. break
  9217. case 14:
  9218. fsiOPFLD.MedChrgitmType = "04"
  9219. break
  9220. case 15:
  9221. fsiOPFLD.MedChrgitmType = "14"
  9222. break
  9223. }
  9224. memo["hosp_appr_flag"] = "1"
  9225. memo["invoice_no"] = order.MdtrtId
  9226. memo["memo"] = "自费"
  9227. bytesData, _ := json.Marshal(memo)
  9228. fsiOPFLD.Memo = string(bytesData)
  9229. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9230. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9231. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9232. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9233. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9234. fsiOPFLD.BilgDeptName = department.Name
  9235. fsiOPFLD.BilgDeptCodg = department.Number
  9236. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9237. fsiOPFLD.BilgDrName = doctor.UserName
  9238. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9239. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9240. fsiOPFLD.MedChrgitmType = "08"
  9241. memo["hosp_appr_flag"] = "1"
  9242. memo["invoice_no"] = order.MdtrtId
  9243. memo["memo"] = "自费"
  9244. bytesData, _ := json.Marshal(memo)
  9245. fsiOPFLD.Memo = string(bytesData)
  9246. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9247. }
  9248. }
  9249. }
  9250. for _, items := range order_info_two {
  9251. memo := make(map[string]interface{})
  9252. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9253. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9254. fsiOPFLD.MedType = "14"
  9255. fsiOPFLD.BkkpSn = items.FeedetlSn
  9256. fsiOPFLD.FixmedinsCode = miConfig.Code
  9257. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9258. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9259. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9260. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9261. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9262. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9263. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9264. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9265. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9266. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9267. fsiOPFLD.BilgDeptName = department.Name
  9268. fsiOPFLD.BilgDeptCodg = department.Number
  9269. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9270. fsiOPFLD.BilgDrName = doctor.UserName
  9271. fsiOPFLD.MedChrgitmType = "09"
  9272. memo["hosp_appr_flag"] = "1"
  9273. memo["invoice_no"] = order.MdtrtId
  9274. memo["memo"] = "自费"
  9275. bytesData, _ := json.Marshal(memo)
  9276. fsiOPFLD.Memo = string(bytesData)
  9277. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9278. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9279. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9280. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9281. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9282. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9283. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9284. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9285. fsiOPFLD.BilgDeptName = department.Name
  9286. fsiOPFLD.BilgDeptCodg = department.Number
  9287. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9288. fsiOPFLD.BilgDrName = doctor.UserName
  9289. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9290. case 0:
  9291. break
  9292. case 1:
  9293. fsiOPFLD.MedChrgitmType = "14"
  9294. break
  9295. case 2:
  9296. fsiOPFLD.MedChrgitmType = "05"
  9297. break
  9298. case 3:
  9299. fsiOPFLD.MedChrgitmType = "03"
  9300. break
  9301. case 4:
  9302. fsiOPFLD.MedChrgitmType = "03"
  9303. break
  9304. case 5:
  9305. fsiOPFLD.MedChrgitmType = "08"
  9306. break
  9307. case 6:
  9308. fsiOPFLD.MedChrgitmType = "14"
  9309. break
  9310. case 7:
  9311. fsiOPFLD.MedChrgitmType = "14"
  9312. break
  9313. case 8:
  9314. fsiOPFLD.MedChrgitmType = "03"
  9315. break
  9316. case 9:
  9317. fsiOPFLD.MedChrgitmType = "14"
  9318. break
  9319. case 10:
  9320. fsiOPFLD.MedChrgitmType = "14"
  9321. break
  9322. case 11:
  9323. fsiOPFLD.MedChrgitmType = "06"
  9324. break
  9325. case 12:
  9326. fsiOPFLD.MedChrgitmType = "12"
  9327. break
  9328. case 13:
  9329. fsiOPFLD.MedChrgitmType = "01"
  9330. break
  9331. case 14:
  9332. fsiOPFLD.MedChrgitmType = "04"
  9333. break
  9334. case 15:
  9335. fsiOPFLD.MedChrgitmType = "14"
  9336. break
  9337. }
  9338. memo["hosp_appr_flag"] = "1"
  9339. memo["invoice_no"] = order.MdtrtId
  9340. memo["memo"] = "自费"
  9341. bytesData, _ := json.Marshal(memo)
  9342. fsiOPFLD.Memo = string(bytesData)
  9343. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9344. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9345. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9346. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9347. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9348. fsiOPFLD.BilgDeptName = department.Name
  9349. fsiOPFLD.BilgDeptCodg = department.Number
  9350. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9351. fsiOPFLD.BilgDrName = doctor.UserName
  9352. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9353. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9354. fsiOPFLD.MedChrgitmType = "08"
  9355. memo["hosp_appr_flag"] = "1"
  9356. memo["invoice_no"] = order.MdtrtId
  9357. memo["memo"] = "自费"
  9358. bytesData, _ := json.Marshal(memo)
  9359. fsiOPFLD.Memo = string(bytesData)
  9360. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9361. }
  9362. }
  9363. }
  9364. fmt.Println(fsiOPFLDs)
  9365. struct4201A.Fopfd = fsiOPFLDs
  9366. fmt.Println(struct4201A.Fopfd)
  9367. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9368. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9369. var res2 ResultSix
  9370. var respJSON2 map[string]interface{}
  9371. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9374. return
  9375. }
  9376. userJSONBytes2, _ := json.Marshal(respJSON2)
  9377. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9378. utils.ErrorLog("解析失败:%v", err)
  9379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9380. return
  9381. }
  9382. if res2.Infcode != 0 {
  9383. c.ServeSuccessJSON(map[string]interface{}{
  9384. "failed_code": -10,
  9385. "msg": res2.ErrMsg,
  9386. })
  9387. return
  9388. } else {
  9389. order.IsUploadOrderInfo = 1
  9390. service.UpdateOrder(order)
  9391. c.ServeSuccessJSON(map[string]interface{}{
  9392. "msg": "上传成功",
  9393. })
  9394. }
  9395. }
  9396. func (c *HisApiController) Get4202() {
  9397. order_id, _ := c.GetInt64("order_id")
  9398. admin_user_id, _ := c.GetInt64("admin_user_id")
  9399. order, _ := service.GetHisOrderByIDTwo(order_id)
  9400. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9401. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9402. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9403. if order.ID == 0 {
  9404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9405. return
  9406. }
  9407. var struct4202 models.Struct4202
  9408. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9409. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9410. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9411. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9412. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9413. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9414. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9415. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9416. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9417. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9418. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9419. var config []*models.HisXtDiagnoseConfig
  9420. for _, item := range diagnosis_ids {
  9421. id, _ := strconv.ParseInt(item, 10, 64)
  9422. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9423. config = append(config, &diagnosisConfig)
  9424. }
  9425. var tempDiaginfos []models.OwnPayPatnDiagListD
  9426. for index, item := range config {
  9427. if index == 0 {
  9428. var tempDiaginfo models.OwnPayPatnDiagListD
  9429. tempDiaginfo.InoutDiagType = "1"
  9430. tempDiaginfo.DiagCode = item.CountryCode
  9431. tempDiaginfo.DiagName = item.CountryContentName
  9432. tempDiaginfo.DiagType = "1"
  9433. tempDiaginfo.DiagSrtNo = "1"
  9434. tempDiaginfo.MaindiagFlag = "1"
  9435. tempDiaginfo.ValiFlag = "1"
  9436. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9437. } else {
  9438. var tempDiaginfo models.OwnPayPatnDiagListD
  9439. tempDiaginfo.DiagCode = item.CountryCode
  9440. tempDiaginfo.DiagName = item.CountryContentName
  9441. tempDiaginfo.DiagType = "2"
  9442. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9443. tempDiaginfo.MaindiagFlag = "0"
  9444. tempDiaginfo.ValiFlag = "1"
  9445. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9446. }
  9447. }
  9448. struct4202.ODiagListD = tempDiaginfos
  9449. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9450. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9451. var res2 ResultSix
  9452. var respJSON2 map[string]interface{}
  9453. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9456. return
  9457. }
  9458. userJSONBytes2, _ := json.Marshal(respJSON2)
  9459. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9460. utils.ErrorLog("解析失败:%v", err)
  9461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9462. return
  9463. }
  9464. if res2.Infcode != 0 {
  9465. c.ServeSuccessJSON(map[string]interface{}{
  9466. "failed_code": -10,
  9467. "msg": res2.ErrMsg,
  9468. })
  9469. return
  9470. } else {
  9471. order.IsUploadDiagnose = 1
  9472. service.UpdateOrder(order)
  9473. c.ServeSuccessJSON(map[string]interface{}{
  9474. "msg": "上传成功",
  9475. })
  9476. }
  9477. }
  9478. func (c *HisApiController) Get4203() {
  9479. admin_user_id, _ := c.GetInt64("admin_user_id")
  9480. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9481. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9482. order_id, _ := c.GetInt64("order_id")
  9483. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9484. number := ""
  9485. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9486. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9487. if his.ID == 0 {
  9488. number = hospital.Number
  9489. } else {
  9490. number = his.Number
  9491. }
  9492. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9493. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9494. var res2 ResultSix
  9495. var respJSON2 map[string]interface{}
  9496. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9499. return
  9500. }
  9501. userJSONBytes2, _ := json.Marshal(respJSON2)
  9502. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9503. utils.ErrorLog("解析失败:%v", err)
  9504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9505. return
  9506. }
  9507. if res2.Infcode != 0 {
  9508. c.ServeSuccessJSON(map[string]interface{}{
  9509. "failed_code": -10,
  9510. "msg": res2.ErrMsg,
  9511. })
  9512. return
  9513. } else {
  9514. order.IsUploadSuccess = 1
  9515. service.UpdateOrderTwo(order)
  9516. c.ServeSuccessJSON(map[string]interface{}{
  9517. "msg": "上传成功",
  9518. })
  9519. }
  9520. }
  9521. func (c *HisApiController) Get4205() {
  9522. order_id, _ := c.GetInt64("order_id")
  9523. admin_user_id, _ := c.GetInt64("admin_user_id")
  9524. fapiao_code := c.GetString("fapiao_code")
  9525. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9526. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9527. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9528. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9529. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9530. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9531. //order_info = append(order_info, order_info_two...)
  9532. department, _ := service.GetDepartMentDetail(his.Departments)
  9533. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9534. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9535. if order.ID == 0 {
  9536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9537. return
  9538. }
  9539. var struct4201A models.Struct4201A
  9540. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9541. for _, items := range order_info {
  9542. memo := make(map[string]interface{})
  9543. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9544. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9545. fsiOPFLD.MedType = pre.MedType
  9546. fsiOPFLD.FixmedinsCode = miConfig.Code
  9547. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9548. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9549. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9550. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9551. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9552. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9553. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9554. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9555. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9556. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9557. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9558. fsiOPFLD.BilgDeptName = department.Name
  9559. fsiOPFLD.BilgDeptCodg = department.Number
  9560. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9561. fsiOPFLD.BilgDrName = doctor.UserName
  9562. fsiOPFLD.MedChrgitmType = "09"
  9563. memo["hosp_appr_flag"] = "1"
  9564. memo["invoice_no"] = fapiao_code
  9565. memo["memo"] = "自费"
  9566. bytesData, _ := json.Marshal(memo)
  9567. fsiOPFLD.Memo = string(bytesData)
  9568. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9569. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9570. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9571. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9572. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9573. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9574. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9575. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9576. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9577. fsiOPFLD.BilgDeptName = department.Name
  9578. fsiOPFLD.BilgDeptCodg = department.Number
  9579. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9580. fsiOPFLD.BilgDrName = doctor.UserName
  9581. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9582. case 0:
  9583. break
  9584. case 1:
  9585. fsiOPFLD.MedChrgitmType = "14"
  9586. break
  9587. case 2:
  9588. fsiOPFLD.MedChrgitmType = "05"
  9589. break
  9590. case 3:
  9591. fsiOPFLD.MedChrgitmType = "03"
  9592. break
  9593. case 4:
  9594. fsiOPFLD.MedChrgitmType = "03"
  9595. break
  9596. case 5:
  9597. fsiOPFLD.MedChrgitmType = "08"
  9598. break
  9599. case 6:
  9600. fsiOPFLD.MedChrgitmType = "14"
  9601. break
  9602. case 7:
  9603. fsiOPFLD.MedChrgitmType = "14"
  9604. break
  9605. case 8:
  9606. fsiOPFLD.MedChrgitmType = "03"
  9607. break
  9608. case 9:
  9609. fsiOPFLD.MedChrgitmType = "14"
  9610. break
  9611. case 10:
  9612. fsiOPFLD.MedChrgitmType = "14"
  9613. break
  9614. case 11:
  9615. fsiOPFLD.MedChrgitmType = "06"
  9616. break
  9617. case 12:
  9618. fsiOPFLD.MedChrgitmType = "12"
  9619. break
  9620. case 13:
  9621. fsiOPFLD.MedChrgitmType = "01"
  9622. break
  9623. case 14:
  9624. fsiOPFLD.MedChrgitmType = "04"
  9625. break
  9626. case 15:
  9627. fsiOPFLD.MedChrgitmType = "14"
  9628. break
  9629. }
  9630. memo["hosp_appr_flag"] = "1"
  9631. memo["invoice_no"] = fapiao_code
  9632. memo["memo"] = "自费"
  9633. bytesData, _ := json.Marshal(memo)
  9634. fsiOPFLD.Memo = string(bytesData)
  9635. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9636. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9637. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9638. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9639. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9640. fsiOPFLD.BilgDeptName = department.Name
  9641. fsiOPFLD.BilgDeptCodg = department.Number
  9642. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9643. fsiOPFLD.BilgDrName = doctor.UserName
  9644. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9645. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9646. fsiOPFLD.MedChrgitmType = "08"
  9647. memo["hosp_appr_flag"] = "1"
  9648. memo["invoice_no"] = fapiao_code
  9649. memo["memo"] = "自费"
  9650. bytesData, _ := json.Marshal(memo)
  9651. fsiOPFLD.Memo = string(bytesData)
  9652. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9653. }
  9654. }
  9655. }
  9656. for _, items := range order_info_two {
  9657. memo := make(map[string]interface{})
  9658. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9659. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9660. fsiOPFLD.MedType = pre.MedType
  9661. fsiOPFLD.BkkpSn = items.FeedetlSn
  9662. fsiOPFLD.FixmedinsCode = miConfig.Code
  9663. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9664. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9665. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9666. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9667. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9668. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9669. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9670. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9671. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9672. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9673. fsiOPFLD.BilgDeptName = department.Name
  9674. fsiOPFLD.BilgDeptCodg = department.Number
  9675. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9676. fsiOPFLD.BilgDrName = doctor.UserName
  9677. fsiOPFLD.MedChrgitmType = "09"
  9678. memo["hosp_appr_flag"] = "1"
  9679. memo["invoice_no"] = fapiao_code
  9680. memo["memo"] = "自费"
  9681. bytesData, _ := json.Marshal(memo)
  9682. fsiOPFLD.Memo = string(bytesData)
  9683. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9684. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9685. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9686. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9687. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9688. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9689. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9690. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9691. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9692. fsiOPFLD.BilgDeptName = department.Name
  9693. fsiOPFLD.BilgDeptCodg = department.Number
  9694. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9695. fsiOPFLD.BilgDrName = doctor.UserName
  9696. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9697. case 0:
  9698. break
  9699. case 1:
  9700. fsiOPFLD.MedChrgitmType = "14"
  9701. break
  9702. case 2:
  9703. fsiOPFLD.MedChrgitmType = "05"
  9704. break
  9705. case 3:
  9706. fsiOPFLD.MedChrgitmType = "03"
  9707. break
  9708. case 4:
  9709. fsiOPFLD.MedChrgitmType = "03"
  9710. break
  9711. case 5:
  9712. fsiOPFLD.MedChrgitmType = "08"
  9713. break
  9714. case 6:
  9715. fsiOPFLD.MedChrgitmType = "14"
  9716. break
  9717. case 7:
  9718. fsiOPFLD.MedChrgitmType = "14"
  9719. break
  9720. case 8:
  9721. fsiOPFLD.MedChrgitmType = "03"
  9722. break
  9723. case 9:
  9724. fsiOPFLD.MedChrgitmType = "14"
  9725. break
  9726. case 10:
  9727. fsiOPFLD.MedChrgitmType = "14"
  9728. break
  9729. case 11:
  9730. fsiOPFLD.MedChrgitmType = "06"
  9731. break
  9732. case 12:
  9733. fsiOPFLD.MedChrgitmType = "12"
  9734. break
  9735. case 13:
  9736. fsiOPFLD.MedChrgitmType = "01"
  9737. break
  9738. case 14:
  9739. fsiOPFLD.MedChrgitmType = "04"
  9740. break
  9741. case 15:
  9742. fsiOPFLD.MedChrgitmType = "14"
  9743. break
  9744. }
  9745. memo["hosp_appr_flag"] = "1"
  9746. memo["invoice_no"] = fapiao_code
  9747. memo["memo"] = "自费"
  9748. bytesData, _ := json.Marshal(memo)
  9749. fsiOPFLD.Memo = string(bytesData)
  9750. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9751. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9752. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9753. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9754. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9755. fsiOPFLD.BilgDeptName = department.Name
  9756. fsiOPFLD.BilgDeptCodg = department.Number
  9757. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9758. fsiOPFLD.BilgDrName = doctor.UserName
  9759. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9760. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9761. fsiOPFLD.MedChrgitmType = "08"
  9762. memo["hosp_appr_flag"] = "1"
  9763. memo["invoice_no"] = fapiao_code
  9764. memo["memo"] = "自费"
  9765. bytesData, _ := json.Marshal(memo)
  9766. fsiOPFLD.Memo = string(bytesData)
  9767. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9768. }
  9769. }
  9770. }
  9771. fmt.Println(fsiOPFLDs)
  9772. struct4201A.Fopfd = fsiOPFLDs
  9773. fmt.Println(struct4201A.Fopfd)
  9774. var struct4202 models.Struct4202
  9775. timeLayout := "2006-01-02 15:04:05"
  9776. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9777. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9778. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9779. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9780. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9781. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9782. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9783. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9784. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9785. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9786. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9787. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9788. var config []*models.HisXtDiagnoseConfig
  9789. for _, item := range diagnosis_ids {
  9790. id, _ := strconv.ParseInt(item, 10, 64)
  9791. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9792. config = append(config, &diagnosisConfig)
  9793. }
  9794. var tempDiaginfos []models.OwnPayPatnDiagListD
  9795. for index, item := range config {
  9796. if index == 0 {
  9797. var tempDiaginfo models.OwnPayPatnDiagListD
  9798. tempDiaginfo.InoutDiagType = "1"
  9799. tempDiaginfo.DiagCode = item.CountryCode
  9800. tempDiaginfo.DiagName = item.CountryContentName
  9801. tempDiaginfo.DiagType = "1"
  9802. tempDiaginfo.DiagSrtNo = "1"
  9803. tempDiaginfo.MaindiagFlag = "1"
  9804. tempDiaginfo.ValiFlag = "1"
  9805. tempDiaginfo.DiagDrName = doctor.UserName
  9806. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9807. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9808. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9809. } else {
  9810. var tempDiaginfo models.OwnPayPatnDiagListD
  9811. tempDiaginfo.DiagCode = item.CountryCode
  9812. tempDiaginfo.DiagName = item.CountryContentName
  9813. tempDiaginfo.DiagType = "2"
  9814. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9815. tempDiaginfo.MaindiagFlag = "0"
  9816. tempDiaginfo.ValiFlag = "1"
  9817. tempDiaginfo.DiagDrName = doctor.UserName
  9818. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9819. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9820. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9821. }
  9822. }
  9823. struct4202.ODiagListD = tempDiaginfos
  9824. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9825. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9826. var res2 ResultSix
  9827. var respJSON2 map[string]interface{}
  9828. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9831. return
  9832. }
  9833. userJSONBytes2, _ := json.Marshal(respJSON2)
  9834. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9835. utils.ErrorLog("解析失败:%v", err)
  9836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9837. return
  9838. }
  9839. if res2.Infcode != 0 {
  9840. c.ServeSuccessJSON(map[string]interface{}{
  9841. "failed_code": -10,
  9842. "msg": res2.ErrMsg,
  9843. })
  9844. return
  9845. } else {
  9846. order.IsUploadDiagnose = 1
  9847. order.IsUploadOrderInfo = 1
  9848. service.UpdateOrderTwo(order)
  9849. c.ServeSuccessJSON(map[string]interface{}{
  9850. "msg": "上传成功",
  9851. })
  9852. }
  9853. }
  9854. func (c *HisApiController) Get4207() {
  9855. admin_user_id, _ := c.GetInt64("admin_user_id")
  9856. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9858. order_id, _ := c.GetInt64("order_id")
  9859. order, _ := service.GetHisOrderByIDTwo(order_id)
  9860. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9861. var struct4207 models.Struct4207
  9862. struct4207.PageNum = "1"
  9863. struct4207.PageSize = "1000"
  9864. struct4207.FixmedinsCode = miConfig.Code
  9865. struct4207.FixmedinsMdtrtID = order.Number
  9866. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9867. saveLog(result, requestLog, "4207", "查询")
  9868. var res2 ResultSix
  9869. var respJSON2 map[string]interface{}
  9870. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9873. return
  9874. }
  9875. userJSONBytes2, _ := json.Marshal(respJSON2)
  9876. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9877. utils.ErrorLog("解析失败:%v", err)
  9878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9879. return
  9880. }
  9881. if res2.Infcode != 0 {
  9882. c.ServeSuccessJSON(map[string]interface{}{
  9883. "failed_code": -10,
  9884. "msg": res2.ErrMsg,
  9885. })
  9886. return
  9887. } else {
  9888. c.ServeSuccessJSON(map[string]interface{}{
  9889. "msg": "查询成功",
  9890. })
  9891. }
  9892. }
  9893. func (c *HisApiController) Get4208() {
  9894. admin_user_id, _ := c.GetInt64("admin_user_id")
  9895. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9896. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9897. order_id, _ := c.GetInt64("order_id")
  9898. order, _ := service.GetHisOrderByIDTwo(order_id)
  9899. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9900. var struct4208 models.Struct4208
  9901. struct4208.PageNum = "1"
  9902. struct4208.PageSize = "1000"
  9903. struct4208.PsnCertType = "01"
  9904. struct4208.Certno = his.Certno
  9905. struct4208.MedType = order.MedType
  9906. struct4208.PsnName = his.Name
  9907. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9908. saveLog(result, requestLog, "4208", "查询")
  9909. var res2 ResultSix
  9910. var respJSON2 map[string]interface{}
  9911. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9914. return
  9915. }
  9916. userJSONBytes2, _ := json.Marshal(respJSON2)
  9917. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9918. utils.ErrorLog("解析失败:%v", err)
  9919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9920. return
  9921. }
  9922. if res2.Infcode != 0 {
  9923. c.ServeSuccessJSON(map[string]interface{}{
  9924. "failed_code": -10,
  9925. "msg": res2.ErrMsg,
  9926. })
  9927. return
  9928. } else {
  9929. c.ServeSuccessJSON(map[string]interface{}{
  9930. "msg": "查询成功",
  9931. })
  9932. }
  9933. }
  9934. func (c *HisApiController) Get4209() {
  9935. admin_user_id, _ := c.GetInt64("admin_user_id")
  9936. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9938. order_id, _ := c.GetInt64("order_id")
  9939. order, _ := service.GetHisOrderByIDTwo(order_id)
  9940. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9941. var struct4209 models.Struct4209
  9942. struct4209.FixmedinsMdtrtID = order.Number
  9943. struct4209.FixmedinsCode = miConfig.Code
  9944. struct4209.PageSize = "1000"
  9945. struct4209.PageNum = "1"
  9946. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9947. saveLog(result, requestLog, "4209", "查询")
  9948. var res2 ResultSix
  9949. var respJSON2 map[string]interface{}
  9950. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9953. return
  9954. }
  9955. userJSONBytes2, _ := json.Marshal(respJSON2)
  9956. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9957. utils.ErrorLog("解析失败:%v", err)
  9958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9959. return
  9960. }
  9961. if res2.Infcode != 0 {
  9962. c.ServeSuccessJSON(map[string]interface{}{
  9963. "failed_code": -10,
  9964. "msg": res2.ErrMsg,
  9965. })
  9966. return
  9967. } else {
  9968. c.ServeSuccessJSON(map[string]interface{}{
  9969. "msg": "查询成功",
  9970. })
  9971. }
  9972. }
  9973. type Result3101 struct {
  9974. Infcode string `json:"infcode"`
  9975. InfRefmsgid string `json:"inf_refmsgid"`
  9976. RefmsgTime string `json:"refmsg_time"`
  9977. RespondTime string `json:"respond_time"`
  9978. Enctype string `json:"enctype"`
  9979. Signtype string `json:"signtype"`
  9980. ErrMsg string `json:"err_msg"`
  9981. Output struct {
  9982. Result []struct {
  9983. JudgeResultDetailDtos []struct {
  9984. VolaItemType string `json:"vola_item_type"`
  9985. MdtrtID string `json:"mdtrt_id"`
  9986. JrdID string `json:"jrd_id"`
  9987. PatnID string `json:"patn_id"`
  9988. RxID string `json:"rx_id"`
  9989. VolaAmt interface{} `json:"vola_amt"`
  9990. } `json:"judge_result_detail_dtos"`
  9991. RuleID string `json:"rule_id"`
  9992. VolaEvid string `json:"vola_evid"`
  9993. MdtrtID string `json:"mdtrt_id"`
  9994. RuleName string `json:"rule_name"`
  9995. VolaAmtStas string `json:"vola_amt_stas"`
  9996. JrID string `json:"jr_id"`
  9997. PatnID string `json:"patn_id"`
  9998. SevDeg string `json:"sev_deg"`
  9999. VolaAmt float64 `json:"vola_amt"`
  10000. VolaBhvrType string `json:"vola_bhvr_type"`
  10001. VolaCont string `json:"vola_cont"`
  10002. } `json:"result"`
  10003. } `json:"output"`
  10004. }
  10005. type Resultgd3101 struct {
  10006. Infcode int64 `json:"infcode"`
  10007. InfRefmsgid string `json:"inf_refmsgid"`
  10008. RefmsgTime string `json:"refmsg_time"`
  10009. RespondTime string `json:"respond_time"`
  10010. Enctype string `json:"enctype"`
  10011. Signtype string `json:"signtype"`
  10012. ErrMsg string `json:"err_msg"`
  10013. Output struct {
  10014. Result []struct {
  10015. JudgeResultDetailDtos []struct {
  10016. VolaItemType string `json:"vola_item_type"`
  10017. MdtrtID string `json:"mdtrt_id"`
  10018. JrdID string `json:"jrd_id"`
  10019. PatnID string `json:"patn_id"`
  10020. RxID string `json:"rx_id"`
  10021. VolaAmt interface{} `json:"vola_amt"`
  10022. } `json:"judge_result_detail_dtos"`
  10023. RuleID string `json:"rule_id"`
  10024. VolaEvid string `json:"vola_evid"`
  10025. MdtrtID string `json:"mdtrt_id"`
  10026. RuleName string `json:"rule_name"`
  10027. VolaAmtStas string `json:"vola_amt_stas"`
  10028. JrID string `json:"jr_id"`
  10029. PatnID string `json:"patn_id"`
  10030. SevDeg string `json:"sev_deg"`
  10031. VolaAmt float64 `json:"vola_amt"`
  10032. VolaBhvrType string `json:"vola_bhvr_type"`
  10033. VolaCont string `json:"vola_cont"`
  10034. } `json:"result"`
  10035. } `json:"output"`
  10036. }
  10037. func (c *HisApiController) ReadEleToken() {
  10038. admin_user_id, _ := c.GetInt64("admin_user_id")
  10039. his_patient_id, _ := c.GetInt64("his_patient_id")
  10040. adminUser := c.GetAdminUserInfo()
  10041. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10042. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10043. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10044. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10045. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10046. if len(tokens) > 0 {
  10047. c.ServeSuccessJSON(map[string]interface{}{
  10048. "msg": "读取成功",
  10049. })
  10050. } else {
  10051. c.ServeSuccessJSON(map[string]interface{}{
  10052. "failed_code": -10,
  10053. "msg": "读取失败",
  10054. })
  10055. }
  10056. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10057. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10058. if len(tokens) > 0 {
  10059. c.ServeSuccessJSON(map[string]interface{}{
  10060. "msg": "读取成功",
  10061. })
  10062. } else {
  10063. c.ServeSuccessJSON(map[string]interface{}{
  10064. "failed_code": -10,
  10065. "msg": "读取失败",
  10066. })
  10067. }
  10068. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10069. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10070. if len(tokens) > 0 {
  10071. c.ServeSuccessJSON(map[string]interface{}{
  10072. "msg": "读取成功",
  10073. })
  10074. } else {
  10075. c.ServeSuccessJSON(map[string]interface{}{
  10076. "failed_code": -10,
  10077. "msg": "读取失败",
  10078. })
  10079. }
  10080. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10081. var api string
  10082. 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 +
  10083. "&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"
  10084. resp, requestErr := http.Get(api)
  10085. if requestErr != nil {
  10086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10087. }
  10088. body, ioErr := ioutil.ReadAll(resp.Body)
  10089. if ioErr != nil {
  10090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10092. }
  10093. var respJSON map[string]interface{}
  10094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10097. return
  10098. }
  10099. var status string
  10100. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10101. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10102. var token string
  10103. var res ResultTwo //1101结果
  10104. var res10265 ResultTwo10265 //1101结果
  10105. if status == "0" { //读卡成功
  10106. var card_info string //卡信息
  10107. var busi_card_info string
  10108. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10109. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10110. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10111. fmt.Println(card_info)
  10112. fmt.Println(busi_card_info)
  10113. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10114. result, _ := json.Marshal(respJSON)
  10115. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10116. utils.ErrorLog("解析失败:%v", err)
  10117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10118. return
  10119. }
  10120. res.ErrMsg = res10265.ErrMsg
  10121. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10122. res.Infcode = infocode
  10123. res.Output = res10265.Output
  10124. res.InfRefmsgid = res10265.InfRefmsgid
  10125. if res.Infcode == 0 {
  10126. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10127. if err == gorm.ErrRecordNotFound {
  10128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10129. return
  10130. } else if err != nil {
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10132. return
  10133. } else {
  10134. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10135. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10136. infoStr := string(Iinfos)
  10137. idetinfoStr := string(Idetinfos)
  10138. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10139. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10140. psn := &models.HisPsn{
  10141. PsnNo: res.Output.Baseinfo.PsnNo,
  10142. PatientId: patient.ID,
  10143. Certno: res.Output.Baseinfo.Certno,
  10144. Gend: res.Output.Baseinfo.Gend,
  10145. Naty: res.Output.Baseinfo.Naty,
  10146. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10147. PsnName: res.Output.Baseinfo.PsnName,
  10148. Age: float64(age),
  10149. Brdy: b,
  10150. Idetinfo: idetinfoStr,
  10151. Insuinfo: infoStr,
  10152. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10153. CardInfo: card_info,
  10154. VerifyNumber: token,
  10155. IdCardType: 4,
  10156. }
  10157. var rf []*ResultFive
  10158. json.Unmarshal([]byte(infoStr), &rf)
  10159. var insutypes []*ResultFive
  10160. var insutype string
  10161. var is390 int = 0
  10162. var is310 int = 0
  10163. for _, item := range rf {
  10164. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10165. insutypes = append(insutypes, item)
  10166. }
  10167. }
  10168. if len(insutypes) == 1 {
  10169. insutype = insutypes[0].Insutype
  10170. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10171. } else {
  10172. for _, i := range insutypes {
  10173. if i.Insutype == "390" {
  10174. is390 = 1
  10175. }
  10176. if i.Insutype == "310" {
  10177. is310 = 1
  10178. }
  10179. }
  10180. }
  10181. if is390 == 1 {
  10182. insutype = "390"
  10183. }
  10184. if is310 == 1 {
  10185. insutype = "310"
  10186. }
  10187. if len(insutypes) == 0 {
  10188. insutype = "310"
  10189. }
  10190. service.CreateHisPsn(psn)
  10191. c.ServeSuccessJSON(map[string]interface{}{
  10192. "patient": patient,
  10193. "number": token,
  10194. "insutype": insutype,
  10195. })
  10196. }
  10197. } else {
  10198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10199. return
  10200. }
  10201. } else { //读卡失败
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10203. return
  10204. }
  10205. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10206. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10207. if len(errMsg) == 0 {
  10208. type ELeData struct {
  10209. Data struct {
  10210. IdNo string `json:"idNo"`
  10211. IdType string `json:"idType"`
  10212. UserName string `json:"userName"`
  10213. EcToken string `json:"ecToken"`
  10214. InsuOrg string `json:"insuOrg"`
  10215. Gender string `json:"gender"`
  10216. Birthday string `json:"birthday"`
  10217. Nationality string `json:"nationality"`
  10218. Email string `json:"email"`
  10219. Extra string `json:"extra"`
  10220. } `json:"data"`
  10221. Code int `json:"code"`
  10222. Message string `json:"message"`
  10223. }
  10224. var ele ELeData
  10225. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10226. if err != nil {
  10227. utils.ErrorLog("解析失败:%v", err)
  10228. }
  10229. token := ele.Data.EcToken
  10230. if len(token) > 0 {
  10231. psn := &models.HisPsn{
  10232. PsnNo: his.PsnNo,
  10233. Age: 0,
  10234. PatientId: his.PatientId,
  10235. Certno: his.Certno,
  10236. Brdy: his.Brdy,
  10237. Gend: his.Gend,
  10238. Naty: his.Naty,
  10239. PsnCertType: his.PsnCertType,
  10240. PsnName: his.PsnName,
  10241. Idetinfo: his.Idetinfo,
  10242. Insuinfo: his.Iinfo,
  10243. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10244. CardInfo: outPutInfo,
  10245. VerifyNumber: token,
  10246. }
  10247. service.CreateHisPsn(psn)
  10248. }
  10249. if len(token) > 0 {
  10250. c.ServeSuccessJSON(map[string]interface{}{
  10251. "msg": "读取成功",
  10252. })
  10253. } else {
  10254. c.ServeSuccessJSON(map[string]interface{}{
  10255. "failed_code": -10,
  10256. "msg": "读取失败",
  10257. })
  10258. }
  10259. }
  10260. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10261. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10262. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10263. type ELeData struct {
  10264. Data struct {
  10265. IdNo string `json:"idNo"`
  10266. IdType string `json:"idType"`
  10267. UserName string `json:"userName"`
  10268. EcToken string `json:"ecToken"`
  10269. InsuOrg string `json:"insuOrg"`
  10270. Gender string `json:"gender"`
  10271. Birthday string `json:"birthday"`
  10272. Nationality string `json:"nationality"`
  10273. Email string `json:"email"`
  10274. Extra string `json:"extra"`
  10275. } `json:"data"`
  10276. Code int `json:"code"`
  10277. Message string `json:"message"`
  10278. }
  10279. var ele ELeData
  10280. err := json.Unmarshal([]byte(result), &ele)
  10281. if err != nil {
  10282. utils.ErrorLog("解析失败:%v", err)
  10283. }
  10284. token := ele.Data.EcToken
  10285. token = Remove0000(token)
  10286. fmt.Println(ele.Data.UserName)
  10287. 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)
  10288. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10289. var res ResultTwo
  10290. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10291. utils.ErrorLog("解析失败:%v", err)
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. return
  10294. }
  10295. if res.Infcode == 0 {
  10296. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10297. if err == gorm.ErrRecordNotFound {
  10298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10299. return
  10300. } else if err != nil {
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10302. return
  10303. } else {
  10304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10306. infoStr := string(Iinfos)
  10307. idetinfoStr := string(Idetinfos)
  10308. psn := &models.HisPsn{
  10309. PsnNo: res.Output.Baseinfo.PsnNo,
  10310. PatientId: patient.ID,
  10311. Certno: res.Output.Baseinfo.Certno,
  10312. Gend: res.Output.Baseinfo.Gend,
  10313. Naty: res.Output.Baseinfo.Naty,
  10314. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10315. PsnName: res.Output.Baseinfo.PsnName,
  10316. Idetinfo: idetinfoStr,
  10317. Insuinfo: infoStr,
  10318. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10319. CardInfo: "",
  10320. VerifyNumber: token,
  10321. }
  10322. service.CreateHisPsn(psn)
  10323. c.ServeSuccessJSON(map[string]interface{}{
  10324. "patient": patient,
  10325. "number": token,
  10326. })
  10327. }
  10328. } else {
  10329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10330. return
  10331. }
  10332. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10333. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10334. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10335. type ELeData struct {
  10336. Data struct {
  10337. IdNo string `json:"idNo"`
  10338. IdType string `json:"idType"`
  10339. UserName string `json:"userName"`
  10340. EcToken string `json:"ecToken"`
  10341. InsuOrg string `json:"insuOrg"`
  10342. Gender string `json:"gender"`
  10343. Birthday string `json:"birthday"`
  10344. Nationality string `json:"nationality"`
  10345. Email string `json:"email"`
  10346. Extra string `json:"extra"`
  10347. } `json:"data"`
  10348. Code int `json:"code"`
  10349. Message string `json:"message"`
  10350. }
  10351. var ele ELeData
  10352. err := json.Unmarshal([]byte(result), &ele)
  10353. if err != nil {
  10354. utils.ErrorLog("解析失败:%v", err)
  10355. }
  10356. token := ele.Data.EcToken
  10357. token = Remove0000(token)
  10358. fmt.Println(ele.Data.UserName)
  10359. 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)
  10360. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10361. var res ResultTwo
  10362. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10363. utils.ErrorLog("解析失败:%v", err)
  10364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10365. return
  10366. }
  10367. if res.Infcode == 0 {
  10368. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10369. if err == gorm.ErrRecordNotFound {
  10370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10371. return
  10372. } else if err != nil {
  10373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10374. return
  10375. } else {
  10376. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10377. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10378. infoStr := string(Iinfos)
  10379. idetinfoStr := string(Idetinfos)
  10380. psn := &models.HisPsn{
  10381. PsnNo: res.Output.Baseinfo.PsnNo,
  10382. PatientId: patient.ID,
  10383. Certno: res.Output.Baseinfo.Certno,
  10384. Gend: res.Output.Baseinfo.Gend,
  10385. Naty: res.Output.Baseinfo.Naty,
  10386. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10387. PsnName: res.Output.Baseinfo.PsnName,
  10388. Idetinfo: idetinfoStr,
  10389. Insuinfo: infoStr,
  10390. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10391. CardInfo: "",
  10392. VerifyNumber: token,
  10393. }
  10394. service.CreateHisPsn(psn)
  10395. c.ServeSuccessJSON(map[string]interface{}{
  10396. "patient": patient,
  10397. "number": token,
  10398. })
  10399. }
  10400. } else {
  10401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10402. return
  10403. }
  10404. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10405. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10406. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10407. type ELeData struct {
  10408. Data struct {
  10409. IdNo string `json:"idNo"`
  10410. IdType string `json:"idType"`
  10411. UserName string `json:"userName"`
  10412. EcToken string `json:"ecToken"`
  10413. InsuOrg string `json:"insuOrg"`
  10414. Gender string `json:"gender"`
  10415. Birthday string `json:"birthday"`
  10416. Nationality string `json:"nationality"`
  10417. Email string `json:"email"`
  10418. Extra string `json:"extra"`
  10419. } `json:"data"`
  10420. Code int `json:"code"`
  10421. Message string `json:"message"`
  10422. }
  10423. var ele ELeData
  10424. err := json.Unmarshal([]byte(result), &ele)
  10425. if err != nil {
  10426. utils.ErrorLog("解析失败:%v", err)
  10427. }
  10428. token := ele.Data.EcToken
  10429. token = Remove0000(token)
  10430. fmt.Println(ele.Data.UserName)
  10431. 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)
  10432. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10433. var res ResultTwo
  10434. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10435. utils.ErrorLog("解析失败:%v", err)
  10436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10437. return
  10438. }
  10439. if res.Infcode == 0 {
  10440. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10441. if err == gorm.ErrRecordNotFound {
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10443. return
  10444. } else if err != nil {
  10445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10446. return
  10447. } else {
  10448. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10449. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10450. infoStr := string(Iinfos)
  10451. idetinfoStr := string(Idetinfos)
  10452. psn := &models.HisPsn{
  10453. PsnNo: res.Output.Baseinfo.PsnNo,
  10454. PatientId: patient.ID,
  10455. Certno: res.Output.Baseinfo.Certno,
  10456. Gend: res.Output.Baseinfo.Gend,
  10457. Naty: res.Output.Baseinfo.Naty,
  10458. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10459. PsnName: res.Output.Baseinfo.PsnName,
  10460. Idetinfo: idetinfoStr,
  10461. Insuinfo: infoStr,
  10462. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10463. CardInfo: "",
  10464. VerifyNumber: token,
  10465. }
  10466. service.CreateHisPsn(psn)
  10467. c.ServeSuccessJSON(map[string]interface{}{
  10468. "patient": patient,
  10469. "number": token,
  10470. })
  10471. }
  10472. } else {
  10473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10474. return
  10475. }
  10476. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10477. //if initFlag == 0 {
  10478. //c.TestGetJiangXiBasBaseInit()
  10479. //}
  10480. //if initEleFlag == 0 {
  10481. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10482. //}
  10483. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10484. utils.ErrorLog("解析失败:%v", json_result)
  10485. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10486. type ELeData struct {
  10487. Data struct {
  10488. IdNo string `json:"idNo"`
  10489. IdType string `json:"idType"`
  10490. UserName string `json:"userName"`
  10491. EcToken string `json:"ecToken"`
  10492. InsuOrg string `json:"insuOrg"`
  10493. Gender string `json:"gender"`
  10494. Birthday string `json:"birthday"`
  10495. Nationality string `json:"nationality"`
  10496. Email string `json:"email"`
  10497. Extra string `json:"extra"`
  10498. } `json:"data"`
  10499. Code int `json:"code"`
  10500. Message string `json:"message"`
  10501. }
  10502. var ele ELeData
  10503. err := json.Unmarshal([]byte(json_result), &ele)
  10504. if err != nil {
  10505. utils.ErrorLog("解析失败:%v", err)
  10506. }
  10507. token := ele.Data.EcToken
  10508. token = Remove0000(token)
  10509. //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)
  10510. 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)
  10511. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10512. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10513. var res ResultTwo
  10514. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10515. utils.ErrorLog("解析失败:%v", err)
  10516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10517. return
  10518. }
  10519. if res.Infcode == 0 {
  10520. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10521. if err == gorm.ErrRecordNotFound {
  10522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10523. return
  10524. } else if err != nil {
  10525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10526. return
  10527. } else {
  10528. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10529. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10530. infoStr := string(Iinfos)
  10531. idetinfoStr := string(Idetinfos)
  10532. psn := &models.HisPsn{
  10533. PsnNo: res.Output.Baseinfo.PsnNo,
  10534. PatientId: patient.ID,
  10535. Certno: res.Output.Baseinfo.Certno,
  10536. Gend: res.Output.Baseinfo.Gend,
  10537. Naty: res.Output.Baseinfo.Naty,
  10538. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10539. PsnName: res.Output.Baseinfo.PsnName,
  10540. Idetinfo: idetinfoStr,
  10541. Insuinfo: infoStr,
  10542. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10543. CardInfo: "",
  10544. VerifyNumber: token,
  10545. InsuplcAdmdvs: ele.Data.InsuOrg,
  10546. }
  10547. service.CreateHisPsn(psn)
  10548. c.ServeSuccessJSON(map[string]interface{}{
  10549. "patient": patient,
  10550. "number": token,
  10551. })
  10552. }
  10553. } else {
  10554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10555. return
  10556. }
  10557. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10558. res := c.GetoleInfo()
  10559. if res.Infcode == 0 {
  10560. var result string
  10561. if res.Output.MdtrtCertType == "01" {
  10562. 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)
  10563. } else if res.Output.MdtrtCertType == "02" {
  10564. 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)
  10565. } else if res.Output.MdtrtCertType == "03" {
  10566. 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)
  10567. }
  10568. var dat map[string]interface{}
  10569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10570. fmt.Println(dat)
  10571. } else {
  10572. fmt.Println(err)
  10573. }
  10574. userJSONBytes, _ := json.Marshal(dat)
  10575. var res2 ResultTwo
  10576. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10577. utils.ErrorLog("解析失败:%v", err)
  10578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10579. return
  10580. }
  10581. if res2.Infcode == 0 {
  10582. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10583. if err == gorm.ErrRecordNotFound {
  10584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10585. return
  10586. } else if err != nil {
  10587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10588. return
  10589. } else {
  10590. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10591. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10592. infoStr := string(Iinfos)
  10593. idetinfoStr := string(Idetinfos)
  10594. var rf []*ResultFive
  10595. json.Unmarshal([]byte(infoStr), &rf)
  10596. var insutypes []*ResultFive
  10597. var insutype string
  10598. var is390 int = 0
  10599. var is310 int = 0
  10600. //var insuplc_admdvs string
  10601. for _, item := range rf {
  10602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10603. insutypes = append(insutypes, item)
  10604. }
  10605. }
  10606. if len(insutypes) == 1 {
  10607. insutype = insutypes[0].Insutype
  10608. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10609. } else {
  10610. for _, i := range insutypes {
  10611. if i.Insutype == "390" {
  10612. is390 = 1
  10613. }
  10614. if i.Insutype == "310" {
  10615. is310 = 1
  10616. }
  10617. }
  10618. }
  10619. if is390 == 1 {
  10620. insutype = "390"
  10621. }
  10622. if is310 == 1 {
  10623. insutype = "310"
  10624. }
  10625. if len(insutypes) == 0 {
  10626. insutype = "310"
  10627. }
  10628. psn := &models.HisPsn{
  10629. PsnNo: res2.Output.Baseinfo.PsnNo,
  10630. PatientId: patient.ID,
  10631. Certno: res2.Output.Baseinfo.Certno,
  10632. Gend: res2.Output.Baseinfo.Gend,
  10633. Naty: res2.Output.Baseinfo.Naty,
  10634. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10635. PsnName: res2.Output.Baseinfo.PsnName,
  10636. Idetinfo: idetinfoStr,
  10637. Insuinfo: infoStr,
  10638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10639. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10640. VerifyNumber: res.Output.EcToken,
  10641. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10642. }
  10643. service.CreateHisPsn(psn)
  10644. c.ServeSuccessJSON(map[string]interface{}{
  10645. "patient": patient,
  10646. "number": res.Output.CardNo,
  10647. "insutype": insutype,
  10648. })
  10649. }
  10650. } else {
  10651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10652. return
  10653. }
  10654. } else {
  10655. c.ServeSuccessJSON(map[string]interface{}{
  10656. "failed_code": -10,
  10657. "msg": res.ErrMsg,
  10658. })
  10659. }
  10660. } else {
  10661. //if initFlag == 0 {
  10662. // c.TestGetBasBaseInit()
  10663. //}
  10664. //token := c.GetEleBaseInfo()
  10665. //token = Remove0000(token)
  10666. type ELeData struct {
  10667. Code string `json:"code"`
  10668. Data struct {
  10669. Aac002 string `json:"aac002"`
  10670. Aaz500 string `json:"aaz500"`
  10671. ActCardNo string `json:"actCardNo"`
  10672. Bab520 string `json:"bab520"`
  10673. Bkz543 string `json:"bkz543"`
  10674. BusinessType string `json:"businessType"`
  10675. CertfCodg string `json:"certfCodg"`
  10676. EcIndexNo string `json:"ecIndexNo"`
  10677. EcToken string `json:"ecToken"`
  10678. ID0000 string `json:"id0000"`
  10679. IDNo string `json:"idNo"`
  10680. IDType string `json:"idType"`
  10681. Idcode string `json:"idcode"`
  10682. IdentityToken string `json:"identity_token"`
  10683. InsuOrg string `json:"insuOrg"`
  10684. OfficeID string `json:"officeId"`
  10685. OfficeName string `json:"officeName"`
  10686. OperatorID string `json:"operatorId"`
  10687. OperatorName string `json:"operatorName"`
  10688. OrgID string `json:"orgId"`
  10689. UserName string `json:"userName"`
  10690. } `json:"data"`
  10691. Infno interface{} `json:"infno"`
  10692. Message string `json:"message"`
  10693. OrgID string `json:"orgId"`
  10694. TransType string `json:"transType"`
  10695. }
  10696. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10697. fmt.Println(result)
  10698. outPutInfo := Remove0000(result)
  10699. fmt.Println(outPutInfo)
  10700. var ele ELeData
  10701. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10702. if err != nil {
  10703. utils.ErrorLog("解析失败:%v", err)
  10704. }
  10705. token := ele.Data.EcToken
  10706. var result2 string
  10707. var requestLog2 string
  10708. if len(token) > 0 {
  10709. if strings.Contains(ele.Data.IDNo, "HKG") {
  10710. 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)
  10711. } else {
  10712. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10713. }
  10714. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10715. var res ResultTwo
  10716. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10717. utils.ErrorLog("解析失败:%v", err)
  10718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10719. return
  10720. }
  10721. if res.Infcode == 0 {
  10722. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10723. if err == gorm.ErrRecordNotFound {
  10724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10725. return
  10726. } else if err != nil {
  10727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10728. return
  10729. } else {
  10730. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10731. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10732. infoStr := string(Iinfos)
  10733. idetinfoStr := string(Idetinfos)
  10734. psn := &models.HisPsn{
  10735. PsnNo: res.Output.Baseinfo.PsnNo,
  10736. PatientId: patient.ID,
  10737. Certno: res.Output.Baseinfo.Certno,
  10738. Gend: res.Output.Baseinfo.Gend,
  10739. Naty: res.Output.Baseinfo.Naty,
  10740. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10741. PsnName: res.Output.Baseinfo.PsnName,
  10742. Idetinfo: idetinfoStr,
  10743. Insuinfo: infoStr,
  10744. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10745. CardInfo: "",
  10746. VerifyNumber: token,
  10747. }
  10748. service.CreateHisPsn(psn)
  10749. c.ServeSuccessJSON(map[string]interface{}{
  10750. "msg": "读取成功",
  10751. })
  10752. }
  10753. } else {
  10754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10755. return
  10756. }
  10757. } else {
  10758. c.ServeSuccessJSON(map[string]interface{}{
  10759. "failed_code": -10,
  10760. "msg": "读取失败",
  10761. })
  10762. }
  10763. }
  10764. }
  10765. func (c *HisApiController) ReadEleFace() {
  10766. admin_user_id, _ := c.GetInt64("admin_user_id")
  10767. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10768. adminUser := c.GetAdminUserInfo()
  10769. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10770. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10771. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10772. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10773. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10774. if len(tokens) > 0 {
  10775. c.ServeSuccessJSON(map[string]interface{}{
  10776. "msg": "读取成功",
  10777. })
  10778. } else {
  10779. c.ServeSuccessJSON(map[string]interface{}{
  10780. "failed_code": -10,
  10781. "msg": "读取失败",
  10782. })
  10783. }
  10784. }
  10785. }
  10786. func timestampToBirthdayString(timestamp int64) string {
  10787. // 将时间戳转换为 time.Time
  10788. t := time.Unix(timestamp, 0)
  10789. // 格式化时间为生日字符串,例如 "2006-01-02"
  10790. birthday := t.Format("2006-01-02")
  10791. return birthday
  10792. }
  10793. func (c *HisApiController) Get9001() {
  10794. adminUser := c.GetAdminUserInfo()
  10795. admin_user_id, _ := c.GetInt64("admin_user_id")
  10796. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10797. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10798. if miConfig.MdtrtareaAdmvs == "350500" {
  10799. service.GetFjAuthorizationInfo(miConfig.Code)
  10800. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10801. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10802. var dat map[string]interface{}
  10803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10804. fmt.Println(dat)
  10805. } else {
  10806. fmt.Println(err)
  10807. }
  10808. userJSONBytes, _ := json.Marshal(dat)
  10809. var res models.Result9001
  10810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10811. utils.ErrorLog("解析失败:%v", err)
  10812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10813. return
  10814. }
  10815. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10816. fmt.Println(miConfig.SecretKey)
  10817. var res models.Result9001Two
  10818. 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 +
  10819. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10820. resp, requestErr := http.Get(api)
  10821. if requestErr != nil {
  10822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10823. return
  10824. }
  10825. body, ioErr := ioutil.ReadAll(resp.Body)
  10826. if ioErr != nil {
  10827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10829. return
  10830. }
  10831. var respJSON map[string]interface{}
  10832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10835. return
  10836. }
  10837. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10838. if status == "0" {
  10839. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10840. c.ServeSuccessJSON(map[string]interface{}{
  10841. "failed_code": -10,
  10842. "msg": err_msg,
  10843. })
  10844. return
  10845. }
  10846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10847. result, _ := json.Marshal(respJSON)
  10848. fmt.Println("log")
  10849. fmt.Println(string(result))
  10850. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10851. utils.ErrorLog("解析失败:%v", err)
  10852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10853. return
  10854. }
  10855. if res.Infcode == 0 {
  10856. sign := models.HisSignIn{
  10857. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10858. SignNo: res.Output.Signinoutb.SignNo,
  10859. SignTime: "",
  10860. Ctime: time.Now().Unix(),
  10861. Mtime: time.Now().Unix(),
  10862. Status: 1,
  10863. InputLog: "",
  10864. OutputLog: "",
  10865. FixmedinsCode: miConfig.Code,
  10866. }
  10867. err := service.CreateSignIn(&sign)
  10868. if err == nil {
  10869. c.ServeSuccessJSON(map[string]interface{}{
  10870. "msg": "签到成功",
  10871. })
  10872. }
  10873. } else {
  10874. c.ServeSuccessJSON(map[string]interface{}{
  10875. "failed_code": -10,
  10876. "msg": res.ErrMsg,
  10877. })
  10878. return
  10879. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10880. //return
  10881. }
  10882. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10883. fmt.Println(miConfig.SecretKey)
  10884. var res models.Result9001Two
  10885. 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 +
  10886. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10887. resp, requestErr := http.Get(api)
  10888. if requestErr != nil {
  10889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10890. return
  10891. }
  10892. body, ioErr := ioutil.ReadAll(resp.Body)
  10893. if ioErr != nil {
  10894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10896. return
  10897. }
  10898. var respJSON map[string]interface{}
  10899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10902. return
  10903. }
  10904. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10905. if status == "0" {
  10906. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10907. c.ServeSuccessJSON(map[string]interface{}{
  10908. "failed_code": -10,
  10909. "msg": err_msg,
  10910. })
  10911. return
  10912. }
  10913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10914. result, _ := json.Marshal(respJSON)
  10915. fmt.Println("log")
  10916. fmt.Println(string(result))
  10917. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10918. utils.ErrorLog("解析失败:%v", err)
  10919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10920. return
  10921. }
  10922. if res.Infcode == 0 {
  10923. sign := models.HisSignIn{
  10924. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10925. SignNo: res.Output.Signinoutb.SignNo,
  10926. SignTime: "",
  10927. Ctime: time.Now().Unix(),
  10928. Mtime: time.Now().Unix(),
  10929. Status: 1,
  10930. InputLog: "",
  10931. OutputLog: "",
  10932. FixmedinsCode: miConfig.Code,
  10933. }
  10934. err := service.CreateSignIn(&sign)
  10935. if err == nil {
  10936. c.ServeSuccessJSON(map[string]interface{}{
  10937. "msg": "签到成功",
  10938. })
  10939. }
  10940. } else {
  10941. c.ServeSuccessJSON(map[string]interface{}{
  10942. "failed_code": -10,
  10943. "msg": res.ErrMsg,
  10944. })
  10945. return
  10946. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10947. //return
  10948. }
  10949. } else {
  10950. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10951. var dat map[string]interface{}
  10952. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10953. fmt.Println(dat)
  10954. } else {
  10955. fmt.Println(err)
  10956. }
  10957. userJSONBytes, _ := json.Marshal(dat)
  10958. var res models.Result9001
  10959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10960. utils.ErrorLog("解析失败:%v", err)
  10961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10962. return
  10963. }
  10964. if res.Infcode == 0 {
  10965. sign := models.HisSignIn{
  10966. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10967. SignNo: res.Output.Signinoutb.SignNo,
  10968. SignTime: res.Output.Signinoutb.SignTime,
  10969. Ctime: time.Now().Unix(),
  10970. Mtime: time.Now().Unix(),
  10971. Status: 1,
  10972. InputLog: "",
  10973. OutputLog: "",
  10974. FixmedinsCode: miConfig.Code,
  10975. }
  10976. err := service.CreateSignIn(&sign)
  10977. if err == nil {
  10978. c.ServeSuccessJSON(map[string]interface{}{
  10979. "msg": "签到成功",
  10980. })
  10981. }
  10982. }
  10983. }
  10984. }
  10985. 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) {
  10986. var res Result3101
  10987. adminUser := c.GetAdminUserInfo()
  10988. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10989. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10990. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10991. //record_time := c.GetString("record_time")
  10992. //trig_scen := c.GetString("trig_scen")
  10993. timeLayout := "2006-01-02"
  10994. loc, _ := time.LoadLocation("Local")
  10995. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10996. if err != nil {
  10997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10998. return res
  10999. }
  11000. recordDateTime := theTime.Unix()
  11001. var patientPrescription models.HisPrescriptionInfo
  11002. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11003. //if patientPrescription.ID == 0 {
  11004. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11005. //}
  11006. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11007. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11008. //
  11009. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11010. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11011. var pp models.PublicParams
  11012. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11013. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11014. pp.FixmedinsName = miConfig.OrgName
  11015. pp.FixmedinsCode = miConfig.Code
  11016. pp.RequestUrl = miConfig.Url
  11017. pp.Cainfo = miConfig.Cainfo
  11018. pp.SecretKey = miConfig.SecretKey
  11019. pp.AccessKey = miConfig.AccessKey
  11020. pp.OpterName = roles.UserName
  11021. var config []*models.HisXtDiagnoseConfig
  11022. for _, item := range diagnosis_ids {
  11023. id, _ := strconv.ParseInt(item, 10, 64)
  11024. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11025. config = append(config, &diagnosisConfig)
  11026. }
  11027. var pd models.PatientDtos
  11028. pd.PatnID = his.PsnNo
  11029. pd.PatnName = his.Name
  11030. pd.Gend = his.Gend
  11031. pd.Brdy = his.Brdy
  11032. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11033. pd.CurrMdtrtID = his.Number
  11034. var fed models.FsiEncounterDtos
  11035. fed.MdtrtID = his.Number
  11036. fed.MedinsID = miConfig.Code
  11037. fed.MedinsName = miConfig.OrgName
  11038. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11039. fed.MedMdtrtType = "1"
  11040. fed.MedinsType = "1"
  11041. fed.MedinsLv = "11"
  11042. tm := time.Unix(his.RecordDate, 0)
  11043. s_tm := tm.Format("2006-01-02 15:04:05")
  11044. fed.AdmDate = s_tm
  11045. fed.DscgDate = s_tm
  11046. fed.DscgMainDiseCodg = config[0].CountryCode
  11047. fed.DscgMainDiseName = config[0].CountryContentName
  11048. //诊断信息
  11049. var fdds []*models.FsiDiagnoseDtos
  11050. for index, item := range config {
  11051. if index == 0 {
  11052. var fdd models.FsiDiagnoseDtos
  11053. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11054. fdd.InoutDiseType = "1"
  11055. fdd.MaindiseFlag = "1"
  11056. fdd.DiseDate = s_tm
  11057. fdd.DiasSrtNo = "1"
  11058. fdd.DiseName = item.CountryContentName
  11059. fdd.DiseCodg = item.CountryCode
  11060. fdds = append(fdds, &fdd)
  11061. } else {
  11062. var fdd models.FsiDiagnoseDtos
  11063. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11064. fdd.InoutDiseType = "1"
  11065. fdd.MaindiseFlag = "1"
  11066. fdd.DiseDate = s_tm
  11067. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11068. fdd.DiseName = item.CountryContentName
  11069. fdd.DiseCodg = item.CountryCode
  11070. fdds = append(fdds, &fdd)
  11071. }
  11072. }
  11073. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11074. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11075. fed.AdmDeptName = de.Name
  11076. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11077. fed.DscgDeptName = de.Name
  11078. fed.MedMdtrtType = "1"
  11079. fed.MedType = "11"
  11080. //if his.Insutype == "390" {
  11081. // fed.MedType = "1402"
  11082. //} else {
  11083. // fed.MedType = "9933"
  11084. //}
  11085. var orders []*models.FsiOrderDtos
  11086. if trig_scen == "2" {
  11087. //处方医嘱信息
  11088. for _, item := range prescriptions {
  11089. for _, subItem := range item.HisDoctorAdviceInfo {
  11090. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11091. var order models.FsiOrderDtos
  11092. order.RxID = strconv.FormatInt(item.ID, 10)
  11093. order.Rxno = strconv.FormatInt(item.ID, 10)
  11094. order.LongDrordFlag = "0"
  11095. order.HilistType = "1"
  11096. order.ChrgType = "1"
  11097. order.DrordBhvr = "-"
  11098. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11099. order.HosplistName = subItem.BaseDrugLib.DrugName
  11100. order.HilistLv = "1"
  11101. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11102. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11103. order.HosplistName = subItem.BaseDrugLib.DrugName
  11104. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11105. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11106. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11107. order.OwnpayAmt = ""
  11108. order.SelfpayAmt = ""
  11109. order.Spec = ""
  11110. order.SpecUnt = ""
  11111. order.DrordBegnDate = s_tm
  11112. order.DrordStopDate = ""
  11113. order.DrordDrCodg = doctor_info.DoctorNumber
  11114. order.DrordDeptName = department.Name
  11115. order.DrordDeptCodg = department.Number
  11116. order.DrordDrName = doctor_info.UserName
  11117. order.DrordDrProfttl = "234"
  11118. order.CurrDrordFlag = "1"
  11119. orders = append(orders, &order)
  11120. }
  11121. }
  11122. for _, subItem := range item.HisPrescriptionProject {
  11123. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11124. var order models.FsiOrderDtos
  11125. order.RxID = strconv.FormatInt(item.ID, 10)
  11126. order.Rxno = strconv.FormatInt(item.ID, 10)
  11127. order.LongDrordFlag = "0"
  11128. order.HilistType = "1"
  11129. order.ChrgType = "1"
  11130. order.DrordBhvr = "-"
  11131. order.HilistCode = subItem.HisProject.MedicalCode
  11132. order.HosplistName = subItem.HisProject.ProjectName
  11133. order.HilistLv = "1"
  11134. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11135. order.HosplistCode = subItem.HisProject.MedicalCode
  11136. order.HosplistName = subItem.HisProject.ProjectName
  11137. order.Cnt = subItem.Count
  11138. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11139. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11140. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11141. order.OwnpayAmt = ""
  11142. order.SelfpayAmt = ""
  11143. order.Spec = ""
  11144. order.SpecUnt = ""
  11145. order.DrordBegnDate = s_tm
  11146. order.DrordStopDate = ""
  11147. order.DrordDrCodg = doctor_info.DoctorNumber
  11148. order.DrordDeptName = department.Name
  11149. order.DrordDeptCodg = department.Number
  11150. order.DrordDrName = doctor_info.UserName
  11151. order.DrordDrProfttl = "234"
  11152. order.CurrDrordFlag = "1"
  11153. orders = append(orders, &order)
  11154. }
  11155. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11156. var order models.FsiOrderDtos
  11157. order.RxID = strconv.FormatInt(item.ID, 10)
  11158. order.Rxno = strconv.FormatInt(item.ID, 10)
  11159. order.LongDrordFlag = "0"
  11160. order.HilistType = "1"
  11161. order.ChrgType = "1"
  11162. order.DrordBhvr = "-"
  11163. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11164. order.HosplistName = subItem.GoodInfo.GoodName
  11165. order.HilistLv = "1"
  11166. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11167. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11168. order.HosplistName = subItem.GoodInfo.GoodName
  11169. order.Cnt = subItem.Count
  11170. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11171. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11172. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11173. order.OwnpayAmt = ""
  11174. order.SelfpayAmt = ""
  11175. order.Spec = ""
  11176. order.SpecUnt = ""
  11177. order.DrordBegnDate = s_tm
  11178. order.DrordStopDate = ""
  11179. order.DrordDrCodg = doctor_info.DoctorNumber
  11180. order.DrordDeptName = department.Name
  11181. order.DrordDeptCodg = department.Number
  11182. order.DrordDrName = doctor_info.UserName
  11183. order.DrordDrProfttl = "234"
  11184. order.CurrDrordFlag = "1"
  11185. orders = append(orders, &order)
  11186. }
  11187. }
  11188. }
  11189. //处方医嘱信息
  11190. }
  11191. fed.MatnStas = "0"
  11192. fed.MedfeeSumamt = "0"
  11193. fed.OwnpayAmt = "0"
  11194. fed.SelfpayAmt = "0"
  11195. fed.AcctPayamt = "0"
  11196. fed.MaAmt = "0"
  11197. fed.HifpPayamt = "0"
  11198. fed.SetlTotlnum = "1"
  11199. fed.Insutype = his.Insutype
  11200. fed.ReimFlag = "0"
  11201. fed.OutSetlFlag = "0"
  11202. var fopd []*models.FsiOperationDtosData
  11203. data := make(map[string]interface{})
  11204. data["fed"] = fed
  11205. data["fdd"] = fdds
  11206. data["fod"] = orders
  11207. data["pd"] = pd
  11208. data["pp"] = pp
  11209. data["fopd"] = fopd
  11210. data["trig_scen"] = trig_scen
  11211. fmt.Println(data)
  11212. fmt.Println(fed)
  11213. fmt.Println(fdds)
  11214. fmt.Println(orders)
  11215. fmt.Println(pd)
  11216. fmt.Println(pp)
  11217. fmt.Println(fopd)
  11218. client := &http.Client{}
  11219. bytesData, _ := json.Marshal(data)
  11220. var req *http.Request
  11221. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11222. if miConfig.MdtrtareaAdmvs == "320830" {
  11223. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11224. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11225. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11226. } else {
  11227. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11228. }
  11229. resp, _ := client.Do(req)
  11230. defer resp.Body.Close()
  11231. body, ioErr := ioutil.ReadAll(resp.Body)
  11232. if ioErr != nil {
  11233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11235. return res
  11236. }
  11237. var respJSON map[string]interface{}
  11238. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11241. return res
  11242. }
  11243. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11244. fmt.Println(respJSON)
  11245. result, _ := json.Marshal(respJSON)
  11246. fmt.Println(result)
  11247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11248. utils.ErrorLog("解析失败:%v", err)
  11249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11250. return res
  11251. }
  11252. return res
  11253. } else {
  11254. //if miConfig.MdtrtareaAdmvs == "441202" {
  11255. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11256. saveLog(output, input, "3101", "事前")
  11257. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11258. utils.ErrorLog("解析失败:%v", err)
  11259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11260. return
  11261. }
  11262. return res
  11263. //}
  11264. }
  11265. }
  11266. 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) {
  11267. adminUser := c.GetAdminUserInfo()
  11268. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11269. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11270. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11271. //record_time := c.GetString("record_time")
  11272. //trig_scen := c.GetString("trig_scen")
  11273. timeLayout := "2006-01-02"
  11274. loc, _ := time.LoadLocation("Local")
  11275. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11276. if err != nil {
  11277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11278. return res
  11279. }
  11280. recordDateTime := theTime.Unix()
  11281. var patientPrescription models.HisPrescriptionInfo
  11282. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11283. if patientPrescription.ID == 0 {
  11284. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11285. }
  11286. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11287. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11288. //
  11289. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11290. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11291. var pp models.PublicParams
  11292. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11293. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11294. pp.FixmedinsName = miConfig.OrgName
  11295. pp.FixmedinsCode = miConfig.Code
  11296. pp.RequestUrl = miConfig.Url
  11297. pp.Cainfo = miConfig.Cainfo
  11298. pp.SecretKey = miConfig.SecretKey
  11299. pp.AccessKey = miConfig.AccessKey
  11300. pp.OpterName = roles.UserName
  11301. var config []*models.HisXtDiagnoseConfig
  11302. for _, item := range diagnosis_ids {
  11303. id, _ := strconv.ParseInt(item, 10, 64)
  11304. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11305. config = append(config, &diagnosisConfig)
  11306. }
  11307. var pd models.PatientDtos
  11308. pd.PatnID = his.PsnNo
  11309. pd.PatnName = his.Name
  11310. pd.Gend = his.Gend
  11311. pd.Brdy = his.Brdy
  11312. pd.Poolarea = his.InsuplcAdmdvs
  11313. pd.CurrMdtrtID = his.Number
  11314. var fed models.FsiEncounterDtos
  11315. fed.MdtrtID = his.Number
  11316. fed.MedinsID = miConfig.Code
  11317. fed.MedinsName = miConfig.OrgName
  11318. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11319. fed.MedMdtrtType = "1"
  11320. fed.MedinsType = "1"
  11321. fed.MedinsLv = "11"
  11322. tm := time.Unix(his.RecordDate, 0)
  11323. s_tm := tm.Format("2006-01-02 15:04:05")
  11324. fed.AdmDate = s_tm
  11325. fed.DscgDate = s_tm
  11326. fed.DscgMainDiseCodg = config[0].CountryCode
  11327. fed.DscgMainDiseName = config[0].CountryContentName
  11328. //诊断信息
  11329. var fdds []*models.FsiDiagnoseDtos
  11330. for index, item := range config {
  11331. if index == 0 {
  11332. var fdd models.FsiDiagnoseDtos
  11333. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11334. fdd.InoutDiseType = "1"
  11335. fdd.MaindiseFlag = "1"
  11336. fdd.DiseDate = s_tm
  11337. fdd.DiasSrtNo = "1"
  11338. fdd.DiseName = item.CountryContentName
  11339. fdd.DiseCodg = item.CountryCode
  11340. fdds = append(fdds, &fdd)
  11341. } else {
  11342. var fdd models.FsiDiagnoseDtos
  11343. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11344. fdd.InoutDiseType = "1"
  11345. fdd.MaindiseFlag = "1"
  11346. fdd.DiseDate = s_tm
  11347. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11348. fdd.DiseName = item.CountryContentName
  11349. fdd.DiseCodg = item.CountryCode
  11350. fdds = append(fdds, &fdd)
  11351. }
  11352. }
  11353. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11354. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11355. fed.AdmDeptName = department.Name
  11356. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11357. fed.DscgDeptName = department.Name
  11358. fed.MedMdtrtType = "1"
  11359. fed.MedType = "11"
  11360. //if his.Insutype == "390" {
  11361. // fed.MedType = "1402"
  11362. //} else {
  11363. // fed.MedType = "9933"
  11364. //}
  11365. var orders []*models.FsiOrderDtos
  11366. if trig_scen == "2" {
  11367. //处方医嘱信息
  11368. for _, item := range prescriptions {
  11369. for _, subItem := range item.HisDoctorAdviceInfo {
  11370. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11371. var order models.FsiOrderDtos
  11372. order.RxID = strconv.FormatInt(item.ID, 10)
  11373. order.Rxno = strconv.FormatInt(item.ID, 10)
  11374. order.LongDrordFlag = "0"
  11375. order.HilistType = "1"
  11376. order.ChrgType = "1"
  11377. order.DrordBhvr = "-"
  11378. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11379. order.HosplistName = subItem.BaseDrugLib.DrugName
  11380. order.HilistLv = "1"
  11381. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11382. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11383. order.HosplistName = subItem.BaseDrugLib.DrugName
  11384. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11385. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11386. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11387. order.OwnpayAmt = ""
  11388. order.SelfpayAmt = ""
  11389. order.Spec = ""
  11390. order.SpecUnt = ""
  11391. order.DrordBegnDate = s_tm
  11392. order.DrordStopDate = ""
  11393. order.DrordDrCodg = doctor_info.DoctorNumber
  11394. order.DrordDeptName = department.Name
  11395. order.DrordDeptCodg = department.Number
  11396. order.DrordDrName = doctor_info.UserName
  11397. order.DrordDrProfttl = "234"
  11398. order.CurrDrordFlag = "1"
  11399. orders = append(orders, &order)
  11400. }
  11401. }
  11402. for _, subItem := range item.HisPrescriptionProject {
  11403. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11404. var order models.FsiOrderDtos
  11405. order.RxID = strconv.FormatInt(item.ID, 10)
  11406. order.Rxno = strconv.FormatInt(item.ID, 10)
  11407. order.LongDrordFlag = "0"
  11408. order.HilistType = "1"
  11409. order.ChrgType = "1"
  11410. order.DrordBhvr = "-"
  11411. order.HilistCode = subItem.HisProject.MedicalCode
  11412. order.HosplistName = subItem.HisProject.ProjectName
  11413. order.HilistLv = "1"
  11414. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11415. order.HosplistCode = subItem.HisProject.MedicalCode
  11416. order.HosplistName = subItem.HisProject.ProjectName
  11417. order.Cnt = subItem.Count
  11418. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11419. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11420. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11421. order.OwnpayAmt = ""
  11422. order.SelfpayAmt = ""
  11423. order.Spec = ""
  11424. order.SpecUnt = ""
  11425. order.DrordBegnDate = s_tm
  11426. order.DrordStopDate = ""
  11427. order.DrordDrCodg = doctor_info.DoctorNumber
  11428. order.DrordDeptName = department.Name
  11429. order.DrordDeptCodg = department.Number
  11430. order.DrordDrName = doctor_info.UserName
  11431. order.DrordDrProfttl = "234"
  11432. order.CurrDrordFlag = "1"
  11433. orders = append(orders, &order)
  11434. }
  11435. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11436. var order models.FsiOrderDtos
  11437. order.RxID = strconv.FormatInt(item.ID, 10)
  11438. order.Rxno = strconv.FormatInt(item.ID, 10)
  11439. order.LongDrordFlag = "0"
  11440. order.HilistType = "1"
  11441. order.ChrgType = "1"
  11442. order.DrordBhvr = "-"
  11443. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11444. order.HosplistName = subItem.GoodInfo.GoodName
  11445. order.HilistLv = "1"
  11446. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11447. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11448. order.HosplistName = subItem.GoodInfo.GoodName
  11449. order.Cnt = subItem.Count
  11450. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11451. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11452. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11453. order.OwnpayAmt = ""
  11454. order.SelfpayAmt = ""
  11455. order.Spec = ""
  11456. order.SpecUnt = ""
  11457. order.DrordBegnDate = s_tm
  11458. order.DrordStopDate = ""
  11459. order.DrordDrCodg = doctor_info.DoctorNumber
  11460. order.DrordDeptName = department.Name
  11461. order.DrordDeptCodg = department.Number
  11462. order.DrordDrName = doctor_info.UserName
  11463. order.DrordDrProfttl = "234"
  11464. order.CurrDrordFlag = "1"
  11465. orders = append(orders, &order)
  11466. }
  11467. }
  11468. }
  11469. //处方医嘱信息
  11470. }
  11471. fed.MatnStas = "0"
  11472. fed.MedfeeSumamt = "0"
  11473. fed.OwnpayAmt = "0"
  11474. fed.SelfpayAmt = "0"
  11475. fed.AcctPayamt = "0"
  11476. fed.MaAmt = "0"
  11477. fed.HifpPayamt = "0"
  11478. fed.SetlTotlnum = "1"
  11479. fed.Insutype = his.Insutype
  11480. fed.ReimFlag = "0"
  11481. fed.OutSetlFlag = "0"
  11482. var fopd []*models.FsiOperationDtosData
  11483. data := make(map[string]interface{})
  11484. data["fed"] = fed
  11485. data["fdd"] = fdds
  11486. data["fod"] = orders
  11487. data["pd"] = pd
  11488. data["pp"] = pp
  11489. data["fopd"] = fopd
  11490. data["trig_scen"] = trig_scen
  11491. fmt.Println(data)
  11492. fmt.Println(fed)
  11493. fmt.Println(fdds)
  11494. fmt.Println(orders)
  11495. fmt.Println(pd)
  11496. fmt.Println(pp)
  11497. fmt.Println(fopd)
  11498. client := &http.Client{}
  11499. bytesData, _ := json.Marshal(data)
  11500. var req *http.Request
  11501. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11502. if miConfig.MdtrtareaAdmvs == "320830" {
  11503. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11504. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11505. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11506. } else {
  11507. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11508. }
  11509. resp, _ := client.Do(req)
  11510. defer resp.Body.Close()
  11511. body, ioErr := ioutil.ReadAll(resp.Body)
  11512. if ioErr != nil {
  11513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11515. return res
  11516. }
  11517. var respJSON map[string]interface{}
  11518. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11521. return res
  11522. }
  11523. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11524. fmt.Println(respJSON)
  11525. result, _ := json.Marshal(respJSON)
  11526. fmt.Println(result)
  11527. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11528. utils.ErrorLog("解析失败:%v", err)
  11529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11530. return res
  11531. }
  11532. return res
  11533. } else {
  11534. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11535. saveLog(output, input, "3101", "事前")
  11536. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11537. utils.ErrorLog("解析失败:%v", err)
  11538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11539. return
  11540. }
  11541. return res
  11542. }
  11543. return res
  11544. }
  11545. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11546. ////patient_id, _ := c.GetInt64("patient_id")
  11547. //order_id, _ := c.GetInt64("order_id")
  11548. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11549. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11550. //trig_scen := c.GetString("trig_scen")
  11551. adminUser := c.GetAdminUserInfo()
  11552. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11553. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11554. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11555. record_time := c.GetString("record_time")
  11556. order, _ := service.GetHisOrderByID(order_id)
  11557. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11558. timeLayout := "2006-01-02"
  11559. loc, _ := time.LoadLocation("Local")
  11560. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11561. if err != nil {
  11562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11563. return
  11564. }
  11565. recordDateTime := theTime.Unix()
  11566. var patientPrescription models.HisPrescriptionInfo
  11567. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11568. if patientPrescription.ID == 0 {
  11569. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11570. }
  11571. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11572. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11573. //
  11574. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11575. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11576. var pp models.PublicParams
  11577. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11578. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11579. pp.FixmedinsName = miConfig.OrgName
  11580. pp.FixmedinsCode = miConfig.Code
  11581. pp.RequestUrl = miConfig.Url
  11582. pp.Cainfo = miConfig.Cainfo
  11583. pp.SecretKey = miConfig.SecretKey
  11584. pp.AccessKey = miConfig.AccessKey
  11585. pp.OpterName = roles.UserName
  11586. var config []*models.HisXtDiagnoseConfig
  11587. for _, item := range diagnosis_ids {
  11588. id, _ := strconv.ParseInt(item, 10, 64)
  11589. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11590. config = append(config, &diagnosisConfig)
  11591. }
  11592. var pd models.PatientDtos
  11593. pd.PatnID = his.PsnNo
  11594. pd.PatnName = his.Name
  11595. pd.Gend = his.Gend
  11596. pd.Brdy = psn_info.Brdy
  11597. pd.Poolarea = his.InsuplcAdmdvs
  11598. pd.CurrMdtrtID = his.Number
  11599. var fed models.FsiEncounterDtos
  11600. fed.MdtrtID = his.Number
  11601. fed.MedinsID = miConfig.Code
  11602. fed.MedinsName = miConfig.OrgName
  11603. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11604. fed.MedMdtrtType = "1"
  11605. fed.MedinsType = "1"
  11606. fed.MedinsLv = "11"
  11607. tm := time.Unix(his.RecordDate, 0)
  11608. s_tm := tm.Format("2006-01-02 15:04:05")
  11609. fed.AdmDate = s_tm
  11610. fed.DscgDate = s_tm
  11611. fed.DscgMainDiseCodg = config[0].CountryCode
  11612. fed.DscgMainDiseName = config[0].CountryContentName
  11613. //诊断信息
  11614. var fdds []*models.FsiDiagnoseDtos
  11615. for index, item := range config {
  11616. if index == 0 {
  11617. var fdd models.FsiDiagnoseDtos
  11618. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11619. fdd.InoutDiseType = "1"
  11620. fdd.MaindiseFlag = "1"
  11621. fdd.DiseDate = s_tm
  11622. fdd.DiasSrtNo = "1"
  11623. fdd.DiseName = item.CountryContentName
  11624. fdd.DiseCodg = item.CountryCode
  11625. fdds = append(fdds, &fdd)
  11626. } else {
  11627. var fdd models.FsiDiagnoseDtos
  11628. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11629. fdd.InoutDiseType = "1"
  11630. fdd.MaindiseFlag = "1"
  11631. fdd.DiseDate = s_tm
  11632. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11633. fdd.DiseName = item.CountryContentName
  11634. fdd.DiseCodg = item.CountryCode
  11635. fdds = append(fdds, &fdd)
  11636. }
  11637. }
  11638. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11639. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11640. fed.AdmDeptName = department.Name
  11641. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11642. fed.DscgDeptName = department.Name
  11643. fed.MedType = order.MedType
  11644. //处方医嘱信息
  11645. var orders []*models.FsiOrderDtos
  11646. //for _, item := range prescriptions {
  11647. // for _, subItem := range item.HisDoctorAdviceInfo {
  11648. // var order models.FsiOrderDtos
  11649. // order.RxID = strconv.FormatInt(item.ID, 10)
  11650. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11651. // order.LongDrordFlag = "0"
  11652. // order.HilistType = "1"
  11653. // order.ChrgType = "1"
  11654. // order.DrordBhvr = "-"
  11655. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11656. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11657. // order.HilistLv = "1"
  11658. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11659. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11660. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11661. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11662. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11663. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11664. // order.OwnpayAmt = ""
  11665. // order.SelfpayAmt = ""
  11666. // order.Spec = ""
  11667. // order.SpecUnt = ""
  11668. // order.DrordBegnDate = s_tm
  11669. // order.DrordStopDate = ""
  11670. // order.DrordDrCodg = "1"
  11671. // order.DrordDeptName = department.Name
  11672. // order.DrordDrCodg = "1"
  11673. // order.DrordDrName = doctor_info.UserName
  11674. // order.DrordDrProfttl = ""
  11675. // order.CurrDrordFlag = "1"
  11676. // orders = append(orders, &order)
  11677. // }
  11678. // for _, subItem := range item.HisPrescriptionProject {
  11679. // if subItem.Type == 2 {
  11680. // var order models.FsiOrderDtos
  11681. // order.RxID = strconv.FormatInt(item.ID, 10)
  11682. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11683. // order.LongDrordFlag = "0"
  11684. // order.HilistType = "1"
  11685. // order.ChrgType = "1"
  11686. // order.DrordBhvr = "-"
  11687. // order.HilistCode = subItem.HisProject.MedicalCode
  11688. // order.HosplistName = subItem.HisProject.ProjectName
  11689. // order.HilistLv = "1"
  11690. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11691. // order.HosplistCode = subItem.HisProject.MedicalCode
  11692. // order.HosplistName = subItem.HisProject.ProjectName
  11693. // order.Cnt = subItem.Count
  11694. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11695. //
  11696. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11697. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11698. // order.OwnpayAmt = ""
  11699. // order.SelfpayAmt = ""
  11700. // order.Spec = ""
  11701. // order.SpecUnt = ""
  11702. // order.DrordBegnDate = s_tm
  11703. // order.DrordStopDate = ""
  11704. // order.DrordDrCodg = "1"
  11705. // order.DrordDeptName = department.Name
  11706. // order.DrordDrCodg = "1"
  11707. // order.DrordDrName = doctor_info.UserName
  11708. // order.DrordDrProfttl = ""
  11709. // order.CurrDrordFlag = "1"
  11710. // orders = append(orders, &order)
  11711. //
  11712. // }
  11713. // if subItem.Type == 3 {
  11714. //
  11715. // var order models.FsiOrderDtos
  11716. // order.RxID = strconv.FormatInt(item.ID, 10)
  11717. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11718. // order.LongDrordFlag = "0"
  11719. // order.HilistType = "1"
  11720. // order.ChrgType = "1"
  11721. // order.DrordBhvr = "-"
  11722. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11723. // order.HosplistName = subItem.GoodInfo.GoodName
  11724. // order.HilistLv = "1"
  11725. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11726. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11727. // order.HosplistName = subItem.GoodInfo.GoodName
  11728. // order.Cnt = subItem.Count
  11729. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11730. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11731. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11732. // order.OwnpayAmt = ""
  11733. // order.SelfpayAmt = ""
  11734. // order.Spec = ""
  11735. // order.SpecUnt = ""
  11736. // order.DrordBegnDate = s_tm
  11737. // order.DrordStopDate = ""
  11738. // order.DrordDrCodg = "1"
  11739. // order.DrordDeptName = department.Name
  11740. // order.DrordDrCodg = "1"
  11741. // order.DrordDrName = doctor_info.UserName
  11742. // order.DrordDrProfttl = ""
  11743. // order.CurrDrordFlag = "1"
  11744. // orders = append(orders, &order)
  11745. //
  11746. // }
  11747. // }
  11748. //}
  11749. for _, item := range prescriptions {
  11750. for _, subItem := range item.HisDoctorAdviceInfo {
  11751. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11752. var order models.FsiOrderDtos
  11753. order.RxID = strconv.FormatInt(item.ID, 10)
  11754. order.Rxno = strconv.FormatInt(item.ID, 10)
  11755. order.LongDrordFlag = "0"
  11756. order.HilistType = "101"
  11757. order.ChrgType = "1"
  11758. order.DrordBhvr = "-"
  11759. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11760. order.HosplistName = subItem.BaseDrugLib.DrugName
  11761. order.HilistLv = "1"
  11762. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11763. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11764. order.HosplistName = subItem.BaseDrugLib.DrugName
  11765. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11766. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11767. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11768. order.OwnpayAmt = ""
  11769. order.SelfpayAmt = ""
  11770. order.Spec = ""
  11771. order.SpecUnt = ""
  11772. order.DrordBegnDate = s_tm
  11773. order.DrordStopDate = ""
  11774. order.DrordDrCodg = doctor_info.DoctorNumber
  11775. order.DrordDeptName = department.Name
  11776. order.DrordDeptCodg = department.Number
  11777. order.DrordDrName = doctor_info.UserName
  11778. order.DrordDrProfttl = "234"
  11779. order.CurrDrordFlag = "1"
  11780. orders = append(orders, &order)
  11781. }
  11782. }
  11783. for _, subItem := range item.HisPrescriptionProject {
  11784. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 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 = "201"
  11790. order.ChrgType = "1"
  11791. order.DrordBhvr = "-"
  11792. order.HilistCode = subItem.HisProject.MedicalCode
  11793. order.HosplistName = subItem.HisProject.ProjectName
  11794. order.HilistLv = "1"
  11795. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11796. order.HosplistCode = subItem.HisProject.MedicalCode
  11797. order.HosplistName = subItem.HisProject.ProjectName
  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 = ""
  11805. order.SpecUnt = ""
  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. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11817. var order models.FsiOrderDtos
  11818. order.RxID = strconv.FormatInt(item.ID, 10)
  11819. order.Rxno = strconv.FormatInt(item.ID, 10)
  11820. order.LongDrordFlag = "0"
  11821. order.HilistType = "301"
  11822. order.ChrgType = "1"
  11823. order.DrordBhvr = "0"
  11824. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11825. order.HosplistName = subItem.GoodInfo.GoodName
  11826. order.HilistLv = "1"
  11827. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11828. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11829. order.HosplistName = subItem.GoodInfo.GoodName
  11830. order.Cnt = subItem.Count
  11831. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11832. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11833. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11834. order.OwnpayAmt = ""
  11835. order.SelfpayAmt = ""
  11836. order.Spec = ""
  11837. order.SpecUnt = ""
  11838. order.DrordBegnDate = s_tm
  11839. order.DrordStopDate = ""
  11840. order.DrordDrCodg = doctor_info.DoctorNumber
  11841. order.DrordDeptName = department.Name
  11842. order.DrordDeptCodg = department.Number
  11843. order.DrordDrName = doctor_info.UserName
  11844. order.DrordDrProfttl = "234"
  11845. order.CurrDrordFlag = "1"
  11846. orders = append(orders, &order)
  11847. }
  11848. }
  11849. }
  11850. //处方医嘱信息
  11851. fed.MatnStas = "0"
  11852. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11853. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11854. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11855. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11856. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11857. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11858. fed.SetlTotlnum = "1"
  11859. fed.Insutype = his.Insutype
  11860. fed.ReimFlag = "0"
  11861. fed.OutSetlFlag = "0"
  11862. var fopd []*models.FsiOperationDtosData
  11863. data := make(map[string]interface{})
  11864. data["fed"] = fed
  11865. data["fdd"] = fdds
  11866. data["fod"] = orders
  11867. data["pd"] = pd
  11868. data["pp"] = pp
  11869. data["fopd"] = fopd
  11870. data["trig_scen"] = trig_scen
  11871. client := &http.Client{}
  11872. bytesData, _ := json.Marshal(data)
  11873. var req *http.Request
  11874. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11875. if miConfig.MdtrtareaAdmvs == "320830" {
  11876. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  11877. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11878. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11879. } else {
  11880. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11881. }
  11882. resp, _ := client.Do(req)
  11883. defer resp.Body.Close()
  11884. body, ioErr := ioutil.ReadAll(resp.Body)
  11885. if ioErr != nil {
  11886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11888. return res
  11889. }
  11890. var respJSON map[string]interface{}
  11891. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11894. return res
  11895. }
  11896. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11897. result, _ := json.Marshal(respJSON)
  11898. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11899. utils.ErrorLog("解析失败:%v", err)
  11900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11901. return res
  11902. }
  11903. return res
  11904. } else {
  11905. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11906. saveLog(output, input, "3102", "事中")
  11907. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11908. utils.ErrorLog("解析失败:%v", err)
  11909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11910. return
  11911. }
  11912. return res
  11913. }
  11914. return res
  11915. }
  11916. 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) {
  11917. var res Resultgd3101
  11918. adminUser := c.GetAdminUserInfo()
  11919. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11920. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11921. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11922. //record_time := c.GetString("record_time")
  11923. //trig_scen := c.GetString("trig_scen")
  11924. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11925. //psn_info, _ := service.GetPatientId(patient_id)
  11926. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11927. timeLayout := "2006-01-02"
  11928. loc, _ := time.LoadLocation("Local")
  11929. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11930. if err != nil {
  11931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11932. return res
  11933. }
  11934. recordDateTime := theTime.Unix()
  11935. var patientPrescription models.HisPrescriptionInfo
  11936. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11937. //if patientPrescription.ID == 0 {
  11938. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11939. //}
  11940. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11941. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11942. //
  11943. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11944. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11945. var str string
  11946. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  11947. str = timestampToBirthdayString(patient.Birthday)
  11948. } else {
  11949. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  11950. }
  11951. var pp models.PublicParams
  11952. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11953. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11954. pp.FixmedinsName = miConfig.OrgName
  11955. pp.FixmedinsCode = miConfig.Code
  11956. pp.RequestUrl = miConfig.Url
  11957. pp.Cainfo = miConfig.Cainfo
  11958. pp.SecretKey = miConfig.SecretKey
  11959. pp.AccessKey = miConfig.AccessKey
  11960. pp.OpterName = roles.UserName
  11961. var config []*models.HisXtDiagnoseConfig
  11962. for _, item := range diagnosis_ids {
  11963. id, _ := strconv.ParseInt(item, 10, 64)
  11964. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11965. config = append(config, &diagnosisConfig)
  11966. }
  11967. var pd models.PatientDtos
  11968. pd.PatnID = his.PsnNo
  11969. pd.PatnName = his.Name
  11970. pd.Gend = his.Gend
  11971. pd.Brdy = str
  11972. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11973. pd.CurrMdtrtID = his.Number
  11974. var fed models.FsiEncounterDtos
  11975. fed.MdtrtID = his.Number
  11976. fed.MedinsID = miConfig.Code
  11977. fed.MedinsName = miConfig.OrgName
  11978. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11979. fed.MedMdtrtType = "1"
  11980. fed.MedinsType = "1"
  11981. fed.MedinsLv = "11"
  11982. tm := time.Unix(his.RecordDate, 0)
  11983. s_tm := tm.Format("2006-01-02 15:04:05")
  11984. fed.AdmDate = s_tm
  11985. fed.DscgDate = s_tm
  11986. fed.DscgMainDiseCodg = config[0].CountryCode
  11987. fed.DscgMainDiseName = config[0].CountryContentName
  11988. //诊断信息
  11989. var fdds []*models.FsiDiagnoseDtos
  11990. for index, item := range config {
  11991. if index == 0 {
  11992. var fdd models.FsiDiagnoseDtos
  11993. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11994. fdd.InoutDiseType = "1"
  11995. fdd.MaindiseFlag = "1"
  11996. fdd.DiseDate = s_tm
  11997. fdd.DiasSrtNo = "1"
  11998. fdd.DiseName = item.CountryContentName
  11999. fdd.DiseCodg = item.CountryCode
  12000. fdds = append(fdds, &fdd)
  12001. } else {
  12002. var fdd models.FsiDiagnoseDtos
  12003. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12004. fdd.InoutDiseType = "1"
  12005. fdd.MaindiseFlag = "1"
  12006. fdd.DiseDate = s_tm
  12007. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12008. fdd.DiseName = item.CountryContentName
  12009. fdd.DiseCodg = item.CountryCode
  12010. fdds = append(fdds, &fdd)
  12011. }
  12012. }
  12013. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12014. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12015. fed.AdmDeptName = de.Name
  12016. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12017. fed.DscgDeptName = de.Name
  12018. fed.MedMdtrtType = "1"
  12019. fed.MedType = "11"
  12020. //if his.Insutype == "390" {
  12021. // fed.MedType = "1402"
  12022. //} else {
  12023. // fed.MedType = "9933"
  12024. //}
  12025. var orders []*models.FsiOrderDtos
  12026. if trig_scen == "2" {
  12027. //处方医嘱信息
  12028. for _, item := range prescriptions {
  12029. for _, subItem := range item.HisDoctorAdviceInfo {
  12030. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12031. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12032. var order models.FsiOrderDtos
  12033. order.RxID = strconv.FormatInt(item.ID, 10)
  12034. order.Rxno = strconv.FormatInt(item.ID, 10)
  12035. order.LongDrordFlag = "0"
  12036. order.HilistType = "101"
  12037. order.ChrgType = "1"
  12038. order.DrordBhvr = "0"
  12039. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12040. order.HosplistName = subItem.BaseDrugLib.DrugName
  12041. order.HilistLv = "1"
  12042. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12043. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12044. order.HosplistName = subItem.BaseDrugLib.DrugName
  12045. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12046. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12047. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12048. order.OwnpayAmt = ""
  12049. order.SelfpayAmt = ""
  12050. order.Spec = spec
  12051. order.SpecUnt = subItem.PrescribingNumberUnit
  12052. order.DrordBegnDate = s_tm
  12053. order.DrordStopDate = ""
  12054. order.DrordDrCodg = doctor_info.DoctorNumber
  12055. order.DrordDeptName = department.Name
  12056. order.DrordDeptCodg = department.Number
  12057. order.DrordDrName = doctor_info.UserName
  12058. order.DrordDrProfttl = "234"
  12059. order.CurrDrordFlag = "1"
  12060. orders = append(orders, &order)
  12061. }
  12062. }
  12063. for _, subItem := range item.HisPrescriptionProject {
  12064. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12065. var order models.FsiOrderDtos
  12066. order.RxID = strconv.FormatInt(item.ID, 10)
  12067. order.Rxno = strconv.FormatInt(item.ID, 10)
  12068. order.LongDrordFlag = "0"
  12069. order.HilistType = "201"
  12070. order.ChrgType = "1"
  12071. order.DrordBhvr = "0"
  12072. order.HilistCode = subItem.HisProject.MedicalCode
  12073. order.HosplistName = subItem.HisProject.ProjectName
  12074. order.HilistLv = "1"
  12075. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12076. order.HosplistCode = subItem.HisProject.MedicalCode
  12077. order.HosplistName = subItem.HisProject.ProjectName
  12078. order.Cnt = subItem.Count
  12079. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12080. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12081. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12082. order.OwnpayAmt = ""
  12083. order.SelfpayAmt = ""
  12084. order.Spec = subItem.Unit
  12085. order.SpecUnt = subItem.Unit
  12086. order.DrordBegnDate = s_tm
  12087. order.DrordStopDate = ""
  12088. order.DrordDrCodg = doctor_info.DoctorNumber
  12089. order.DrordDeptName = department.Name
  12090. order.DrordDeptCodg = department.Number
  12091. order.DrordDrName = doctor_info.UserName
  12092. order.DrordDrProfttl = "234"
  12093. order.CurrDrordFlag = "1"
  12094. orders = append(orders, &order)
  12095. }
  12096. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12097. var order models.FsiOrderDtos
  12098. order.RxID = strconv.FormatInt(item.ID, 10)
  12099. order.Rxno = strconv.FormatInt(item.ID, 10)
  12100. order.LongDrordFlag = "0"
  12101. order.HilistType = "301"
  12102. order.ChrgType = "1"
  12103. order.DrordBhvr = "0"
  12104. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12105. order.HosplistName = subItem.GoodInfo.GoodName
  12106. order.HilistLv = "1"
  12107. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12108. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12109. order.HosplistName = subItem.GoodInfo.GoodName
  12110. order.Cnt = subItem.Count
  12111. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12112. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12113. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12114. order.OwnpayAmt = ""
  12115. order.SelfpayAmt = ""
  12116. order.Spec = subItem.GoodInfo.SpecificationName
  12117. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12118. order.DrordBegnDate = s_tm
  12119. order.DrordStopDate = ""
  12120. order.DrordDrCodg = doctor_info.DoctorNumber
  12121. order.DrordDeptName = department.Name
  12122. order.DrordDeptCodg = department.Number
  12123. order.DrordDrName = doctor_info.UserName
  12124. order.DrordDrProfttl = "234"
  12125. order.CurrDrordFlag = "1"
  12126. orders = append(orders, &order)
  12127. }
  12128. }
  12129. }
  12130. //处方医嘱信息
  12131. }
  12132. fed.MatnStas = "0"
  12133. fed.MedfeeSumamt = "0"
  12134. fed.OwnpayAmt = "0"
  12135. fed.SelfpayAmt = "0"
  12136. fed.AcctPayamt = "0"
  12137. fed.MaAmt = "0"
  12138. fed.HifpPayamt = "0"
  12139. fed.SetlTotlnum = "1"
  12140. fed.Insutype = his.Insutype
  12141. fed.ReimFlag = "0"
  12142. fed.OutSetlFlag = "0"
  12143. var fopd []*models.FsiOperationDtosData
  12144. data := make(map[string]interface{})
  12145. data["fed"] = fed
  12146. data["fdd"] = fdds
  12147. data["fod"] = orders
  12148. data["pd"] = pd
  12149. data["pp"] = pp
  12150. data["fopd"] = fopd
  12151. data["trig_scen"] = trig_scen
  12152. fmt.Println(data)
  12153. fmt.Println(fed)
  12154. fmt.Println(fdds)
  12155. fmt.Println(orders)
  12156. fmt.Println(pd)
  12157. fmt.Println(pp)
  12158. fmt.Println(fopd)
  12159. client := &http.Client{}
  12160. bytesData, _ := json.Marshal(data)
  12161. var req *http.Request
  12162. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12163. if miConfig.MdtrtareaAdmvs == "320830" {
  12164. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12165. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12166. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12167. } else {
  12168. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12169. }
  12170. resp, _ := client.Do(req)
  12171. defer resp.Body.Close()
  12172. body, ioErr := ioutil.ReadAll(resp.Body)
  12173. if ioErr != nil {
  12174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12176. return res
  12177. }
  12178. var respJSON map[string]interface{}
  12179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12182. return res
  12183. }
  12184. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12185. fmt.Println(respJSON)
  12186. result, _ := json.Marshal(respJSON)
  12187. fmt.Println(result)
  12188. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12189. utils.ErrorLog("解析失败:%v", err)
  12190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12191. return res
  12192. }
  12193. return res
  12194. } else {
  12195. //if miConfig.MdtrtareaAdmvs == "441202" {
  12196. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12197. saveLog(output, input, "3101", "事前")
  12198. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12199. utils.ErrorLog("解析失败:%v", err)
  12200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12201. return
  12202. }
  12203. return res
  12204. //}
  12205. }
  12206. }
  12207. 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) {
  12208. adminUser := c.GetAdminUserInfo()
  12209. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12210. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12211. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12212. //record_time := c.GetString("record_time")
  12213. //trig_scen := c.GetString("trig_scen")
  12214. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12215. timeLayout := "2006-01-02"
  12216. loc, _ := time.LoadLocation("Local")
  12217. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12218. if err != nil {
  12219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12220. return res
  12221. }
  12222. recordDateTime := theTime.Unix()
  12223. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12224. var patientPrescription models.HisPrescriptionInfo
  12225. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12226. if patientPrescription.ID == 0 {
  12227. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12228. }
  12229. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12230. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12231. //
  12232. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12233. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12234. var pp models.PublicParams
  12235. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12236. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12237. pp.FixmedinsName = miConfig.OrgName
  12238. pp.FixmedinsCode = miConfig.Code
  12239. pp.RequestUrl = miConfig.Url
  12240. pp.Cainfo = miConfig.Cainfo
  12241. pp.SecretKey = miConfig.SecretKey
  12242. pp.AccessKey = miConfig.AccessKey
  12243. pp.OpterName = roles.UserName
  12244. var config []*models.HisXtDiagnoseConfig
  12245. for _, item := range diagnosis_ids {
  12246. id, _ := strconv.ParseInt(item, 10, 64)
  12247. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12248. config = append(config, &diagnosisConfig)
  12249. }
  12250. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12251. var str string
  12252. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12253. str = timestampToBirthdayString(patient.Birthday)
  12254. } else {
  12255. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12256. }
  12257. var pd models.PatientDtos
  12258. pd.PatnID = his.PsnNo
  12259. pd.PatnName = his.Name
  12260. pd.Gend = his.Gend
  12261. pd.Brdy = str
  12262. pd.Poolarea = his.InsuplcAdmdvs
  12263. pd.CurrMdtrtID = his.Number
  12264. var fed models.FsiEncounterDtos
  12265. fed.MdtrtID = his.Number
  12266. fed.MedinsID = miConfig.Code
  12267. fed.MedinsName = miConfig.OrgName
  12268. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12269. fed.MedMdtrtType = "1"
  12270. fed.MedinsType = "1"
  12271. fed.MedinsLv = "11"
  12272. tm := time.Unix(his.RecordDate, 0)
  12273. s_tm := tm.Format("2006-01-02 15:04:05")
  12274. fed.AdmDate = s_tm
  12275. fed.DscgDate = s_tm
  12276. fed.DscgMainDiseCodg = config[0].CountryCode
  12277. fed.DscgMainDiseName = config[0].CountryContentName
  12278. //诊断信息
  12279. var fdds []*models.FsiDiagnoseDtos
  12280. for index, item := range config {
  12281. if index == 0 {
  12282. var fdd models.FsiDiagnoseDtos
  12283. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12284. fdd.InoutDiseType = "1"
  12285. fdd.MaindiseFlag = "1"
  12286. fdd.DiseDate = s_tm
  12287. fdd.DiasSrtNo = "1"
  12288. fdd.DiseName = item.CountryContentName
  12289. fdd.DiseCodg = item.CountryCode
  12290. fdds = append(fdds, &fdd)
  12291. } else {
  12292. var fdd models.FsiDiagnoseDtos
  12293. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12294. fdd.InoutDiseType = "1"
  12295. fdd.MaindiseFlag = "1"
  12296. fdd.DiseDate = s_tm
  12297. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12298. fdd.DiseName = item.CountryContentName
  12299. fdd.DiseCodg = item.CountryCode
  12300. fdds = append(fdds, &fdd)
  12301. }
  12302. }
  12303. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12304. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12305. fed.AdmDeptName = department.Name
  12306. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12307. fed.DscgDeptName = department.Name
  12308. fed.MedMdtrtType = "1"
  12309. fed.MedType = "11"
  12310. //if his.Insutype == "390" {
  12311. // fed.MedType = "1402"
  12312. //} else {
  12313. // fed.MedType = "9933"
  12314. //}
  12315. var orders []*models.FsiOrderDtos
  12316. if trig_scen == "2" {
  12317. //处方医嘱信息
  12318. for _, item := range prescriptions {
  12319. for _, subItem := range item.HisDoctorAdviceInfo {
  12320. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12321. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12322. var order models.FsiOrderDtos
  12323. order.RxID = strconv.FormatInt(item.ID, 10)
  12324. order.Rxno = strconv.FormatInt(item.ID, 10)
  12325. order.LongDrordFlag = "0"
  12326. order.HilistType = "101"
  12327. order.ChrgType = "1"
  12328. order.DrordBhvr = "0"
  12329. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12330. order.HosplistName = subItem.BaseDrugLib.DrugName
  12331. order.HilistLv = "1"
  12332. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12333. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12334. order.HosplistName = subItem.BaseDrugLib.DrugName
  12335. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12336. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12337. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12338. order.OwnpayAmt = ""
  12339. order.SelfpayAmt = ""
  12340. order.Spec = spec
  12341. order.SpecUnt = subItem.PrescribingNumberUnit
  12342. order.DrordBegnDate = s_tm
  12343. order.DrordStopDate = ""
  12344. order.DrordDrCodg = doctor_info.DoctorNumber
  12345. order.DrordDeptName = department.Name
  12346. order.DrordDeptCodg = department.Number
  12347. order.DrordDrName = doctor_info.UserName
  12348. order.DrordDrProfttl = "234"
  12349. order.CurrDrordFlag = "1"
  12350. orders = append(orders, &order)
  12351. }
  12352. }
  12353. for _, subItem := range item.HisPrescriptionProject {
  12354. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12355. var order models.FsiOrderDtos
  12356. order.RxID = strconv.FormatInt(item.ID, 10)
  12357. order.Rxno = strconv.FormatInt(item.ID, 10)
  12358. order.LongDrordFlag = "0"
  12359. order.HilistType = "201"
  12360. order.ChrgType = "1"
  12361. order.DrordBhvr = "0"
  12362. order.HilistCode = subItem.HisProject.MedicalCode
  12363. order.HosplistName = subItem.HisProject.ProjectName
  12364. order.HilistLv = "1"
  12365. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12366. order.HosplistCode = subItem.HisProject.MedicalCode
  12367. order.HosplistName = subItem.HisProject.ProjectName
  12368. order.Cnt = subItem.Count
  12369. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12370. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12371. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12372. order.OwnpayAmt = ""
  12373. order.SelfpayAmt = ""
  12374. order.Spec = subItem.Unit
  12375. order.SpecUnt = subItem.Unit
  12376. order.DrordBegnDate = s_tm
  12377. order.DrordStopDate = ""
  12378. order.DrordDrCodg = doctor_info.DoctorNumber
  12379. order.DrordDeptName = department.Name
  12380. order.DrordDeptCodg = department.Number
  12381. order.DrordDrName = doctor_info.UserName
  12382. order.DrordDrProfttl = "234"
  12383. order.CurrDrordFlag = "1"
  12384. orders = append(orders, &order)
  12385. }
  12386. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12387. var order models.FsiOrderDtos
  12388. order.RxID = strconv.FormatInt(item.ID, 10)
  12389. order.Rxno = strconv.FormatInt(item.ID, 10)
  12390. order.LongDrordFlag = "0"
  12391. order.HilistType = "301"
  12392. order.ChrgType = "1"
  12393. order.DrordBhvr = "0"
  12394. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12395. order.HosplistName = subItem.GoodInfo.GoodName
  12396. order.HilistLv = "1"
  12397. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12398. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12399. order.HosplistName = subItem.GoodInfo.GoodName
  12400. order.Cnt = subItem.Count
  12401. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12402. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12403. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12404. order.OwnpayAmt = ""
  12405. order.SelfpayAmt = ""
  12406. order.Spec = subItem.GoodInfo.SpecificationName
  12407. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12408. order.DrordBegnDate = s_tm
  12409. order.DrordStopDate = ""
  12410. order.DrordDrCodg = doctor_info.DoctorNumber
  12411. order.DrordDeptName = department.Name
  12412. order.DrordDeptCodg = department.Number
  12413. order.DrordDrName = doctor_info.UserName
  12414. order.DrordDrProfttl = "234"
  12415. order.CurrDrordFlag = "1"
  12416. orders = append(orders, &order)
  12417. }
  12418. }
  12419. }
  12420. //处方医嘱信息
  12421. }
  12422. fed.MatnStas = "0"
  12423. fed.MedfeeSumamt = "0"
  12424. fed.OwnpayAmt = "0"
  12425. fed.SelfpayAmt = "0"
  12426. fed.AcctPayamt = "0"
  12427. fed.MaAmt = "0"
  12428. fed.HifpPayamt = "0"
  12429. fed.SetlTotlnum = "1"
  12430. fed.Insutype = his.Insutype
  12431. fed.ReimFlag = "0"
  12432. fed.OutSetlFlag = "0"
  12433. var fopd []*models.FsiOperationDtosData
  12434. data := make(map[string]interface{})
  12435. data["fed"] = fed
  12436. data["fdd"] = fdds
  12437. data["fod"] = orders
  12438. data["pd"] = pd
  12439. data["pp"] = pp
  12440. data["fopd"] = fopd
  12441. data["trig_scen"] = trig_scen
  12442. fmt.Println(data)
  12443. fmt.Println(fed)
  12444. fmt.Println(fdds)
  12445. fmt.Println(orders)
  12446. fmt.Println(pd)
  12447. fmt.Println(pp)
  12448. fmt.Println(fopd)
  12449. client := &http.Client{}
  12450. bytesData, _ := json.Marshal(data)
  12451. var req *http.Request
  12452. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12453. if miConfig.MdtrtareaAdmvs == "320830" {
  12454. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12455. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12456. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12457. } else {
  12458. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12459. }
  12460. resp, _ := client.Do(req)
  12461. defer resp.Body.Close()
  12462. body, ioErr := ioutil.ReadAll(resp.Body)
  12463. if ioErr != nil {
  12464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12466. return res
  12467. }
  12468. var respJSON map[string]interface{}
  12469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12472. return res
  12473. }
  12474. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12475. fmt.Println(respJSON)
  12476. result, _ := json.Marshal(respJSON)
  12477. fmt.Println(result)
  12478. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12479. utils.ErrorLog("解析失败:%v", err)
  12480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12481. return res
  12482. }
  12483. return res
  12484. } else {
  12485. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12486. saveLog(output, input, "3101", "事前")
  12487. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12488. utils.ErrorLog("解析失败:%v", err)
  12489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12490. return
  12491. }
  12492. return res
  12493. }
  12494. return res
  12495. }
  12496. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12497. adminUser := c.GetAdminUserInfo()
  12498. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12499. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12500. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12501. record_time := c.GetString("record_time")
  12502. order, _ := service.GetHisOrderByID(order_id)
  12503. timeLayout := "2006-01-02"
  12504. loc, _ := time.LoadLocation("Local")
  12505. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12506. if err != nil {
  12507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12508. return
  12509. }
  12510. recordDateTime := theTime.Unix()
  12511. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12512. var patientPrescription models.HisPrescriptionInfo
  12513. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12514. if patientPrescription.ID == 0 {
  12515. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12516. }
  12517. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12518. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12519. //
  12520. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12521. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12522. var pp models.PublicParams
  12523. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12524. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12525. pp.FixmedinsName = miConfig.OrgName
  12526. pp.FixmedinsCode = miConfig.Code
  12527. pp.RequestUrl = miConfig.Url
  12528. pp.Cainfo = miConfig.Cainfo
  12529. pp.SecretKey = miConfig.SecretKey
  12530. pp.AccessKey = miConfig.AccessKey
  12531. pp.OpterName = roles.UserName
  12532. var config []*models.HisXtDiagnoseConfig
  12533. for _, item := range diagnosis_ids {
  12534. id, _ := strconv.ParseInt(item, 10, 64)
  12535. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12536. config = append(config, &diagnosisConfig)
  12537. }
  12538. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12539. var str string
  12540. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12541. str = timestampToBirthdayString(patient.Birthday)
  12542. } else {
  12543. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12544. }
  12545. var pd models.PatientDtos
  12546. pd.PatnID = his.PsnNo
  12547. pd.PatnName = his.Name
  12548. pd.Gend = his.Gend
  12549. pd.Brdy = str
  12550. pd.Poolarea = his.InsuplcAdmdvs
  12551. pd.CurrMdtrtID = his.Number
  12552. var fed models.FsiEncounterDtos
  12553. fed.MdtrtID = his.Number
  12554. fed.MedinsID = miConfig.Code
  12555. fed.MedinsName = miConfig.OrgName
  12556. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12557. fed.MedMdtrtType = "1"
  12558. fed.MedinsType = "1"
  12559. fed.MedinsLv = "11"
  12560. tm := time.Unix(his.RecordDate, 0)
  12561. s_tm := tm.Format("2006-01-02 15:04:05")
  12562. fed.AdmDate = s_tm
  12563. fed.DscgDate = s_tm
  12564. fed.DscgMainDiseCodg = config[0].CountryCode
  12565. fed.DscgMainDiseName = config[0].CountryContentName
  12566. //诊断信息
  12567. var fdds []*models.FsiDiagnoseDtos
  12568. for index, item := range config {
  12569. if index == 0 {
  12570. var fdd models.FsiDiagnoseDtos
  12571. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12572. fdd.InoutDiseType = "1"
  12573. fdd.MaindiseFlag = "1"
  12574. fdd.DiseDate = s_tm
  12575. fdd.DiasSrtNo = "1"
  12576. fdd.DiseName = item.CountryContentName
  12577. fdd.DiseCodg = item.CountryCode
  12578. fdds = append(fdds, &fdd)
  12579. } else {
  12580. var fdd models.FsiDiagnoseDtos
  12581. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12582. fdd.InoutDiseType = "1"
  12583. fdd.MaindiseFlag = "1"
  12584. fdd.DiseDate = s_tm
  12585. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12586. fdd.DiseName = item.CountryContentName
  12587. fdd.DiseCodg = item.CountryCode
  12588. fdds = append(fdds, &fdd)
  12589. }
  12590. }
  12591. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12592. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12593. fed.AdmDeptName = department.Name
  12594. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12595. fed.DscgDeptName = department.Name
  12596. fed.MedType = order.MedType
  12597. //处方医嘱信息
  12598. var orders []*models.FsiOrderDtos
  12599. //for _, item := range prescriptions {
  12600. // for _, subItem := range item.HisDoctorAdviceInfo {
  12601. // var order models.FsiOrderDtos
  12602. // order.RxID = strconv.FormatInt(item.ID, 10)
  12603. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12604. // order.LongDrordFlag = "0"
  12605. // order.HilistType = "1"
  12606. // order.ChrgType = "1"
  12607. // order.DrordBhvr = "-"
  12608. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12609. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12610. // order.HilistLv = "1"
  12611. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12612. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12613. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12614. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12615. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12616. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12617. // order.OwnpayAmt = ""
  12618. // order.SelfpayAmt = ""
  12619. // order.Spec = ""
  12620. // order.SpecUnt = ""
  12621. // order.DrordBegnDate = s_tm
  12622. // order.DrordStopDate = ""
  12623. // order.DrordDrCodg = "1"
  12624. // order.DrordDeptName = department.Name
  12625. // order.DrordDrCodg = "1"
  12626. // order.DrordDrName = doctor_info.UserName
  12627. // order.DrordDrProfttl = ""
  12628. // order.CurrDrordFlag = "1"
  12629. // orders = append(orders, &order)
  12630. // }
  12631. // for _, subItem := range item.HisPrescriptionProject {
  12632. // if subItem.Type == 2 {
  12633. // var order models.FsiOrderDtos
  12634. // order.RxID = strconv.FormatInt(item.ID, 10)
  12635. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12636. // order.LongDrordFlag = "0"
  12637. // order.HilistType = "1"
  12638. // order.ChrgType = "1"
  12639. // order.DrordBhvr = "-"
  12640. // order.HilistCode = subItem.HisProject.MedicalCode
  12641. // order.HosplistName = subItem.HisProject.ProjectName
  12642. // order.HilistLv = "1"
  12643. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12644. // order.HosplistCode = subItem.HisProject.MedicalCode
  12645. // order.HosplistName = subItem.HisProject.ProjectName
  12646. // order.Cnt = subItem.Count
  12647. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12648. //
  12649. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12650. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12651. // order.OwnpayAmt = ""
  12652. // order.SelfpayAmt = ""
  12653. // order.Spec = ""
  12654. // order.SpecUnt = ""
  12655. // order.DrordBegnDate = s_tm
  12656. // order.DrordStopDate = ""
  12657. // order.DrordDrCodg = "1"
  12658. // order.DrordDeptName = department.Name
  12659. // order.DrordDrCodg = "1"
  12660. // order.DrordDrName = doctor_info.UserName
  12661. // order.DrordDrProfttl = ""
  12662. // order.CurrDrordFlag = "1"
  12663. // orders = append(orders, &order)
  12664. //
  12665. // }
  12666. // if subItem.Type == 3 {
  12667. //
  12668. // var order models.FsiOrderDtos
  12669. // order.RxID = strconv.FormatInt(item.ID, 10)
  12670. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12671. // order.LongDrordFlag = "0"
  12672. // order.HilistType = "1"
  12673. // order.ChrgType = "1"
  12674. // order.DrordBhvr = "-"
  12675. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12676. // order.HosplistName = subItem.GoodInfo.GoodName
  12677. // order.HilistLv = "1"
  12678. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12679. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12680. // order.HosplistName = subItem.GoodInfo.GoodName
  12681. // order.Cnt = subItem.Count
  12682. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12683. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12684. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12685. // order.OwnpayAmt = ""
  12686. // order.SelfpayAmt = ""
  12687. // order.Spec = ""
  12688. // order.SpecUnt = ""
  12689. // order.DrordBegnDate = s_tm
  12690. // order.DrordStopDate = ""
  12691. // order.DrordDrCodg = "1"
  12692. // order.DrordDeptName = department.Name
  12693. // order.DrordDrCodg = "1"
  12694. // order.DrordDrName = doctor_info.UserName
  12695. // order.DrordDrProfttl = ""
  12696. // order.CurrDrordFlag = "1"
  12697. // orders = append(orders, &order)
  12698. //
  12699. // }
  12700. // }
  12701. //}
  12702. for _, item := range prescriptions {
  12703. for _, subItem := range item.HisDoctorAdviceInfo {
  12704. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12705. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12706. var order models.FsiOrderDtos
  12707. order.RxID = strconv.FormatInt(item.ID, 10)
  12708. order.Rxno = strconv.FormatInt(item.ID, 10)
  12709. order.LongDrordFlag = "0"
  12710. order.HilistType = "101"
  12711. order.ChrgType = "01"
  12712. order.DrordBhvr = "0"
  12713. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12714. order.HosplistName = subItem.BaseDrugLib.DrugName
  12715. order.HilistLv = "1"
  12716. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12717. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12718. order.HosplistName = subItem.BaseDrugLib.DrugName
  12719. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12720. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12721. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12722. order.OwnpayAmt = ""
  12723. order.SelfpayAmt = ""
  12724. order.Spec = spec
  12725. order.SpecUnt = subItem.PrescribingNumberUnit
  12726. order.DrordBegnDate = s_tm
  12727. order.DrordStopDate = ""
  12728. order.DrordDrCodg = doctor_info.DoctorNumber
  12729. order.DrordDeptName = department.Name
  12730. order.DrordDeptCodg = department.Number
  12731. order.DrordDrName = doctor_info.UserName
  12732. order.DrordDrProfttl = "234"
  12733. order.CurrDrordFlag = "1"
  12734. orders = append(orders, &order)
  12735. }
  12736. }
  12737. for _, subItem := range item.HisPrescriptionProject {
  12738. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12739. var order models.FsiOrderDtos
  12740. order.RxID = strconv.FormatInt(item.ID, 10)
  12741. order.Rxno = strconv.FormatInt(item.ID, 10)
  12742. order.LongDrordFlag = "0"
  12743. order.HilistType = "201"
  12744. order.ChrgType = "05"
  12745. order.DrordBhvr = "0"
  12746. order.HilistCode = subItem.HisProject.MedicalCode
  12747. order.HosplistName = subItem.HisProject.ProjectName
  12748. order.HilistLv = "1"
  12749. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12750. order.HosplistCode = subItem.HisProject.MedicalCode
  12751. order.HosplistName = subItem.HisProject.ProjectName
  12752. order.Cnt = subItem.Count
  12753. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12754. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12755. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12756. order.OwnpayAmt = ""
  12757. order.SelfpayAmt = ""
  12758. order.Spec = subItem.Unit
  12759. order.SpecUnt = subItem.Unit
  12760. order.DrordBegnDate = s_tm
  12761. order.DrordStopDate = ""
  12762. order.DrordDrCodg = doctor_info.DoctorNumber
  12763. order.DrordDeptName = department.Name
  12764. order.DrordDeptCodg = department.Number
  12765. order.DrordDrName = doctor_info.UserName
  12766. order.DrordDrProfttl = "234"
  12767. order.CurrDrordFlag = "1"
  12768. orders = append(orders, &order)
  12769. }
  12770. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12771. var order models.FsiOrderDtos
  12772. order.RxID = strconv.FormatInt(item.ID, 10)
  12773. order.Rxno = strconv.FormatInt(item.ID, 10)
  12774. order.LongDrordFlag = "0"
  12775. order.HilistType = "301"
  12776. order.ChrgType = "08"
  12777. order.DrordBhvr = "0"
  12778. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12779. order.HosplistName = subItem.GoodInfo.GoodName
  12780. order.HilistLv = "1"
  12781. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12782. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12783. order.HosplistName = subItem.GoodInfo.GoodName
  12784. order.Cnt = subItem.Count
  12785. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12786. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12787. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12788. order.OwnpayAmt = ""
  12789. order.SelfpayAmt = ""
  12790. order.Spec = subItem.GoodInfo.SpecificationName
  12791. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12792. order.DrordBegnDate = s_tm
  12793. order.DrordStopDate = ""
  12794. order.DrordDrCodg = doctor_info.DoctorNumber
  12795. order.DrordDeptName = department.Name
  12796. order.DrordDeptCodg = department.Number
  12797. order.DrordDrName = doctor_info.UserName
  12798. order.DrordDrProfttl = "234"
  12799. order.CurrDrordFlag = "1"
  12800. orders = append(orders, &order)
  12801. }
  12802. }
  12803. }
  12804. //处方医嘱信息
  12805. fed.MatnStas = "0"
  12806. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12807. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12808. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12809. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12810. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12811. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12812. fed.SetlTotlnum = "1"
  12813. fed.Insutype = his.Insutype
  12814. fed.ReimFlag = "0"
  12815. fed.OutSetlFlag = "0"
  12816. var fopd []*models.FsiOperationDtosData
  12817. data := make(map[string]interface{})
  12818. data["fed"] = fed
  12819. data["fdd"] = fdds
  12820. data["fod"] = orders
  12821. data["pd"] = pd
  12822. data["pp"] = pp
  12823. data["fopd"] = fopd
  12824. data["trig_scen"] = trig_scen
  12825. client := &http.Client{}
  12826. bytesData, _ := json.Marshal(data)
  12827. var req *http.Request
  12828. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12829. if miConfig.MdtrtareaAdmvs == "320830" {
  12830. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12831. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12832. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12833. } else {
  12834. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12835. }
  12836. resp, _ := client.Do(req)
  12837. defer resp.Body.Close()
  12838. body, ioErr := ioutil.ReadAll(resp.Body)
  12839. if ioErr != nil {
  12840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12842. return res
  12843. }
  12844. var respJSON map[string]interface{}
  12845. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12848. return res
  12849. }
  12850. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12851. result, _ := json.Marshal(respJSON)
  12852. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12853. utils.ErrorLog("解析失败:%v", err)
  12854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12855. return res
  12856. }
  12857. return res
  12858. } else {
  12859. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12860. saveLog(output, input, "3102", "事中")
  12861. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12862. utils.ErrorLog("解析失败:%v", err)
  12863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12864. return
  12865. }
  12866. return res
  12867. }
  12868. return res
  12869. }
  12870. func (c *HisApiController) Check() {
  12871. psn_no := c.GetString("psn_no")
  12872. in := c.GetString("in")
  12873. mt := c.GetString("mt")
  12874. baseParams := models.BaseParams{
  12875. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12876. FixmedinsCode: "H15049901371",
  12877. InsuplcAdmdvs: "150499",
  12878. MdtrtareaAdmvs: "150499",
  12879. OrgName: "赤峰费森血液透析中心",
  12880. Doctor: "1111",
  12881. }
  12882. service.Gdyb2001(baseParams, psn_no, in, mt)
  12883. }
  12884. func (c *HisApiController) GetPsnNcdsInfo() {
  12885. admin_user_id, _ := c.GetInt64("admin_user_id")
  12886. patient_id, _ := c.GetInt64("patient_id")
  12887. //id, _ := c.GetInt64("id")
  12888. adminUser := c.GetAdminUserInfo()
  12889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12890. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12891. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12892. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12893. //psn_record, _ := service.GetP(id)
  12894. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12895. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12896. //
  12897. //if psn_record.ID == 0 {
  12898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12899. // return
  12900. //}
  12901. var res Result5301
  12902. var res10265 Result5301For10265
  12903. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12904. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12905. var api string
  12906. if miConfig.MdtrtareaAdmvs == "320830" {
  12907. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12908. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12909. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12910. 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 +
  12911. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12912. } else {
  12913. 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 +
  12914. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12915. }
  12916. resp, requestErr := http.Get(api)
  12917. if requestErr != nil {
  12918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12919. return
  12920. }
  12921. body, ioErr := ioutil.ReadAll(resp.Body)
  12922. if ioErr != nil {
  12923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12925. return
  12926. }
  12927. var respJSON map[string]interface{}
  12928. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12931. return
  12932. }
  12933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12934. result, _ := json.Marshal(respJSON)
  12935. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12936. utils.ErrorLog("解析失败:%v", err)
  12937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12938. return
  12939. }
  12940. res.ErrMsg = res10265.ErrMsg
  12941. res.Output = res10265.Output
  12942. res.InfRefmsgid = res10265.InfRefmsgid
  12943. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12944. res.Infcode = infocode
  12945. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12946. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12947. var api string
  12948. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12949. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12950. resp, requestErr := http.Get(api)
  12951. if requestErr != nil {
  12952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12953. return
  12954. }
  12955. body, ioErr := ioutil.ReadAll(resp.Body)
  12956. if ioErr != nil {
  12957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12959. return
  12960. }
  12961. var respJSON map[string]interface{}
  12962. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12965. return
  12966. }
  12967. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12968. if status == "0" {
  12969. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12970. c.ServeSuccessJSON(map[string]interface{}{
  12971. "failed_code": -10,
  12972. "msg": err_msg,
  12973. })
  12974. return
  12975. }
  12976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12977. result, _ := json.Marshal(respJSON)
  12978. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12979. utils.ErrorLog("解析失败:%v", err)
  12980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12981. return
  12982. }
  12983. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12984. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12985. var api string
  12986. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12987. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12988. resp, requestErr := http.Get(api)
  12989. if requestErr != nil {
  12990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12991. return
  12992. }
  12993. body, ioErr := ioutil.ReadAll(resp.Body)
  12994. if ioErr != nil {
  12995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12997. return
  12998. }
  12999. var respJSON map[string]interface{}
  13000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13003. return
  13004. }
  13005. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13006. if status == "0" {
  13007. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13008. c.ServeSuccessJSON(map[string]interface{}{
  13009. "failed_code": -10,
  13010. "msg": err_msg,
  13011. })
  13012. return
  13013. }
  13014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13015. result, _ := json.Marshal(respJSON)
  13016. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13017. utils.ErrorLog("解析失败:%v", err)
  13018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13019. return
  13020. }
  13021. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13022. p, _ := service.GetHisPatientById(patient_id)
  13023. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13024. var dat map[string]interface{}
  13025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13026. fmt.Println(dat)
  13027. } else {
  13028. fmt.Println(err)
  13029. }
  13030. userJSONBytes, _ := json.Marshal(dat)
  13031. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13032. utils.ErrorLog("解析失败:%v", err)
  13033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13034. return
  13035. }
  13036. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13037. p, _ := service.GetHisPatientById(patient_id)
  13038. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13039. var dat map[string]interface{}
  13040. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13041. fmt.Println(dat)
  13042. } else {
  13043. fmt.Println(err)
  13044. }
  13045. userJSONBytes, _ := json.Marshal(dat)
  13046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13047. utils.ErrorLog("解析失败:%v", err)
  13048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13049. return
  13050. }
  13051. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13052. p, _ := service.GetHisPatientById(patient_id)
  13053. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13054. var dat map[string]interface{}
  13055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13056. fmt.Println(dat)
  13057. } else {
  13058. fmt.Println(err)
  13059. }
  13060. userJSONBytes, _ := json.Marshal(dat)
  13061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13062. utils.ErrorLog("解析失败:%v", err)
  13063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13064. return
  13065. }
  13066. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13067. p, _ := service.GetHisPatientById(patient_id)
  13068. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13069. var dat map[string]interface{}
  13070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13071. fmt.Println(dat)
  13072. } else {
  13073. fmt.Println(err)
  13074. }
  13075. userJSONBytes, _ := json.Marshal(dat)
  13076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13077. utils.ErrorLog("解析失败:%v", err)
  13078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13079. return
  13080. }
  13081. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13082. p, _ := service.GetHisPatientById(patient_id)
  13083. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13084. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13085. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13086. resp, requestErr := http.Get(api)
  13087. if requestErr != nil {
  13088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13089. return
  13090. }
  13091. body, ioErr := ioutil.ReadAll(resp.Body)
  13092. if ioErr != nil {
  13093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13095. return
  13096. }
  13097. var respJSON map[string]interface{}
  13098. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13101. return
  13102. }
  13103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13104. result, _ := json.Marshal(respJSON)
  13105. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13106. utils.ErrorLog("解析失败:%v", err)
  13107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13108. return
  13109. }
  13110. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13111. p, _ := service.GetHisPatientById(patient_id)
  13112. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13113. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13114. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13115. resp, requestErr := http.Get(api)
  13116. if requestErr != nil {
  13117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13118. return
  13119. }
  13120. body, ioErr := ioutil.ReadAll(resp.Body)
  13121. if ioErr != nil {
  13122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13124. return
  13125. }
  13126. var respJSON map[string]interface{}
  13127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13130. return
  13131. }
  13132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13133. result, _ := json.Marshal(respJSON)
  13134. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13135. utils.ErrorLog("解析失败:%v", err)
  13136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13137. return
  13138. }
  13139. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13140. p, _ := service.GetHisPatientById(patient_id)
  13141. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13142. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13143. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13144. resp, requestErr := http.Get(api)
  13145. if requestErr != nil {
  13146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13147. return
  13148. }
  13149. body, ioErr := ioutil.ReadAll(resp.Body)
  13150. if ioErr != nil {
  13151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13153. return
  13154. }
  13155. var respJSON map[string]interface{}
  13156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13159. return
  13160. }
  13161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13162. result, _ := json.Marshal(respJSON)
  13163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13164. utils.ErrorLog("解析失败:%v", err)
  13165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13166. return
  13167. }
  13168. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13169. p, _ := service.GetHisPatientById(patient_id)
  13170. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13171. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13172. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13173. resp, requestErr := http.Get(api)
  13174. if requestErr != nil {
  13175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13176. return
  13177. }
  13178. body, ioErr := ioutil.ReadAll(resp.Body)
  13179. if ioErr != nil {
  13180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13182. return
  13183. }
  13184. var respJSON map[string]interface{}
  13185. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13188. return
  13189. }
  13190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13191. result, _ := json.Marshal(respJSON)
  13192. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13193. utils.ErrorLog("解析失败:%v", err)
  13194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13195. return
  13196. }
  13197. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13198. p, _ := service.GetHisPatientById(patient_id)
  13199. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13200. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13201. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13202. resp, requestErr := http.Get(api)
  13203. if requestErr != nil {
  13204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13205. return
  13206. }
  13207. body, ioErr := ioutil.ReadAll(resp.Body)
  13208. if ioErr != nil {
  13209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13211. return
  13212. }
  13213. var respJSON map[string]interface{}
  13214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13217. return
  13218. }
  13219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13220. result, _ := json.Marshal(respJSON)
  13221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13222. utils.ErrorLog("解析失败:%v", err)
  13223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13224. return
  13225. }
  13226. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13227. p, _ := service.GetHisPatientById(patient_id)
  13228. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13229. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13230. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13231. resp, requestErr := http.Get(api)
  13232. if requestErr != nil {
  13233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13234. return
  13235. }
  13236. body, ioErr := ioutil.ReadAll(resp.Body)
  13237. if ioErr != nil {
  13238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13240. return
  13241. }
  13242. var respJSON map[string]interface{}
  13243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13246. return
  13247. }
  13248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13249. result, _ := json.Marshal(respJSON)
  13250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13251. utils.ErrorLog("解析失败:%v", err)
  13252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13253. return
  13254. }
  13255. } else {
  13256. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13257. var dat map[string]interface{}
  13258. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13259. fmt.Println(dat)
  13260. } else {
  13261. fmt.Println(err)
  13262. }
  13263. userJSONBytes, _ := json.Marshal(dat)
  13264. if miConfig.Code == "H15049901371" {
  13265. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13266. utils.ErrorLog("解析失败:%v", err)
  13267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13268. return
  13269. }
  13270. res.InfRefmsgid = res10265.InfRefmsgid
  13271. res.Output = res10265.Output
  13272. res.ErrMsg = res10265.ErrMsg
  13273. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13274. res.Infcode = infocode
  13275. } else {
  13276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13277. utils.ErrorLog("解析失败:%v", err)
  13278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13279. return
  13280. }
  13281. }
  13282. }
  13283. if res.Infcode == 0 {
  13284. c.ServeSuccessJSON(map[string]interface{}{
  13285. "result": res.Output.Result,
  13286. })
  13287. }
  13288. }
  13289. func (c *HisApiController) CheckInsutype() {
  13290. his_patient_id, _ := c.GetInt64("his_patient_id")
  13291. admin_user_id, _ := c.GetInt64("admin_user_id")
  13292. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13293. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13294. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13295. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13296. var dat map[string]interface{}
  13297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13298. fmt.Println(dat)
  13299. } else {
  13300. fmt.Println(err)
  13301. }
  13302. userJSONBytes, _ := json.Marshal(dat)
  13303. var res Result90100
  13304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13305. utils.ErrorLog("解析失败:%v", err)
  13306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13307. return
  13308. }
  13309. if res.Infcode != 0 {
  13310. c.ServeSuccessJSON(map[string]interface{}{
  13311. "failed_code": -10,
  13312. "msg": res.ErrMsg,
  13313. })
  13314. return
  13315. } else {
  13316. fmt.Println(res)
  13317. }
  13318. }
  13319. func (c *HisApiController) CheckCardPWD() {
  13320. card_pwd := c.GetString("card_pwd")
  13321. his_patient_id, _ := c.GetInt64("his_patient_id")
  13322. admin_user_id, _ := c.GetInt64("admin_user_id")
  13323. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13324. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13325. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13326. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13327. bas := strings.Split(psn.CardInfo, "|")
  13328. basNumber := bas[2]
  13329. if psn.InsuplcAdmdvs[:4] == "4403" {
  13330. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13331. var dat map[string]interface{}
  13332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13333. fmt.Println(dat)
  13334. } else {
  13335. fmt.Println(err)
  13336. }
  13337. userJSONBytes, _ := json.Marshal(dat)
  13338. var res Result90991
  13339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13340. utils.ErrorLog("解析失败:%v", err)
  13341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13342. return
  13343. }
  13344. if res.Infcode != 0 {
  13345. c.ServeSuccessJSON(map[string]interface{}{
  13346. "failed_code": -10,
  13347. "msg": res.ErrMsg,
  13348. })
  13349. return
  13350. } else {
  13351. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13352. var msg string
  13353. switch res.Output.Result.CardStat {
  13354. case "00":
  13355. msg = "未激活"
  13356. break
  13357. case "10":
  13358. msg = "激活"
  13359. break
  13360. case "20":
  13361. msg = "窗口挂失"
  13362. break
  13363. case "21":
  13364. msg = "电话挂失"
  13365. break
  13366. case "22":
  13367. msg = "单位网上申报挂失"
  13368. break
  13369. case "23":
  13370. msg = "保健办挂失"
  13371. break
  13372. case "24":
  13373. msg = "个人网上挂失"
  13374. break
  13375. case "25":
  13376. msg = "网上服务大厅挂失"
  13377. break
  13378. case "30":
  13379. msg = "注销"
  13380. break
  13381. case "40":
  13382. msg = "回收"
  13383. break
  13384. case "99":
  13385. msg = "制卡中(无效卡)"
  13386. break
  13387. }
  13388. c.ServeSuccessJSON(map[string]interface{}{
  13389. "failed_code": -10,
  13390. "msg": msg,
  13391. })
  13392. return
  13393. } else {
  13394. c.ServeSuccessJSON(map[string]interface{}{
  13395. "msg": "校验成功",
  13396. })
  13397. return
  13398. }
  13399. }
  13400. } else {
  13401. c.ServeSuccessJSON(map[string]interface{}{
  13402. "msg": "校验成功",
  13403. })
  13404. return
  13405. }
  13406. }
  13407. func (c *HisApiController) CheckCardPWDTwo() {
  13408. //card_pwd := c.GetString("card_pwd")
  13409. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13410. admin_user_id, _ := c.GetInt64("admin_user_id")
  13411. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13412. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13413. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13414. var dat map[string]interface{}
  13415. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13416. fmt.Println(dat)
  13417. } else {
  13418. fmt.Println(err)
  13419. }
  13420. userJSONBytes, _ := json.Marshal(dat)
  13421. var res Result90991
  13422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13423. utils.ErrorLog("解析失败:%v", err)
  13424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13425. return
  13426. }
  13427. if res.Infcode != 0 {
  13428. c.ServeSuccessJSON(map[string]interface{}{
  13429. "failed_code": -10,
  13430. "msg": res.ErrMsg,
  13431. })
  13432. return
  13433. } else {
  13434. if res.Output.Result.SscnoCheckStat == "0" {
  13435. var msg string
  13436. switch res.Output.Result.CardStat {
  13437. case "00":
  13438. msg = "未激活"
  13439. break
  13440. case "10":
  13441. msg = "激活"
  13442. break
  13443. case "20":
  13444. msg = "窗口挂失"
  13445. break
  13446. case "21":
  13447. msg = "电话挂失"
  13448. break
  13449. case "22":
  13450. msg = "单位网上申报挂失"
  13451. break
  13452. case "23":
  13453. msg = "保健办挂失"
  13454. break
  13455. case "24":
  13456. msg = "个人网上挂失"
  13457. break
  13458. case "25":
  13459. msg = "网上服务大厅挂失"
  13460. break
  13461. case "30":
  13462. msg = "注销"
  13463. break
  13464. case "40":
  13465. msg = "回收"
  13466. break
  13467. case "99":
  13468. msg = "制卡中(无效卡)"
  13469. break
  13470. }
  13471. c.ServeSuccessJSON(map[string]interface{}{
  13472. "failed_code": -10,
  13473. "msg": msg,
  13474. })
  13475. return
  13476. } else {
  13477. c.ServeSuccessJSON(map[string]interface{}{
  13478. "msg": "校验成功",
  13479. })
  13480. return
  13481. }
  13482. }
  13483. }
  13484. type ELeCertData struct {
  13485. Data struct {
  13486. Extra string `json:"extra"`
  13487. IDNo string `json:"idNo"`
  13488. IDType string `json:"idType"`
  13489. EcToken string `json:"ecToken"`
  13490. InsuOrg string `json:"insuOrg"`
  13491. UserName string `json:"userName"`
  13492. EcIndexNo string `json:"ecIndexNo"`
  13493. Gender string `json:"gender"`
  13494. Birthday string `json:"birthday"`
  13495. Nationality string `json:"nationality"`
  13496. Email string `json:"email"`
  13497. } `json:"OutData"`
  13498. }
  13499. func (c *HisApiController) ReadCard() {
  13500. id_card_type, _ := c.GetInt64("id_card_type")
  13501. admin_user_id, _ := c.GetInt64("admin_user_id")
  13502. certificates, _ := c.GetInt64("certificates")
  13503. //
  13504. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13505. id_card_no := c.GetString("id_card_no")
  13506. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13507. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13508. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13509. switch id_card_type {
  13510. case 1:
  13511. if miConfig.MdtrtareaAdmvs == "421300" {
  13512. var res ResultTwo
  13513. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13514. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13515. "&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)
  13516. resp, requestErr := http.Get(api)
  13517. if requestErr != nil {
  13518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13519. return
  13520. }
  13521. body, ioErr := ioutil.ReadAll(resp.Body)
  13522. if ioErr != nil {
  13523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13525. return
  13526. }
  13527. var respJSON map[string]interface{}
  13528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13531. return
  13532. }
  13533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13534. result, _ := json.Marshal(respJSON)
  13535. fmt.Println("log")
  13536. fmt.Println(string(result))
  13537. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13538. utils.ErrorLog("解析失败:%v", err)
  13539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13540. return
  13541. }
  13542. if res.Infcode == 0 {
  13543. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13544. if err == gorm.ErrRecordNotFound {
  13545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13546. return
  13547. } else if err != nil {
  13548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13549. return
  13550. } else {
  13551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13553. infoStr := string(Iinfos)
  13554. idetinfoStr := string(Idetinfos)
  13555. var rf []*ResultFive
  13556. json.Unmarshal([]byte(infoStr), &rf)
  13557. var insutypes []*ResultFive
  13558. var insutype string
  13559. var is390 int = 0
  13560. var is310 int = 0
  13561. for _, item := range rf {
  13562. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13563. insutypes = append(insutypes, item)
  13564. }
  13565. }
  13566. if len(insutypes) == 1 {
  13567. insutype = insutypes[0].Insutype
  13568. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13569. } else {
  13570. for _, i := range insutypes {
  13571. if i.Insutype == "390" {
  13572. is390 = 1
  13573. }
  13574. if i.Insutype == "310" {
  13575. is310 = 1
  13576. }
  13577. }
  13578. }
  13579. if is390 == 1 {
  13580. insutype = "390"
  13581. }
  13582. if is310 == 1 {
  13583. insutype = "310"
  13584. }
  13585. if len(insutypes) == 0 {
  13586. insutype = "390"
  13587. }
  13588. var insuplc_admdvs string
  13589. for _, item := range rf {
  13590. if item.Insutype == insutype {
  13591. insuplc_admdvs = item.InsuplcAdmdvs
  13592. }
  13593. }
  13594. if strings.Contains(insuplc_admdvs, "4213") {
  13595. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13596. }
  13597. psn := &models.HisPsn{
  13598. PsnNo: res.Output.Baseinfo.PsnNo,
  13599. PatientId: patient.ID,
  13600. Certno: res.Output.Baseinfo.Certno,
  13601. Gend: res.Output.Baseinfo.Gend,
  13602. Naty: res.Output.Baseinfo.Naty,
  13603. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13604. PsnName: res.Output.Baseinfo.PsnName,
  13605. Idetinfo: idetinfoStr,
  13606. Insuinfo: infoStr,
  13607. InsuplcAdmdvs: insuplc_admdvs,
  13608. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13609. }
  13610. service.CreateHisPsn(psn)
  13611. c.ServeSuccessJSON(map[string]interface{}{
  13612. "patient": patient,
  13613. "number": res.Output.Baseinfo.Certno,
  13614. })
  13615. }
  13616. } else {
  13617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13618. return
  13619. }
  13620. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13621. var res ResultTwo
  13622. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13623. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13624. "&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)
  13625. resp, requestErr := http.Get(api)
  13626. if requestErr != nil {
  13627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13628. return
  13629. }
  13630. body, ioErr := ioutil.ReadAll(resp.Body)
  13631. if ioErr != nil {
  13632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13634. return
  13635. }
  13636. var respJSON map[string]interface{}
  13637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13640. return
  13641. }
  13642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13643. result, _ := json.Marshal(respJSON)
  13644. fmt.Println("log")
  13645. fmt.Println(string(result))
  13646. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13647. utils.ErrorLog("解析失败:%v", err)
  13648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13649. return
  13650. }
  13651. if res.Infcode == 0 {
  13652. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13653. if err == gorm.ErrRecordNotFound {
  13654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13655. return
  13656. } else if err != nil {
  13657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13658. return
  13659. } else {
  13660. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13661. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13662. infoStr := string(Iinfos)
  13663. idetinfoStr := string(Idetinfos)
  13664. psn := &models.HisPsn{
  13665. PsnNo: res.Output.Baseinfo.PsnNo,
  13666. PatientId: patient.ID,
  13667. Certno: res.Output.Baseinfo.Certno,
  13668. Gend: res.Output.Baseinfo.Gend,
  13669. Naty: res.Output.Baseinfo.Naty,
  13670. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13671. PsnName: res.Output.Baseinfo.PsnName,
  13672. Idetinfo: idetinfoStr,
  13673. Insuinfo: infoStr,
  13674. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13675. }
  13676. service.CreateHisPsn(psn)
  13677. var rf []*ResultFive
  13678. json.Unmarshal([]byte(infoStr), &rf)
  13679. var insutypes []*ResultFive
  13680. var insutype string
  13681. var is390 int = 0
  13682. var is310 int = 0
  13683. for _, item := range rf {
  13684. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13685. insutypes = append(insutypes, item)
  13686. }
  13687. }
  13688. if len(insutypes) == 1 {
  13689. insutype = insutypes[0].Insutype
  13690. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13691. } else {
  13692. for _, i := range insutypes {
  13693. if i.Insutype == "390" {
  13694. is390 = 1
  13695. }
  13696. if i.Insutype == "310" {
  13697. is310 = 1
  13698. }
  13699. }
  13700. }
  13701. if is390 == 1 {
  13702. insutype = "390"
  13703. }
  13704. if is310 == 1 {
  13705. insutype = "310"
  13706. }
  13707. if len(insutypes) == 0 {
  13708. insutype = "310"
  13709. }
  13710. c.ServeSuccessJSON(map[string]interface{}{
  13711. "patient": patient,
  13712. "number": res.Output.Baseinfo.Certno,
  13713. "insutype": insutype,
  13714. })
  13715. }
  13716. } else {
  13717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13718. return
  13719. }
  13720. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13721. var res ResultTwo
  13722. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13723. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13724. "&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)
  13725. resp, requestErr := http.Get(api)
  13726. if requestErr != nil {
  13727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13728. return
  13729. }
  13730. body, ioErr := ioutil.ReadAll(resp.Body)
  13731. if ioErr != nil {
  13732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13734. return
  13735. }
  13736. var respJSON map[string]interface{}
  13737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13740. return
  13741. }
  13742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13743. result, _ := json.Marshal(respJSON)
  13744. fmt.Println("log")
  13745. fmt.Println(string(result))
  13746. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13747. utils.ErrorLog("解析失败:%v", err)
  13748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13749. return
  13750. }
  13751. if res.Infcode == 0 {
  13752. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13753. if err == gorm.ErrRecordNotFound {
  13754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13755. return
  13756. } else if err != nil {
  13757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13758. return
  13759. } else {
  13760. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13761. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13762. infoStr := string(Iinfos)
  13763. idetinfoStr := string(Idetinfos)
  13764. var rf []*ResultFive
  13765. json.Unmarshal([]byte(infoStr), &rf)
  13766. var insutypes []*ResultFive
  13767. var insutype string
  13768. var is390 int = 0
  13769. var is310 int = 0
  13770. for _, item := range rf {
  13771. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13772. insutypes = append(insutypes, item)
  13773. }
  13774. }
  13775. if len(insutypes) == 1 {
  13776. insutype = insutypes[0].Insutype
  13777. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13778. } else {
  13779. for _, i := range insutypes {
  13780. if i.Insutype == "390" {
  13781. is390 = 1
  13782. }
  13783. if i.Insutype == "310" {
  13784. is310 = 1
  13785. }
  13786. }
  13787. }
  13788. if is390 == 1 {
  13789. insutype = "390"
  13790. }
  13791. if is310 == 1 {
  13792. insutype = "310"
  13793. }
  13794. if len(insutypes) == 0 {
  13795. insutype = "390"
  13796. }
  13797. var insuplc_admdvs string
  13798. for _, item := range rf {
  13799. if item.Insutype == insutype {
  13800. insuplc_admdvs = item.InsuplcAdmdvs
  13801. }
  13802. }
  13803. psn := &models.HisPsn{
  13804. PsnNo: res.Output.Baseinfo.PsnNo,
  13805. PatientId: patient.ID,
  13806. Certno: res.Output.Baseinfo.Certno,
  13807. Gend: res.Output.Baseinfo.Gend,
  13808. Naty: res.Output.Baseinfo.Naty,
  13809. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13810. PsnName: res.Output.Baseinfo.PsnName,
  13811. Idetinfo: idetinfoStr,
  13812. Insuinfo: infoStr,
  13813. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13814. InsuplcAdmdvs: insuplc_admdvs,
  13815. }
  13816. service.CreateHisPsn(psn)
  13817. for _, item := range rf {
  13818. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13819. insutypes = append(insutypes, item)
  13820. }
  13821. }
  13822. if len(insutypes) == 1 {
  13823. insutype = insutypes[0].Insutype
  13824. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13825. } else {
  13826. for _, i := range insutypes {
  13827. if i.Insutype == "390" {
  13828. is390 = 1
  13829. }
  13830. if i.Insutype == "310" {
  13831. is310 = 1
  13832. }
  13833. }
  13834. }
  13835. if is390 == 1 {
  13836. insutype = "390"
  13837. }
  13838. if is310 == 1 {
  13839. insutype = "310"
  13840. }
  13841. if len(insutypes) == 0 {
  13842. insutype = "310"
  13843. }
  13844. c.ServeSuccessJSON(map[string]interface{}{
  13845. "patient": patient,
  13846. "number": res.Output.Baseinfo.Certno,
  13847. "insutype": insutype,
  13848. })
  13849. }
  13850. } else {
  13851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13852. return
  13853. }
  13854. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13855. var res ResultTwo
  13856. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13857. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13858. "&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)
  13859. resp, requestErr := http.Get(api)
  13860. if requestErr != nil {
  13861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13862. return
  13863. }
  13864. body, ioErr := ioutil.ReadAll(resp.Body)
  13865. if ioErr != nil {
  13866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13868. return
  13869. }
  13870. var respJSON map[string]interface{}
  13871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13874. return
  13875. }
  13876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13877. result, _ := json.Marshal(respJSON)
  13878. fmt.Println("log")
  13879. fmt.Println(string(result))
  13880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13881. utils.ErrorLog("解析失败:%v", err)
  13882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13883. return
  13884. }
  13885. if res.Infcode == 0 {
  13886. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13887. if err == gorm.ErrRecordNotFound {
  13888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13889. return
  13890. } else if err != nil {
  13891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13892. return
  13893. } else {
  13894. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13895. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13896. infoStr := string(Iinfos)
  13897. idetinfoStr := string(Idetinfos)
  13898. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13899. psn := &models.HisPsn{
  13900. PsnNo: res.Output.Baseinfo.PsnNo,
  13901. PatientId: patient.ID,
  13902. Certno: res.Output.Baseinfo.Certno,
  13903. Brdy: b,
  13904. Age: float64(age),
  13905. Gend: res.Output.Baseinfo.Gend,
  13906. Naty: res.Output.Baseinfo.Naty,
  13907. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13908. PsnName: res.Output.Baseinfo.PsnName,
  13909. Idetinfo: idetinfoStr,
  13910. Insuinfo: infoStr,
  13911. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13912. }
  13913. service.CreateHisPsn(psn)
  13914. var rf []*ResultFive
  13915. json.Unmarshal([]byte(infoStr), &rf)
  13916. var insutypes []*ResultFive
  13917. var insutype string
  13918. var is390 int = 0
  13919. var is310 int = 0
  13920. for _, item := range rf {
  13921. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13922. insutypes = append(insutypes, item)
  13923. }
  13924. }
  13925. if len(insutypes) == 1 {
  13926. insutype = insutypes[0].Insutype
  13927. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13928. } else {
  13929. for _, i := range insutypes {
  13930. if i.Insutype == "390" {
  13931. is390 = 1
  13932. }
  13933. if i.Insutype == "310" {
  13934. is310 = 1
  13935. }
  13936. }
  13937. }
  13938. if is390 == 1 {
  13939. insutype = "390"
  13940. }
  13941. if is310 == 1 {
  13942. insutype = "310"
  13943. }
  13944. if len(insutypes) == 0 {
  13945. insutype = "310"
  13946. }
  13947. c.ServeSuccessJSON(map[string]interface{}{
  13948. "patient": patient,
  13949. "number": res.Output.Baseinfo.Certno,
  13950. "insutype": insutype,
  13951. })
  13952. }
  13953. } else {
  13954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13955. return
  13956. }
  13957. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13958. var api string
  13959. if miConfig.MdtrtareaAdmvs == "320830" {
  13960. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13961. "&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
  13962. fmt.Println(api)
  13963. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13964. 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 +
  13965. "&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
  13966. fmt.Println(api)
  13967. } else {
  13968. 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 +
  13969. "&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)
  13970. }
  13971. resp, requestErr := http.Get(api)
  13972. if requestErr != nil {
  13973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13974. return
  13975. }
  13976. body, ioErr := ioutil.ReadAll(resp.Body)
  13977. if ioErr != nil {
  13978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13980. return
  13981. }
  13982. var respJSON map[string]interface{}
  13983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13986. return
  13987. }
  13988. var status string
  13989. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13990. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13991. //console.log()
  13992. fmt.Println("type===")
  13993. fmt.Println(card_type)
  13994. var token string
  13995. var res ResultTwo //1101结果
  13996. var res10265 ResultTwo10265 //1101结果
  13997. var card_info string //卡信息
  13998. var busi_card_info string
  13999. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14000. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14001. if status == "0" { //读卡成功
  14002. if card_type == "1" {
  14003. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14004. result, _ := json.Marshal(respJSON)
  14005. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14006. utils.ErrorLog("解析失败:%v", err)
  14007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14008. return
  14009. }
  14010. res.ErrMsg = res10265.ErrMsg
  14011. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14012. res.Infcode = infocode
  14013. res.Output = res10265.Output
  14014. res.InfRefmsgid = res10265.InfRefmsgid
  14015. } else {
  14016. //var card_info string //卡信息
  14017. //var busi_card_info string
  14018. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14019. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14020. //fmt.Println(card_info)
  14021. //fmt.Println(busi_card_info)
  14022. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14023. result, _ := json.Marshal(respJSON)
  14024. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14025. utils.ErrorLog("解析失败:%v", err)
  14026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14027. return
  14028. }
  14029. res.ErrMsg = res10265.ErrMsg
  14030. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14031. res.Infcode = infocode
  14032. res.Output = res10265.Output
  14033. res.InfRefmsgid = res10265.InfRefmsgid
  14034. }
  14035. if res.Infcode == 0 {
  14036. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14037. if err == gorm.ErrRecordNotFound {
  14038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14039. return
  14040. } else if err != nil {
  14041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14042. return
  14043. } else {
  14044. if card_type == "1" {
  14045. bas := strings.Split(card_info, "|")
  14046. basNumber := bas[2]
  14047. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14048. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14049. infoStr := string(Iinfos)
  14050. idetinfoStr := string(Idetinfos)
  14051. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14052. psn := &models.HisPsn{
  14053. PsnNo: res.Output.Baseinfo.PsnNo,
  14054. PatientId: patient.ID,
  14055. Certno: res.Output.Baseinfo.Certno,
  14056. Brdy: b,
  14057. Age: float64(age),
  14058. Gend: res.Output.Baseinfo.Gend,
  14059. Naty: res.Output.Baseinfo.Naty,
  14060. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14061. PsnName: res.Output.Baseinfo.PsnName,
  14062. Idetinfo: idetinfoStr,
  14063. Insuinfo: infoStr,
  14064. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14065. CardInfo: card_info,
  14066. VerifyNumber: busi_card_info,
  14067. }
  14068. service.CreateHisPsn(psn)
  14069. var rf []*ResultFive
  14070. json.Unmarshal([]byte(infoStr), &rf)
  14071. var insutypes []*ResultFive
  14072. var insutype string
  14073. var is390 int = 0
  14074. var is310 int = 0
  14075. for _, item := range rf {
  14076. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14077. insutypes = append(insutypes, item)
  14078. }
  14079. }
  14080. if len(insutypes) == 1 {
  14081. insutype = insutypes[0].Insutype
  14082. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14083. } else {
  14084. for _, i := range insutypes {
  14085. if i.Insutype == "390" {
  14086. is390 = 1
  14087. }
  14088. if i.Insutype == "310" {
  14089. is310 = 1
  14090. }
  14091. }
  14092. }
  14093. if is390 == 1 {
  14094. insutype = "390"
  14095. }
  14096. if is310 == 1 {
  14097. insutype = "310"
  14098. }
  14099. if len(insutypes) == 0 {
  14100. insutype = "310"
  14101. }
  14102. c.ServeSuccessJSON(map[string]interface{}{
  14103. "patient": patient,
  14104. "number": basNumber,
  14105. "insutype": insutype,
  14106. })
  14107. } else {
  14108. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14109. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14110. infoStr := string(Iinfos)
  14111. idetinfoStr := string(Idetinfos)
  14112. psn := &models.HisPsn{
  14113. PsnNo: res.Output.Baseinfo.PsnNo,
  14114. PatientId: patient.ID,
  14115. Certno: res.Output.Baseinfo.Certno,
  14116. Gend: res.Output.Baseinfo.Gend,
  14117. Naty: res.Output.Baseinfo.Naty,
  14118. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14119. PsnName: res.Output.Baseinfo.PsnName,
  14120. Idetinfo: idetinfoStr,
  14121. Insuinfo: infoStr,
  14122. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14123. CardInfo: card_info,
  14124. VerifyNumber: token,
  14125. }
  14126. service.CreateHisPsn(psn)
  14127. c.ServeSuccessJSON(map[string]interface{}{
  14128. "patient": patient,
  14129. "number": token,
  14130. })
  14131. }
  14132. }
  14133. } else {
  14134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14135. return
  14136. }
  14137. } else { //读卡失败
  14138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14139. return
  14140. }
  14141. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14142. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14143. cardnum = DeleteExtraSpaceTwo(cardnum)
  14144. cardCode = DeleteExtraSpaceTwo(cardCode)
  14145. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14146. name = DeleteExtraSpaceTwo(name)
  14147. errmsg = DeleteExtraSpaceTwo(errmsg)
  14148. cardnum = Remove0000(cardnum)
  14149. cardCode = Remove0000(cardCode)
  14150. id_card_no = Remove0000(id_card_no)
  14151. name = Remove0000(name)
  14152. errmsg = Remove0000(errmsg)
  14153. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14154. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14155. //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)
  14156. //fmt.Println(result2)
  14157. //fmt.Println(requestLog2)
  14158. //fmt.Println(errMsgLog2)
  14159. 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)
  14160. saveLog(result, requestLog, "1101", "获取人员信息")
  14161. fmt.Println(errMsgLog)
  14162. if len(errMsgLog) > 0 {
  14163. } else {
  14164. var dat map[string]interface{}
  14165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14166. fmt.Println(dat)
  14167. } else {
  14168. fmt.Println(err)
  14169. }
  14170. userJSONBytes, _ := json.Marshal(dat)
  14171. var res ResultTwo
  14172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14173. utils.ErrorLog("解析失败:%v", err)
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. return
  14176. }
  14177. res.ErrMsg = errMsgLog
  14178. if res.Infcode == 0 {
  14179. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14180. if err == gorm.ErrRecordNotFound {
  14181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14182. return
  14183. } else if err != nil {
  14184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14185. return
  14186. } else {
  14187. fmt.Println(res)
  14188. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14189. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14190. infoStr := string(Iinfos)
  14191. idetinfoStr := string(Idetinfos)
  14192. var rf []*ResultFive
  14193. json.Unmarshal([]byte(infoStr), &rf)
  14194. var insutypes []*ResultFive
  14195. var insutype string
  14196. var is390 int = 0
  14197. var is310 int = 0
  14198. for _, item := range rf {
  14199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14200. insutypes = append(insutypes, item)
  14201. }
  14202. }
  14203. if len(insutypes) == 1 {
  14204. insutype = insutypes[0].Insutype
  14205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14206. } else {
  14207. for _, i := range insutypes {
  14208. if i.Insutype == "390" {
  14209. is390 = 1
  14210. }
  14211. if i.Insutype == "310" {
  14212. is310 = 1
  14213. }
  14214. }
  14215. }
  14216. if is390 == 1 {
  14217. insutype = "390"
  14218. }
  14219. if is310 == 1 {
  14220. insutype = "310"
  14221. }
  14222. if len(insutypes) == 0 {
  14223. insutype = "390"
  14224. }
  14225. var insuplc_admdvs string
  14226. for _, item := range rf {
  14227. if item.Insutype == insutype {
  14228. insuplc_admdvs = item.InsuplcAdmdvs
  14229. }
  14230. }
  14231. psn := &models.HisPsn{
  14232. PsnNo: res.Output.Baseinfo.PsnNo,
  14233. PatientId: patient.ID,
  14234. Certno: res.Output.Baseinfo.Certno,
  14235. Gend: res.Output.Baseinfo.Gend,
  14236. Naty: res.Output.Baseinfo.Naty,
  14237. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14238. PsnName: res.Output.Baseinfo.PsnName,
  14239. Idetinfo: idetinfoStr,
  14240. Insuinfo: infoStr,
  14241. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14242. CardInfo: basStr,
  14243. VerifyNumber: "",
  14244. InsuplcAdmdvs: insuplc_admdvs,
  14245. }
  14246. service.CreateHisPsn(psn)
  14247. c.ServeSuccessJSON(map[string]interface{}{
  14248. "patient": patient,
  14249. "number": cardnum,
  14250. "insutype": insutype,
  14251. })
  14252. }
  14253. } else {
  14254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14255. return
  14256. }
  14257. }
  14258. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14259. fmt.Println(initFlag)
  14260. fmt.Println("initFlag")
  14261. if initFlag == 0 {
  14262. c.TestGetJiangXiBasBaseInit()
  14263. }
  14264. basStr := c.GetBasBaseInfo()
  14265. if len(basStr) == 0 {
  14266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14267. return
  14268. }
  14269. fmt.Println(basStr)
  14270. bas := strings.Split(basStr, "|")
  14271. basNumber := bas[1]
  14272. fmt.Println(basNumber)
  14273. card := bas[2]
  14274. card_sn := bas[3]
  14275. fmt.Println(card_sn)
  14276. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14277. result, _ := service.Jxyb11012(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, card)
  14278. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14279. var dat map[string]interface{}
  14280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14281. fmt.Println(dat)
  14282. } else {
  14283. fmt.Println(err)
  14284. }
  14285. userJSONBytes, _ := json.Marshal(dat)
  14286. var res ResultTwo
  14287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14288. utils.ErrorLog("解析失败:%v", err)
  14289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14290. return
  14291. }
  14292. if res.Infcode == 0 {
  14293. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14294. if err == gorm.ErrRecordNotFound {
  14295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14296. return
  14297. } else if err != nil {
  14298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14299. return
  14300. } else {
  14301. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14302. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14303. infoStr := string(Iinfos)
  14304. idetinfoStr := string(Idetinfos)
  14305. var rf []*ResultFive
  14306. json.Unmarshal([]byte(infoStr), &rf)
  14307. var insutypes []*ResultFive
  14308. var insutype string
  14309. var is390 int = 0
  14310. var is310 int = 0
  14311. var insuplc_admdvs string
  14312. for _, item := range rf {
  14313. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14314. insutypes = append(insutypes, item)
  14315. }
  14316. }
  14317. if len(insutypes) == 1 {
  14318. insutype = insutypes[0].Insutype
  14319. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14320. } else {
  14321. for _, i := range insutypes {
  14322. if i.Insutype == "390" {
  14323. is390 = 1
  14324. }
  14325. if i.Insutype == "310" {
  14326. is310 = 1
  14327. }
  14328. }
  14329. }
  14330. if is390 == 1 {
  14331. insutype = "390"
  14332. }
  14333. if is310 == 1 {
  14334. insutype = "310"
  14335. }
  14336. if len(insutypes) == 0 {
  14337. insutype = "310"
  14338. }
  14339. for _, item := range rf {
  14340. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14341. insuplc_admdvs = item.InsuplcAdmdvs
  14342. }
  14343. }
  14344. psn := &models.HisPsn{
  14345. PsnNo: res.Output.Baseinfo.PsnNo,
  14346. PatientId: patient.ID,
  14347. Certno: res.Output.Baseinfo.Certno,
  14348. Gend: res.Output.Baseinfo.Gend,
  14349. Naty: res.Output.Baseinfo.Naty,
  14350. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14351. PsnName: res.Output.Baseinfo.PsnName,
  14352. Idetinfo: idetinfoStr,
  14353. Insuinfo: infoStr,
  14354. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14355. CardInfo: basStr,
  14356. InsuplcAdmdvs: insuplc_admdvs,
  14357. VerifyNumber: "",
  14358. }
  14359. service.CreateHisPsn(psn)
  14360. c.ServeSuccessJSON(map[string]interface{}{
  14361. "patient": patient,
  14362. "number": basNumber,
  14363. "insutype": insutype,
  14364. })
  14365. }
  14366. } else {
  14367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14368. return
  14369. }
  14370. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14371. basStr := c.GetBasBaseInfo22222()
  14372. fmt.Println(basStr)
  14373. if len(basStr) == 0 {
  14374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14375. return
  14376. }
  14377. fmt.Println(basStr)
  14378. bas := strings.Split(basStr, "|")
  14379. basNumber := bas[2] //卡号
  14380. card_sn := bas[3] //
  14381. id_card_No := bas[1] //卡号
  14382. fmt.Println(basNumber)
  14383. fmt.Println(card_sn)
  14384. fmt.Println(id_card_No)
  14385. var patient service.Patients
  14386. if len(id_card_No) == 0 {
  14387. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14388. } else {
  14389. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14390. }
  14391. 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)
  14392. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14393. var dat map[string]interface{}
  14394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14395. fmt.Println(dat)
  14396. } else {
  14397. fmt.Println(err)
  14398. }
  14399. userJSONBytes, _ := json.Marshal(dat)
  14400. var res ResultTwo
  14401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14402. utils.ErrorLog("解析失败:%v", err)
  14403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14404. return
  14405. }
  14406. if res.Infcode == 0 {
  14407. var pateint2 service.Patients
  14408. var err error
  14409. if len(id_card_No) == 0 {
  14410. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14411. } else {
  14412. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14413. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14414. }
  14415. if err == gorm.ErrRecordNotFound {
  14416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14417. return
  14418. } else if err != nil {
  14419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14420. return
  14421. } else {
  14422. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14423. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14424. infoStr := string(Iinfos)
  14425. idetinfoStr := string(Idetinfos)
  14426. var rf []*ResultFive
  14427. json.Unmarshal([]byte(infoStr), &rf)
  14428. var insutypes []*ResultFive
  14429. var insutype string
  14430. var is390 int = 0
  14431. var is310 int = 0
  14432. var insuplc_admdvs string
  14433. for _, item := range rf {
  14434. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14435. insutypes = append(insutypes, item)
  14436. }
  14437. }
  14438. if len(insutypes) == 1 {
  14439. insutype = insutypes[0].Insutype
  14440. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14441. } else {
  14442. for _, i := range insutypes {
  14443. if i.Insutype == "390" {
  14444. is390 = 1
  14445. }
  14446. if i.Insutype == "310" {
  14447. is310 = 1
  14448. }
  14449. }
  14450. }
  14451. if is390 == 1 {
  14452. insutype = "390"
  14453. }
  14454. if is310 == 1 {
  14455. insutype = "310"
  14456. }
  14457. if len(insutypes) == 0 {
  14458. insutype = "310"
  14459. }
  14460. for _, item := range rf {
  14461. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14462. insuplc_admdvs = item.InsuplcAdmdvs
  14463. }
  14464. }
  14465. psn := &models.HisPsn{
  14466. PsnNo: res.Output.Baseinfo.PsnNo,
  14467. PatientId: pateint2.ID,
  14468. Certno: res.Output.Baseinfo.Certno,
  14469. Gend: res.Output.Baseinfo.Gend,
  14470. Naty: res.Output.Baseinfo.Naty,
  14471. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14472. PsnName: res.Output.Baseinfo.PsnName,
  14473. Idetinfo: idetinfoStr,
  14474. Insuinfo: infoStr,
  14475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14476. CardInfo: basStr,
  14477. InsuplcAdmdvs: insuplc_admdvs,
  14478. VerifyNumber: "",
  14479. }
  14480. service.CreateHisPsn(psn)
  14481. c.ServeSuccessJSON(map[string]interface{}{
  14482. "patient": patient,
  14483. "number": basNumber,
  14484. "insutype": insutype,
  14485. })
  14486. }
  14487. } else {
  14488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14489. return
  14490. }
  14491. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14492. fmt.Println(initFlag)
  14493. fmt.Println("initFlag")
  14494. if initFlag == 0 {
  14495. c.TestGetJiangXiBasBaseInittwo()
  14496. }
  14497. basStr := c.GetBasBaseInfo()
  14498. if len(basStr) == 0 {
  14499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14500. return
  14501. }
  14502. fmt.Println(basStr)
  14503. bas := strings.Split(basStr, "|")
  14504. basNumber := bas[1]
  14505. fmt.Println(basNumber)
  14506. card_sn := bas[3]
  14507. fmt.Println(card_sn)
  14508. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14509. 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)
  14510. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14511. var dat map[string]interface{}
  14512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14513. fmt.Println(dat)
  14514. } else {
  14515. fmt.Println(err)
  14516. }
  14517. userJSONBytes, _ := json.Marshal(dat)
  14518. var res ResultTwo
  14519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14520. utils.ErrorLog("解析失败:%v", err)
  14521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14522. return
  14523. }
  14524. if res.Infcode == 0 {
  14525. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14526. if err == gorm.ErrRecordNotFound {
  14527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14528. return
  14529. } else if err != nil {
  14530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14531. return
  14532. } else {
  14533. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14534. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14535. infoStr := string(Iinfos)
  14536. idetinfoStr := string(Idetinfos)
  14537. var rf []*ResultFive
  14538. json.Unmarshal([]byte(infoStr), &rf)
  14539. var insutypes []*ResultFive
  14540. var insutype string
  14541. var is390 int = 0
  14542. var is310 int = 0
  14543. var insuplc_admdvs string
  14544. for _, item := range rf {
  14545. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14546. insutypes = append(insutypes, item)
  14547. }
  14548. }
  14549. if len(insutypes) == 1 {
  14550. insutype = insutypes[0].Insutype
  14551. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14552. } else {
  14553. for _, i := range insutypes {
  14554. if i.Insutype == "390" {
  14555. is390 = 1
  14556. }
  14557. if i.Insutype == "310" {
  14558. is310 = 1
  14559. }
  14560. }
  14561. }
  14562. if is390 == 1 {
  14563. insutype = "390"
  14564. }
  14565. if is310 == 1 {
  14566. insutype = "310"
  14567. }
  14568. if len(insutypes) == 0 {
  14569. insutype = "310"
  14570. }
  14571. for _, item := range rf {
  14572. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14573. insuplc_admdvs = item.InsuplcAdmdvs
  14574. }
  14575. }
  14576. psn := &models.HisPsn{
  14577. PsnNo: res.Output.Baseinfo.PsnNo,
  14578. PatientId: patient.ID,
  14579. Certno: res.Output.Baseinfo.Certno,
  14580. Gend: res.Output.Baseinfo.Gend,
  14581. Naty: res.Output.Baseinfo.Naty,
  14582. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14583. PsnName: res.Output.Baseinfo.PsnName,
  14584. Idetinfo: idetinfoStr,
  14585. Insuinfo: infoStr,
  14586. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14587. CardInfo: basStr,
  14588. InsuplcAdmdvs: insuplc_admdvs,
  14589. VerifyNumber: "",
  14590. }
  14591. service.CreateHisPsn(psn)
  14592. c.ServeSuccessJSON(map[string]interface{}{
  14593. "patient": patient,
  14594. "number": basNumber,
  14595. "insutype": insutype,
  14596. })
  14597. }
  14598. } else {
  14599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14600. return
  14601. }
  14602. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14603. fmt.Println(initFlag)
  14604. fmt.Println("initFlag")
  14605. if initFlag == 0 {
  14606. c.TestGetHnBasBaseInit()
  14607. }
  14608. basStr := c.GetBasBaseInfo()
  14609. if len(basStr) == 0 {
  14610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14611. return
  14612. }
  14613. fmt.Println(basStr)
  14614. bas := strings.Split(basStr, "|")
  14615. basNumber := bas[1]
  14616. fmt.Println(basNumber)
  14617. card_sn := bas[3]
  14618. card_no := bas[2]
  14619. fmt.Println(card_sn)
  14620. name := bas[4]
  14621. name = ConvertToString(name, "gbk", "utf-8")
  14622. 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)
  14623. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14624. var dat map[string]interface{}
  14625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14626. fmt.Println(dat)
  14627. } else {
  14628. fmt.Println(err)
  14629. }
  14630. userJSONBytes, _ := json.Marshal(dat)
  14631. var res ResultTwo
  14632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14633. utils.ErrorLog("解析失败:%v", err)
  14634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14635. return
  14636. }
  14637. if res.Infcode == 0 {
  14638. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14639. if err == gorm.ErrRecordNotFound {
  14640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14641. return
  14642. } else if err != nil {
  14643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14644. return
  14645. } else {
  14646. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14647. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14648. infoStr := string(Iinfos)
  14649. idetinfoStr := string(Idetinfos)
  14650. psn := &models.HisPsn{
  14651. PsnNo: res.Output.Baseinfo.PsnNo,
  14652. PatientId: patient.ID,
  14653. Certno: res.Output.Baseinfo.Certno,
  14654. Gend: res.Output.Baseinfo.Gend,
  14655. Naty: res.Output.Baseinfo.Naty,
  14656. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14657. PsnName: res.Output.Baseinfo.PsnName,
  14658. Idetinfo: idetinfoStr,
  14659. Insuinfo: infoStr,
  14660. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14661. CardInfo: basStr,
  14662. VerifyNumber: "",
  14663. }
  14664. service.CreateHisPsn(psn)
  14665. var rf []*ResultFive
  14666. json.Unmarshal([]byte(infoStr), &rf)
  14667. var insutypes []*ResultFive
  14668. var insutype string
  14669. var is390 int = 0
  14670. var is310 int = 0
  14671. for _, item := range rf {
  14672. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14673. insutypes = append(insutypes, item)
  14674. }
  14675. }
  14676. if len(insutypes) == 1 {
  14677. insutype = insutypes[0].Insutype
  14678. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14679. } else {
  14680. for _, i := range insutypes {
  14681. if i.Insutype == "390" {
  14682. is390 = 1
  14683. }
  14684. if i.Insutype == "310" {
  14685. is310 = 1
  14686. }
  14687. }
  14688. }
  14689. if is390 == 1 {
  14690. insutype = "390"
  14691. }
  14692. if is310 == 1 {
  14693. insutype = "310"
  14694. }
  14695. if len(insutypes) == 0 {
  14696. insutype = "310"
  14697. }
  14698. c.ServeSuccessJSON(map[string]interface{}{
  14699. "patient": patient,
  14700. "number": basNumber,
  14701. "insutype": insutype,
  14702. })
  14703. }
  14704. } else {
  14705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14706. return
  14707. }
  14708. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14709. var api string
  14710. 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 +
  14711. "&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
  14712. fmt.Println(api)
  14713. resp, requestErr := http.Get(api)
  14714. if requestErr != nil {
  14715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14716. return
  14717. }
  14718. body, ioErr := ioutil.ReadAll(resp.Body)
  14719. if ioErr != nil {
  14720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14722. return
  14723. }
  14724. var respJSON map[string]interface{}
  14725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14728. return
  14729. }
  14730. var res ResultTwo //1101结果
  14731. var res10265 ResultTwo10265 //1101结果
  14732. var card_info string //卡信息
  14733. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14734. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14735. result, _ := json.Marshal(respJSON)
  14736. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14737. utils.ErrorLog("解析失败:%v", err)
  14738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14739. return
  14740. }
  14741. res.ErrMsg = res10265.ErrMsg
  14742. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14743. res.Infcode = infocode
  14744. res.Output = res10265.Output
  14745. res.InfRefmsgid = res10265.InfRefmsgid
  14746. if res.Infcode == 0 {
  14747. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14748. if err == gorm.ErrRecordNotFound {
  14749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14750. return
  14751. } else if err != nil {
  14752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14753. return
  14754. } else {
  14755. bas := strings.Split(card_info, "|")
  14756. basNumber := bas[2]
  14757. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14758. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14759. infoStr := string(Iinfos)
  14760. idetinfoStr := string(Idetinfos)
  14761. psn := &models.HisPsn{
  14762. PsnNo: res.Output.Baseinfo.PsnNo,
  14763. PatientId: patient.ID,
  14764. Certno: res.Output.Baseinfo.Certno,
  14765. Gend: res.Output.Baseinfo.Gend,
  14766. Naty: res.Output.Baseinfo.Naty,
  14767. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14768. PsnName: res.Output.Baseinfo.PsnName,
  14769. Idetinfo: idetinfoStr,
  14770. Insuinfo: infoStr,
  14771. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14772. CardInfo: card_info,
  14773. VerifyNumber: token,
  14774. }
  14775. service.CreateHisPsn(psn)
  14776. var rf []*ResultFive
  14777. json.Unmarshal([]byte(infoStr), &rf)
  14778. var insutypes []*ResultFive
  14779. var insutype string
  14780. var is390 int = 0
  14781. var is310 int = 0
  14782. for _, item := range rf {
  14783. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14784. insutypes = append(insutypes, item)
  14785. }
  14786. }
  14787. if len(insutypes) == 1 {
  14788. insutype = insutypes[0].Insutype
  14789. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14790. } else {
  14791. for _, i := range insutypes {
  14792. if i.Insutype == "390" {
  14793. is390 = 1
  14794. }
  14795. if i.Insutype == "310" {
  14796. is310 = 1
  14797. }
  14798. }
  14799. }
  14800. if is390 == 1 {
  14801. insutype = "390"
  14802. }
  14803. if is310 == 1 {
  14804. insutype = "310"
  14805. }
  14806. if len(insutypes) == 0 {
  14807. insutype = "310"
  14808. }
  14809. c.ServeSuccessJSON(map[string]interface{}{
  14810. "patient": patient,
  14811. "number": basNumber,
  14812. "insutype": insutype,
  14813. })
  14814. }
  14815. } else {
  14816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14817. return
  14818. }
  14819. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14820. res := c.GetoleInfo()
  14821. if res.Infcode == 0 {
  14822. var result string
  14823. if res.Output.MdtrtCertType == "01" {
  14824. 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)
  14825. } else if res.Output.MdtrtCertType == "02" {
  14826. 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)
  14827. } else if res.Output.MdtrtCertType == "03" {
  14828. 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)
  14829. }
  14830. var dat map[string]interface{}
  14831. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14832. fmt.Println(dat)
  14833. } else {
  14834. fmt.Println(err)
  14835. }
  14836. userJSONBytes, _ := json.Marshal(dat)
  14837. var res2 ResultTwo
  14838. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14839. utils.ErrorLog("解析失败:%v", err)
  14840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14841. return
  14842. }
  14843. if res2.Infcode == 0 {
  14844. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14845. if err == gorm.ErrRecordNotFound {
  14846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14847. return
  14848. } else if err != nil {
  14849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14850. return
  14851. } else {
  14852. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14853. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14854. infoStr := string(Iinfos)
  14855. idetinfoStr := string(Idetinfos)
  14856. var rf []*ResultFive
  14857. json.Unmarshal([]byte(infoStr), &rf)
  14858. var insutypes []*ResultFive
  14859. var insutype string
  14860. var is390 int = 0
  14861. var is310 int = 0
  14862. //var insuplc_admdvs string
  14863. for _, item := range rf {
  14864. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14865. insutypes = append(insutypes, item)
  14866. }
  14867. }
  14868. if len(insutypes) == 1 {
  14869. insutype = insutypes[0].Insutype
  14870. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14871. } else {
  14872. for _, i := range insutypes {
  14873. if i.Insutype == "390" {
  14874. is390 = 1
  14875. }
  14876. if i.Insutype == "310" {
  14877. is310 = 1
  14878. }
  14879. }
  14880. }
  14881. if is390 == 1 {
  14882. insutype = "390"
  14883. }
  14884. if is310 == 1 {
  14885. insutype = "310"
  14886. }
  14887. if len(insutypes) == 0 {
  14888. insutype = "310"
  14889. }
  14890. psn := &models.HisPsn{
  14891. PsnNo: res2.Output.Baseinfo.PsnNo,
  14892. PatientId: patient.ID,
  14893. Certno: res2.Output.Baseinfo.Certno,
  14894. Gend: res2.Output.Baseinfo.Gend,
  14895. Naty: res2.Output.Baseinfo.Naty,
  14896. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14897. PsnName: res2.Output.Baseinfo.PsnName,
  14898. Idetinfo: idetinfoStr,
  14899. Insuinfo: infoStr,
  14900. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14901. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14902. VerifyNumber: res.Output.EcToken,
  14903. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14904. }
  14905. if res.Output.MdtrtCertType == "01" {
  14906. psn.VerifyNumber = res.Output.EcToken
  14907. //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)
  14908. } else if res.Output.MdtrtCertType == "02" {
  14909. psn.VerifyNumber = res.Output.MdtrtCertNo
  14910. //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)
  14911. } else if res.Output.MdtrtCertType == "03" {
  14912. psn.VerifyNumber = res.Output.MdtrtCertNo
  14913. //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)
  14914. }
  14915. var balc float64
  14916. for _, item := range rf {
  14917. if item.Insutype == insutype {
  14918. balc = item.Balc
  14919. }
  14920. }
  14921. service.CreateHisPsn(psn)
  14922. c.ServeSuccessJSON(map[string]interface{}{
  14923. "patient": patient,
  14924. "number": res.Output.CardNo,
  14925. "insutype": insutype,
  14926. "blac": balc,
  14927. "desc": idetinfoStr,
  14928. })
  14929. }
  14930. } else {
  14931. c.ServeSuccessJSON(map[string]interface{}{
  14932. "failed_code": -10,
  14933. "msg": res2.ErrMsg,
  14934. })
  14935. }
  14936. } else {
  14937. c.ServeSuccessJSON(map[string]interface{}{
  14938. "failed_code": -10,
  14939. "msg": res.ErrMsg,
  14940. })
  14941. }
  14942. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14943. var api string
  14944. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14945. "&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
  14946. fmt.Println(api)
  14947. resp, requestErr := http.Get(api)
  14948. if requestErr != nil {
  14949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14950. return
  14951. }
  14952. body, ioErr := ioutil.ReadAll(resp.Body)
  14953. if ioErr != nil {
  14954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14956. return
  14957. }
  14958. var respJSON map[string]interface{}
  14959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14962. return
  14963. }
  14964. var status string
  14965. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14966. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14967. //console.log()
  14968. fmt.Println("type===")
  14969. fmt.Println(card_type)
  14970. var token string
  14971. var res ResultTwo //1101结果
  14972. //var res10265 ResultTwoesultTwo10265 //1101结果
  14973. var card_info string //卡信息
  14974. var busi_card_info string
  14975. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14976. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14977. if status == "0" { //读卡成功
  14978. if card_type == "1" {
  14979. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14980. result, _ := json.Marshal(respJSON)
  14981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14982. utils.ErrorLog("解析失败:%v", err)
  14983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14984. return
  14985. }
  14986. } else {
  14987. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14988. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14989. result, _ := json.Marshal(respJSON)
  14990. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14991. utils.ErrorLog("解析失败:%v", err)
  14992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14993. return
  14994. }
  14995. }
  14996. if res.Infcode == 0 {
  14997. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14998. if err == gorm.ErrRecordNotFound {
  14999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15000. return
  15001. } else if err != nil {
  15002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15003. return
  15004. } else {
  15005. if card_type == "1" {
  15006. bas := strings.Split(card_info, "|")
  15007. basNumber := bas[2]
  15008. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15009. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15010. infoStr := string(Iinfos)
  15011. idetinfoStr := string(Idetinfos)
  15012. psn := &models.HisPsn{
  15013. PsnNo: res.Output.Baseinfo.PsnNo,
  15014. PatientId: patient.ID,
  15015. Certno: res.Output.Baseinfo.Certno,
  15016. Gend: res.Output.Baseinfo.Gend,
  15017. Naty: res.Output.Baseinfo.Naty,
  15018. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15019. PsnName: res.Output.Baseinfo.PsnName,
  15020. Idetinfo: idetinfoStr,
  15021. Insuinfo: infoStr,
  15022. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15023. CardInfo: card_info,
  15024. VerifyNumber: busi_card_info,
  15025. }
  15026. service.CreateHisPsn(psn)
  15027. var rf []*ResultFive
  15028. json.Unmarshal([]byte(infoStr), &rf)
  15029. var insutypes []*ResultFive
  15030. var insutype string
  15031. var is390 int = 0
  15032. var is310 int = 0
  15033. for _, item := range rf {
  15034. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15035. insutypes = append(insutypes, item)
  15036. }
  15037. }
  15038. if len(insutypes) == 1 {
  15039. insutype = insutypes[0].Insutype
  15040. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15041. } else {
  15042. for _, i := range insutypes {
  15043. if i.Insutype == "390" {
  15044. is390 = 1
  15045. }
  15046. if i.Insutype == "310" {
  15047. is310 = 1
  15048. }
  15049. }
  15050. }
  15051. if is390 == 1 {
  15052. insutype = "390"
  15053. }
  15054. if is310 == 1 {
  15055. insutype = "310"
  15056. }
  15057. if len(insutypes) == 0 {
  15058. insutype = "310"
  15059. }
  15060. c.ServeSuccessJSON(map[string]interface{}{
  15061. "patient": patient,
  15062. "number": basNumber,
  15063. "insutype": insutype,
  15064. })
  15065. } else {
  15066. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15067. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15068. infoStr := string(Iinfos)
  15069. idetinfoStr := string(Idetinfos)
  15070. psn := &models.HisPsn{
  15071. PsnNo: res.Output.Baseinfo.PsnNo,
  15072. PatientId: patient.ID,
  15073. Certno: res.Output.Baseinfo.Certno,
  15074. Gend: res.Output.Baseinfo.Gend,
  15075. Naty: res.Output.Baseinfo.Naty,
  15076. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15077. PsnName: res.Output.Baseinfo.PsnName,
  15078. Idetinfo: idetinfoStr,
  15079. Insuinfo: infoStr,
  15080. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15081. CardInfo: card_info,
  15082. VerifyNumber: token,
  15083. }
  15084. service.CreateHisPsn(psn)
  15085. c.ServeSuccessJSON(map[string]interface{}{
  15086. "patient": patient,
  15087. "number": token,
  15088. })
  15089. }
  15090. }
  15091. } else {
  15092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15093. return
  15094. }
  15095. } else { //读卡失败
  15096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15097. return
  15098. }
  15099. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15100. var api string
  15101. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15102. "&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
  15103. fmt.Println(api)
  15104. resp, requestErr := http.Get(api)
  15105. if requestErr != nil {
  15106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15107. return
  15108. }
  15109. body, ioErr := ioutil.ReadAll(resp.Body)
  15110. if ioErr != nil {
  15111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15113. return
  15114. }
  15115. var respJSON map[string]interface{}
  15116. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15119. return
  15120. }
  15121. var status string
  15122. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15123. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15124. //console.log()
  15125. fmt.Println("type===")
  15126. fmt.Println(card_type)
  15127. var token string
  15128. var res ResultTwo //1101结果
  15129. //var res10265 ResultTwoesultTwo10265 //1101结果
  15130. var card_info string //卡信息
  15131. //var busi_card_info string
  15132. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15133. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15134. if status == "0" { //读卡成功
  15135. if card_type == "1" {
  15136. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15137. result, _ := json.Marshal(respJSON)
  15138. fmt.Println(result)
  15139. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15140. utils.ErrorLog("解析失败:%v", err)
  15141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15142. return
  15143. }
  15144. fmt.Println(res)
  15145. } else {
  15146. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15147. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15148. result, _ := json.Marshal(respJSON)
  15149. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15150. utils.ErrorLog("解析失败:%v", err)
  15151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15152. return
  15153. }
  15154. }
  15155. if res.Infcode == 0 {
  15156. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15157. if err == gorm.ErrRecordNotFound {
  15158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15159. return
  15160. } else if err != nil {
  15161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15162. return
  15163. } else {
  15164. if card_type == "1" {
  15165. bas := strings.Split(card_info, "|")
  15166. basNumber := bas[2]
  15167. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15168. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15169. infoStr := string(Iinfos)
  15170. idetinfoStr := string(Idetinfos)
  15171. psn := &models.HisPsn{
  15172. PsnNo: res.Output.Baseinfo.PsnNo,
  15173. PatientId: patient.ID,
  15174. Certno: res.Output.Baseinfo.Certno,
  15175. Gend: res.Output.Baseinfo.Gend,
  15176. Naty: res.Output.Baseinfo.Naty,
  15177. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15178. PsnName: res.Output.Baseinfo.PsnName,
  15179. Idetinfo: idetinfoStr,
  15180. Insuinfo: infoStr,
  15181. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15182. CardInfo: card_info,
  15183. //VerifyNumber: busi_card_info,
  15184. }
  15185. service.CreateHisPsn(psn)
  15186. var rf []*ResultFive
  15187. json.Unmarshal([]byte(infoStr), &rf)
  15188. var insutypes []*ResultFive
  15189. var insutype string
  15190. var is390 int = 0
  15191. var is310 int = 0
  15192. for _, item := range rf {
  15193. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15194. insutypes = append(insutypes, item)
  15195. }
  15196. }
  15197. if len(insutypes) == 1 {
  15198. insutype = insutypes[0].Insutype
  15199. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15200. } else {
  15201. for _, i := range insutypes {
  15202. if i.Insutype == "390" {
  15203. is390 = 1
  15204. }
  15205. if i.Insutype == "310" {
  15206. is310 = 1
  15207. }
  15208. }
  15209. }
  15210. if is390 == 1 {
  15211. insutype = "390"
  15212. }
  15213. if is310 == 1 {
  15214. insutype = "310"
  15215. }
  15216. if len(insutypes) == 0 {
  15217. insutype = "310"
  15218. }
  15219. c.ServeSuccessJSON(map[string]interface{}{
  15220. "patient": patient,
  15221. "number": basNumber,
  15222. "insutype": insutype,
  15223. })
  15224. } else {
  15225. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15226. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15227. infoStr := string(Iinfos)
  15228. idetinfoStr := string(Idetinfos)
  15229. psn := &models.HisPsn{
  15230. PsnNo: res.Output.Baseinfo.PsnNo,
  15231. PatientId: patient.ID,
  15232. Certno: res.Output.Baseinfo.Certno,
  15233. Gend: res.Output.Baseinfo.Gend,
  15234. Naty: res.Output.Baseinfo.Naty,
  15235. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15236. PsnName: res.Output.Baseinfo.PsnName,
  15237. Idetinfo: idetinfoStr,
  15238. Insuinfo: infoStr,
  15239. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15240. CardInfo: card_info,
  15241. VerifyNumber: token,
  15242. }
  15243. service.CreateHisPsn(psn)
  15244. c.ServeSuccessJSON(map[string]interface{}{
  15245. "patient": patient,
  15246. "number": token,
  15247. })
  15248. }
  15249. }
  15250. } else {
  15251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15252. return
  15253. }
  15254. } else { //读卡失败
  15255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15256. return
  15257. }
  15258. } else {
  15259. if initFlag == 0 {
  15260. c.TestGetBasBaseInit()
  15261. }
  15262. basStr := c.GetBasBaseInfo()
  15263. if len(basStr) == 0 {
  15264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15265. return
  15266. }
  15267. fmt.Println(basStr)
  15268. bas := strings.Split(basStr, "|")
  15269. basNumber := bas[1]
  15270. fmt.Println(basNumber)
  15271. card_sn := bas[3]
  15272. fmt.Println(card_sn)
  15273. cardNumber := bas[2]
  15274. fmt.Println(cardNumber)
  15275. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15276. var result string
  15277. if bas[0][:2] == "44" {
  15278. 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)
  15279. } else {
  15280. 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)
  15281. }
  15282. var dat map[string]interface{}
  15283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15284. fmt.Println(dat)
  15285. } else {
  15286. fmt.Println(err)
  15287. }
  15288. userJSONBytes, _ := json.Marshal(dat)
  15289. var res ResultTwo
  15290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15291. utils.ErrorLog("解析失败:%v", err)
  15292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15293. return
  15294. }
  15295. if res.Infcode == 0 {
  15296. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15297. if err == gorm.ErrRecordNotFound {
  15298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15299. return
  15300. } else if err != nil {
  15301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15302. return
  15303. } else {
  15304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15306. infoStr := string(Iinfos)
  15307. idetinfoStr := string(Idetinfos)
  15308. var rf []*ResultFive
  15309. json.Unmarshal([]byte(infoStr), &rf)
  15310. var insutypes []*ResultFive
  15311. var insutype string
  15312. var is390 int = 0
  15313. var is310 int = 0
  15314. var insuplc_admdvs string
  15315. for _, item := range rf {
  15316. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15317. insutypes = append(insutypes, item)
  15318. }
  15319. }
  15320. if len(insutypes) == 1 {
  15321. insutype = insutypes[0].Insutype
  15322. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15323. } else {
  15324. for _, i := range insutypes {
  15325. if i.Insutype == "390" {
  15326. is390 = 1
  15327. }
  15328. if i.Insutype == "310" {
  15329. is310 = 1
  15330. }
  15331. }
  15332. }
  15333. if is390 == 1 {
  15334. insutype = "390"
  15335. }
  15336. if is310 == 1 {
  15337. insutype = "310"
  15338. }
  15339. if len(insutypes) == 0 {
  15340. insutype = "310"
  15341. }
  15342. for _, item := range rf {
  15343. if item.Insutype == insutype {
  15344. insuplc_admdvs = item.InsuplcAdmdvs
  15345. }
  15346. }
  15347. psn := &models.HisPsn{
  15348. PsnNo: res.Output.Baseinfo.PsnNo,
  15349. PatientId: patient.ID,
  15350. Certno: res.Output.Baseinfo.Certno,
  15351. Gend: res.Output.Baseinfo.Gend,
  15352. Naty: res.Output.Baseinfo.Naty,
  15353. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15354. PsnName: res.Output.Baseinfo.PsnName,
  15355. Idetinfo: idetinfoStr,
  15356. Insuinfo: infoStr,
  15357. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15358. CardInfo: basStr,
  15359. VerifyNumber: "",
  15360. InsuplcAdmdvs: insuplc_admdvs,
  15361. }
  15362. service.CreateHisPsn(psn)
  15363. c.ServeSuccessJSON(map[string]interface{}{
  15364. "patient": patient,
  15365. "insutype": insutype,
  15366. "number": basNumber,
  15367. })
  15368. }
  15369. } else {
  15370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15371. return
  15372. }
  15373. break
  15374. }
  15375. case 2:
  15376. if miConfig.MdtrtareaAdmvs == "430800" {
  15377. if initFlag == 0 {
  15378. c.TestGetHnBasBaseInit()
  15379. }
  15380. SFZStr := c.GetSFZBaseInfo()
  15381. if len(SFZStr) == 0 {
  15382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15383. return
  15384. }
  15385. fmt.Println(SFZStr)
  15386. id_card_str := strings.Split(SFZStr, "^")
  15387. card_no := id_card_str[0]
  15388. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15389. //name := id_card_str[1]
  15390. //name = ConvertToString(name, "gbk", "utf-8")
  15391. 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)
  15392. var dat map[string]interface{}
  15393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15394. fmt.Println(dat)
  15395. } else {
  15396. fmt.Println(err)
  15397. }
  15398. userJSONBytes, _ := json.Marshal(dat)
  15399. var res ResultTwo
  15400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15401. utils.ErrorLog("解析失败:%v", err)
  15402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15403. return
  15404. }
  15405. if res.Infcode == 0 {
  15406. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15407. if err == gorm.ErrRecordNotFound {
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15409. return
  15410. } else if err != nil {
  15411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15412. return
  15413. } else {
  15414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15416. infoStr := string(Iinfos)
  15417. idetinfoStr := string(Idetinfos)
  15418. var rf []*ResultFive
  15419. json.Unmarshal([]byte(infoStr), &rf)
  15420. var insutypes []*ResultFive
  15421. var insutype string
  15422. var is390 int = 0
  15423. var is310 int = 0
  15424. for _, item := range rf {
  15425. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15426. insutypes = append(insutypes, item)
  15427. }
  15428. }
  15429. if len(insutypes) == 1 {
  15430. insutype = insutypes[0].Insutype
  15431. } else {
  15432. for _, i := range insutypes {
  15433. if i.Insutype == "390" {
  15434. is390 = 1
  15435. }
  15436. if i.Insutype == "310" {
  15437. is310 = 1
  15438. }
  15439. }
  15440. }
  15441. if is390 == 1 {
  15442. insutype = "390"
  15443. }
  15444. if is310 == 1 {
  15445. insutype = "310"
  15446. }
  15447. if len(insutypes) == 0 {
  15448. insutype = "310"
  15449. }
  15450. var InsuplcAdmdvs string
  15451. for _, item := range rf {
  15452. if item.Insutype == insutype {
  15453. InsuplcAdmdvs = item.InsuplcAdmdvs
  15454. }
  15455. }
  15456. psn := &models.HisPsn{
  15457. PsnNo: res.Output.Baseinfo.PsnNo,
  15458. PatientId: patient.ID,
  15459. Certno: res.Output.Baseinfo.Certno,
  15460. Gend: res.Output.Baseinfo.Gend,
  15461. Naty: res.Output.Baseinfo.Naty,
  15462. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15463. PsnName: res.Output.Baseinfo.PsnName,
  15464. Idetinfo: idetinfoStr,
  15465. Insuinfo: infoStr,
  15466. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15467. CardInfo: SFZStr,
  15468. VerifyNumber: "",
  15469. InsuplcAdmdvs: InsuplcAdmdvs,
  15470. }
  15471. service.CreateHisPsn(psn)
  15472. c.ServeSuccessJSON(map[string]interface{}{
  15473. "patient": patient,
  15474. "number": card_no,
  15475. "insutype": insutype,
  15476. })
  15477. }
  15478. } else {
  15479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15480. return
  15481. }
  15482. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15483. var res ResultTwo
  15484. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15485. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15486. "&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)
  15487. resp, requestErr := http.Get(api)
  15488. if requestErr != nil {
  15489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15490. return
  15491. }
  15492. body, ioErr := ioutil.ReadAll(resp.Body)
  15493. if ioErr != nil {
  15494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15496. return
  15497. }
  15498. var respJSON map[string]interface{}
  15499. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15502. return
  15503. }
  15504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15505. result, _ := json.Marshal(respJSON)
  15506. fmt.Println("log")
  15507. fmt.Println(string(result))
  15508. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15509. utils.ErrorLog("解析失败:%v", err)
  15510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15511. return
  15512. }
  15513. if res.Infcode == 0 {
  15514. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15515. if err == gorm.ErrRecordNotFound {
  15516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15517. return
  15518. } else if err != nil {
  15519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15520. return
  15521. } else {
  15522. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15523. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15524. infoStr := string(Iinfos)
  15525. idetinfoStr := string(Idetinfos)
  15526. psn := &models.HisPsn{
  15527. PsnNo: res.Output.Baseinfo.PsnNo,
  15528. PatientId: patient.ID,
  15529. Certno: res.Output.Baseinfo.Certno,
  15530. Gend: res.Output.Baseinfo.Gend,
  15531. Naty: res.Output.Baseinfo.Naty,
  15532. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15533. PsnName: res.Output.Baseinfo.PsnName,
  15534. Idetinfo: idetinfoStr,
  15535. Insuinfo: infoStr,
  15536. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15537. }
  15538. service.CreateHisPsn(psn)
  15539. c.ServeSuccessJSON(map[string]interface{}{
  15540. "patient": patient,
  15541. "number": res.Output.Baseinfo.Certno,
  15542. })
  15543. }
  15544. } else {
  15545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15546. return
  15547. }
  15548. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15549. var res ResultTwo
  15550. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15551. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15552. "&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)
  15553. resp, requestErr := http.Get(api)
  15554. if requestErr != nil {
  15555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15556. return
  15557. }
  15558. body, ioErr := ioutil.ReadAll(resp.Body)
  15559. if ioErr != nil {
  15560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15562. return
  15563. }
  15564. var respJSON map[string]interface{}
  15565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15568. return
  15569. }
  15570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15571. result, _ := json.Marshal(respJSON)
  15572. fmt.Println("log")
  15573. fmt.Println(string(result))
  15574. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15575. utils.ErrorLog("解析失败:%v", err)
  15576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15577. return
  15578. }
  15579. if res.Infcode == 0 {
  15580. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15581. if err == gorm.ErrRecordNotFound {
  15582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15583. return
  15584. } else if err != nil {
  15585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15586. return
  15587. } else {
  15588. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15589. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15590. infoStr := string(Iinfos)
  15591. idetinfoStr := string(Idetinfos)
  15592. psn := &models.HisPsn{
  15593. PsnNo: res.Output.Baseinfo.PsnNo,
  15594. PatientId: patient.ID,
  15595. Certno: res.Output.Baseinfo.Certno,
  15596. Gend: res.Output.Baseinfo.Gend,
  15597. Naty: res.Output.Baseinfo.Naty,
  15598. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15599. PsnName: res.Output.Baseinfo.PsnName,
  15600. Idetinfo: idetinfoStr,
  15601. Insuinfo: infoStr,
  15602. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15603. }
  15604. service.CreateHisPsn(psn)
  15605. c.ServeSuccessJSON(map[string]interface{}{
  15606. "patient": patient,
  15607. "number": res.Output.Baseinfo.Certno,
  15608. })
  15609. }
  15610. } else {
  15611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15612. return
  15613. }
  15614. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15615. var res ResultTwo
  15616. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15617. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15618. "&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)
  15619. resp, requestErr := http.Get(api)
  15620. if requestErr != nil {
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15622. return
  15623. }
  15624. body, ioErr := ioutil.ReadAll(resp.Body)
  15625. if ioErr != nil {
  15626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15628. return
  15629. }
  15630. var respJSON map[string]interface{}
  15631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15634. return
  15635. }
  15636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15637. result, _ := json.Marshal(respJSON)
  15638. fmt.Println("log")
  15639. fmt.Println(string(result))
  15640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15641. utils.ErrorLog("解析失败:%v", err)
  15642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15643. return
  15644. }
  15645. if res.Infcode == 0 {
  15646. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15647. if err == gorm.ErrRecordNotFound {
  15648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15649. return
  15650. } else if err != nil {
  15651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15652. return
  15653. } else {
  15654. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15655. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15656. infoStr := string(Iinfos)
  15657. idetinfoStr := string(Idetinfos)
  15658. var rf []*ResultFive
  15659. json.Unmarshal([]byte(infoStr), &rf)
  15660. var insutypes []*ResultFive
  15661. var insutype string
  15662. var is390 int = 0
  15663. var is310 int = 0
  15664. for _, item := range rf {
  15665. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15666. insutypes = append(insutypes, item)
  15667. }
  15668. }
  15669. if len(insutypes) == 1 {
  15670. insutype = insutypes[0].Insutype
  15671. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15672. } else {
  15673. for _, i := range insutypes {
  15674. if i.Insutype == "390" {
  15675. is390 = 1
  15676. }
  15677. if i.Insutype == "310" {
  15678. is310 = 1
  15679. }
  15680. }
  15681. }
  15682. if is390 == 1 {
  15683. insutype = "390"
  15684. }
  15685. if is310 == 1 {
  15686. insutype = "310"
  15687. }
  15688. if len(insutypes) == 0 {
  15689. insutype = "390"
  15690. }
  15691. var insuplc_admdvs string
  15692. for _, item := range rf {
  15693. if item.Insutype == insutype {
  15694. insuplc_admdvs = item.InsuplcAdmdvs
  15695. }
  15696. }
  15697. psn := &models.HisPsn{
  15698. PsnNo: res.Output.Baseinfo.PsnNo,
  15699. PatientId: patient.ID,
  15700. Certno: res.Output.Baseinfo.Certno,
  15701. Gend: res.Output.Baseinfo.Gend,
  15702. Naty: res.Output.Baseinfo.Naty,
  15703. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15704. PsnName: res.Output.Baseinfo.PsnName,
  15705. Idetinfo: idetinfoStr,
  15706. Insuinfo: infoStr,
  15707. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15708. InsuplcAdmdvs: insuplc_admdvs,
  15709. }
  15710. service.CreateHisPsn(psn)
  15711. c.ServeSuccessJSON(map[string]interface{}{
  15712. "patient": patient,
  15713. "number": res.Output.Baseinfo.Certno,
  15714. })
  15715. }
  15716. } else {
  15717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15718. return
  15719. }
  15720. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15721. res := c.GetoleInfo()
  15722. if res.Infcode == 0 {
  15723. var result string
  15724. if res.Output.MdtrtCertType == "01" {
  15725. 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)
  15726. } else if res.Output.MdtrtCertType == "02" {
  15727. 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)
  15728. } else if res.Output.MdtrtCertType == "03" {
  15729. 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)
  15730. }
  15731. var dat map[string]interface{}
  15732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15733. fmt.Println(dat)
  15734. } else {
  15735. fmt.Println(err)
  15736. }
  15737. userJSONBytes, _ := json.Marshal(dat)
  15738. var res2 ResultTwo
  15739. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15740. utils.ErrorLog("解析失败:%v", err)
  15741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15742. return
  15743. }
  15744. if res2.Infcode == 0 {
  15745. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15746. if err == gorm.ErrRecordNotFound {
  15747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15748. return
  15749. } else if err != nil {
  15750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15751. return
  15752. } else {
  15753. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15754. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15755. infoStr := string(Iinfos)
  15756. idetinfoStr := string(Idetinfos)
  15757. var rf []*ResultFive
  15758. json.Unmarshal([]byte(infoStr), &rf)
  15759. var insutypes []*ResultFive
  15760. var insutype string
  15761. var is390 int = 0
  15762. var is310 int = 0
  15763. //var insuplc_admdvs string
  15764. for _, item := range rf {
  15765. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15766. insutypes = append(insutypes, item)
  15767. }
  15768. }
  15769. if len(insutypes) == 1 {
  15770. insutype = insutypes[0].Insutype
  15771. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15772. } else {
  15773. for _, i := range insutypes {
  15774. if i.Insutype == "390" {
  15775. is390 = 1
  15776. }
  15777. if i.Insutype == "310" {
  15778. is310 = 1
  15779. }
  15780. }
  15781. }
  15782. if is390 == 1 {
  15783. insutype = "390"
  15784. }
  15785. if is310 == 1 {
  15786. insutype = "310"
  15787. }
  15788. if len(insutypes) == 0 {
  15789. insutype = "310"
  15790. }
  15791. psn := &models.HisPsn{
  15792. PsnNo: res2.Output.Baseinfo.PsnNo,
  15793. PatientId: patient.ID,
  15794. //Brdy: res2.Output.Baseinfo.Brdy,
  15795. Certno: res2.Output.Baseinfo.Certno,
  15796. Gend: res2.Output.Baseinfo.Gend,
  15797. Naty: res2.Output.Baseinfo.Naty,
  15798. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15799. PsnName: res2.Output.Baseinfo.PsnName,
  15800. Idetinfo: idetinfoStr,
  15801. Insuinfo: infoStr,
  15802. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15803. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15804. VerifyNumber: res.Output.EcToken,
  15805. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15806. }
  15807. service.CreateHisPsn(psn)
  15808. var balc float64
  15809. for _, item := range rf {
  15810. if item.Insutype == insutype {
  15811. balc = item.Balc
  15812. }
  15813. }
  15814. c.ServeSuccessJSON(map[string]interface{}{
  15815. "patient": patient,
  15816. "number": res.Output.CardNo,
  15817. "insutype": insutype,
  15818. "blac": balc,
  15819. "desc": idetinfoStr,
  15820. })
  15821. }
  15822. } else {
  15823. c.ServeSuccessJSON(map[string]interface{}{
  15824. "failed_code": -10,
  15825. "msg": res2.ErrMsg,
  15826. })
  15827. }
  15828. } else {
  15829. c.ServeSuccessJSON(map[string]interface{}{
  15830. "failed_code": -10,
  15831. "msg": res.ErrMsg,
  15832. })
  15833. }
  15834. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15835. var insuplc_admdvs string
  15836. if len(patient.InsuplcAdmdvs) > 0 {
  15837. insuplc_admdvs = patient.InsuplcAdmdvs
  15838. } else {
  15839. if len(insuplc_admdvs_str) > 0 {
  15840. insuplc_admdvs = insuplc_admdvs_str
  15841. } else {
  15842. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15843. }
  15844. }
  15845. //请求内网数据
  15846. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15847. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15848. "&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=" + ""
  15849. resp, requestErr := http.Get(api)
  15850. if requestErr != nil {
  15851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15852. return
  15853. }
  15854. body, ioErr := ioutil.ReadAll(resp.Body)
  15855. if ioErr != nil {
  15856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15858. return
  15859. }
  15860. var respJSON map[string]interface{}
  15861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15864. return
  15865. }
  15866. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15867. if status == "0" {
  15868. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15869. c.ServeSuccessJSON(map[string]interface{}{
  15870. "failed_code": -10,
  15871. "msg": err_msg,
  15872. })
  15873. return
  15874. }
  15875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15876. var res ResultTwo
  15877. result, _ := json.Marshal(respJSON)
  15878. fmt.Println("log")
  15879. fmt.Println(string(result))
  15880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15881. utils.ErrorLog("解析失败:%v", err)
  15882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15883. return
  15884. }
  15885. if res.Infcode == 0 {
  15886. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15887. if err == gorm.ErrRecordNotFound {
  15888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15889. return
  15890. } else if err != nil {
  15891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15892. return
  15893. } else {
  15894. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15895. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15896. infoStr := string(Iinfos)
  15897. idetinfoStr := string(Idetinfos)
  15898. psn := &models.HisPsn{
  15899. PsnNo: res.Output.Baseinfo.PsnNo,
  15900. PatientId: patient.ID,
  15901. Certno: res.Output.Baseinfo.Certno,
  15902. Gend: res.Output.Baseinfo.Gend,
  15903. Naty: res.Output.Baseinfo.Naty,
  15904. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15905. PsnName: res.Output.Baseinfo.PsnName,
  15906. Idetinfo: idetinfoStr,
  15907. Insuinfo: infoStr,
  15908. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15909. }
  15910. service.CreateHisPsn(psn)
  15911. var rf []*ResultFive
  15912. json.Unmarshal([]byte(infoStr), &rf)
  15913. var insutypes []*ResultFive
  15914. var is390 int = 0
  15915. var is310 int = 0
  15916. var insutype string
  15917. for _, item := range rf {
  15918. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15919. insutypes = append(insutypes, item)
  15920. }
  15921. }
  15922. if len(insutypes) == 1 {
  15923. insutype = insutypes[0].Insutype
  15924. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15925. } else {
  15926. for _, i := range insutypes {
  15927. if i.Insutype == "390" {
  15928. is390 = 1
  15929. }
  15930. if i.Insutype == "310" {
  15931. is310 = 1
  15932. }
  15933. }
  15934. }
  15935. if is390 == 1 {
  15936. insutype = "390"
  15937. }
  15938. if is310 == 1 {
  15939. insutype = "310"
  15940. }
  15941. if len(insutypes) == 0 {
  15942. insutype = "390"
  15943. }
  15944. c.ServeSuccessJSON(map[string]interface{}{
  15945. "patient": patient,
  15946. "insutype": insutype,
  15947. "number": res.Output.Baseinfo.Certno,
  15948. "info": res,
  15949. })
  15950. }
  15951. } else {
  15952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15953. return
  15954. }
  15955. } else {
  15956. SFZStr := c.GetSFZBaseInfo()
  15957. id_card_str := strings.Split(SFZStr, "^")
  15958. id_card_number := id_card_str[0]
  15959. card_sn := ""
  15960. 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)
  15961. var dat map[string]interface{}
  15962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15963. fmt.Println(dat)
  15964. } else {
  15965. fmt.Println(err)
  15966. }
  15967. userJSONBytes, _ := json.Marshal(dat)
  15968. var res ResultTwo
  15969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15970. utils.ErrorLog("解析失败:%v", err)
  15971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15972. return
  15973. }
  15974. if res.Infcode == 0 {
  15975. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15976. if err == gorm.ErrRecordNotFound {
  15977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15978. return
  15979. } else if err != nil {
  15980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15981. return
  15982. } else {
  15983. c.ServeSuccessJSON(map[string]interface{}{
  15984. "patient": patient,
  15985. "number": id_card_number,
  15986. })
  15987. }
  15988. } else {
  15989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15990. return
  15991. }
  15992. }
  15993. break
  15994. case 3:
  15995. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  15996. var api string
  15997. if miConfig.MdtrtareaAdmvs == "320830" {
  15998. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15999. "&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
  16000. fmt.Println(api)
  16001. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16002. 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 +
  16003. "&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
  16004. fmt.Println(api)
  16005. } else {
  16006. 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 +
  16007. "&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)
  16008. }
  16009. resp, requestErr := http.Get(api)
  16010. if requestErr != nil {
  16011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16012. return
  16013. }
  16014. body, ioErr := ioutil.ReadAll(resp.Body)
  16015. if ioErr != nil {
  16016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16018. return
  16019. }
  16020. var respJSON map[string]interface{}
  16021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16024. return
  16025. }
  16026. var status string
  16027. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16028. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16029. var token string
  16030. var res ResultTwo //1101结果
  16031. var res10265 ResultTwo10265 //1101结果
  16032. var card_info string //卡信息
  16033. var busi_card_info string
  16034. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16035. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16036. if status == "0" { //读卡成功
  16037. if card_type == "1" {
  16038. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16039. result, _ := json.Marshal(respJSON)
  16040. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16041. utils.ErrorLog("解析失败:%v", err)
  16042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16043. return
  16044. }
  16045. res.ErrMsg = res10265.ErrMsg
  16046. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16047. res.Infcode = infocode
  16048. res.Output = res10265.Output
  16049. res.InfRefmsgid = res10265.InfRefmsgid
  16050. } else {
  16051. //var card_info string //卡信息
  16052. //var busi_card_info string
  16053. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16054. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16055. //fmt.Println(card_info)
  16056. //fmt.Println(busi_card_info)
  16057. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16058. result, _ := json.Marshal(respJSON)
  16059. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16060. utils.ErrorLog("解析失败:%v", err)
  16061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16062. return
  16063. }
  16064. res.ErrMsg = res10265.ErrMsg
  16065. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16066. res.Infcode = infocode
  16067. res.Output = res10265.Output
  16068. res.InfRefmsgid = res10265.InfRefmsgid
  16069. }
  16070. if res.Infcode == 0 {
  16071. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16072. if err == gorm.ErrRecordNotFound {
  16073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16074. return
  16075. } else if err != nil {
  16076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16077. return
  16078. } else {
  16079. if card_type == "1" {
  16080. bas := strings.Split(card_info, "|")
  16081. basNumber := bas[2]
  16082. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16083. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16084. infoStr := string(Iinfos)
  16085. idetinfoStr := string(Idetinfos)
  16086. psn := &models.HisPsn{
  16087. PsnNo: res.Output.Baseinfo.PsnNo,
  16088. PatientId: patient.ID,
  16089. Certno: res.Output.Baseinfo.Certno,
  16090. //Brdy: res.Output.Baseinfo.Brdy,
  16091. Gend: res.Output.Baseinfo.Gend,
  16092. Naty: res.Output.Baseinfo.Naty,
  16093. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16094. PsnName: res.Output.Baseinfo.PsnName,
  16095. Idetinfo: idetinfoStr,
  16096. Insuinfo: infoStr,
  16097. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16098. CardInfo: card_info,
  16099. VerifyNumber: busi_card_info,
  16100. }
  16101. service.CreateHisPsn(psn)
  16102. c.ServeSuccessJSON(map[string]interface{}{
  16103. "patient": patient,
  16104. "number": basNumber,
  16105. })
  16106. } else {
  16107. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16108. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16109. infoStr := string(Iinfos)
  16110. idetinfoStr := string(Idetinfos)
  16111. psn := &models.HisPsn{
  16112. PsnNo: res.Output.Baseinfo.PsnNo,
  16113. PatientId: patient.ID,
  16114. Certno: res.Output.Baseinfo.Certno,
  16115. Gend: res.Output.Baseinfo.Gend,
  16116. Naty: res.Output.Baseinfo.Naty,
  16117. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16118. PsnName: res.Output.Baseinfo.PsnName,
  16119. Idetinfo: idetinfoStr,
  16120. Insuinfo: infoStr,
  16121. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16122. CardInfo: card_info,
  16123. VerifyNumber: token,
  16124. }
  16125. service.CreateHisPsn(psn)
  16126. var rf []*ResultFive
  16127. json.Unmarshal([]byte(infoStr), &rf)
  16128. var insutypes []*ResultFive
  16129. var insutype string
  16130. var is390 int = 0
  16131. var is310 int = 0
  16132. for _, item := range rf {
  16133. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16134. insutypes = append(insutypes, item)
  16135. }
  16136. }
  16137. if len(insutypes) == 1 {
  16138. insutype = insutypes[0].Insutype
  16139. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16140. } else {
  16141. for _, i := range insutypes {
  16142. if i.Insutype == "390" {
  16143. is390 = 1
  16144. }
  16145. if i.Insutype == "310" {
  16146. is310 = 1
  16147. }
  16148. }
  16149. }
  16150. if is390 == 1 {
  16151. insutype = "390"
  16152. }
  16153. if is310 == 1 {
  16154. insutype = "310"
  16155. }
  16156. if len(insutypes) == 0 {
  16157. insutype = "310"
  16158. }
  16159. c.ServeSuccessJSON(map[string]interface{}{
  16160. "patient": patient,
  16161. "number": token,
  16162. "insutype": insutype,
  16163. })
  16164. }
  16165. }
  16166. } else {
  16167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16168. return
  16169. }
  16170. } else { //读卡失败
  16171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16172. return
  16173. }
  16174. }
  16175. break
  16176. case 4:
  16177. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16178. var api string
  16179. if miConfig.MdtrtareaAdmvs == "320830" {
  16180. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16181. "&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
  16182. fmt.Println(api)
  16183. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16184. 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 +
  16185. "&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
  16186. fmt.Println(api)
  16187. } else {
  16188. 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 +
  16189. "&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)
  16190. }
  16191. resp, requestErr := http.Get(api)
  16192. if requestErr != nil {
  16193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16194. return
  16195. }
  16196. body, ioErr := ioutil.ReadAll(resp.Body)
  16197. if ioErr != nil {
  16198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16200. return
  16201. }
  16202. var respJSON map[string]interface{}
  16203. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16206. return
  16207. }
  16208. var status string
  16209. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16210. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16211. var token string
  16212. var res ResultTwo //1101结果
  16213. var res10265 ResultTwo10265 //1101结果
  16214. if status == "0" { //读卡成功
  16215. var card_info string //卡信息
  16216. var busi_card_info string
  16217. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16218. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16219. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16220. fmt.Println(card_info)
  16221. fmt.Println(busi_card_info)
  16222. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16223. result, _ := json.Marshal(respJSON)
  16224. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16225. utils.ErrorLog("解析失败:%v", err)
  16226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16227. return
  16228. }
  16229. res.ErrMsg = res10265.ErrMsg
  16230. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16231. res.Infcode = infocode
  16232. res.Output = res10265.Output
  16233. res.InfRefmsgid = res10265.InfRefmsgid
  16234. if res.Infcode == 0 {
  16235. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16236. if err == gorm.ErrRecordNotFound {
  16237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16238. return
  16239. } else if err != nil {
  16240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16241. return
  16242. } else {
  16243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16245. infoStr := string(Iinfos)
  16246. idetinfoStr := string(Idetinfos)
  16247. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16248. psn := &models.HisPsn{
  16249. PsnNo: res.Output.Baseinfo.PsnNo,
  16250. PatientId: patient.ID,
  16251. Certno: res.Output.Baseinfo.Certno,
  16252. Brdy: b,
  16253. Age: float64(age),
  16254. //Brdy: res.Output.Baseinfo.Brdy,
  16255. Gend: res.Output.Baseinfo.Gend,
  16256. Naty: res.Output.Baseinfo.Naty,
  16257. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16258. PsnName: res.Output.Baseinfo.PsnName,
  16259. Idetinfo: idetinfoStr,
  16260. Insuinfo: infoStr,
  16261. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16262. CardInfo: card_info,
  16263. VerifyNumber: token,
  16264. }
  16265. var rf []*ResultFive
  16266. json.Unmarshal([]byte(infoStr), &rf)
  16267. var insutypes []*ResultFive
  16268. var insutype string
  16269. var is390 int = 0
  16270. var is310 int = 0
  16271. for _, item := range rf {
  16272. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16273. insutypes = append(insutypes, item)
  16274. }
  16275. }
  16276. if len(insutypes) == 1 {
  16277. insutype = insutypes[0].Insutype
  16278. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16279. } else {
  16280. for _, i := range insutypes {
  16281. if i.Insutype == "390" {
  16282. is390 = 1
  16283. }
  16284. if i.Insutype == "310" {
  16285. is310 = 1
  16286. }
  16287. }
  16288. }
  16289. if is390 == 1 {
  16290. insutype = "390"
  16291. }
  16292. if is310 == 1 {
  16293. insutype = "310"
  16294. }
  16295. if len(insutypes) == 0 {
  16296. insutype = "310"
  16297. }
  16298. service.CreateHisPsn(psn)
  16299. c.ServeSuccessJSON(map[string]interface{}{
  16300. "patient": patient,
  16301. "number": token,
  16302. "insutype": insutype,
  16303. })
  16304. }
  16305. } else {
  16306. c.ServeSuccessJSON(map[string]interface{}{
  16307. "failed_code": -10,
  16308. "msg": res.ErrMsg,
  16309. })
  16310. }
  16311. } else { //读卡失败
  16312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16313. return
  16314. }
  16315. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16316. var api string
  16317. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16318. "&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
  16319. resp, requestErr := http.Get(api)
  16320. if requestErr != nil {
  16321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16322. return
  16323. }
  16324. body, ioErr := ioutil.ReadAll(resp.Body)
  16325. if ioErr != nil {
  16326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16328. return
  16329. }
  16330. var respJSON map[string]interface{}
  16331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16334. return
  16335. }
  16336. var status string
  16337. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16338. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16339. var token string
  16340. var res ResultTwo //1101结果
  16341. if status == "1" { //读卡成功
  16342. var card_info string //卡信息
  16343. var busi_card_info string
  16344. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16345. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16346. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16347. fmt.Println(card_info)
  16348. fmt.Println(busi_card_info)
  16349. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16350. result, _ := json.Marshal(respJSON)
  16351. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16352. utils.ErrorLog("解析失败:%v", err)
  16353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16354. return
  16355. }
  16356. if res.Infcode == 0 {
  16357. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16358. if err == gorm.ErrRecordNotFound {
  16359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16360. return
  16361. } else if err != nil {
  16362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16363. return
  16364. } else {
  16365. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16366. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16367. infoStr := string(Iinfos)
  16368. idetinfoStr := string(Idetinfos)
  16369. psn := &models.HisPsn{
  16370. PsnNo: res.Output.Baseinfo.PsnNo,
  16371. PatientId: patient.ID,
  16372. Certno: res.Output.Baseinfo.Certno,
  16373. Gend: res.Output.Baseinfo.Gend,
  16374. Naty: res.Output.Baseinfo.Naty,
  16375. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16376. PsnName: res.Output.Baseinfo.PsnName,
  16377. Idetinfo: idetinfoStr,
  16378. Insuinfo: infoStr,
  16379. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16380. CardInfo: card_info,
  16381. VerifyNumber: token,
  16382. }
  16383. var rf []*ResultFive
  16384. json.Unmarshal([]byte(infoStr), &rf)
  16385. var insutypes []*ResultFive
  16386. var insutype string
  16387. var is390 int = 0
  16388. var is310 int = 0
  16389. for _, item := range rf {
  16390. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16391. insutypes = append(insutypes, item)
  16392. }
  16393. }
  16394. if len(insutypes) == 1 {
  16395. insutype = insutypes[0].Insutype
  16396. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16397. } else {
  16398. for _, i := range insutypes {
  16399. if i.Insutype == "390" {
  16400. is390 = 1
  16401. }
  16402. if i.Insutype == "310" {
  16403. is310 = 1
  16404. }
  16405. }
  16406. }
  16407. if is390 == 1 {
  16408. insutype = "390"
  16409. }
  16410. if is310 == 1 {
  16411. insutype = "310"
  16412. }
  16413. if len(insutypes) == 0 {
  16414. insutype = "310"
  16415. }
  16416. service.CreateHisPsn(psn)
  16417. c.ServeSuccessJSON(map[string]interface{}{
  16418. "patient": patient,
  16419. "number": token,
  16420. "insutype": insutype,
  16421. })
  16422. }
  16423. } else {
  16424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16425. return
  16426. }
  16427. } else { //读卡失败
  16428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16429. return
  16430. }
  16431. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16432. var api string
  16433. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16434. "&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
  16435. resp, requestErr := http.Get(api)
  16436. if requestErr != nil {
  16437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16438. return
  16439. }
  16440. body, ioErr := ioutil.ReadAll(resp.Body)
  16441. if ioErr != nil {
  16442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16444. return
  16445. }
  16446. var respJSON map[string]interface{}
  16447. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16450. return
  16451. }
  16452. var status string
  16453. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16454. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16455. var token string
  16456. var res ResultTwo //1101结果
  16457. if status == "1" { //读卡成功
  16458. var card_info string //卡信息
  16459. var busi_card_info string
  16460. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16461. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16462. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16463. fmt.Println(card_info)
  16464. fmt.Println(busi_card_info)
  16465. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16466. result, _ := json.Marshal(respJSON)
  16467. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16468. utils.ErrorLog("解析失败:%v", err)
  16469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16470. return
  16471. }
  16472. if res.Infcode == 0 {
  16473. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16474. if err == gorm.ErrRecordNotFound {
  16475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16476. return
  16477. } else if err != nil {
  16478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16479. return
  16480. } else {
  16481. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16482. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16483. infoStr := string(Iinfos)
  16484. idetinfoStr := string(Idetinfos)
  16485. psn := &models.HisPsn{
  16486. PsnNo: res.Output.Baseinfo.PsnNo,
  16487. PatientId: patient.ID,
  16488. Certno: res.Output.Baseinfo.Certno,
  16489. Gend: res.Output.Baseinfo.Gend,
  16490. Naty: res.Output.Baseinfo.Naty,
  16491. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16492. PsnName: res.Output.Baseinfo.PsnName,
  16493. Idetinfo: idetinfoStr,
  16494. Insuinfo: infoStr,
  16495. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16496. CardInfo: card_info,
  16497. VerifyNumber: token,
  16498. }
  16499. var rf []*ResultFive
  16500. json.Unmarshal([]byte(infoStr), &rf)
  16501. var insutypes []*ResultFive
  16502. var insutype string
  16503. var is390 int = 0
  16504. var is310 int = 0
  16505. for _, item := range rf {
  16506. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16507. insutypes = append(insutypes, item)
  16508. }
  16509. }
  16510. if len(insutypes) == 1 {
  16511. insutype = insutypes[0].Insutype
  16512. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16513. } else {
  16514. for _, i := range insutypes {
  16515. if i.Insutype == "390" {
  16516. is390 = 1
  16517. }
  16518. if i.Insutype == "310" {
  16519. is310 = 1
  16520. }
  16521. }
  16522. }
  16523. if is390 == 1 {
  16524. insutype = "390"
  16525. }
  16526. if is310 == 1 {
  16527. insutype = "310"
  16528. }
  16529. if len(insutypes) == 0 {
  16530. insutype = "390"
  16531. }
  16532. service.CreateHisPsn(psn)
  16533. c.ServeSuccessJSON(map[string]interface{}{
  16534. "patient": patient,
  16535. "number": token,
  16536. "insutype": insutype,
  16537. })
  16538. }
  16539. } else {
  16540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16541. return
  16542. }
  16543. } else { //读卡失败
  16544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16545. return
  16546. }
  16547. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16548. //idNo := c.GetString("idNo")
  16549. //userName := c.GetString("userName")
  16550. //ecToken := c.GetString("ecToken")
  16551. //insuOrg := c.GetString("insuOrg")
  16552. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16553. utils.ErrorLog("解析失败:%v", json_result)
  16554. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16555. type ELeData struct {
  16556. Data struct {
  16557. IdNo string `json:"idNo"`
  16558. IdType string `json:"idType"`
  16559. UserName string `json:"userName"`
  16560. EcToken string `json:"ecToken"`
  16561. InsuOrg string `json:"insuOrg"`
  16562. Gender string `json:"gender"`
  16563. Birthday string `json:"birthday"`
  16564. Nationality string `json:"nationality"`
  16565. Email string `json:"email"`
  16566. Extra string `json:"extra"`
  16567. } `json:"data"`
  16568. Code int `json:"code"`
  16569. Message string `json:"message"`
  16570. }
  16571. var ele ELeData
  16572. err := json.Unmarshal([]byte(json_result), &ele)
  16573. if err != nil {
  16574. utils.ErrorLog("解析失败:%v", err)
  16575. }
  16576. token := ele.Data.EcToken
  16577. token = Remove0000(token)
  16578. 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)
  16579. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16580. var res ResultTwo
  16581. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16582. utils.ErrorLog("解析失败:%v", err)
  16583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16584. return
  16585. }
  16586. if res.Infcode == 0 {
  16587. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16588. if err == gorm.ErrRecordNotFound {
  16589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16590. return
  16591. } else if err != nil {
  16592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16593. return
  16594. } else {
  16595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16597. infoStr := string(Iinfos)
  16598. idetinfoStr := string(Idetinfos)
  16599. psn := &models.HisPsn{
  16600. PsnNo: res.Output.Baseinfo.PsnNo,
  16601. PatientId: patient.ID,
  16602. Certno: res.Output.Baseinfo.Certno,
  16603. Gend: res.Output.Baseinfo.Gend,
  16604. Naty: res.Output.Baseinfo.Naty,
  16605. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16606. PsnName: res.Output.Baseinfo.PsnName,
  16607. Idetinfo: idetinfoStr,
  16608. Insuinfo: infoStr,
  16609. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16610. CardInfo: "",
  16611. Stage: "1",
  16612. VerifyNumber: token,
  16613. InsuplcAdmdvs: ele.Data.InsuOrg,
  16614. }
  16615. service.CreateHisPsn(psn)
  16616. var rf []*ResultFive
  16617. json.Unmarshal([]byte(infoStr), &rf)
  16618. var insutypes []*ResultFive
  16619. var insutype string
  16620. var is390 int = 0
  16621. var is310 int = 0
  16622. for _, item := range rf {
  16623. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16624. insutypes = append(insutypes, item)
  16625. }
  16626. }
  16627. if len(insutypes) == 1 {
  16628. insutype = insutypes[0].Insutype
  16629. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16630. } else {
  16631. for _, i := range insutypes {
  16632. if i.Insutype == "390" {
  16633. is390 = 1
  16634. }
  16635. if i.Insutype == "310" {
  16636. is310 = 1
  16637. }
  16638. }
  16639. }
  16640. if is390 == 1 {
  16641. insutype = "390"
  16642. }
  16643. if is310 == 1 {
  16644. insutype = "310"
  16645. }
  16646. if len(insutypes) == 0 {
  16647. insutype = "310"
  16648. }
  16649. c.ServeSuccessJSON(map[string]interface{}{
  16650. "patient": patient,
  16651. "number": token,
  16652. "insutype": insutype,
  16653. })
  16654. }
  16655. } else {
  16656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16657. return
  16658. }
  16659. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16660. //if initFlag == 0 {
  16661. //c.TestGetJiangXiBasBaseInit()
  16662. //}
  16663. //if initEleFlag == 0 {
  16664. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16665. //}
  16666. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16667. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16668. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16669. type ELeData struct {
  16670. Data struct {
  16671. IdNo string `json:"idNo"`
  16672. IdType string `json:"idType"`
  16673. UserName string `json:"userName"`
  16674. EcToken string `json:"ecToken"`
  16675. InsuOrg string `json:"insuOrg"`
  16676. Gender string `json:"gender"`
  16677. Birthday string `json:"birthday"`
  16678. Nationality string `json:"nationality"`
  16679. Email string `json:"email"`
  16680. Extra string `json:"extra"`
  16681. } `json:"data"`
  16682. Code int `json:"code"`
  16683. Message string `json:"message"`
  16684. }
  16685. var ele ELeData
  16686. err := json.Unmarshal([]byte(result), &ele)
  16687. if err != nil {
  16688. utils.ErrorLog("解析失败:%v", err)
  16689. }
  16690. token := ele.Data.EcToken
  16691. token = Remove0000(token)
  16692. 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)
  16693. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16694. var res ResultTwo
  16695. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16696. utils.ErrorLog("解析失败:%v", err)
  16697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16698. return
  16699. }
  16700. if res.Infcode == 0 {
  16701. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16702. if err == gorm.ErrRecordNotFound {
  16703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16704. return
  16705. } else if err != nil {
  16706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16707. return
  16708. } else {
  16709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16711. infoStr := string(Iinfos)
  16712. idetinfoStr := string(Idetinfos)
  16713. psn := &models.HisPsn{
  16714. PsnNo: res.Output.Baseinfo.PsnNo,
  16715. PatientId: patient.ID,
  16716. Certno: res.Output.Baseinfo.Certno,
  16717. Gend: res.Output.Baseinfo.Gend,
  16718. Naty: res.Output.Baseinfo.Naty,
  16719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16720. PsnName: res.Output.Baseinfo.PsnName,
  16721. Idetinfo: idetinfoStr,
  16722. Insuinfo: infoStr,
  16723. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16724. CardInfo: "",
  16725. VerifyNumber: token,
  16726. InsuplcAdmdvs: ele.Data.InsuOrg,
  16727. }
  16728. service.CreateHisPsn(psn)
  16729. var rf []*ResultFive
  16730. json.Unmarshal([]byte(infoStr), &rf)
  16731. var insutypes []*ResultFive
  16732. var insutype string
  16733. var is390 int = 0
  16734. var is310 int = 0
  16735. for _, item := range rf {
  16736. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16737. insutypes = append(insutypes, item)
  16738. }
  16739. }
  16740. if len(insutypes) == 1 {
  16741. insutype = insutypes[0].Insutype
  16742. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16743. } else {
  16744. for _, i := range insutypes {
  16745. if i.Insutype == "390" {
  16746. is390 = 1
  16747. }
  16748. if i.Insutype == "310" {
  16749. is310 = 1
  16750. }
  16751. }
  16752. }
  16753. if is390 == 1 {
  16754. insutype = "390"
  16755. }
  16756. if is310 == 1 {
  16757. insutype = "310"
  16758. }
  16759. if len(insutypes) == 0 {
  16760. insutype = "310"
  16761. }
  16762. c.ServeSuccessJSON(map[string]interface{}{
  16763. "patient": patient,
  16764. "number": token,
  16765. "insutype": insutype,
  16766. })
  16767. }
  16768. } else {
  16769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16770. return
  16771. }
  16772. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16773. //if initFlag == 0 {
  16774. //c.TestGetJiangXiBasBaseInit()
  16775. //}
  16776. //if initEleFlag == 0 {
  16777. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16778. //}
  16779. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16780. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16781. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16782. type ELeData struct {
  16783. Data struct {
  16784. IdNo string `json:"idNo"`
  16785. IdType string `json:"idType"`
  16786. UserName string `json:"userName"`
  16787. EcToken string `json:"ecToken"`
  16788. InsuOrg string `json:"insuOrg"`
  16789. Gender string `json:"gender"`
  16790. Birthday string `json:"birthday"`
  16791. Nationality string `json:"nationality"`
  16792. Email string `json:"email"`
  16793. Extra string `json:"extra"`
  16794. } `json:"data"`
  16795. Code int `json:"code"`
  16796. Message string `json:"message"`
  16797. }
  16798. var ele ELeData
  16799. err := json.Unmarshal([]byte(result), &ele)
  16800. if err != nil {
  16801. utils.ErrorLog("解析失败:%v", err)
  16802. }
  16803. token := ele.Data.EcToken
  16804. token = Remove0000(token)
  16805. 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)
  16806. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16807. var res ResultTwo
  16808. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16809. utils.ErrorLog("解析失败:%v", err)
  16810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16811. return
  16812. }
  16813. if res.Infcode == 0 {
  16814. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16815. if err == gorm.ErrRecordNotFound {
  16816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16817. return
  16818. } else if err != nil {
  16819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16820. return
  16821. } else {
  16822. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16823. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16824. infoStr := string(Iinfos)
  16825. idetinfoStr := string(Idetinfos)
  16826. psn := &models.HisPsn{
  16827. PsnNo: res.Output.Baseinfo.PsnNo,
  16828. PatientId: patient.ID,
  16829. Certno: res.Output.Baseinfo.Certno,
  16830. Gend: res.Output.Baseinfo.Gend,
  16831. Naty: res.Output.Baseinfo.Naty,
  16832. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16833. PsnName: res.Output.Baseinfo.PsnName,
  16834. Idetinfo: idetinfoStr,
  16835. Insuinfo: infoStr,
  16836. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16837. CardInfo: "",
  16838. VerifyNumber: token,
  16839. InsuplcAdmdvs: ele.Data.InsuOrg,
  16840. }
  16841. service.CreateHisPsn(psn)
  16842. var rf []*ResultFive
  16843. json.Unmarshal([]byte(infoStr), &rf)
  16844. var insutypes []*ResultFive
  16845. var insutype string
  16846. var is390 int = 0
  16847. var is310 int = 0
  16848. for _, item := range rf {
  16849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16850. insutypes = append(insutypes, item)
  16851. }
  16852. }
  16853. if len(insutypes) == 1 {
  16854. insutype = insutypes[0].Insutype
  16855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16856. } else {
  16857. for _, i := range insutypes {
  16858. if i.Insutype == "390" {
  16859. is390 = 1
  16860. }
  16861. if i.Insutype == "310" {
  16862. is310 = 1
  16863. }
  16864. }
  16865. }
  16866. if is390 == 1 {
  16867. insutype = "390"
  16868. }
  16869. if is310 == 1 {
  16870. insutype = "310"
  16871. }
  16872. if len(insutypes) == 0 {
  16873. insutype = "310"
  16874. }
  16875. c.ServeSuccessJSON(map[string]interface{}{
  16876. "patient": patient,
  16877. "number": token,
  16878. "insutype": insutype,
  16879. })
  16880. }
  16881. } else {
  16882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16883. return
  16884. }
  16885. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16886. //if initFlag == 0 {
  16887. //c.TestGetJiangXiBasBaseInit()
  16888. //}
  16889. //if initEleFlag == 0 {
  16890. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16891. //}
  16892. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16893. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16894. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16895. type ELeData struct {
  16896. Data struct {
  16897. IdNo string `json:"idNo"`
  16898. IdType string `json:"idType"`
  16899. UserName string `json:"userName"`
  16900. EcToken string `json:"ecToken"`
  16901. InsuOrg string `json:"insuOrg"`
  16902. Gender string `json:"gender"`
  16903. Birthday string `json:"birthday"`
  16904. Nationality string `json:"nationality"`
  16905. Email string `json:"email"`
  16906. Extra string `json:"extra"`
  16907. } `json:"data"`
  16908. Code int `json:"code"`
  16909. Message string `json:"message"`
  16910. }
  16911. var ele ELeData
  16912. err := json.Unmarshal([]byte(result), &ele)
  16913. if err != nil {
  16914. utils.ErrorLog("解析失败:%v", err)
  16915. }
  16916. token := ele.Data.EcToken
  16917. token = Remove0000(token)
  16918. 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)
  16919. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16920. var res ResultTwo
  16921. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16922. utils.ErrorLog("解析失败:%v", err)
  16923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16924. return
  16925. }
  16926. if res.Infcode == 0 {
  16927. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16928. if err == gorm.ErrRecordNotFound {
  16929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16930. return
  16931. } else if err != nil {
  16932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16933. return
  16934. } else {
  16935. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16936. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16937. infoStr := string(Iinfos)
  16938. idetinfoStr := string(Idetinfos)
  16939. psn := &models.HisPsn{
  16940. PsnNo: res.Output.Baseinfo.PsnNo,
  16941. PatientId: patient.ID,
  16942. Certno: res.Output.Baseinfo.Certno,
  16943. Gend: res.Output.Baseinfo.Gend,
  16944. Naty: res.Output.Baseinfo.Naty,
  16945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16946. PsnName: res.Output.Baseinfo.PsnName,
  16947. Idetinfo: idetinfoStr,
  16948. Insuinfo: infoStr,
  16949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16950. CardInfo: "",
  16951. VerifyNumber: token,
  16952. InsuplcAdmdvs: ele.Data.InsuOrg,
  16953. }
  16954. service.CreateHisPsn(psn)
  16955. var rf []*ResultFive
  16956. json.Unmarshal([]byte(infoStr), &rf)
  16957. var insutypes []*ResultFive
  16958. var insutype string
  16959. var is390 int = 0
  16960. var is310 int = 0
  16961. for _, item := range rf {
  16962. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16963. insutypes = append(insutypes, item)
  16964. }
  16965. }
  16966. if len(insutypes) == 1 {
  16967. insutype = insutypes[0].Insutype
  16968. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16969. } else {
  16970. for _, i := range insutypes {
  16971. if i.Insutype == "390" {
  16972. is390 = 1
  16973. }
  16974. if i.Insutype == "310" {
  16975. is310 = 1
  16976. }
  16977. }
  16978. }
  16979. if is390 == 1 {
  16980. insutype = "390"
  16981. }
  16982. if is310 == 1 {
  16983. insutype = "310"
  16984. }
  16985. if len(insutypes) == 0 {
  16986. insutype = "310"
  16987. }
  16988. c.ServeSuccessJSON(map[string]interface{}{
  16989. "patient": patient,
  16990. "number": token,
  16991. "insutype": insutype,
  16992. })
  16993. }
  16994. } else {
  16995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16996. return
  16997. }
  16998. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16999. //if initFlag == 0 {
  17000. c.TestGetJiangXiBasBaseInit()
  17001. //}
  17002. //if initEleFlag == 0 {
  17003. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17004. //}
  17005. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17006. type ELeData struct {
  17007. Data struct {
  17008. IdNo string `json:"idNo"`
  17009. IdType string `json:"idType"`
  17010. UserName string `json:"userName"`
  17011. EcToken string `json:"ecToken"`
  17012. InsuOrg string `json:"insuOrg"`
  17013. Gender string `json:"gender"`
  17014. Birthday string `json:"birthday"`
  17015. Nationality string `json:"nationality"`
  17016. Email string `json:"email"`
  17017. Extra string `json:"extra"`
  17018. } `json:"data"`
  17019. Code int `json:"code"`
  17020. Message string `json:"message"`
  17021. }
  17022. var ele ELeData
  17023. err := json.Unmarshal([]byte(json_result), &ele)
  17024. if err != nil {
  17025. utils.ErrorLog("解析失败:%v", err)
  17026. }
  17027. token := ele.Data.EcToken
  17028. token = Remove0000(token)
  17029. 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)
  17030. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17031. var res ResultTwo
  17032. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17033. utils.ErrorLog("解析失败:%v", err)
  17034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17035. return
  17036. }
  17037. if res.Infcode == 0 {
  17038. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17039. if err == gorm.ErrRecordNotFound {
  17040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17041. return
  17042. } else if err != nil {
  17043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17044. return
  17045. } else {
  17046. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17047. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17048. infoStr := string(Iinfos)
  17049. idetinfoStr := string(Idetinfos)
  17050. psn := &models.HisPsn{
  17051. PsnNo: res.Output.Baseinfo.PsnNo,
  17052. PatientId: patient.ID,
  17053. Certno: res.Output.Baseinfo.Certno,
  17054. Gend: res.Output.Baseinfo.Gend,
  17055. Naty: res.Output.Baseinfo.Naty,
  17056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17057. PsnName: res.Output.Baseinfo.PsnName,
  17058. Idetinfo: idetinfoStr,
  17059. Insuinfo: infoStr,
  17060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17061. CardInfo: "",
  17062. VerifyNumber: token,
  17063. }
  17064. service.CreateHisPsn(psn)
  17065. var rf []*ResultFive
  17066. json.Unmarshal([]byte(infoStr), &rf)
  17067. var insutypes []*ResultFive
  17068. var insutype string
  17069. var is390 int = 0
  17070. var is310 int = 0
  17071. for _, item := range rf {
  17072. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17073. insutypes = append(insutypes, item)
  17074. }
  17075. }
  17076. if len(insutypes) == 1 {
  17077. insutype = insutypes[0].Insutype
  17078. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17079. } else {
  17080. for _, i := range insutypes {
  17081. if i.Insutype == "390" {
  17082. is390 = 1
  17083. }
  17084. if i.Insutype == "310" {
  17085. is310 = 1
  17086. }
  17087. }
  17088. }
  17089. if is390 == 1 {
  17090. insutype = "390"
  17091. }
  17092. if is310 == 1 {
  17093. insutype = "310"
  17094. }
  17095. if len(insutypes) == 0 {
  17096. insutype = "310"
  17097. }
  17098. c.ServeSuccessJSON(map[string]interface{}{
  17099. "patient": patient,
  17100. "number": token,
  17101. "insutype": insutype,
  17102. })
  17103. }
  17104. } else {
  17105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17106. return
  17107. }
  17108. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17109. type ELeData struct {
  17110. Code string `json:"code"`
  17111. Data struct {
  17112. Aac002 string `json:"aac002"`
  17113. Aaz500 string `json:"aaz500"`
  17114. ActCardNo string `json:"actCardNo"`
  17115. Bab520 string `json:"bab520"`
  17116. Bkz543 string `json:"bkz543"`
  17117. BusinessType string `json:"businessType"`
  17118. CertfCodg string `json:"certfCodg"`
  17119. EcIndexNo string `json:"ecIndexNo"`
  17120. EcToken string `json:"ecToken"`
  17121. ID0000 string `json:"id0000"`
  17122. IDNo string `json:"idNo"`
  17123. IDType string `json:"idType"`
  17124. Idcode string `json:"idcode"`
  17125. IdentityToken string `json:"identity_token"`
  17126. InsuOrg string `json:"insuOrg"`
  17127. OfficeID string `json:"officeId"`
  17128. OfficeName string `json:"officeName"`
  17129. OperatorID string `json:"operatorId"`
  17130. OperatorName string `json:"operatorName"`
  17131. OrgID string `json:"orgId"`
  17132. UserName string `json:"userName"`
  17133. } `json:"data"`
  17134. Infno interface{} `json:"infno"`
  17135. Message string `json:"message"`
  17136. OrgID string `json:"orgId"`
  17137. TransType string `json:"transType"`
  17138. }
  17139. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17140. outPutInfo = Remove0000(outPutInfo)
  17141. if len(outPutInfo) > 0 {
  17142. var ele ELeData
  17143. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17144. if err != nil {
  17145. utils.ErrorLog("解析失败:%v", err)
  17146. }
  17147. token := ele.Data.EcToken
  17148. fmt.Println(inputInfo)
  17149. fmt.Println(outPutInfo)
  17150. 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)
  17151. saveLog(result, requestLog, "1101", "获取人员信息")
  17152. var dat map[string]interface{}
  17153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17154. fmt.Println(dat)
  17155. } else {
  17156. fmt.Println(err)
  17157. }
  17158. userJSONBytes, _ := json.Marshal(dat)
  17159. var res ResultTwo
  17160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17161. utils.ErrorLog("解析失败:%v", err)
  17162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17163. return
  17164. }
  17165. res.ErrMsg = errMsgLog
  17166. if res.Infcode == 0 {
  17167. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17168. if err == gorm.ErrRecordNotFound {
  17169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17170. return
  17171. } else if err != nil {
  17172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17173. return
  17174. } else {
  17175. fmt.Println(res)
  17176. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17177. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17178. infoStr := string(Iinfos)
  17179. idetinfoStr := string(Idetinfos)
  17180. psn := &models.HisPsn{
  17181. PsnNo: res.Output.Baseinfo.PsnNo,
  17182. PatientId: patient.ID,
  17183. Certno: res.Output.Baseinfo.Certno,
  17184. Gend: res.Output.Baseinfo.Gend,
  17185. Naty: res.Output.Baseinfo.Naty,
  17186. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17187. PsnName: res.Output.Baseinfo.PsnName,
  17188. Idetinfo: idetinfoStr,
  17189. Insuinfo: infoStr,
  17190. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17191. CardInfo: outPutInfo,
  17192. VerifyNumber: token,
  17193. InsuplcAdmdvs: ele.Data.InsuOrg,
  17194. }
  17195. service.CreateHisPsn(psn)
  17196. var rf []*ResultFive
  17197. json.Unmarshal([]byte(infoStr), &rf)
  17198. var insutypes []*ResultFive
  17199. var insutype string
  17200. var is390 int = 0
  17201. var is310 int = 0
  17202. for _, item := range rf {
  17203. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17204. insutypes = append(insutypes, item)
  17205. }
  17206. }
  17207. if len(insutypes) == 1 {
  17208. insutype = insutypes[0].Insutype
  17209. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17210. } else {
  17211. for _, i := range insutypes {
  17212. if i.Insutype == "390" {
  17213. is390 = 1
  17214. }
  17215. if i.Insutype == "310" {
  17216. is310 = 1
  17217. }
  17218. }
  17219. }
  17220. if is390 == 1 {
  17221. insutype = "390"
  17222. }
  17223. if is310 == 1 {
  17224. insutype = "310"
  17225. }
  17226. if len(insutypes) == 0 {
  17227. insutype = "310"
  17228. }
  17229. c.ServeSuccessJSON(map[string]interface{}{
  17230. "patient": patient,
  17231. "number": token,
  17232. "insutype": insutype,
  17233. })
  17234. }
  17235. } else {
  17236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17237. return
  17238. }
  17239. }
  17240. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17241. var api string
  17242. 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 +
  17243. "&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
  17244. resp, requestErr := http.Get(api)
  17245. if requestErr != nil {
  17246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17247. return
  17248. }
  17249. body, ioErr := ioutil.ReadAll(resp.Body)
  17250. if ioErr != nil {
  17251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17253. return
  17254. }
  17255. var respJSON map[string]interface{}
  17256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17259. return
  17260. }
  17261. var status string
  17262. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17263. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17264. var token string
  17265. var res ResultTwo //1101结果
  17266. var res10265 ResultTwo10265 //1101结果
  17267. if status == "0" { //读卡成功
  17268. var card_info string //卡信息
  17269. var busi_card_info string
  17270. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17271. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17272. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17273. fmt.Println(card_info)
  17274. fmt.Println(busi_card_info)
  17275. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17276. result, _ := json.Marshal(respJSON)
  17277. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17278. utils.ErrorLog("解析失败:%v", err)
  17279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17280. return
  17281. }
  17282. res.ErrMsg = res10265.ErrMsg
  17283. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17284. res.Infcode = infocode
  17285. res.Output = res10265.Output
  17286. res.InfRefmsgid = res10265.InfRefmsgid
  17287. if res.Infcode == 0 {
  17288. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17289. if err == gorm.ErrRecordNotFound {
  17290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17291. return
  17292. } else if err != nil {
  17293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17294. return
  17295. } else {
  17296. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17297. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17298. infoStr := string(Iinfos)
  17299. idetinfoStr := string(Idetinfos)
  17300. psn := &models.HisPsn{
  17301. PsnNo: res.Output.Baseinfo.PsnNo,
  17302. PatientId: patient.ID,
  17303. Certno: res.Output.Baseinfo.Certno,
  17304. Gend: res.Output.Baseinfo.Gend,
  17305. Naty: res.Output.Baseinfo.Naty,
  17306. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17307. PsnName: res.Output.Baseinfo.PsnName,
  17308. Idetinfo: idetinfoStr,
  17309. Insuinfo: infoStr,
  17310. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17311. CardInfo: card_info,
  17312. VerifyNumber: token,
  17313. }
  17314. var rf []*ResultFive
  17315. json.Unmarshal([]byte(infoStr), &rf)
  17316. var insutypes []*ResultFive
  17317. var insutype string
  17318. var is390 int = 0
  17319. var is310 int = 0
  17320. for _, item := range rf {
  17321. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17322. insutypes = append(insutypes, item)
  17323. }
  17324. }
  17325. if len(insutypes) == 1 {
  17326. insutype = insutypes[0].Insutype
  17327. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17328. } else {
  17329. for _, i := range insutypes {
  17330. if i.Insutype == "390" {
  17331. is390 = 1
  17332. }
  17333. if i.Insutype == "310" {
  17334. is310 = 1
  17335. }
  17336. }
  17337. }
  17338. if is390 == 1 {
  17339. insutype = "390"
  17340. }
  17341. if is310 == 1 {
  17342. insutype = "310"
  17343. }
  17344. if len(insutypes) == 0 {
  17345. insutype = "310"
  17346. }
  17347. service.CreateHisPsn(psn)
  17348. c.ServeSuccessJSON(map[string]interface{}{
  17349. "patient": patient,
  17350. "number": token,
  17351. "insutype": insutype,
  17352. })
  17353. }
  17354. } else {
  17355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17356. return
  17357. }
  17358. } else { //读卡失败
  17359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17360. return
  17361. }
  17362. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17363. res := c.GetoleInfo()
  17364. if res.Infcode == 0 {
  17365. var result string
  17366. if res.Output.MdtrtCertType == "01" {
  17367. 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)
  17368. } else if res.Output.MdtrtCertType == "02" {
  17369. 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)
  17370. } else if res.Output.MdtrtCertType == "03" {
  17371. 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)
  17372. }
  17373. var dat map[string]interface{}
  17374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17375. fmt.Println(dat)
  17376. } else {
  17377. fmt.Println(err)
  17378. }
  17379. userJSONBytes, _ := json.Marshal(dat)
  17380. var res2 ResultTwo
  17381. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17382. utils.ErrorLog("解析失败:%v", err)
  17383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17384. return
  17385. }
  17386. if res2.Infcode == 0 {
  17387. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17388. if err == gorm.ErrRecordNotFound {
  17389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17390. return
  17391. } else if err != nil {
  17392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17393. return
  17394. } else {
  17395. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17396. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17397. infoStr := string(Iinfos)
  17398. idetinfoStr := string(Idetinfos)
  17399. var rf []*ResultFive
  17400. json.Unmarshal([]byte(infoStr), &rf)
  17401. var insutypes []*ResultFive
  17402. var insutype string
  17403. var is390 int = 0
  17404. var is310 int = 0
  17405. //var insuplc_admdvs string
  17406. for _, item := range rf {
  17407. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17408. insutypes = append(insutypes, item)
  17409. }
  17410. }
  17411. if len(insutypes) == 1 {
  17412. insutype = insutypes[0].Insutype
  17413. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17414. } else {
  17415. for _, i := range insutypes {
  17416. if i.Insutype == "390" {
  17417. is390 = 1
  17418. }
  17419. if i.Insutype == "310" {
  17420. is310 = 1
  17421. }
  17422. }
  17423. }
  17424. if is390 == 1 {
  17425. insutype = "390"
  17426. }
  17427. if is310 == 1 {
  17428. insutype = "310"
  17429. }
  17430. if len(insutypes) == 0 {
  17431. insutype = "310"
  17432. }
  17433. psn := &models.HisPsn{
  17434. PsnNo: res2.Output.Baseinfo.PsnNo,
  17435. PatientId: patient.ID,
  17436. Certno: res2.Output.Baseinfo.Certno,
  17437. Gend: res2.Output.Baseinfo.Gend,
  17438. Naty: res2.Output.Baseinfo.Naty,
  17439. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17440. PsnName: res2.Output.Baseinfo.PsnName,
  17441. Idetinfo: idetinfoStr,
  17442. Insuinfo: infoStr,
  17443. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17444. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17445. VerifyNumber: res.Output.EcToken,
  17446. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17447. }
  17448. if res.Output.MdtrtCertType == "01" {
  17449. psn.VerifyNumber = res.Output.EcToken
  17450. //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)
  17451. } else if res.Output.MdtrtCertType == "02" {
  17452. psn.VerifyNumber = res.Output.CardNo
  17453. //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)
  17454. } else if res.Output.MdtrtCertType == "03" {
  17455. psn.VerifyNumber = res.Output.MdtrtCertNo
  17456. //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)
  17457. }
  17458. service.CreateHisPsn(psn)
  17459. var balc float64
  17460. for _, item := range rf {
  17461. if item.Insutype == insutype {
  17462. balc = item.Balc
  17463. }
  17464. }
  17465. c.ServeSuccessJSON(map[string]interface{}{
  17466. "patient": patient,
  17467. "number": res.Output.CardNo,
  17468. "insutype": insutype,
  17469. "blac": balc,
  17470. "desc": idetinfoStr,
  17471. })
  17472. }
  17473. } else {
  17474. c.ServeSuccessJSON(map[string]interface{}{
  17475. "failed_code": -10,
  17476. "msg": res2.ErrMsg,
  17477. })
  17478. }
  17479. } else {
  17480. c.ServeSuccessJSON(map[string]interface{}{
  17481. "failed_code": -10,
  17482. "msg": res.ErrMsg,
  17483. })
  17484. }
  17485. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17486. var res ResultTwo
  17487. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17488. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17489. "&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)
  17490. resp, requestErr := http.Get(api)
  17491. if requestErr != nil {
  17492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17493. return
  17494. }
  17495. body, ioErr := ioutil.ReadAll(resp.Body)
  17496. if ioErr != nil {
  17497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17499. return
  17500. }
  17501. var respJSON map[string]interface{}
  17502. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17505. return
  17506. }
  17507. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17508. result, _ := json.Marshal(respJSON)
  17509. fmt.Println("log")
  17510. fmt.Println(string(result))
  17511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17512. utils.ErrorLog("解析失败:%v", err)
  17513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17514. return
  17515. }
  17516. if res.Infcode == 0 {
  17517. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17518. if err == gorm.ErrRecordNotFound {
  17519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17520. return
  17521. } else if err != nil {
  17522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17523. return
  17524. } else {
  17525. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17526. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17527. infoStr := string(Iinfos)
  17528. idetinfoStr := string(Idetinfos)
  17529. var rf []*ResultFive
  17530. json.Unmarshal([]byte(infoStr), &rf)
  17531. var insutypes []*ResultFive
  17532. var insutype string
  17533. var is390 int = 0
  17534. var is310 int = 0
  17535. for _, item := range rf {
  17536. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17537. insutypes = append(insutypes, item)
  17538. }
  17539. }
  17540. if len(insutypes) == 1 {
  17541. insutype = insutypes[0].Insutype
  17542. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17543. } else {
  17544. for _, i := range insutypes {
  17545. if i.Insutype == "390" {
  17546. is390 = 1
  17547. }
  17548. if i.Insutype == "310" {
  17549. is310 = 1
  17550. }
  17551. }
  17552. }
  17553. if is390 == 1 {
  17554. insutype = "390"
  17555. }
  17556. if is310 == 1 {
  17557. insutype = "310"
  17558. }
  17559. if len(insutypes) == 0 {
  17560. insutype = "390"
  17561. }
  17562. var insuplc_admdvs string
  17563. for _, item := range rf {
  17564. if item.Insutype == insutype {
  17565. insuplc_admdvs = item.InsuplcAdmdvs
  17566. }
  17567. }
  17568. psn := &models.HisPsn{
  17569. PsnNo: res.Output.Baseinfo.PsnNo,
  17570. PatientId: patient.ID,
  17571. Certno: res.Output.Baseinfo.Certno,
  17572. Gend: res.Output.Baseinfo.Gend,
  17573. Naty: res.Output.Baseinfo.Naty,
  17574. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17575. PsnName: res.Output.Baseinfo.PsnName,
  17576. Idetinfo: idetinfoStr,
  17577. Insuinfo: infoStr,
  17578. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17579. InsuplcAdmdvs: insuplc_admdvs,
  17580. }
  17581. service.CreateHisPsn(psn)
  17582. c.ServeSuccessJSON(map[string]interface{}{
  17583. "patient": patient,
  17584. "number": res.Output.Baseinfo.Certno,
  17585. })
  17586. }
  17587. } else {
  17588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17589. return
  17590. }
  17591. } else {
  17592. type ELeData struct {
  17593. Code string `json:"code"`
  17594. Data struct {
  17595. Aac002 string `json:"aac002"`
  17596. Aaz500 string `json:"aaz500"`
  17597. ActCardNo string `json:"actCardNo"`
  17598. Bab520 string `json:"bab520"`
  17599. Bkz543 string `json:"bkz543"`
  17600. BusinessType string `json:"businessType"`
  17601. CertfCodg string `json:"certfCodg"`
  17602. EcIndexNo string `json:"ecIndexNo"`
  17603. EcToken string `json:"ecToken"`
  17604. ID0000 string `json:"id0000"`
  17605. IDNo string `json:"idNo"`
  17606. IDType string `json:"idType"`
  17607. Idcode string `json:"idcode"`
  17608. IdentityToken string `json:"identity_token"`
  17609. InsuOrg string `json:"insuOrg"`
  17610. OfficeID string `json:"officeId"`
  17611. OfficeName string `json:"officeName"`
  17612. OperatorID string `json:"operatorId"`
  17613. OperatorName string `json:"operatorName"`
  17614. OrgID string `json:"orgId"`
  17615. UserName string `json:"userName"`
  17616. } `json:"data"`
  17617. Infno interface{} `json:"infno"`
  17618. Message string `json:"message"`
  17619. OrgID string `json:"orgId"`
  17620. TransType string `json:"transType"`
  17621. }
  17622. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17623. fmt.Println(result)
  17624. outPutInfo := Remove0000(result)
  17625. fmt.Println(outPutInfo)
  17626. if len(outPutInfo) > 0 {
  17627. var ele ELeData
  17628. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17629. if err != nil {
  17630. utils.ErrorLog("解析失败:%v", err)
  17631. }
  17632. token := ele.Data.EcToken
  17633. fmt.Println(outPutInfo)
  17634. 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)
  17635. saveLog(result, requestLog, "1101", "获取人员信息")
  17636. var dat map[string]interface{}
  17637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17638. fmt.Println(dat)
  17639. } else {
  17640. fmt.Println(err)
  17641. }
  17642. userJSONBytes, _ := json.Marshal(dat)
  17643. var res ResultTwo
  17644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17645. utils.ErrorLog("解析失败:%v", err)
  17646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17647. return
  17648. }
  17649. if res.Infcode == 0 {
  17650. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17651. if err == gorm.ErrRecordNotFound {
  17652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17653. return
  17654. } else if err != nil {
  17655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17656. return
  17657. } else {
  17658. fmt.Println(res)
  17659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17661. infoStr := string(Iinfos)
  17662. idetinfoStr := string(Idetinfos)
  17663. psn := &models.HisPsn{
  17664. PsnNo: res.Output.Baseinfo.PsnNo,
  17665. PatientId: patient.ID,
  17666. Certno: res.Output.Baseinfo.Certno,
  17667. Gend: res.Output.Baseinfo.Gend,
  17668. Naty: res.Output.Baseinfo.Naty,
  17669. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17670. PsnName: res.Output.Baseinfo.PsnName,
  17671. Idetinfo: idetinfoStr,
  17672. Insuinfo: infoStr,
  17673. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17674. CardInfo: outPutInfo,
  17675. VerifyNumber: token,
  17676. InsuplcAdmdvs: ele.Data.InsuOrg,
  17677. }
  17678. service.CreateHisPsn(psn)
  17679. var rf []*ResultFive
  17680. json.Unmarshal([]byte(infoStr), &rf)
  17681. var insutypes []*ResultFive
  17682. var insutype string
  17683. var is390 int = 0
  17684. var is310 int = 0
  17685. for _, item := range rf {
  17686. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17687. insutypes = append(insutypes, item)
  17688. }
  17689. }
  17690. if len(insutypes) == 1 {
  17691. insutype = insutypes[0].Insutype
  17692. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17693. } else {
  17694. for _, i := range insutypes {
  17695. if i.Insutype == "390" {
  17696. is390 = 1
  17697. }
  17698. if i.Insutype == "310" {
  17699. is310 = 1
  17700. }
  17701. }
  17702. }
  17703. if is390 == 1 {
  17704. insutype = "390"
  17705. }
  17706. if is310 == 1 {
  17707. insutype = "310"
  17708. }
  17709. if len(insutypes) == 0 {
  17710. insutype = "310"
  17711. }
  17712. c.ServeSuccessJSON(map[string]interface{}{
  17713. "patient": patient,
  17714. "number": token,
  17715. "insutype": insutype,
  17716. })
  17717. }
  17718. } else {
  17719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17720. return
  17721. }
  17722. }
  17723. //fmt.Println(result)
  17724. //
  17725. //if initFlag == 0 {
  17726. // c.TestGetBasBaseInit()
  17727. //}
  17728. //token := c.GetEleBaseInfo()
  17729. //
  17730. //token = Remove0000(token)
  17731. //
  17732. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17733. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17734. ////
  17735. //var res ResultTwo
  17736. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17737. // utils.ErrorLog("解析失败:%v", err)
  17738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17739. // return
  17740. //}
  17741. //
  17742. //if res.Infcode == 0 {
  17743. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17744. // if err == gorm.ErrRecordNotFound {
  17745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17746. // return
  17747. // } else if err != nil {
  17748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17749. // return
  17750. //
  17751. // } else {
  17752. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17753. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17754. // infoStr := string(Iinfos)
  17755. // idetinfoStr := string(Idetinfos)
  17756. //
  17757. //
  17758. //
  17759. //
  17760. // var rf []*ResultFive
  17761. // json.Unmarshal([]byte(infoStr), &rf)
  17762. //
  17763. // var insutypes []*ResultFive
  17764. // var insutype string
  17765. // var is390 int = 0
  17766. // var is310 int = 0
  17767. // var insuplc_admdvs string
  17768. //
  17769. // for _, item := range rf {
  17770. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17771. // insutypes = append(insutypes, item)
  17772. // }
  17773. // }
  17774. //
  17775. // if len(insutypes) == 1 {
  17776. // insutype = insutypes[0].Insutype
  17777. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17778. // } else {
  17779. // for _, i := range insutypes {
  17780. // if i.Insutype == "390" {
  17781. // is390 = 1
  17782. // }
  17783. //
  17784. // if i.Insutype == "310" {
  17785. // is310 = 1
  17786. // }
  17787. // }
  17788. // }
  17789. // if is390 == 1 {
  17790. // insutype = "390"
  17791. // }
  17792. //
  17793. // if is310 == 1 {
  17794. // insutype = "310"
  17795. // }
  17796. // if len(insutypes) == 0 {
  17797. // insutype = "310"
  17798. // }
  17799. // for _, item := range rf {
  17800. // if item.Insutype == insutype {
  17801. // insuplc_admdvs = item.InsuplcAdmdvs
  17802. // }
  17803. // }
  17804. // psn := &models.HisPsn{
  17805. // PsnNo: res.Output.Baseinfo.PsnNo,
  17806. // Age: res.Output.Baseinfo.Age,
  17807. // PatientId: patient.ID,
  17808. // Certno: res.Output.Baseinfo.Certno,
  17809. // Brdy: res.Output.Baseinfo.Brdy,
  17810. // Gend: res.Output.Baseinfo.Gend,
  17811. // Naty: res.Output.Baseinfo.Naty,
  17812. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17813. // PsnName: res.Output.Baseinfo.PsnName,
  17814. // Idetinfo: idetinfoStr,
  17815. // Insuinfo: infoStr,
  17816. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17817. // CardInfo: "",
  17818. // VerifyNumber: token,
  17819. // InsuplcAdmdvs: insuplc_admdvs,
  17820. // }
  17821. // service.CreateHisPsn(psn)
  17822. //
  17823. // c.ServeSuccessJSON(map[string]interface{}{
  17824. // "patient": patient,
  17825. // "number": token,
  17826. // })
  17827. // }
  17828. //} else {
  17829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17830. // return
  17831. //}
  17832. }
  17833. break
  17834. case 5:
  17835. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  17836. var api string
  17837. if miConfig.MdtrtareaAdmvs == "320830" {
  17838. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17839. "&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
  17840. fmt.Println(api)
  17841. } else if miConfig.MdtrtareaAdmvs == "320921" {
  17842. 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 +
  17843. "&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
  17844. fmt.Println(api)
  17845. } else {
  17846. 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 +
  17847. "&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)
  17848. }
  17849. resp, requestErr := http.Get(api)
  17850. if requestErr != nil {
  17851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17852. return
  17853. }
  17854. body, ioErr := ioutil.ReadAll(resp.Body)
  17855. if ioErr != nil {
  17856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17858. return
  17859. }
  17860. var respJSON map[string]interface{}
  17861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17864. return
  17865. }
  17866. var status string
  17867. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17868. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17869. var token string
  17870. var res ResultTwo //1101结果
  17871. var res10265 ResultTwo10265 //1101结果
  17872. if status == "0" { //读卡成功
  17873. var card_info string //卡信息
  17874. //var busi_card_info string
  17875. var auth_info string
  17876. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17877. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17878. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17879. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17880. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17881. result, _ := json.Marshal(respJSON)
  17882. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17883. utils.ErrorLog("解析失败:%v", err)
  17884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17885. return
  17886. }
  17887. res.ErrMsg = res10265.ErrMsg
  17888. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17889. res.Infcode = infocode
  17890. res.Output = res10265.Output
  17891. res.InfRefmsgid = res10265.InfRefmsgid
  17892. if res.Infcode == 0 {
  17893. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17894. if err == gorm.ErrRecordNotFound {
  17895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17896. return
  17897. } else if err != nil {
  17898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17899. return
  17900. } else {
  17901. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17902. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17903. infoStr := string(Iinfos)
  17904. idetinfoStr := string(Idetinfos)
  17905. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17906. psn := &models.HisPsn{
  17907. PsnNo: res.Output.Baseinfo.PsnNo,
  17908. PatientId: patient.ID,
  17909. Certno: res.Output.Baseinfo.Certno,
  17910. Gend: res.Output.Baseinfo.Gend,
  17911. Brdy: b,
  17912. Age: float64(age),
  17913. Naty: res.Output.Baseinfo.Naty,
  17914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17915. PsnName: res.Output.Baseinfo.PsnName,
  17916. Idetinfo: idetinfoStr,
  17917. Insuinfo: infoStr,
  17918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17919. CardInfo: card_info,
  17920. VerifyNumber: token,
  17921. AuthInfo: auth_info,
  17922. }
  17923. var rf []*ResultFive
  17924. json.Unmarshal([]byte(infoStr), &rf)
  17925. var insutypes []*ResultFive
  17926. var insutype string
  17927. var is390 int = 0
  17928. var is310 int = 0
  17929. for _, item := range rf {
  17930. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17931. insutypes = append(insutypes, item)
  17932. }
  17933. }
  17934. if len(insutypes) == 1 {
  17935. insutype = insutypes[0].Insutype
  17936. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17937. } else {
  17938. for _, i := range insutypes {
  17939. if i.Insutype == "390" {
  17940. is390 = 1
  17941. }
  17942. if i.Insutype == "310" {
  17943. is310 = 1
  17944. }
  17945. }
  17946. }
  17947. if is390 == 1 {
  17948. insutype = "390"
  17949. }
  17950. if is310 == 1 {
  17951. insutype = "310"
  17952. }
  17953. if len(insutypes) == 0 {
  17954. insutype = "310"
  17955. }
  17956. service.CreateHisPsn(psn)
  17957. c.ServeSuccessJSON(map[string]interface{}{
  17958. "patient": patient,
  17959. "number": token,
  17960. "insutype": insutype,
  17961. })
  17962. }
  17963. } else {
  17964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17965. return
  17966. }
  17967. } else { //读卡失败
  17968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17969. return
  17970. }
  17971. }
  17972. break
  17973. }
  17974. }
  17975. var initFlag int64 = 0
  17976. var initEleFlag int64 = 0
  17977. func (c *HisApiController) TestGetBasBaseInit() {
  17978. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17979. Iinit := DllDef.MustFindProc("Init")
  17980. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17981. url := ""
  17982. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  17983. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  17984. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  17985. url = ""
  17986. } else {
  17987. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  17988. }
  17989. fmt.Println("SSCard的报错原因:", url)
  17990. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  17991. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  17992. if ret != 0 {
  17993. fmt.Println("SSCard的报错原因:", err)
  17994. fmt.Println("SSCard的运算结果为:", ret)
  17995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17996. return
  17997. }
  17998. result := int(ret)
  17999. fmt.Println("SSCard的运算结果为1:", result)
  18000. initFlag = 1
  18001. return
  18002. }
  18003. func (c *HisApiController) HandleJiangXiReadCard() {
  18004. fmt.Println("~~~~~~")
  18005. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18006. admin_user_id, _ := c.GetInt64("admin_user_id")
  18007. id_card_type, _ := c.GetInt64("id_card_type")
  18008. //certificates, _ := c.GetInt64("certificates")
  18009. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18010. if initFlag == 0 {
  18011. c.TestGetJiangXiBasBaseInit()
  18012. }
  18013. basStr := c.GetBasBaseInfo()
  18014. if len(basStr) == 0 {
  18015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18016. return
  18017. }
  18018. fmt.Println(basStr)
  18019. bas := strings.Split(basStr, "|")
  18020. basNumber := bas[1]
  18021. fmt.Println(basNumber)
  18022. card_sn := bas[3]
  18023. fmt.Println(card_sn)
  18024. 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, "")
  18025. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18026. var dat map[string]interface{}
  18027. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18028. fmt.Println(dat)
  18029. } else {
  18030. fmt.Println(err)
  18031. }
  18032. userJSONBytes, _ := json.Marshal(dat)
  18033. var res ResultTwo
  18034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18035. utils.ErrorLog("解析失败:%v", err)
  18036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18037. return
  18038. }
  18039. if res.Infcode == 0 {
  18040. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18041. if err == gorm.ErrRecordNotFound {
  18042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18043. return
  18044. } else if err != nil {
  18045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18046. return
  18047. } else {
  18048. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18049. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18050. infoStr := string(Iinfos)
  18051. idetinfoStr := string(Idetinfos)
  18052. psn := &models.HisPsn{
  18053. PsnNo: res.Output.Baseinfo.PsnNo,
  18054. PatientId: patient.ID,
  18055. Certno: res.Output.Baseinfo.Certno,
  18056. Gend: res.Output.Baseinfo.Gend,
  18057. Naty: res.Output.Baseinfo.Naty,
  18058. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18059. PsnName: res.Output.Baseinfo.PsnName,
  18060. Idetinfo: idetinfoStr,
  18061. Insuinfo: infoStr,
  18062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18063. CardInfo: basStr,
  18064. VerifyNumber: "",
  18065. }
  18066. service.CreateHisPsn(psn)
  18067. c.ServeSuccessJSON(map[string]interface{}{
  18068. "patient": patient,
  18069. "number": basNumber,
  18070. })
  18071. }
  18072. } else {
  18073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18074. return
  18075. }
  18076. }
  18077. func (c *HisApiController) TestGetHnBasBaseInit() {
  18078. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18079. Iinit := DllDef.MustFindProc("Init")
  18080. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18081. //http://10.77.211.236/CSB/hsa-fsi-1303
  18082. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18083. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18084. // 调用 Init 函数
  18085. 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"))))
  18086. //if ret != 0 {
  18087. fmt.Println("SSCard的报错原因:", err)
  18088. fmt.Println("SSCard的运算结果为:", ret)
  18089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18090. // return
  18091. //}
  18092. result := int(ret)
  18093. fmt.Println("SSCard的运算结果为1:", result)
  18094. initFlag = 1
  18095. return
  18096. }
  18097. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18098. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18099. Iinit := DllDef.MustFindProc("Init")
  18100. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18101. //http://10.77.211.236/CSB/hsa-fsi-1303
  18102. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18103. if ret != 0 {
  18104. fmt.Println("SSCard的报错原因:", err)
  18105. fmt.Println("SSCard的运算结果为:", ret)
  18106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18107. return
  18108. }
  18109. result := int(ret)
  18110. fmt.Println("SSCard的运算结果为1:", result)
  18111. initFlag = 1
  18112. return
  18113. }
  18114. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18115. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18116. Iinit := DllDef.MustFindProc("Init")
  18117. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18118. //http://10.77.211.236/CSB/hsa-fsi-1303
  18119. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18120. if ret != 0 {
  18121. fmt.Println("SSCard的报错原因:", err)
  18122. fmt.Println("SSCard的运算结果为:", ret)
  18123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18124. return
  18125. }
  18126. result := int(ret)
  18127. fmt.Println("SSCard的运算结果为1:", result)
  18128. initFlag = 1
  18129. return
  18130. }
  18131. func (c *HisApiController) GetSFZBaseInfo() string {
  18132. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18133. readCard := DllDef.MustFindProc("ReadSFZ")
  18134. if readCard == nil {
  18135. fmt.Println("readcard is nil")
  18136. readCard = DllDef.MustFindProc("ReadSFZ")
  18137. }
  18138. str := make([]byte, 8096)
  18139. str1 := make([]byte, 8096)
  18140. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18141. fmt.Println(r)
  18142. return Remove0000(string(str))
  18143. }
  18144. func (c *HisApiController) GetEleBaseInfo() string {
  18145. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18146. readCard := DllDef.MustFindProc("GetQRBase")
  18147. fmt.Println(readCard)
  18148. if readCard == nil {
  18149. fmt.Println("readcard is nil")
  18150. readCard = DllDef.MustFindProc("GetQRBase")
  18151. }
  18152. str := make([]byte, 1024)
  18153. str1 := make([]byte, 1024)
  18154. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18155. fmt.Println(ret2)
  18156. fmt.Println(string(str1))
  18157. fmt.Println(string(str))
  18158. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18159. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18160. if ret2 != 0 {
  18161. return ""
  18162. }
  18163. return string(str)
  18164. }
  18165. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18166. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18167. readCard := DllDef.MustFindProc("NationEcTrans")
  18168. fmt.Println(readCard)
  18169. fmt.Println("!!!!!")
  18170. pBusiCardInfo := make([]byte, 2048)
  18171. input := make(map[string]interface{})
  18172. inputData := make(map[string]interface{})
  18173. inputData["orgId"] = code
  18174. inputData["businessType"] = "01101"
  18175. inputData["operatorId"] = "1"
  18176. inputData["operatorName"] = "admin"
  18177. inputData["officeId"] = "001"
  18178. inputData["officeName"] = "血透室"
  18179. inputData["deviceType"] = ""
  18180. input["data"] = inputData
  18181. input["orgId"] = code
  18182. input["transType"] = "ec.query"
  18183. bytesData, _ := json.Marshal(input)
  18184. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18185. fmt.Println(ret2)
  18186. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18187. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18188. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18189. }
  18190. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18191. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18192. readCard := DllDef.MustFindProc("NationEcTrans")
  18193. fmt.Println(readCard)
  18194. fmt.Println("!!!!!")
  18195. pBusiCardInfo := make([]byte, 2048)
  18196. input := make(map[string]interface{})
  18197. inputData := make(map[string]interface{})
  18198. inputData["orgId"] = code
  18199. inputData["businessType"] = "01101"
  18200. inputData["operatorId"] = "9"
  18201. inputData["operatorName"] = "admin"
  18202. inputData["officeId"] = "001"
  18203. inputData["officeName"] = "血透室"
  18204. inputData["deviceType"] = ""
  18205. input["data"] = inputData
  18206. input["orgId"] = code
  18207. input["transType"] = "ec.query"
  18208. bytesData, _ := json.Marshal(input)
  18209. 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])))
  18210. fmt.Println(ret2)
  18211. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18212. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18213. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18214. }
  18215. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18216. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18217. readCard := DllDef.MustFindProc("NationEcTrans")
  18218. fmt.Println(readCard)
  18219. fmt.Println("!!!!!")
  18220. pBusiCardInfo := make([]byte, 2048)
  18221. input := make(map[string]interface{})
  18222. inputData := make(map[string]interface{})
  18223. inputData["orgId"] = code
  18224. inputData["businessType"] = "01301"
  18225. inputData["operatorId"] = "9"
  18226. inputData["operatorName"] = "admin"
  18227. inputData["officeId"] = "001"
  18228. inputData["officeName"] = "血透室"
  18229. inputData["deviceType"] = ""
  18230. input["data"] = inputData
  18231. input["orgId"] = code
  18232. input["transType"] = "ec.query"
  18233. bytesData, _ := json.Marshal(input)
  18234. 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])))
  18235. fmt.Println(ret2)
  18236. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18237. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18238. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18239. }
  18240. func GetJxEleBaseInfo(org_id int64) string {
  18241. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18242. readCard := DllDef.MustFindProc("NationEcTrans")
  18243. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18244. if readCard == nil {
  18245. fmt.Println("readcard is nil")
  18246. readCard = DllDef.MustFindProc("NationEcTrans")
  18247. }
  18248. str1 := make([]byte, 1024)
  18249. data := make(map[string]interface{})
  18250. inputData := make(map[string]interface{})
  18251. inputData["orgId"] = miConfig.Code
  18252. inputData["businessType"] = "01101"
  18253. inputData["operatorId"] = "test001"
  18254. inputData["operatorName"] = "cn"
  18255. inputData["officeId"] = "32760"
  18256. inputData["officeName"] = "waike"
  18257. inputData["deviceType"] = ""
  18258. data["data"] = inputData
  18259. data["transType"] = "ec.query"
  18260. data["extra "] = ""
  18261. data["orgId"] = miConfig.Code
  18262. bytesData, _ := json.Marshal(data)
  18263. //bytesData, _ := json.Marshal(data)
  18264. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18265. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18266. fmt.Println(ret2)
  18267. fmt.Println(string(str1))
  18268. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18269. if ret2 != 0 {
  18270. return ""
  18271. }
  18272. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18273. }
  18274. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18275. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18276. // readCard := DllDef.MustFindProc("NationEcTrans")
  18277. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18278. //
  18279. // if readCard == nil {
  18280. // fmt.Println("readcard is nil")
  18281. // readCard = DllDef.MustFindProc("NationEcTrans")
  18282. // }
  18283. // str1 := make([]byte, 1024)
  18284. //
  18285. // data := make(map[string]interface{})
  18286. //
  18287. // inputData := make(map[string]interface{})
  18288. // inputData["orgId"] = miConfig.Code
  18289. // inputData["businessType"] = "01101"
  18290. // inputData["operatorId"] = "test001"
  18291. // inputData["operatorName"] = "cn"
  18292. // inputData["officeId"] = "32760"
  18293. // inputData["officeName"] = "waike"
  18294. // inputData["deviceType"] = ""
  18295. //
  18296. // data["data"] = inputData
  18297. // data["transType"] = "ec.query"
  18298. // data["extra "] = ""
  18299. // data["orgId"] = miConfig.Code
  18300. // bytesData, _ := json.Marshal(data)
  18301. // //bytesData, _ := json.Marshal(data)
  18302. //
  18303. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18304. //
  18305. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18306. // fmt.Println(ret2)
  18307. // fmt.Println(string(str1))
  18308. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18309. //
  18310. // if ret2 != 0 {
  18311. // return ""
  18312. // }
  18313. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18314. //}
  18315. func GetJxEleBaseInitInfo(org_id int64) string {
  18316. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18317. readCard := DllDef.MustFindProc("NationEcTrans")
  18318. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18319. if readCard == nil {
  18320. fmt.Println("readcard is nil")
  18321. readCard = DllDef.MustFindProc("NationEcTrans")
  18322. }
  18323. str1 := make([]byte, 2048)
  18324. data := make(map[string]interface{})
  18325. inputData := make(map[string]interface{})
  18326. inputData["orgId"] = miConfig.Code
  18327. inputData["businessType"] = "01101"
  18328. inputData["operatorId"] = "1"
  18329. inputData["operatorName"] = "huangchuang"
  18330. inputData["officeId"] = "101"
  18331. inputData["officeName"] = "xuetou"
  18332. inputData["deviceType"] = ""
  18333. data["data"] = inputData
  18334. data["transType"] = "ec.query"
  18335. data["orgId"] = miConfig.Code
  18336. bytesData, _ := json.Marshal(data)
  18337. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18338. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18339. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18340. fmt.Println(ret2)
  18341. fmt.Println(string(str1))
  18342. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18343. if ret2 != 0 {
  18344. return ""
  18345. }
  18346. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18347. initEleFlag = 1
  18348. }
  18349. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18350. }
  18351. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18352. // // 构建命令
  18353. // cmd := exec.Command("python", "b.py")
  18354. //
  18355. // // 执行命令并等待完成
  18356. // output, err := cmd.CombinedOutput()
  18357. // if err != nil {
  18358. // fmt.Println("Error executing Python script:", err)
  18359. // return
  18360. // }
  18361. //
  18362. // // 打印Python脚本的输出
  18363. // fmt.Println(string(output))
  18364. //}
  18365. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18366. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18367. readCard := DllDef.MustFindProc("gxyb_call")
  18368. if readCard == nil {
  18369. fmt.Println("readcard is nil")
  18370. readCard = DllDef.MustFindProc("gxyb_call")
  18371. }
  18372. str := make([]byte, 1024)
  18373. str1 := make([]byte, 1024)
  18374. //data := make(map[string]interface{})
  18375. currentTime := time.Now()
  18376. // 格式化时间为 "YYYYMMDDHH24MISS"
  18377. formattedTime := currentTime.Format("20060102150405")
  18378. inputData := make(map[string]interface{})
  18379. inputData2 := make(map[string]interface{})
  18380. inputData["transNo"] = "1401"
  18381. inputData["transType"] = "passwordCheck"
  18382. inputData["timestamp"] = formattedTime
  18383. inputData2["fixmedinsCode"] = code
  18384. inputData2["psnNo"] = ""
  18385. inputData["data"] = inputData2
  18386. jsonBytes, err := json.Marshal(inputData)
  18387. if err != nil {
  18388. fmt.Println("Error encoding map to JSON:", err)
  18389. }
  18390. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18391. fmt.Println(string(str1))
  18392. fmt.Println(string(str))
  18393. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18394. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18395. if ret2 != 0 {
  18396. return ""
  18397. }
  18398. return string(str)
  18399. }
  18400. func (c *HisApiController) GetoleInfo() Response {
  18401. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18402. defer ole.CoUninitialize()
  18403. // Replace with the ProgID or CLSID of your COM object
  18404. progID := "YinHai.XJ.Actual.Interface.New"
  18405. // Create COM object
  18406. unknown, err := oleutil.CreateObject(progID)
  18407. if err != nil {
  18408. fmt.Println("Unable to create COM object:", err)
  18409. }
  18410. defer unknown.Release()
  18411. // Query for the IDispatch interface
  18412. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18413. if err != nil {
  18414. fmt.Println("Unable to get IDispatch interface:", err)
  18415. }
  18416. defer dispatch.Release()
  18417. // Prepare parameters
  18418. transNo := "1401"
  18419. transType := "passwordCheck"
  18420. timestamp := time.Now().Unix()
  18421. fixmedinsCode := "H45072101171"
  18422. psnNo := ""
  18423. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18424. result2 := ""
  18425. // Call COM object's method using the IDispatch interface
  18426. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18427. fmt.Println(resulr)
  18428. fmt.Println(result2)
  18429. if err != nil {
  18430. fmt.Println("调用COM对象方法失败:", err)
  18431. }
  18432. var response Response
  18433. err2 := json.Unmarshal([]byte(result2), &response)
  18434. if err2 != nil {
  18435. fmt.Println("解析JSON失败:", err)
  18436. }
  18437. return response
  18438. }
  18439. func (c *HisApiController) GetBasBaseInfo() string {
  18440. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18441. readCard := DllDef.MustFindProc("ReadCardBas")
  18442. if readCard == nil {
  18443. fmt.Println("readcard is nil")
  18444. readCard = DllDef.MustFindProc("ReadCardBas")
  18445. }
  18446. str := make([]byte, 1024)
  18447. str1 := make([]byte, 1024)
  18448. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18449. fmt.Println(string(str1))
  18450. fmt.Println(string(str))
  18451. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18452. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18453. if ret2 != 0 {
  18454. return ""
  18455. }
  18456. return string(str)
  18457. }
  18458. type Program struct {
  18459. FunctionID string `xml:"function_id"`
  18460. CardInfo string `xml:"cardinfo"`
  18461. User string `xml:"user"`
  18462. }
  18463. func (c *HisApiController) GetBasBaseInfo1111() string {
  18464. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18465. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18466. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18467. if readCard == nil {
  18468. fmt.Println("readcard is nil")
  18469. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18470. }
  18471. if readCard2 == nil {
  18472. fmt.Println("readcard is nil")
  18473. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18474. }
  18475. str := make([]byte, 1024)
  18476. str1 := make([]byte, 1024)
  18477. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18478. str3 := make([]byte, 1024)
  18479. str4 := make([]byte, 1024)
  18480. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18481. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18482. //if err != nil {
  18483. // fmt.Println("Error opening file:", err)
  18484. //}
  18485. //defer file.Close()
  18486. //
  18487. //var lastProgram Program
  18488. //scanner := bufio.NewScanner(file)
  18489. //inProgram := false
  18490. //
  18491. //for scanner.Scan() {
  18492. // line := scanner.Text()
  18493. // if strings.Contains(line, "<program>") {
  18494. // inProgram = true
  18495. // programXML := "<program>"
  18496. // for scanner.Scan() {
  18497. // line = scanner.Text()
  18498. // programXML += line
  18499. // if strings.Contains(line, "</program>") {
  18500. // programXML += "</program>"
  18501. // break
  18502. // }
  18503. // }
  18504. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18505. // // 解析成功,更新最后的 Program
  18506. // }
  18507. // inProgram = false
  18508. // }
  18509. //}
  18510. //
  18511. // fmt.Println("Error reading file:", inProgram)
  18512. //
  18513. //if err := scanner.Err(); err != nil {
  18514. // fmt.Println("Error reading file:", err)
  18515. //}
  18516. // 输出最后一次的 Program
  18517. //fmt.Printf("最后一次的 <program>:\n")
  18518. //fmt.Printf("<program>\n")
  18519. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18520. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18521. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18522. //fmt.Printf("</program>\n")
  18523. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18524. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18525. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18526. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18527. return ConvertToString(string(str), "gbk", "utf-8")
  18528. }
  18529. func (c *HisApiController) GetBasBaseInfo22222() string {
  18530. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18531. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18532. if readCard == nil {
  18533. fmt.Println("readcard is nil")
  18534. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18535. }
  18536. str := make([]byte, 1024)
  18537. str1 := make([]byte, 1024)
  18538. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18539. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18540. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18541. //if err != nil {
  18542. // fmt.Println("Error opening file:", err)
  18543. //}
  18544. //defer file.Close()
  18545. //
  18546. //var lastProgram Program
  18547. //scanner := bufio.NewScanner(file)
  18548. //inProgram := false
  18549. //
  18550. //for scanner.Scan() {
  18551. // line := scanner.Text()
  18552. // if strings.Contains(line, "<program>") {
  18553. // inProgram = true
  18554. // programXML := "<program>"
  18555. // for scanner.Scan() {
  18556. // line = scanner.Text()
  18557. // programXML += line
  18558. // if strings.Contains(line, "</program>") {
  18559. // programXML += "</program>"
  18560. // break
  18561. // }
  18562. // }
  18563. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18564. // // 解析成功,更新最后的 Program
  18565. // }
  18566. // inProgram = false
  18567. // }
  18568. //}
  18569. //
  18570. // fmt.Println("Error reading file:", inProgram)
  18571. //
  18572. //if err := scanner.Err(); err != nil {
  18573. // fmt.Println("Error reading file:", err)
  18574. //}
  18575. // 输出最后一次的 Program
  18576. //fmt.Printf("最后一次的 <program>:\n")
  18577. //fmt.Printf("<program>\n")
  18578. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18579. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18580. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18581. //fmt.Printf("</program>\n")
  18582. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18583. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18584. return ConvertToString(string(str1), "gbk", "utf-8")
  18585. }
  18586. func (c *HisApiController) GetahBasBaseInfo() string {
  18587. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18588. readCard := DllDef.MustFindProc("iReadCardBas")
  18589. if readCard == nil {
  18590. fmt.Println("readcard is nil")
  18591. readCard = DllDef.MustFindProc("iReadCardBas")
  18592. }
  18593. //str := make([]byte, 1024)
  18594. str1 := make([]byte, 1024)
  18595. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18596. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18597. //if err != nil {
  18598. // fmt.Println("Error opening file:", err)
  18599. //}
  18600. //defer file.Close()
  18601. //
  18602. //var lastProgram Program
  18603. //scanner := bufio.NewScanner(file)
  18604. //inProgram := false
  18605. //
  18606. //for scanner.Scan() {
  18607. // line := scanner.Text()
  18608. // if strings.Contains(line, "<program>") {
  18609. // inProgram = true
  18610. // programXML := "<program>"
  18611. // for scanner.Scan() {
  18612. // line = scanner.Text()
  18613. // programXML += line
  18614. // if strings.Contains(line, "</program>") {
  18615. // programXML += "</program>"
  18616. // break
  18617. // }
  18618. // }
  18619. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18620. // // 解析成功,更新最后的 Program
  18621. // }
  18622. // inProgram = false
  18623. // }
  18624. //}
  18625. //
  18626. // fmt.Println("Error reading file:", inProgram)
  18627. //
  18628. //if err := scanner.Err(); err != nil {
  18629. // fmt.Println("Error reading file:", err)
  18630. //}
  18631. // 输出最后一次的 Program
  18632. //fmt.Printf("最后一次的 <program>:\n")
  18633. //fmt.Printf("<program>\n")
  18634. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18635. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18636. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18637. //fmt.Printf("</program>\n")
  18638. fmt.Println(string(str1))
  18639. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18640. if ret2 != 0 {
  18641. return ""
  18642. }
  18643. return string(str1)
  18644. }
  18645. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18646. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18647. readCard := DllDef.MustFindProc("read_cardinfo")
  18648. if readCard == nil {
  18649. fmt.Println("readcard is nil")
  18650. readCard = DllDef.MustFindProc("read_cardinfo")
  18651. }
  18652. str := make([]byte, 1024) //卡号
  18653. str1 := make([]byte, 1024) //卡识别码
  18654. str2 := make([]byte, 1024) //身份证号
  18655. str3 := make([]byte, 1024) //姓名
  18656. str4 := make([]byte, 1024) //错误信息
  18657. 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])))
  18658. fmt.Println(string(str1))
  18659. fmt.Println(string(str))
  18660. fmt.Println(string(str2))
  18661. fmt.Println(string(str3))
  18662. fmt.Println(string(str4))
  18663. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18664. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18665. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18666. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18667. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18668. if ret2 != 0 {
  18669. return "", "", "", "", ""
  18670. }
  18671. return string(str), string(str1), string(str2), string(str3), string(str4)
  18672. }
  18673. type CustomFundPay struct {
  18674. FundPayType string `json:"fund_pay_type"`
  18675. FundPayamt float64 `json:"fund_payamt"`
  18676. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18677. }
  18678. //func (c *HisApiController) GetBatchSettleList() {
  18679. // start_time_str := c.GetString("start_time")
  18680. // //end_time_str := c.GetString("end_time")
  18681. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18682. //
  18683. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18684. //
  18685. // for _, item := range orders {
  18686. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18687. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18688. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18689. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18690. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18691. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18692. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18693. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18694. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18695. //
  18696. // if order.ID == 0 {
  18697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18698. // return
  18699. // }
  18700. //
  18701. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18702. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18703. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18704. // //fmt.Println(count)
  18705. // //var zero string
  18706. // //number := count + 1
  18707. // //if number >= 1000 {
  18708. // // zero = "0000" + strconv.FormatInt(number, 10)
  18709. // //} else if number >= 10000 {
  18710. // // zero = "000" + strconv.FormatInt(number, 10)
  18711. // //} else if number >= 100000 {
  18712. // // zero = "00" + strconv.FormatInt(number, 10)
  18713. // //} else if number >= 1000000 {
  18714. // // zero = "0" + strconv.FormatInt(number, 10)
  18715. // //} else {
  18716. // // zero = strconv.FormatInt(number, 10)
  18717. // //}
  18718. // //fmt.Println(zero)
  18719. //
  18720. // struct4101 := service.Struct4101{
  18721. // PsnNo: order.PsnNo,
  18722. // MdtrtId: order.MdtrtId,
  18723. // SetlId: order.SetlId,
  18724. // PsnName: order.PsnName,
  18725. // Gend: order.Gend,
  18726. // Brdy: his.Brdy,
  18727. // Age: his.Age,
  18728. // Naty: order.Naty,
  18729. // PatnCertType: "01",
  18730. // Certno: order.Certno,
  18731. // Prfs: "90",
  18732. // ConerName: roles[0].UserName,
  18733. // PatnRlts: "99",
  18734. // ConerAddr: miConfig.OrgName,
  18735. // ConerTel: admin.Mobile,
  18736. // HiType: order.Insutype,
  18737. // Insuplc: miConfig.InsuplcAdmdvs,
  18738. // MaindiagFlag: "1",
  18739. // BillCode: order.SetlId,
  18740. // BillNo: order.SetlId,
  18741. // BizSn: order.Number,
  18742. // PsnSelfPay: order.PsnPartAmt,
  18743. // PsnOwnPay: order.PsnPartAmt,
  18744. // AcctPay: order.AcctPay,
  18745. // PsnCashpay: order.PsnCashPay,
  18746. // HiPaymtd: "1",
  18747. // Hsorg: miConfig.InsuplcAdmdvs,
  18748. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18749. // MedinsFillPsn: curRoles.UserName,
  18750. // MedinsFillDept: miConfig.OrgName,
  18751. // IptMedType: "2",
  18752. // }
  18753. // struct4101.SetlBegnDate = order.SetlTime
  18754. // struct4101.SetlEndDate = order.SetlTime
  18755. // time_arr := strings.Split(order.SetlTime, " ")
  18756. // struct4101.AdmTime = time_arr[0]
  18757. // struct4101.AdmEndTime = time_arr[0]
  18758. //
  18759. // var rf []CustomFundPay
  18760. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18761. //
  18762. // var tempFunPays []service.CustomStruct
  18763. // for _, item := range rf {
  18764. // var tempFunPay service.CustomStruct
  18765. // tempFunPay.FundPayamt = item.FundPayamt
  18766. // tempFunPay.FundPayType = item.FundPayType
  18767. // tempFunPays = append(tempFunPays, tempFunPay)
  18768. // }
  18769. // struct4101.CustomStruct = tempFunPays
  18770. //
  18771. // var tempDiaginfos []service.DiaginfoStructTwo
  18772. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18773. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18774. //
  18775. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18776. // var config []*models.HisXtDiagnoseConfig
  18777. // for _, item := range diagnosis_ids {
  18778. // id, _ := strconv.ParseInt(item, 10, 64)
  18779. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18780. // config = append(config, &diagnosisConfig)
  18781. // }
  18782. //
  18783. // for index, item := range config {
  18784. // if index == 0 {
  18785. // var tempDiaginfo service.DiaginfoStructTwo
  18786. // tempDiaginfo.DiagCode = item.CountryCode
  18787. // tempDiaginfo.DiagName = item.CountryContentName
  18788. // tempDiaginfo.DiagType = "1"
  18789. // tempDiaginfo.MaindiagFlag = "1"
  18790. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18791. // } else {
  18792. // var tempDiaginfo service.DiaginfoStructTwo
  18793. // tempDiaginfo.DiagCode = item.CountryCode
  18794. // tempDiaginfo.DiagName = item.CountryContentName
  18795. // tempDiaginfo.DiagType = "1"
  18796. // tempDiaginfo.MaindiagFlag = "0"
  18797. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18798. // }
  18799. // }
  18800. // struct4101.Diseinfo = tempDiaginfos
  18801. //
  18802. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18803. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18804. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18805. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18806. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18807. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18808. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18809. //
  18810. // var iteminfo service.IteminfoStruct
  18811. //
  18812. // var bedCostTotal float64 = 0 //床位总费
  18813. // var bedCostSelfTotal float64 = 0 //床位自费
  18814. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18815. //
  18816. // var operationCostTotal float64 = 0 //手术费
  18817. // var operationCostSelfTotal float64 = 0 //手术费
  18818. // var operationCostPartSelfTotal float64 = 0 //手术费
  18819. //
  18820. // var otherCostTotal float64 = 0 //其他费用
  18821. // var otherCostSelfTotal float64 = 0 //其他费用
  18822. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18823. //
  18824. // var materialCostTotal float64 = 0 //材料费
  18825. // var materialCostSelfTotal float64 = 0 //材料费
  18826. // var materialCostPartSelfTotal float64 = 0 //材料费
  18827. //
  18828. // var westernMedicineCostTotal float64 = 0 //西药费
  18829. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18830. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18831. //
  18832. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18833. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18834. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18835. //
  18836. // var checkCostTotal float64 = 0 //检查费
  18837. // var checkCostSelfTotal float64 = 0 //检查费
  18838. // var checkCostPartSelfTotal float64 = 0 //检查费
  18839. //
  18840. // var laboratoryCostTotal float64 = 0 //化验费
  18841. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18842. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18843. //
  18844. // var treatCostTotal float64 = 0 //治疗费用
  18845. // var treatCostSelfTotal float64 = 0 //治疗费用
  18846. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18847. //
  18848. // decimal.DivisionPrecision = 2
  18849. //
  18850. // var bed_fulamt_ownpay_amt float64 = 0
  18851. // var operation_fulamt_ownpay_amt float64 = 0
  18852. // var other_fulamt_ownpay_amt float64 = 0
  18853. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18854. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18855. // var check_fulamt_ownpay_amt float64 = 0
  18856. // var material_fulamt_ownpay_amt float64 = 0
  18857. // var laboratory_fulamt_ownpay_amt float64 = 0
  18858. // var treat_fulamt_ownpay_amt float64 = 0
  18859. //
  18860. // var bed_claa_sunmfee float64 = 0
  18861. // var bed_clab_amt float64 = 0
  18862. // var bed_other_amt float64 = 0
  18863. //
  18864. // var operation_claa_sunmfee float64 = 0
  18865. // var operation_clab_amt float64 = 0
  18866. // var operation_other_amt float64 = 0
  18867. //
  18868. // var other_claa_sunmfee float64 = 0
  18869. // var other_clab_amt float64 = 0
  18870. // var other_other_amt float64 = 0
  18871. //
  18872. // var westernMedicine_claa_sunmfee float64 = 0
  18873. // var westernMedicine_clab_amt float64 = 0
  18874. // var westernMedicine_other_amt float64 = 0
  18875. //
  18876. // var chineseTraditional_claa_sunmfee float64 = 0
  18877. // var chineseTraditional_clab_amt float64 = 0
  18878. // var chineseTraditional_other_amt float64 = 0
  18879. //
  18880. // var check_claa_sunmfee float64 = 0
  18881. // var check_clab_amt float64 = 0
  18882. // var check_other_amt float64 = 0
  18883. //
  18884. // var material_claa_sunmfee float64 = 0
  18885. // var material_clab_amt float64 = 0
  18886. // var material_other_amt float64 = 0
  18887. //
  18888. // var laboratory_claa_sunmfee float64 = 0
  18889. // var laboratory_clab_amt float64 = 0
  18890. // var laboratory_other_amt float64 = 0
  18891. //
  18892. // var treat_claa_sunmfee float64 = 0
  18893. // var treat_clab_amt float64 = 0
  18894. // var treat_other_amt float64 = 0
  18895. //
  18896. // for _, item := range order.HisOrderInfo {
  18897. // if item.MedChrgitmType == "01" { //床位费
  18898. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18899. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18900. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18901. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18902. // if item.ChrgitmLv == "1" {
  18903. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18904. // }
  18905. // if item.ChrgitmLv == "2" {
  18906. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18907. //
  18908. // }
  18909. // if item.ChrgitmLv == "3" {
  18910. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18911. // }
  18912. //
  18913. // }
  18914. //
  18915. // if item.MedChrgitmType == "03" { //检查费
  18916. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18917. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18918. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18919. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18920. // if item.ChrgitmLv == "1" {
  18921. //
  18922. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18923. //
  18924. // }
  18925. // if item.ChrgitmLv == "2" {
  18926. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18927. //
  18928. // }
  18929. // if item.ChrgitmLv == "3" {
  18930. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18931. // }
  18932. // }
  18933. //
  18934. // if item.MedChrgitmType == "04" { //化验费
  18935. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18936. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18937. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18938. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18939. // if item.ChrgitmLv == "1" {
  18940. //
  18941. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18942. //
  18943. // }
  18944. // if item.ChrgitmLv == "2" {
  18945. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18946. //
  18947. // }
  18948. // if item.ChrgitmLv == "3" {
  18949. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18950. // }
  18951. // }
  18952. //
  18953. // if item.MedChrgitmType == "05" { //治疗费
  18954. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18955. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18956. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18957. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18958. // if item.ChrgitmLv == "1" {
  18959. //
  18960. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18961. //
  18962. // }
  18963. // if item.ChrgitmLv == "2" {
  18964. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. //
  18966. // }
  18967. // if item.ChrgitmLv == "3" {
  18968. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18969. // }
  18970. // }
  18971. //
  18972. // if item.MedChrgitmType == "06" { //手术费
  18973. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18974. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18975. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18976. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18977. //
  18978. // if item.ChrgitmLv == "1" {
  18979. //
  18980. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18981. //
  18982. // }
  18983. // if item.ChrgitmLv == "2" {
  18984. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18985. //
  18986. // }
  18987. // if item.ChrgitmLv == "3" {
  18988. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18989. // }
  18990. // }
  18991. //
  18992. // if item.MedChrgitmType == "08" { //材料费
  18993. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18994. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18995. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18996. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18997. // if item.ChrgitmLv == "1" {
  18998. //
  18999. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19000. //
  19001. // }
  19002. // if item.ChrgitmLv == "2" {
  19003. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19004. //
  19005. // }
  19006. // if item.ChrgitmLv == "3" {
  19007. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19008. // }
  19009. // }
  19010. //
  19011. // if item.MedChrgitmType == "09" { //西药费
  19012. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19013. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19014. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19015. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19016. // if item.ChrgitmLv == "1" {
  19017. //
  19018. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19019. //
  19020. // }
  19021. // if item.ChrgitmLv == "2" {
  19022. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19023. //
  19024. // }
  19025. // if item.ChrgitmLv == "3" {
  19026. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19027. // }
  19028. // }
  19029. //
  19030. // if item.MedChrgitmType == "11" { //中成费
  19031. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19032. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19033. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19034. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19035. // if item.ChrgitmLv == "1" {
  19036. //
  19037. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19038. //
  19039. // }
  19040. // if item.ChrgitmLv == "2" {
  19041. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19042. //
  19043. // }
  19044. // if item.ChrgitmLv == "3" {
  19045. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19046. // }
  19047. // }
  19048. //
  19049. // if item.MedChrgitmType == "14" { //其他费
  19050. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19051. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19052. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19053. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19054. // if item.ChrgitmLv == "1" {
  19055. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19056. //
  19057. // }
  19058. // if item.ChrgitmLv == "2" {
  19059. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19060. //
  19061. // }
  19062. // if item.ChrgitmLv == "3" {
  19063. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19064. // }
  19065. // }
  19066. //
  19067. // }
  19068. //
  19069. // var iteminfoStructs []service.IteminfoStruct
  19070. //
  19071. // if bedCostTotal != 0 {
  19072. // iteminfo.MedChrgitm = "01"
  19073. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19074. // iteminfo.Amt = bedCostTotal
  19075. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19076. // iteminfo.ClabAmt = bed_clab_amt
  19077. // iteminfo.OthAmt = bed_other_amt
  19078. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19079. // }
  19080. //
  19081. // if checkCostTotal != 0 {
  19082. // iteminfo.MedChrgitm = "03"
  19083. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19084. // iteminfo.Amt = checkCostTotal
  19085. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19086. // iteminfo.ClabAmt = check_clab_amt
  19087. // iteminfo.OthAmt = check_other_amt
  19088. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19089. //
  19090. // }
  19091. //
  19092. // if laboratoryCostTotal != 0 {
  19093. // iteminfo.MedChrgitm = "04"
  19094. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19095. // iteminfo.Amt = laboratoryCostTotal
  19096. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19097. // iteminfo.ClabAmt = laboratory_clab_amt
  19098. // iteminfo.OthAmt = laboratory_other_amt
  19099. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19100. //
  19101. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19102. //
  19103. // }
  19104. //
  19105. // if treatCostTotal != 0 {
  19106. // iteminfo.MedChrgitm = "05"
  19107. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19108. // iteminfo.Amt = treatCostTotal
  19109. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19110. // iteminfo.ClabAmt = treat_clab_amt
  19111. // iteminfo.OthAmt = treat_other_amt
  19112. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19113. // //(struct4101.IteminfoStruct, iteminfo)
  19114. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19115. // }
  19116. //
  19117. // if operationCostTotal != 0 {
  19118. // iteminfo.MedChrgitm = "06"
  19119. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19120. // iteminfo.Amt = operationCostTotal
  19121. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19122. // iteminfo.ClabAmt = operation_clab_amt
  19123. // iteminfo.OthAmt = operation_other_amt
  19124. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19125. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19126. // }
  19127. //
  19128. // if materialCostTotal != 0 {
  19129. // iteminfo.MedChrgitm = "08"
  19130. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19131. // iteminfo.Amt = materialCostTotal
  19132. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19133. // iteminfo.ClabAmt = material_clab_amt
  19134. // iteminfo.OthAmt = material_other_amt
  19135. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19136. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19137. // }
  19138. //
  19139. // if westernMedicineCostTotal != 0 {
  19140. // iteminfo.MedChrgitm = "09"
  19141. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19142. // iteminfo.Amt = westernMedicineCostTotal
  19143. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19144. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19145. // iteminfo.OthAmt = westernMedicine_other_amt
  19146. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19147. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19148. //
  19149. // }
  19150. // if chineseTraditionalMedicineCostTotal != 0 {
  19151. // iteminfo.MedChrgitm = "11"
  19152. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19153. // iteminfo.Amt = westernMedicineCostTotal
  19154. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19155. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19156. // iteminfo.OthAmt = westernMedicine_other_amt
  19157. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19158. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19159. //
  19160. // }
  19161. // if otherCostTotal != 0 {
  19162. // iteminfo.MedChrgitm = "14"
  19163. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19164. // iteminfo.Amt = otherCostTotal
  19165. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19166. // iteminfo.ClabAmt = other_clab_amt
  19167. // iteminfo.OthAmt = other_other_amt
  19168. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19169. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19170. //
  19171. // }
  19172. // struct4101.IteminfoStruct = iteminfoStructs
  19173. // struct4101.Ntly = "中国"
  19174. // struct4101.AdmCaty = "A03.06"
  19175. //
  19176. // struct4101.DoctorName = doctor.UserName
  19177. // struct4101.DoctorCode = doctor.DoctorNumber
  19178. //
  19179. // var res ResultSeventeen
  19180. //
  19181. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19182. // struct4101.BillCode = order.Number
  19183. // struct4101.BillNo = order.SetlId
  19184. // var resOther ResultSeventeenOther
  19185. // var pp models.PublicParams
  19186. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19187. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19188. // pp.FixmedinsName = miConfig.OrgName
  19189. // pp.FixmedinsCode = miConfig.Code
  19190. // pp.RequestUrl = miConfig.Url
  19191. // pp.Cainfo = miConfig.Cainfo
  19192. // pp.SecretKey = miConfig.SecretKey
  19193. // pp.AccessKey = miConfig.AccessKey
  19194. // pp.OpterName = curRoles.UserName
  19195. //
  19196. // client := &http.Client{}
  19197. // var req *http.Request
  19198. // data := make(map[string]interface{})
  19199. // data["struct4101"] = struct4101
  19200. // data["pp"] = pp
  19201. // bytesData, _ := json.Marshal(data)
  19202. // if miConfig.MdtrtareaAdmvs == "320921" {
  19203. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19204. // } else {
  19205. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19206. // }
  19207. // resp, _ := client.Do(req)
  19208. // defer resp.Body.Close()
  19209. // body, ioErr := ioutil.ReadAll(resp.Body)
  19210. // if ioErr != nil {
  19211. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19213. // return
  19214. // }
  19215. // var respJSON map[string]interface{}
  19216. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19217. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19218. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19219. // return
  19220. // }
  19221. //
  19222. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19223. // userJSONBytes, _ := json.Marshal(respJSON)
  19224. // fmt.Println("log")
  19225. // fmt.Println(string(userJSONBytes))
  19226. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19227. // utils.ErrorLog("解析失败:%v", err)
  19228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19229. // return
  19230. // }
  19231. // res.InfRefmsgid = resOther.InfRefmsgid
  19232. // res.Output = resOther.Output
  19233. // res.ErrMsg = resOther.ErrMsg
  19234. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19235. // res.Infcode = infocode
  19236. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19237. //
  19238. // var pp models.PublicParams
  19239. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19240. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19241. // pp.FixmedinsName = miConfig.OrgName
  19242. // pp.FixmedinsCode = miConfig.Code
  19243. // pp.RequestUrl = miConfig.Url
  19244. // pp.Cainfo = miConfig.Cainfo
  19245. // pp.SecretKey = miConfig.SecretKey
  19246. // pp.AccessKey = miConfig.AccessKey
  19247. // pp.OpterName = curRoles.UserName
  19248. // result, _ := service.Jxyb4101(struct4101, pp)
  19249. // var dat map[string]interface{}
  19250. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19251. // fmt.Println(dat)
  19252. // } else {
  19253. // fmt.Println(err)
  19254. // }
  19255. // userJSONBytes, _ := json.Marshal(dat)
  19256. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19257. // utils.ErrorLog("解析失败:%v", err)
  19258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19259. // return
  19260. // }
  19261. //
  19262. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19263. // var pp models.PublicParams
  19264. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19265. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19266. // pp.FixmedinsName = miConfig.OrgName
  19267. // pp.FixmedinsCode = miConfig.Code
  19268. // pp.RequestUrl = miConfig.Url
  19269. // pp.Cainfo = miConfig.Cainfo
  19270. // pp.SecretKey = miConfig.SecretKey
  19271. // pp.AccessKey = miConfig.AccessKey
  19272. // pp.OpterName = curRoles.UserName
  19273. // result, _ := service.Hnyb4101(struct4101, pp)
  19274. // var dat map[string]interface{}
  19275. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19276. // fmt.Println(dat)
  19277. // } else {
  19278. // fmt.Println(err)
  19279. // }
  19280. // userJSONBytes, _ := json.Marshal(dat)
  19281. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19282. // utils.ErrorLog("解析失败:%v", err)
  19283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19284. // return
  19285. // }
  19286. //
  19287. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19288. // var resOther ResultSeventeenOther
  19289. //
  19290. // var pp models.PublicParams
  19291. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19292. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19293. // pp.FixmedinsName = miConfig.OrgName
  19294. // pp.FixmedinsCode = miConfig.Code
  19295. // pp.RequestUrl = miConfig.Url
  19296. // pp.Cainfo = miConfig.Cainfo
  19297. // pp.SecretKey = miConfig.SecretKey
  19298. // pp.AccessKey = miConfig.AccessKey
  19299. // pp.OpterName = curRoles.UserName
  19300. // client := &http.Client{}
  19301. // var req *http.Request
  19302. // data := make(map[string]interface{})
  19303. // data["struct4101"] = struct4101
  19304. // data["pp"] = pp
  19305. // bytesData, _ := json.Marshal(data)
  19306. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19307. // resp, _ := client.Do(req)
  19308. // defer resp.Body.Close()
  19309. // body, ioErr := ioutil.ReadAll(resp.Body)
  19310. // if ioErr != nil {
  19311. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19313. // return
  19314. // }
  19315. // var respJSON map[string]interface{}
  19316. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19317. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19319. // return
  19320. // }
  19321. //
  19322. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19323. // userJSONBytes, _ := json.Marshal(respJSON)
  19324. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19325. // utils.ErrorLog("解析失败:%v", err)
  19326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19327. // return
  19328. // }
  19329. // res.InfRefmsgid = resOther.InfRefmsgid
  19330. // res.Output = resOther.Output
  19331. // res.ErrMsg = resOther.ErrMsg
  19332. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19333. // res.Infcode = infocode
  19334. //
  19335. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19336. // var pp models.PublicParams
  19337. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19338. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19339. // pp.FixmedinsName = miConfig.OrgName
  19340. // pp.FixmedinsCode = miConfig.Code
  19341. // pp.RequestUrl = miConfig.Url
  19342. // pp.Cainfo = miConfig.Cainfo
  19343. // pp.SecretKey = miConfig.SecretKey
  19344. // pp.AccessKey = miConfig.AccessKey
  19345. // pp.OpterName = curRoles.UserName
  19346. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19347. // fmt.Println(requestLog)
  19348. // fmt.Println(errMsgLog)
  19349. //
  19350. // saveLog(result, requestLog, "4101a", "上传清单")
  19351. //
  19352. // var dat map[string]interface{}
  19353. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19354. // fmt.Println(dat)
  19355. // } else {
  19356. // fmt.Println(err)
  19357. // }
  19358. // userJSONBytes, _ := json.Marshal(dat)
  19359. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19360. // utils.ErrorLog("解析失败:%v", err)
  19361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19362. // return
  19363. // }
  19364. //
  19365. // } else {
  19366. //
  19367. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19368. // var dat map[string]interface{}
  19369. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19370. // fmt.Println(dat)
  19371. // } else {
  19372. // fmt.Println(err)
  19373. // }
  19374. // userJSONBytes, _ := json.Marshal(dat)
  19375. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19376. // utils.ErrorLog("解析失败:%v", err)
  19377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19378. // return
  19379. // }
  19380. // }
  19381. //
  19382. // if res.Infcode != 0 {
  19383. // adminUser := c.GetAdminUserInfo()
  19384. // errlog := &models.HisOrderError{
  19385. // UserOrgId: adminUser.CurrentOrgId,
  19386. // Ctime: time.Now().Unix(),
  19387. // Mtime: time.Now().Unix(),
  19388. // ErrMsg: res.ErrMsg,
  19389. // Status: 1,
  19390. // PatientId: order.ID,
  19391. // Stage: 10265,
  19392. // }
  19393. // service.CreateErrMsgLog(errlog)
  19394. // continue
  19395. // } else {
  19396. // //order.FaPiaoNumber = zero
  19397. // //order.FaPiaoCode = last_order.FaPiaoCode
  19398. // //service.UpdateOrder(order)
  19399. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19400. // Number: res.Output.SetlListId,
  19401. // Status: 1,
  19402. // Ctime: time.Now().Unix(),
  19403. // Mtime: time.Now().Unix(),
  19404. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19405. // IsUpload: 1,
  19406. // OrderId: order.ID,
  19407. // }
  19408. // service.CreateUploadRecord(hisFundSettleListResult)
  19409. // c.ServeSuccessJSON(map[string]interface{}{
  19410. // "msg": "上传成功",
  19411. // "result": hisFundSettleListResult,
  19412. // })
  19413. // continue
  19414. // }
  19415. // }
  19416. //}
  19417. func (c *HisApiController) GetbatchSettleList() {
  19418. //order_id, _ := c.GetInt64("order_id")
  19419. admin_user_id, _ := c.GetInt64("admin_user_id")
  19420. orders, _ := service.GetAllHisOrderTwo10485()
  19421. for _, item := range orders {
  19422. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19423. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19424. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19425. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19426. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19427. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19429. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19430. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19431. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19432. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19433. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19434. //fmt.Println(count)
  19435. //var zero string
  19436. //number := count + 1
  19437. //if number >= 1000 {
  19438. // zero = "0000" + strconv.FormatInt(number, 10)
  19439. //} else if number >= 10000 {
  19440. // zero = "000" + strconv.FormatInt(number, 10)
  19441. //} else if number >= 100000 {
  19442. // zero = "00" + strconv.FormatInt(number, 10)
  19443. //} else if number >= 1000000 {
  19444. // zero = "0" + strconv.FormatInt(number, 10)
  19445. //} else {
  19446. // zero = strconv.FormatInt(number, 10)
  19447. //}
  19448. //fmt.Println(zero)
  19449. struct4101 := service.Struct4101{
  19450. PsnNo: order.PsnNo,
  19451. MdtrtId: order.MdtrtId,
  19452. SetlId: order.SetlId,
  19453. PsnName: order.PsnName,
  19454. Gend: order.Gend,
  19455. Brdy: his.Brdy,
  19456. Age: his.Age,
  19457. Naty: order.Naty,
  19458. PatnCertType: "01",
  19459. Certno: order.Certno,
  19460. Prfs: "90",
  19461. ConerName: roles[0].UserName,
  19462. PatnRlts: "99",
  19463. ConerAddr: miConfig.OrgName,
  19464. ConerTel: admin.Mobile,
  19465. HiType: order.Insutype,
  19466. Insuplc: miConfig.InsuplcAdmdvs,
  19467. MaindiagFlag: "1",
  19468. BillCode: order.SetlId,
  19469. BillNo: order.SetlId,
  19470. BizSn: order.Number,
  19471. PsnSelfPay: order.PsnPartAmt,
  19472. PsnOwnPay: order.PsnPartAmt,
  19473. AcctPay: order.AcctPay,
  19474. PsnCashpay: order.PsnCashPay,
  19475. HiPaymtd: "1",
  19476. Hsorg: miConfig.InsuplcAdmdvs,
  19477. HsorgOpter: miConfig.InsuplcAdmdvs,
  19478. MedinsFillPsn: curRoles.UserName,
  19479. MedinsFillDept: miConfig.OrgName,
  19480. IptMedType: "2",
  19481. }
  19482. struct4101.SetlBegnDate = order.SetlTime
  19483. struct4101.SetlEndDate = order.SetlTime
  19484. time_arr := strings.Split(order.SetlTime, " ")
  19485. struct4101.AdmTime = time_arr[0]
  19486. struct4101.AdmEndTime = time_arr[0]
  19487. //var rf []CustomFundPay
  19488. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19489. //
  19490. //var tempFunPays []service.CustomStruct
  19491. //for _, item := range rf {
  19492. // var tempFunPay service.CustomStruct
  19493. // tempFunPay.FundPayamt = item.FundPayamt
  19494. // tempFunPay.FundPayType = item.FundPayType
  19495. // tempFunPays = append(tempFunPays, tempFunPay)
  19496. //}
  19497. //struct4101.CustomStruct = tempFunPays
  19498. var tempDiaginfos []service.DiaginfoStructTwo
  19499. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19500. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19501. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19502. var config []*models.HisXtDiagnoseConfig
  19503. for _, item := range diagnosis_ids {
  19504. id, _ := strconv.ParseInt(item, 10, 64)
  19505. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19506. config = append(config, &diagnosisConfig)
  19507. }
  19508. for index, item := range config {
  19509. if index == 0 {
  19510. var tempDiaginfo service.DiaginfoStructTwo
  19511. tempDiaginfo.DiagCode = item.CountryCode
  19512. tempDiaginfo.DiagName = item.CountryContentName
  19513. tempDiaginfo.DiagType = "1"
  19514. tempDiaginfo.MaindiagFlag = "1"
  19515. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19516. } else {
  19517. var tempDiaginfo service.DiaginfoStructTwo
  19518. tempDiaginfo.DiagCode = item.CountryCode
  19519. tempDiaginfo.DiagName = item.CountryContentName
  19520. tempDiaginfo.DiagType = "1"
  19521. tempDiaginfo.MaindiagFlag = "0"
  19522. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19523. }
  19524. }
  19525. struct4101.Diseinfo = tempDiaginfos
  19526. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19527. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19528. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19529. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19530. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19531. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19532. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19533. var iteminfo service.IteminfoStruct
  19534. var bedCostTotal float64 = 0 //床位总费
  19535. var bedCostSelfTotal float64 = 0 //床位自费
  19536. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19537. var operationCostTotal float64 = 0 //手术费
  19538. var operationCostSelfTotal float64 = 0 //手术费
  19539. var operationCostPartSelfTotal float64 = 0 //手术费
  19540. var otherCostTotal float64 = 0 //其他费用
  19541. var otherCostSelfTotal float64 = 0 //其他费用
  19542. var otherCostPartSelfTotal float64 = 0 //其他费用
  19543. var materialCostTotal float64 = 0 //材料费
  19544. var materialCostSelfTotal float64 = 0 //材料费
  19545. var materialCostPartSelfTotal float64 = 0 //材料费
  19546. var westernMedicineCostTotal float64 = 0 //西药费
  19547. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19548. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19549. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19550. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19551. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19552. var checkCostTotal float64 = 0 //检查费
  19553. var checkCostSelfTotal float64 = 0 //检查费
  19554. var checkCostPartSelfTotal float64 = 0 //检查费
  19555. var laboratoryCostTotal float64 = 0 //化验费
  19556. var laboratoryCostSelfTotal float64 = 0 //化验费
  19557. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19558. var treatCostTotal float64 = 0 //治疗费用
  19559. var treatCostSelfTotal float64 = 0 //治疗费用
  19560. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19561. decimal.DivisionPrecision = 2
  19562. var bed_fulamt_ownpay_amt float64 = 0
  19563. var operation_fulamt_ownpay_amt float64 = 0
  19564. var other_fulamt_ownpay_amt float64 = 0
  19565. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19566. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19567. var check_fulamt_ownpay_amt float64 = 0
  19568. var material_fulamt_ownpay_amt float64 = 0
  19569. var laboratory_fulamt_ownpay_amt float64 = 0
  19570. var treat_fulamt_ownpay_amt float64 = 0
  19571. var bed_claa_sunmfee float64 = 0
  19572. var bed_clab_amt float64 = 0
  19573. var bed_other_amt float64 = 0
  19574. var operation_claa_sunmfee float64 = 0
  19575. var operation_clab_amt float64 = 0
  19576. var operation_other_amt float64 = 0
  19577. var other_claa_sunmfee float64 = 0
  19578. var other_clab_amt float64 = 0
  19579. var other_other_amt float64 = 0
  19580. var westernMedicine_claa_sunmfee float64 = 0
  19581. var westernMedicine_clab_amt float64 = 0
  19582. var westernMedicine_other_amt float64 = 0
  19583. var chineseTraditional_claa_sunmfee float64 = 0
  19584. var chineseTraditional_clab_amt float64 = 0
  19585. var chineseTraditional_other_amt float64 = 0
  19586. var check_claa_sunmfee float64 = 0
  19587. var check_clab_amt float64 = 0
  19588. var check_other_amt float64 = 0
  19589. var material_claa_sunmfee float64 = 0
  19590. var material_clab_amt float64 = 0
  19591. var material_other_amt float64 = 0
  19592. var laboratory_claa_sunmfee float64 = 0
  19593. var laboratory_clab_amt float64 = 0
  19594. var laboratory_other_amt float64 = 0
  19595. var treat_claa_sunmfee float64 = 0
  19596. var treat_clab_amt float64 = 0
  19597. var treat_other_amt float64 = 0
  19598. for _, item := range order.HisOrderInfo {
  19599. if item.MedChrgitmType == "01" { //床位费
  19600. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19601. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19602. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19603. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19604. if item.ChrgitmLv == "1" {
  19605. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19606. }
  19607. if item.ChrgitmLv == "2" {
  19608. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19609. }
  19610. if item.ChrgitmLv == "3" {
  19611. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19612. }
  19613. }
  19614. if item.MedChrgitmType == "03" { //检查费
  19615. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19616. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19617. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19618. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19619. if item.ChrgitmLv == "1" {
  19620. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19621. }
  19622. if item.ChrgitmLv == "2" {
  19623. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19624. }
  19625. if item.ChrgitmLv == "3" {
  19626. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19627. }
  19628. }
  19629. if item.MedChrgitmType == "04" { //化验费
  19630. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19631. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19632. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19633. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19634. if item.ChrgitmLv == "1" {
  19635. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19636. }
  19637. if item.ChrgitmLv == "2" {
  19638. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19639. }
  19640. if item.ChrgitmLv == "3" {
  19641. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19642. }
  19643. }
  19644. if item.MedChrgitmType == "05" { //治疗费
  19645. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19646. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19647. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19648. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19649. if item.ChrgitmLv == "1" {
  19650. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19651. }
  19652. if item.ChrgitmLv == "2" {
  19653. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19654. }
  19655. if item.ChrgitmLv == "3" {
  19656. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19657. }
  19658. }
  19659. if item.MedChrgitmType == "06" { //手术费
  19660. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19661. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19662. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19663. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19664. if item.ChrgitmLv == "1" {
  19665. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19666. }
  19667. if item.ChrgitmLv == "2" {
  19668. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19669. }
  19670. if item.ChrgitmLv == "3" {
  19671. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19672. }
  19673. }
  19674. if item.MedChrgitmType == "08" { //材料费
  19675. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19676. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19677. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19678. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19679. if item.ChrgitmLv == "1" {
  19680. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19681. }
  19682. if item.ChrgitmLv == "2" {
  19683. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19684. }
  19685. if item.ChrgitmLv == "3" {
  19686. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19687. }
  19688. }
  19689. if item.MedChrgitmType == "09" { //西药费
  19690. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19691. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19692. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19693. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19694. if item.ChrgitmLv == "1" {
  19695. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19696. }
  19697. if item.ChrgitmLv == "2" {
  19698. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19699. }
  19700. if item.ChrgitmLv == "3" {
  19701. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19702. }
  19703. }
  19704. if item.MedChrgitmType == "11" { //中成费
  19705. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19706. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19707. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19708. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19709. if item.ChrgitmLv == "1" {
  19710. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19711. }
  19712. if item.ChrgitmLv == "2" {
  19713. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19714. }
  19715. if item.ChrgitmLv == "3" {
  19716. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19717. }
  19718. }
  19719. if item.MedChrgitmType == "14" { //其他费
  19720. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19721. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19722. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19723. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19724. if item.ChrgitmLv == "1" {
  19725. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19726. }
  19727. if item.ChrgitmLv == "2" {
  19728. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19729. }
  19730. if item.ChrgitmLv == "3" {
  19731. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19732. }
  19733. }
  19734. }
  19735. var iteminfoStructs []service.IteminfoStruct
  19736. if bedCostTotal != 0 {
  19737. iteminfo.MedChrgitm = "01"
  19738. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19739. iteminfo.Amt = bedCostTotal
  19740. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19741. iteminfo.ClabAmt = bed_clab_amt
  19742. iteminfo.OthAmt = bed_other_amt
  19743. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19744. }
  19745. if checkCostTotal != 0 {
  19746. iteminfo.MedChrgitm = "03"
  19747. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19748. iteminfo.Amt = checkCostTotal
  19749. iteminfo.ClaaSumfee = check_claa_sunmfee
  19750. iteminfo.ClabAmt = check_clab_amt
  19751. iteminfo.OthAmt = check_other_amt
  19752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19753. }
  19754. if laboratoryCostTotal != 0 {
  19755. iteminfo.MedChrgitm = "04"
  19756. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19757. iteminfo.Amt = laboratoryCostTotal
  19758. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19759. iteminfo.ClabAmt = laboratory_clab_amt
  19760. iteminfo.OthAmt = laboratory_other_amt
  19761. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19762. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19763. }
  19764. if treatCostTotal != 0 {
  19765. iteminfo.MedChrgitm = "05"
  19766. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19767. iteminfo.Amt = treatCostTotal
  19768. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19769. iteminfo.ClabAmt = treat_clab_amt
  19770. iteminfo.OthAmt = treat_other_amt
  19771. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19772. //(struct4101.IteminfoStruct, iteminfo)
  19773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19774. }
  19775. if operationCostTotal != 0 {
  19776. iteminfo.MedChrgitm = "06"
  19777. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19778. iteminfo.Amt = operationCostTotal
  19779. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19780. iteminfo.ClabAmt = operation_clab_amt
  19781. iteminfo.OthAmt = operation_other_amt
  19782. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19783. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19784. }
  19785. if materialCostTotal != 0 {
  19786. iteminfo.MedChrgitm = "08"
  19787. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19788. iteminfo.Amt = materialCostTotal
  19789. iteminfo.ClaaSumfee = material_claa_sunmfee
  19790. iteminfo.ClabAmt = material_clab_amt
  19791. iteminfo.OthAmt = material_other_amt
  19792. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19793. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19794. }
  19795. if westernMedicineCostTotal != 0 {
  19796. iteminfo.MedChrgitm = "09"
  19797. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19798. iteminfo.Amt = westernMedicineCostTotal
  19799. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19800. iteminfo.ClabAmt = westernMedicine_clab_amt
  19801. iteminfo.OthAmt = westernMedicine_other_amt
  19802. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19803. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19804. }
  19805. if chineseTraditionalMedicineCostTotal != 0 {
  19806. iteminfo.MedChrgitm = "11"
  19807. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19808. iteminfo.Amt = westernMedicineCostTotal
  19809. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19810. iteminfo.ClabAmt = westernMedicine_clab_amt
  19811. iteminfo.OthAmt = westernMedicine_other_amt
  19812. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19813. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19814. }
  19815. if otherCostTotal != 0 {
  19816. iteminfo.MedChrgitm = "14"
  19817. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19818. iteminfo.Amt = otherCostTotal
  19819. iteminfo.ClaaSumfee = other_claa_sunmfee
  19820. iteminfo.ClabAmt = other_clab_amt
  19821. iteminfo.OthAmt = other_other_amt
  19822. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19823. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19824. }
  19825. struct4101.IteminfoStruct = iteminfoStructs
  19826. struct4101.Ntly = "中国"
  19827. struct4101.AdmCaty = "A03.06"
  19828. struct4101.DoctorName = doctor.UserName
  19829. struct4101.DoctorCode = doctor.DoctorNumber
  19830. var res ResultSeventeen
  19831. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  19832. struct4101.BillCode = order.Number
  19833. struct4101.BillNo = order.SetlId
  19834. var resOther ResultSeventeenOther
  19835. var pp models.PublicParams
  19836. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19837. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19838. pp.FixmedinsName = miConfig.OrgName
  19839. pp.FixmedinsCode = miConfig.Code
  19840. pp.RequestUrl = miConfig.Url
  19841. pp.Cainfo = miConfig.Cainfo
  19842. pp.SecretKey = miConfig.SecretKey
  19843. pp.AccessKey = miConfig.AccessKey
  19844. pp.OpterName = curRoles.UserName
  19845. client := &http.Client{}
  19846. var req *http.Request
  19847. data := make(map[string]interface{})
  19848. data["struct4101"] = struct4101
  19849. data["pp"] = pp
  19850. bytesData, _ := json.Marshal(data)
  19851. if miConfig.MdtrtareaAdmvs == "320830" {
  19852. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  19853. } else if miConfig.MdtrtareaAdmvs == "320921" {
  19854. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19855. } else {
  19856. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19857. }
  19858. resp, _ := client.Do(req)
  19859. defer resp.Body.Close()
  19860. body, ioErr := ioutil.ReadAll(resp.Body)
  19861. if ioErr != nil {
  19862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19864. return
  19865. }
  19866. var respJSON map[string]interface{}
  19867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19870. return
  19871. }
  19872. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19873. userJSONBytes, _ := json.Marshal(respJSON)
  19874. fmt.Println("log")
  19875. fmt.Println(string(userJSONBytes))
  19876. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19877. utils.ErrorLog("解析失败:%v", err)
  19878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19879. return
  19880. }
  19881. res.InfRefmsgid = resOther.InfRefmsgid
  19882. res.Output = resOther.Output
  19883. res.ErrMsg = resOther.ErrMsg
  19884. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19885. res.Infcode = infocode
  19886. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19887. var pp models.PublicParams
  19888. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19889. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19890. pp.FixmedinsName = miConfig.OrgName
  19891. pp.FixmedinsCode = miConfig.Code
  19892. pp.RequestUrl = miConfig.Url
  19893. pp.Cainfo = miConfig.Cainfo
  19894. pp.SecretKey = miConfig.SecretKey
  19895. pp.AccessKey = miConfig.AccessKey
  19896. pp.OpterName = curRoles.UserName
  19897. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19898. result, _ := service.Jxyb4101(struct4101, pp)
  19899. var dat map[string]interface{}
  19900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19901. fmt.Println(dat)
  19902. } else {
  19903. fmt.Println(err)
  19904. }
  19905. userJSONBytes, _ := json.Marshal(dat)
  19906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19907. utils.ErrorLog("解析失败:%v", err)
  19908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19909. return
  19910. }
  19911. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19912. var pp models.PublicParams
  19913. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19914. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19915. pp.FixmedinsName = miConfig.OrgName
  19916. pp.FixmedinsCode = miConfig.Code
  19917. pp.RequestUrl = miConfig.Url
  19918. pp.Cainfo = miConfig.Cainfo
  19919. pp.SecretKey = miConfig.SecretKey
  19920. pp.AccessKey = miConfig.AccessKey
  19921. pp.OpterName = curRoles.UserName
  19922. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19923. result, _ := service.Jxyb4101(struct4101, pp)
  19924. var dat map[string]interface{}
  19925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19926. fmt.Println(dat)
  19927. } else {
  19928. fmt.Println(err)
  19929. }
  19930. userJSONBytes, _ := json.Marshal(dat)
  19931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19932. utils.ErrorLog("解析失败:%v", err)
  19933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19934. return
  19935. }
  19936. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19937. var pp models.PublicParams
  19938. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19939. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19940. pp.FixmedinsName = miConfig.OrgName
  19941. pp.FixmedinsCode = miConfig.Code
  19942. pp.RequestUrl = miConfig.Url
  19943. pp.Cainfo = miConfig.Cainfo
  19944. pp.SecretKey = miConfig.SecretKey
  19945. pp.AccessKey = miConfig.AccessKey
  19946. pp.OpterName = curRoles.UserName
  19947. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19948. result, _ := service.Jxyb4101(struct4101, pp)
  19949. var dat map[string]interface{}
  19950. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19951. fmt.Println(dat)
  19952. } else {
  19953. fmt.Println(err)
  19954. }
  19955. userJSONBytes, _ := json.Marshal(dat)
  19956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19957. utils.ErrorLog("解析失败:%v", err)
  19958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19959. return
  19960. }
  19961. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19962. var pp models.PublicParams
  19963. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19964. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19965. pp.FixmedinsName = miConfig.OrgName
  19966. pp.FixmedinsCode = miConfig.Code
  19967. pp.RequestUrl = miConfig.Url
  19968. pp.Cainfo = miConfig.Cainfo
  19969. pp.SecretKey = miConfig.SecretKey
  19970. pp.AccessKey = miConfig.AccessKey
  19971. pp.OpterName = curRoles.UserName
  19972. result, _ := service.Hnyb4101(struct4101, pp)
  19973. var dat map[string]interface{}
  19974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19975. fmt.Println(dat)
  19976. } else {
  19977. fmt.Println(err)
  19978. }
  19979. userJSONBytes, _ := json.Marshal(dat)
  19980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19981. utils.ErrorLog("解析失败:%v", err)
  19982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19983. return
  19984. }
  19985. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19986. var resOther ResultSeventeenOther
  19987. var pp models.PublicParams
  19988. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19989. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19990. pp.FixmedinsName = miConfig.OrgName
  19991. pp.FixmedinsCode = miConfig.Code
  19992. pp.RequestUrl = miConfig.Url
  19993. pp.Cainfo = miConfig.Cainfo
  19994. pp.SecretKey = miConfig.SecretKey
  19995. pp.AccessKey = miConfig.AccessKey
  19996. pp.OpterName = curRoles.UserName
  19997. client := &http.Client{}
  19998. var req *http.Request
  19999. data := make(map[string]interface{})
  20000. data["struct4101"] = struct4101
  20001. data["pp"] = pp
  20002. bytesData, _ := json.Marshal(data)
  20003. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20004. resp, _ := client.Do(req)
  20005. defer resp.Body.Close()
  20006. body, ioErr := ioutil.ReadAll(resp.Body)
  20007. if ioErr != nil {
  20008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20010. return
  20011. }
  20012. var respJSON map[string]interface{}
  20013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20016. return
  20017. }
  20018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20019. userJSONBytes, _ := json.Marshal(respJSON)
  20020. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20021. utils.ErrorLog("解析失败:%v", err)
  20022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20023. return
  20024. }
  20025. res.InfRefmsgid = resOther.InfRefmsgid
  20026. res.Output = resOther.Output
  20027. res.ErrMsg = resOther.ErrMsg
  20028. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20029. res.Infcode = infocode
  20030. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20031. var pp models.PublicParams
  20032. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20033. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20034. pp.FixmedinsName = miConfig.OrgName
  20035. pp.FixmedinsCode = miConfig.Code
  20036. pp.RequestUrl = miConfig.Url
  20037. pp.Cainfo = miConfig.Cainfo
  20038. pp.SecretKey = miConfig.SecretKey
  20039. pp.AccessKey = miConfig.AccessKey
  20040. pp.OpterName = curRoles.UserName
  20041. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20042. fmt.Println(requestLog)
  20043. fmt.Println(errMsgLog)
  20044. saveLog(result, requestLog, "4101a", "上传清单")
  20045. var dat map[string]interface{}
  20046. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20047. fmt.Println(dat)
  20048. } else {
  20049. fmt.Println(err)
  20050. }
  20051. userJSONBytes, _ := json.Marshal(dat)
  20052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20053. utils.ErrorLog("解析失败:%v", err)
  20054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20055. return
  20056. }
  20057. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20058. var pp models.PublicParams
  20059. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20060. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20061. pp.FixmedinsName = miConfig.OrgName
  20062. pp.FixmedinsCode = miConfig.Code
  20063. pp.RequestUrl = miConfig.Url
  20064. pp.Cainfo = miConfig.Cainfo
  20065. pp.SecretKey = miConfig.SecretKey
  20066. pp.AccessKey = miConfig.AccessKey
  20067. pp.OpterName = curRoles.UserName
  20068. client := &http.Client{}
  20069. var req *http.Request
  20070. data := make(map[string]interface{})
  20071. data["struct4101"] = struct4101
  20072. data["pp"] = pp
  20073. bytesData, _ := json.Marshal(data)
  20074. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20075. resp, _ := client.Do(req)
  20076. defer resp.Body.Close()
  20077. body, ioErr := ioutil.ReadAll(resp.Body)
  20078. if ioErr != nil {
  20079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20081. return
  20082. }
  20083. var respJSON map[string]interface{}
  20084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20087. return
  20088. }
  20089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20090. userJSONBytes, _ := json.Marshal(respJSON)
  20091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20092. utils.ErrorLog("解析失败:%v", err)
  20093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20094. return
  20095. }
  20096. } else {
  20097. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20098. var dat map[string]interface{}
  20099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20100. fmt.Println(dat)
  20101. } else {
  20102. fmt.Println(err)
  20103. }
  20104. userJSONBytes, _ := json.Marshal(dat)
  20105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20106. utils.ErrorLog("解析失败:%v", err)
  20107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20108. return
  20109. }
  20110. }
  20111. if res.Infcode != 0 {
  20112. errlog := &models.HisOrderError{
  20113. UserOrgId: order.UserOrgId,
  20114. Ctime: time.Now().Unix(),
  20115. Mtime: time.Now().Unix(),
  20116. ErrMsg: res.ErrMsg + "解析失败",
  20117. Status: 1,
  20118. PatientId: order.ID,
  20119. Stage: 10485,
  20120. }
  20121. service.CreateErrMsgLog(errlog)
  20122. continue
  20123. //c.ServeSuccessJSON(map[string]interface{}{
  20124. // "failed_code": -10,
  20125. // "msg": res.ErrMsg,
  20126. //})
  20127. } else {
  20128. //order.FaPiaoNumber = zero
  20129. //order.FaPiaoCode = last_order.FaPiaoCode
  20130. //service.UpdateOrder(order)
  20131. hisFundSettleListResult := &models.HisFundSettleListResult{
  20132. Number: res.Output.SetlListId,
  20133. Status: 1,
  20134. Ctime: time.Now().Unix(),
  20135. Mtime: time.Now().Unix(),
  20136. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20137. IsUpload: 1,
  20138. OrderId: order.ID,
  20139. }
  20140. service.CreateUploadRecord(hisFundSettleListResult)
  20141. continue
  20142. }
  20143. }
  20144. }
  20145. func (c *HisApiController) GetSettleList() {
  20146. order_id, _ := c.GetInt64("order_id")
  20147. admin_user_id, _ := c.GetInt64("admin_user_id")
  20148. order, _ := service.GetHisOrderByIDTwo(order_id)
  20149. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20150. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20151. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20152. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20153. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20154. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20155. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20156. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20157. if order.ID == 0 {
  20158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20159. return
  20160. }
  20161. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20162. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20163. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20164. //fmt.Println(count)
  20165. //var zero string
  20166. //number := count + 1
  20167. //if number >= 1000 {
  20168. // zero = "0000" + strconv.FormatInt(number, 10)
  20169. //} else if number >= 10000 {
  20170. // zero = "000" + strconv.FormatInt(number, 10)
  20171. //} else if number >= 100000 {
  20172. // zero = "00" + strconv.FormatInt(number, 10)
  20173. //} else if number >= 1000000 {
  20174. // zero = "0" + strconv.FormatInt(number, 10)
  20175. //} else {
  20176. // zero = strconv.FormatInt(number, 10)
  20177. //}
  20178. //fmt.Println(zero)
  20179. struct4101 := service.Struct4101{
  20180. PsnNo: order.PsnNo,
  20181. MdtrtId: order.MdtrtId,
  20182. SetlId: order.SetlId,
  20183. PsnName: order.PsnName,
  20184. Gend: order.Gend,
  20185. Brdy: his.Brdy,
  20186. Age: his.Age,
  20187. Naty: order.Naty,
  20188. PatnCertType: "01",
  20189. Certno: order.Certno,
  20190. Prfs: "90",
  20191. ConerName: roles[0].UserName,
  20192. PatnRlts: "99",
  20193. ConerAddr: miConfig.OrgName,
  20194. ConerTel: admin.Mobile,
  20195. HiType: order.Insutype,
  20196. Insuplc: miConfig.InsuplcAdmdvs,
  20197. MaindiagFlag: "1",
  20198. BillCode: order.SetlId,
  20199. BillNo: order.SetlId,
  20200. BizSn: order.Number,
  20201. PsnSelfPay: order.PsnPartAmt,
  20202. PsnOwnPay: order.PsnPartAmt,
  20203. AcctPay: order.AcctPay,
  20204. PsnCashpay: order.PsnCashPay,
  20205. HiPaymtd: "1",
  20206. Hsorg: miConfig.InsuplcAdmdvs,
  20207. HsorgOpter: miConfig.InsuplcAdmdvs,
  20208. MedinsFillPsn: curRoles.UserName,
  20209. MedinsFillDept: miConfig.OrgName,
  20210. IptMedType: "2",
  20211. }
  20212. struct4101.SetlBegnDate = order.SetlTime
  20213. struct4101.SetlEndDate = order.SetlTime
  20214. time_arr := strings.Split(order.SetlTime, " ")
  20215. struct4101.AdmTime = time_arr[0]
  20216. struct4101.AdmEndTime = time_arr[0]
  20217. //
  20218. //var rf []CustomFundPay
  20219. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20220. //
  20221. //var tempFunPays []service.CustomStruct
  20222. //for _, item := range rf {
  20223. // var tempFunPay service.CustomStruct
  20224. // tempFunPay.FundPayamt = item.FundPayamt
  20225. // tempFunPay.FundPayType = item.FundPayType
  20226. // tempFunPays = append(tempFunPays, tempFunPay)
  20227. //}
  20228. //struct4101.CustomStruct = tempFunPays
  20229. var tempDiaginfos []service.DiaginfoStructTwo
  20230. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20231. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20232. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20233. var config []*models.HisXtDiagnoseConfig
  20234. for _, item := range diagnosis_ids {
  20235. id, _ := strconv.ParseInt(item, 10, 64)
  20236. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20237. config = append(config, &diagnosisConfig)
  20238. }
  20239. if miConfig.Code == "H15049901371" {
  20240. //for _, item := range config {
  20241. // if item.ID == 138 {
  20242. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20243. var tempDiaginfo service.DiaginfoStructTwo
  20244. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20245. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20246. tempDiaginfo.DiagType = "1"
  20247. tempDiaginfo.MaindiagFlag = "1"
  20248. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20249. //}
  20250. //}
  20251. for _, item := range config {
  20252. if item.ID != 138 {
  20253. var tempDiaginfo service.DiaginfoStructTwo
  20254. tempDiaginfo.DiagCode = item.CountryCode
  20255. tempDiaginfo.DiagName = item.CountryContentName
  20256. tempDiaginfo.DiagType = "1"
  20257. tempDiaginfo.MaindiagFlag = "0"
  20258. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20259. }
  20260. }
  20261. } else {
  20262. for index, item := range config {
  20263. if index == 0 {
  20264. var tempDiaginfo service.DiaginfoStructTwo
  20265. tempDiaginfo.DiagCode = item.CountryCode
  20266. tempDiaginfo.DiagName = item.CountryContentName
  20267. tempDiaginfo.DiagType = "1"
  20268. tempDiaginfo.MaindiagFlag = "1"
  20269. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20270. } else {
  20271. var tempDiaginfo service.DiaginfoStructTwo
  20272. tempDiaginfo.DiagCode = item.CountryCode
  20273. tempDiaginfo.DiagName = item.CountryContentName
  20274. tempDiaginfo.DiagType = "1"
  20275. tempDiaginfo.MaindiagFlag = "0"
  20276. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20277. }
  20278. }
  20279. }
  20280. struct4101.Diseinfo = tempDiaginfos
  20281. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20282. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20283. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20284. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20285. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20286. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20287. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20288. var iteminfo service.IteminfoStruct
  20289. var bedCostTotal float64 = 0 //床位总费
  20290. var bedCostSelfTotal float64 = 0 //床位自费
  20291. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20292. var operationCostTotal float64 = 0 //手术费
  20293. var operationCostSelfTotal float64 = 0 //手术费
  20294. var operationCostPartSelfTotal float64 = 0 //手术费
  20295. var otherCostTotal float64 = 0 //其他费用
  20296. var otherCostSelfTotal float64 = 0 //其他费用
  20297. var otherCostPartSelfTotal float64 = 0 //其他费用
  20298. var materialCostTotal float64 = 0 //材料费
  20299. var materialCostSelfTotal float64 = 0 //材料费
  20300. var materialCostPartSelfTotal float64 = 0 //材料费
  20301. var westernMedicineCostTotal float64 = 0 //西药费
  20302. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20303. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20304. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20305. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20306. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20307. var checkCostTotal float64 = 0 //检查费
  20308. var checkCostSelfTotal float64 = 0 //检查费
  20309. var checkCostPartSelfTotal float64 = 0 //检查费
  20310. var laboratoryCostTotal float64 = 0 //化验费
  20311. var laboratoryCostSelfTotal float64 = 0 //化验费
  20312. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20313. var treatCostTotal float64 = 0 //治疗费用
  20314. var treatCostSelfTotal float64 = 0 //治疗费用
  20315. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20316. decimal.DivisionPrecision = 2
  20317. var bed_fulamt_ownpay_amt float64 = 0
  20318. var operation_fulamt_ownpay_amt float64 = 0
  20319. var other_fulamt_ownpay_amt float64 = 0
  20320. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20321. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20322. var check_fulamt_ownpay_amt float64 = 0
  20323. var material_fulamt_ownpay_amt float64 = 0
  20324. var laboratory_fulamt_ownpay_amt float64 = 0
  20325. var treat_fulamt_ownpay_amt float64 = 0
  20326. var bed_claa_sunmfee float64 = 0
  20327. var bed_clab_amt float64 = 0
  20328. var bed_other_amt float64 = 0
  20329. var operation_claa_sunmfee float64 = 0
  20330. var operation_clab_amt float64 = 0
  20331. var operation_other_amt float64 = 0
  20332. var other_claa_sunmfee float64 = 0
  20333. var other_clab_amt float64 = 0
  20334. var other_other_amt float64 = 0
  20335. var westernMedicine_claa_sunmfee float64 = 0
  20336. var westernMedicine_clab_amt float64 = 0
  20337. var westernMedicine_other_amt float64 = 0
  20338. var chineseTraditional_claa_sunmfee float64 = 0
  20339. var chineseTraditional_clab_amt float64 = 0
  20340. var chineseTraditional_other_amt float64 = 0
  20341. var check_claa_sunmfee float64 = 0
  20342. var check_clab_amt float64 = 0
  20343. var check_other_amt float64 = 0
  20344. var material_claa_sunmfee float64 = 0
  20345. var material_clab_amt float64 = 0
  20346. var material_other_amt float64 = 0
  20347. var laboratory_claa_sunmfee float64 = 0
  20348. var laboratory_clab_amt float64 = 0
  20349. var laboratory_other_amt float64 = 0
  20350. var treat_claa_sunmfee float64 = 0
  20351. var treat_clab_amt float64 = 0
  20352. var treat_other_amt float64 = 0
  20353. for _, item := range order.HisOrderInfo {
  20354. if item.MedChrgitmType == "01" { //床位费
  20355. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20356. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20357. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20358. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20359. if item.ChrgitmLv == "1" {
  20360. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20361. }
  20362. if item.ChrgitmLv == "2" {
  20363. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20364. }
  20365. if item.ChrgitmLv == "3" {
  20366. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20367. }
  20368. }
  20369. if item.MedChrgitmType == "03" { //检查费
  20370. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20371. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20372. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20373. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20374. if item.ChrgitmLv == "1" {
  20375. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20376. }
  20377. if item.ChrgitmLv == "2" {
  20378. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20379. }
  20380. if item.ChrgitmLv == "3" {
  20381. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20382. }
  20383. }
  20384. if item.MedChrgitmType == "04" { //化验费
  20385. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20386. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20387. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20388. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20389. if item.ChrgitmLv == "1" {
  20390. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20391. }
  20392. if item.ChrgitmLv == "2" {
  20393. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20394. }
  20395. if item.ChrgitmLv == "3" {
  20396. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20397. }
  20398. }
  20399. if item.MedChrgitmType == "05" { //治疗费
  20400. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20401. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20402. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20403. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20404. if item.ChrgitmLv == "1" {
  20405. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20406. }
  20407. if item.ChrgitmLv == "2" {
  20408. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20409. }
  20410. if item.ChrgitmLv == "3" {
  20411. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20412. }
  20413. }
  20414. if item.MedChrgitmType == "06" { //手术费
  20415. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20416. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20417. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20418. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20419. if item.ChrgitmLv == "1" {
  20420. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20421. }
  20422. if item.ChrgitmLv == "2" {
  20423. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20424. }
  20425. if item.ChrgitmLv == "3" {
  20426. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20427. }
  20428. }
  20429. if item.MedChrgitmType == "08" { //材料费
  20430. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20431. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20432. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20433. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20434. if item.ChrgitmLv == "1" {
  20435. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20436. }
  20437. if item.ChrgitmLv == "2" {
  20438. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20439. }
  20440. if item.ChrgitmLv == "3" {
  20441. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20442. }
  20443. }
  20444. if item.MedChrgitmType == "09" { //西药费
  20445. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20446. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20447. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20448. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20449. if item.ChrgitmLv == "1" {
  20450. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20451. }
  20452. if item.ChrgitmLv == "2" {
  20453. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20454. }
  20455. if item.ChrgitmLv == "3" {
  20456. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20457. }
  20458. }
  20459. if item.MedChrgitmType == "11" { //中成费
  20460. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20461. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20462. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20463. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20464. if item.ChrgitmLv == "1" {
  20465. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20466. }
  20467. if item.ChrgitmLv == "2" {
  20468. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20469. }
  20470. if item.ChrgitmLv == "3" {
  20471. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20472. }
  20473. }
  20474. if item.MedChrgitmType == "14" { //其他费
  20475. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20476. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20477. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20478. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20479. if item.ChrgitmLv == "1" {
  20480. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20481. }
  20482. if item.ChrgitmLv == "2" {
  20483. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20484. }
  20485. if item.ChrgitmLv == "3" {
  20486. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20487. }
  20488. }
  20489. }
  20490. var iteminfoStructs []service.IteminfoStruct
  20491. if bedCostTotal != 0 {
  20492. iteminfo.MedChrgitm = "01"
  20493. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20494. iteminfo.Amt = bedCostTotal
  20495. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20496. iteminfo.ClabAmt = bed_clab_amt
  20497. iteminfo.OthAmt = bed_other_amt
  20498. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20499. }
  20500. if checkCostTotal != 0 {
  20501. iteminfo.MedChrgitm = "03"
  20502. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20503. iteminfo.Amt = checkCostTotal
  20504. iteminfo.ClaaSumfee = check_claa_sunmfee
  20505. iteminfo.ClabAmt = check_clab_amt
  20506. iteminfo.OthAmt = check_other_amt
  20507. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20508. }
  20509. if laboratoryCostTotal != 0 {
  20510. iteminfo.MedChrgitm = "04"
  20511. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20512. iteminfo.Amt = laboratoryCostTotal
  20513. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20514. iteminfo.ClabAmt = laboratory_clab_amt
  20515. iteminfo.OthAmt = laboratory_other_amt
  20516. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20517. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20518. }
  20519. if treatCostTotal != 0 {
  20520. iteminfo.MedChrgitm = "05"
  20521. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20522. iteminfo.Amt = treatCostTotal
  20523. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20524. iteminfo.ClabAmt = treat_clab_amt
  20525. iteminfo.OthAmt = treat_other_amt
  20526. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20527. //(struct4101.IteminfoStruct, iteminfo)
  20528. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20529. }
  20530. if operationCostTotal != 0 {
  20531. iteminfo.MedChrgitm = "06"
  20532. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20533. iteminfo.Amt = operationCostTotal
  20534. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20535. iteminfo.ClabAmt = operation_clab_amt
  20536. iteminfo.OthAmt = operation_other_amt
  20537. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20538. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20539. }
  20540. if materialCostTotal != 0 {
  20541. iteminfo.MedChrgitm = "08"
  20542. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20543. iteminfo.Amt = materialCostTotal
  20544. iteminfo.ClaaSumfee = material_claa_sunmfee
  20545. iteminfo.ClabAmt = material_clab_amt
  20546. iteminfo.OthAmt = material_other_amt
  20547. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20549. }
  20550. if westernMedicineCostTotal != 0 {
  20551. iteminfo.MedChrgitm = "09"
  20552. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20553. iteminfo.Amt = westernMedicineCostTotal
  20554. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20555. iteminfo.ClabAmt = westernMedicine_clab_amt
  20556. iteminfo.OthAmt = westernMedicine_other_amt
  20557. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20559. }
  20560. if chineseTraditionalMedicineCostTotal != 0 {
  20561. iteminfo.MedChrgitm = "11"
  20562. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20563. iteminfo.Amt = westernMedicineCostTotal
  20564. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20565. iteminfo.ClabAmt = westernMedicine_clab_amt
  20566. iteminfo.OthAmt = westernMedicine_other_amt
  20567. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20569. }
  20570. if otherCostTotal != 0 {
  20571. iteminfo.MedChrgitm = "14"
  20572. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20573. iteminfo.Amt = otherCostTotal
  20574. iteminfo.ClaaSumfee = other_claa_sunmfee
  20575. iteminfo.ClabAmt = other_clab_amt
  20576. iteminfo.OthAmt = other_other_amt
  20577. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20578. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20579. }
  20580. struct4101.IteminfoStruct = iteminfoStructs
  20581. struct4101.Ntly = "中国"
  20582. struct4101.AdmCaty = "A03.06"
  20583. struct4101.DoctorName = doctor.UserName
  20584. struct4101.DoctorCode = doctor.DoctorNumber
  20585. var res ResultSeventeen
  20586. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20587. struct4101.BillCode = order.Number
  20588. struct4101.BillNo = order.SetlId
  20589. var resOther ResultSeventeenOther
  20590. var pp models.PublicParams
  20591. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20592. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20593. pp.FixmedinsName = miConfig.OrgName
  20594. pp.FixmedinsCode = miConfig.Code
  20595. pp.RequestUrl = miConfig.Url
  20596. pp.Cainfo = miConfig.Cainfo
  20597. pp.SecretKey = miConfig.SecretKey
  20598. pp.AccessKey = miConfig.AccessKey
  20599. pp.OpterName = curRoles.UserName
  20600. client := &http.Client{}
  20601. var req *http.Request
  20602. data := make(map[string]interface{})
  20603. data["struct4101"] = struct4101
  20604. data["pp"] = pp
  20605. bytesData, _ := json.Marshal(data)
  20606. if miConfig.MdtrtareaAdmvs == "320830" {
  20607. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20608. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20609. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20610. } else {
  20611. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20612. }
  20613. resp, _ := client.Do(req)
  20614. defer resp.Body.Close()
  20615. body, ioErr := ioutil.ReadAll(resp.Body)
  20616. if ioErr != nil {
  20617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20619. return
  20620. }
  20621. var respJSON map[string]interface{}
  20622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20625. return
  20626. }
  20627. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20628. userJSONBytes, _ := json.Marshal(respJSON)
  20629. fmt.Println("log")
  20630. fmt.Println(string(userJSONBytes))
  20631. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20632. utils.ErrorLog("解析失败:%v", err)
  20633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20634. return
  20635. }
  20636. res.InfRefmsgid = resOther.InfRefmsgid
  20637. res.Output = resOther.Output
  20638. res.ErrMsg = resOther.ErrMsg
  20639. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20640. res.Infcode = infocode
  20641. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20642. var pp models.PublicParams
  20643. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20644. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20645. pp.FixmedinsName = miConfig.OrgName
  20646. pp.FixmedinsCode = miConfig.Code
  20647. pp.RequestUrl = miConfig.Url
  20648. pp.Cainfo = miConfig.Cainfo
  20649. pp.SecretKey = miConfig.SecretKey
  20650. pp.AccessKey = miConfig.AccessKey
  20651. pp.OpterName = curRoles.UserName
  20652. result, _ := service.Jxyb4101(struct4101, pp)
  20653. var dat map[string]interface{}
  20654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20655. fmt.Println(dat)
  20656. } else {
  20657. fmt.Println(err)
  20658. }
  20659. userJSONBytes, _ := json.Marshal(dat)
  20660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20661. utils.ErrorLog("解析失败:%v", err)
  20662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20663. return
  20664. }
  20665. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20666. var pp models.PublicParams
  20667. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20668. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20669. pp.FixmedinsName = miConfig.OrgName
  20670. pp.FixmedinsCode = miConfig.Code
  20671. pp.RequestUrl = miConfig.Url
  20672. pp.Cainfo = miConfig.Cainfo
  20673. pp.SecretKey = miConfig.SecretKey
  20674. pp.AccessKey = miConfig.AccessKey
  20675. pp.OpterName = curRoles.UserName
  20676. result, _ := service.Jxyb4101(struct4101, pp)
  20677. var dat map[string]interface{}
  20678. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20679. fmt.Println(dat)
  20680. } else {
  20681. fmt.Println(err)
  20682. }
  20683. userJSONBytes, _ := json.Marshal(dat)
  20684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20685. utils.ErrorLog("解析失败:%v", err)
  20686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20687. return
  20688. }
  20689. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20690. var pp models.PublicParams
  20691. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20692. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20693. pp.FixmedinsName = miConfig.OrgName
  20694. pp.FixmedinsCode = miConfig.Code
  20695. pp.RequestUrl = miConfig.Url
  20696. pp.Cainfo = miConfig.Cainfo
  20697. pp.SecretKey = miConfig.SecretKey
  20698. pp.AccessKey = miConfig.AccessKey
  20699. pp.OpterName = curRoles.UserName
  20700. result, _ := service.Jxyb4101(struct4101, pp)
  20701. var dat map[string]interface{}
  20702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20703. fmt.Println(dat)
  20704. } else {
  20705. fmt.Println(err)
  20706. }
  20707. userJSONBytes, _ := json.Marshal(dat)
  20708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20709. utils.ErrorLog("解析失败:%v", err)
  20710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20711. return
  20712. }
  20713. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20714. var pp models.PublicParams
  20715. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20716. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20717. pp.FixmedinsName = miConfig.OrgName
  20718. pp.FixmedinsCode = miConfig.Code
  20719. pp.RequestUrl = miConfig.Url
  20720. pp.Cainfo = miConfig.Cainfo
  20721. pp.SecretKey = miConfig.SecretKey
  20722. pp.AccessKey = miConfig.AccessKey
  20723. pp.OpterName = curRoles.UserName
  20724. result, _ := service.Hnyb4101(struct4101, pp)
  20725. var dat map[string]interface{}
  20726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20727. fmt.Println(dat)
  20728. } else {
  20729. fmt.Println(err)
  20730. }
  20731. userJSONBytes, _ := json.Marshal(dat)
  20732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20733. utils.ErrorLog("解析失败:%v", err)
  20734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20735. return
  20736. }
  20737. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20738. var resOther ResultSeventeenOther
  20739. var pp models.PublicParams
  20740. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20741. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20742. pp.FixmedinsName = miConfig.OrgName
  20743. pp.FixmedinsCode = miConfig.Code
  20744. pp.RequestUrl = miConfig.Url
  20745. pp.Cainfo = miConfig.Cainfo
  20746. pp.SecretKey = miConfig.SecretKey
  20747. pp.AccessKey = miConfig.AccessKey
  20748. pp.OpterName = curRoles.UserName
  20749. client := &http.Client{}
  20750. var req *http.Request
  20751. data := make(map[string]interface{})
  20752. data["struct4101"] = struct4101
  20753. data["pp"] = pp
  20754. bytesData, _ := json.Marshal(data)
  20755. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20756. resp, _ := client.Do(req)
  20757. defer resp.Body.Close()
  20758. body, ioErr := ioutil.ReadAll(resp.Body)
  20759. if ioErr != nil {
  20760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20762. return
  20763. }
  20764. var respJSON map[string]interface{}
  20765. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20768. return
  20769. }
  20770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20771. userJSONBytes, _ := json.Marshal(respJSON)
  20772. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20773. utils.ErrorLog("解析失败:%v", err)
  20774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20775. return
  20776. }
  20777. res.InfRefmsgid = resOther.InfRefmsgid
  20778. res.Output = resOther.Output
  20779. res.ErrMsg = resOther.ErrMsg
  20780. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20781. res.Infcode = infocode
  20782. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20783. var pp models.PublicParams
  20784. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20785. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20786. pp.FixmedinsName = miConfig.OrgName
  20787. pp.FixmedinsCode = miConfig.Code
  20788. pp.RequestUrl = miConfig.Url
  20789. pp.Cainfo = miConfig.Cainfo
  20790. pp.SecretKey = miConfig.SecretKey
  20791. pp.AccessKey = miConfig.AccessKey
  20792. pp.OpterName = curRoles.UserName
  20793. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20794. fmt.Println(requestLog)
  20795. fmt.Println(errMsgLog)
  20796. saveLog(result, requestLog, "4101a", "上传清单")
  20797. var dat map[string]interface{}
  20798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20799. fmt.Println(dat)
  20800. } else {
  20801. fmt.Println(err)
  20802. }
  20803. userJSONBytes, _ := json.Marshal(dat)
  20804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20805. utils.ErrorLog("解析失败:%v", err)
  20806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20807. return
  20808. }
  20809. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20810. var pp models.PublicParams
  20811. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20812. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20813. pp.FixmedinsName = miConfig.OrgName
  20814. pp.FixmedinsCode = miConfig.Code
  20815. pp.RequestUrl = miConfig.Url
  20816. pp.Cainfo = miConfig.Cainfo
  20817. pp.SecretKey = miConfig.SecretKey
  20818. pp.AccessKey = miConfig.AccessKey
  20819. pp.OpterName = curRoles.UserName
  20820. client := &http.Client{}
  20821. var req *http.Request
  20822. data := make(map[string]interface{})
  20823. data["struct4101"] = struct4101
  20824. data["pp"] = pp
  20825. bytesData, _ := json.Marshal(data)
  20826. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20827. resp, _ := client.Do(req)
  20828. defer resp.Body.Close()
  20829. body, ioErr := ioutil.ReadAll(resp.Body)
  20830. if ioErr != nil {
  20831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20833. return
  20834. }
  20835. var respJSON map[string]interface{}
  20836. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20839. return
  20840. }
  20841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20842. userJSONBytes, _ := json.Marshal(respJSON)
  20843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20844. utils.ErrorLog("解析失败:%v", err)
  20845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20846. return
  20847. }
  20848. } else {
  20849. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20850. var dat map[string]interface{}
  20851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20852. fmt.Println(dat)
  20853. } else {
  20854. fmt.Println(err)
  20855. }
  20856. userJSONBytes, _ := json.Marshal(dat)
  20857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20858. utils.ErrorLog("解析失败:%v", err)
  20859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20860. return
  20861. }
  20862. }
  20863. if res.Infcode != 0 {
  20864. c.ServeSuccessJSON(map[string]interface{}{
  20865. "failed_code": -10,
  20866. "msg": res.ErrMsg,
  20867. })
  20868. return
  20869. } else {
  20870. //order.FaPiaoNumber = zero
  20871. //order.FaPiaoCode = last_order.FaPiaoCode
  20872. //service.UpdateOrder(order)
  20873. hisFundSettleListResult := &models.HisFundSettleListResult{
  20874. Number: res.Output.SetlListId,
  20875. Status: 1,
  20876. Ctime: time.Now().Unix(),
  20877. Mtime: time.Now().Unix(),
  20878. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20879. IsUpload: 1,
  20880. OrderId: order_id,
  20881. }
  20882. service.CreateUploadRecord(hisFundSettleListResult)
  20883. c.ServeSuccessJSON(map[string]interface{}{
  20884. "msg": "上传成功",
  20885. "result": hisFundSettleListResult,
  20886. })
  20887. return
  20888. }
  20889. }
  20890. func (c *HisApiController) GetSettleListHospital() {
  20891. order_id, _ := c.GetInt64("order_id")
  20892. admin_user_id, _ := c.GetInt64("admin_user_id")
  20893. order, _ := service.GetHisOrderByIDTwo(order_id)
  20894. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20895. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20896. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20897. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20898. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20899. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20900. if order.ID == 0 {
  20901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20902. return
  20903. }
  20904. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20905. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20906. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20907. fmt.Println(count)
  20908. var zero string
  20909. number := count + 1
  20910. if number >= 1000 {
  20911. zero = "0000" + strconv.FormatInt(number, 10)
  20912. } else if number >= 10000 {
  20913. zero = "000" + strconv.FormatInt(number, 10)
  20914. } else if number >= 100000 {
  20915. zero = "00" + strconv.FormatInt(number, 10)
  20916. } else if number >= 1000000 {
  20917. zero = "0" + strconv.FormatInt(number, 10)
  20918. } else {
  20919. zero = strconv.FormatInt(number, 10)
  20920. }
  20921. fmt.Println(zero)
  20922. struct4101 := service.Struct4101{
  20923. PsnNo: order.PsnNo,
  20924. MdtrtId: order.MdtrtId,
  20925. SetlId: order.SetlId,
  20926. PsnName: order.PsnName,
  20927. Gend: order.Gend,
  20928. Brdy: his.Brdy,
  20929. Age: int64(order.Age),
  20930. Naty: order.Naty,
  20931. PatnCertType: "01",
  20932. Certno: order.Certno,
  20933. Prfs: "90",
  20934. ConerName: roles[0].UserName,
  20935. PatnRlts: "99",
  20936. ConerAddr: miConfig.OrgName,
  20937. ConerTel: admin.Mobile,
  20938. HiType: order.Insutype,
  20939. Insuplc: miConfig.InsuplcAdmdvs,
  20940. MaindiagFlag: "1",
  20941. BillCode: order.SetlId,
  20942. BillNo: order.SetlId,
  20943. BizSn: order.Number,
  20944. PsnSelfPay: order.PsnPartAmt,
  20945. PsnOwnPay: order.PsnPartAmt,
  20946. AcctPay: order.AcctPay,
  20947. PsnCashpay: order.PsnCashPay,
  20948. HiPaymtd: "1",
  20949. Hsorg: miConfig.InsuplcAdmdvs,
  20950. HsorgOpter: miConfig.InsuplcAdmdvs,
  20951. MedinsFillPsn: curRoles.UserName,
  20952. MedinsFillDept: depart.Name,
  20953. IptMedType: "2",
  20954. AdmTime: his.InHosptialTime,
  20955. AdmEndTime: his.OutHosptialTime,
  20956. }
  20957. struct4101.SetlBegnDate = order.SetlTime
  20958. struct4101.SetlEndDate = order.SetlTime
  20959. //var rf []CustomFundPay
  20960. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20961. //
  20962. //var tempFunPays []service.CustomStruct
  20963. //for _, item := range rf {
  20964. // var tempFunPay service.CustomStruct
  20965. // tempFunPay.FundPayamt = item.FundPayamt
  20966. // tempFunPay.FundPayType = item.FundPayType
  20967. // tempFunPays = append(tempFunPays, tempFunPay)
  20968. //}
  20969. //struct4101.CustomStruct = tempFunPays
  20970. var tempDiaginfos []service.DiaginfoStructTwo
  20971. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20972. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20973. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  20974. //for _, item := range infos {
  20975. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  20976. //}
  20977. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  20978. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  20979. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20980. fmt.Println(diagnosis_ids_arr)
  20981. if order.UserOrgId == 10210 {
  20982. var diagnosis_ids_arr_two []int64
  20983. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  20984. var config []*models.HisXtDiagnoseConfig
  20985. for _, id := range diagnosis_ids_arr_two {
  20986. //id, _ := strconv.ParseInt(item, 10, 64)
  20987. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20988. if diagnosisConfig.ID > 0 {
  20989. config = append(config, &diagnosisConfig)
  20990. }
  20991. }
  20992. for index, item := range config {
  20993. if item.ID > 0 {
  20994. if index == 0 {
  20995. var tempDiaginfo service.DiaginfoStructTwo
  20996. tempDiaginfo.DiagCode = item.CountryCode
  20997. tempDiaginfo.DiagName = item.CountryContentName
  20998. tempDiaginfo.DiagType = "1"
  20999. tempDiaginfo.MaindiagFlag = "1"
  21000. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21001. } else {
  21002. var tempDiaginfo service.DiaginfoStructTwo
  21003. tempDiaginfo.DiagCode = item.CountryCode
  21004. tempDiaginfo.DiagName = item.CountryContentName
  21005. tempDiaginfo.DiagType = "1"
  21006. tempDiaginfo.MaindiagFlag = "0"
  21007. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21008. }
  21009. }
  21010. }
  21011. struct4101.Diseinfo = tempDiaginfos
  21012. } else {
  21013. var config []*models.HisXtDiagnoseConfig
  21014. for _, item := range diagnosis_ids_arr {
  21015. id, _ := strconv.ParseInt(item, 10, 64)
  21016. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21017. if diagnosisConfig.ID > 0 {
  21018. config = append(config, &diagnosisConfig)
  21019. }
  21020. }
  21021. for index, item := range config {
  21022. if item.ID > 0 {
  21023. if index == 0 {
  21024. var tempDiaginfo service.DiaginfoStructTwo
  21025. tempDiaginfo.DiagCode = item.CountryCode
  21026. tempDiaginfo.DiagName = item.CountryContentName
  21027. tempDiaginfo.DiagType = "1"
  21028. tempDiaginfo.MaindiagFlag = "1"
  21029. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21030. } else {
  21031. var tempDiaginfo service.DiaginfoStructTwo
  21032. tempDiaginfo.DiagCode = item.CountryCode
  21033. tempDiaginfo.DiagName = item.CountryContentName
  21034. tempDiaginfo.DiagType = "1"
  21035. tempDiaginfo.MaindiagFlag = "0"
  21036. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21037. }
  21038. }
  21039. }
  21040. struct4101.Diseinfo = tempDiaginfos
  21041. }
  21042. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21043. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21044. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21045. tempOpspdiseinfo2.OprnOprtCode = ""
  21046. tempOpspdiseinfo2.OprnOprtName = ""
  21047. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21048. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21049. var iteminfo service.IteminfoStruct
  21050. var bedCostTotal float64 = 0 //床位总费
  21051. var bedCostSelfTotal float64 = 0 //床位自费
  21052. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21053. var operationCostTotal float64 = 0 //手术费
  21054. var operationCostSelfTotal float64 = 0 //手术费
  21055. var operationCostPartSelfTotal float64 = 0 //手术费
  21056. var otherCostTotal float64 = 0 //其他费用
  21057. var otherCostSelfTotal float64 = 0 //其他费用
  21058. var otherCostPartSelfTotal float64 = 0 //其他费用
  21059. var materialCostTotal float64 = 0 //材料费
  21060. var materialCostSelfTotal float64 = 0 //材料费
  21061. var materialCostPartSelfTotal float64 = 0 //材料费
  21062. var westernMedicineCostTotal float64 = 0 //西药费
  21063. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21064. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21065. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21066. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21067. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21068. var checkCostTotal float64 = 0 //检查费
  21069. var checkCostSelfTotal float64 = 0 //检查费
  21070. var checkCostPartSelfTotal float64 = 0 //检查费
  21071. var laboratoryCostTotal float64 = 0 //化验费
  21072. var laboratoryCostSelfTotal float64 = 0 //化验费
  21073. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21074. var treatCostTotal float64 = 0 //治疗费用
  21075. var treatCostSelfTotal float64 = 0 //治疗费用
  21076. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21077. decimal.DivisionPrecision = 2
  21078. var bed_fulamt_ownpay_amt float64 = 0
  21079. var operation_fulamt_ownpay_amt float64 = 0
  21080. var other_fulamt_ownpay_amt float64 = 0
  21081. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21082. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21083. var check_fulamt_ownpay_amt float64 = 0
  21084. var material_fulamt_ownpay_amt float64 = 0
  21085. var laboratory_fulamt_ownpay_amt float64 = 0
  21086. var treat_fulamt_ownpay_amt float64 = 0
  21087. var bed_claa_sunmfee float64 = 0
  21088. var bed_clab_amt float64 = 0
  21089. var bed_other_amt float64 = 0
  21090. var operation_claa_sunmfee float64 = 0
  21091. var operation_clab_amt float64 = 0
  21092. var operation_other_amt float64 = 0
  21093. var other_claa_sunmfee float64 = 0
  21094. var other_clab_amt float64 = 0
  21095. var other_other_amt float64 = 0
  21096. var westernMedicine_claa_sunmfee float64 = 0
  21097. var westernMedicine_clab_amt float64 = 0
  21098. var westernMedicine_other_amt float64 = 0
  21099. var chineseTraditional_claa_sunmfee float64 = 0
  21100. var chineseTraditional_clab_amt float64 = 0
  21101. var chineseTraditional_other_amt float64 = 0
  21102. var check_claa_sunmfee float64 = 0
  21103. var check_clab_amt float64 = 0
  21104. var check_other_amt float64 = 0
  21105. var material_claa_sunmfee float64 = 0
  21106. var material_clab_amt float64 = 0
  21107. var material_other_amt float64 = 0
  21108. var laboratory_claa_sunmfee float64 = 0
  21109. var laboratory_clab_amt float64 = 0
  21110. var laboratory_other_amt float64 = 0
  21111. var treat_claa_sunmfee float64 = 0
  21112. var treat_clab_amt float64 = 0
  21113. var treat_other_amt float64 = 0
  21114. for _, item := range order.HisOrderInfo {
  21115. if item.MedChrgitmType == "01" { //床位费
  21116. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21117. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21118. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21119. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21120. if item.ChrgitmLv == "1" {
  21121. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21122. }
  21123. if item.ChrgitmLv == "2" {
  21124. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21125. }
  21126. if item.ChrgitmLv == "3" {
  21127. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21128. }
  21129. }
  21130. if item.MedChrgitmType == "03" { //检查费
  21131. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21132. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21133. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21134. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21135. if item.ChrgitmLv == "1" {
  21136. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21137. }
  21138. if item.ChrgitmLv == "2" {
  21139. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21140. }
  21141. if item.ChrgitmLv == "3" {
  21142. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21143. }
  21144. }
  21145. if item.MedChrgitmType == "04" { //化验费
  21146. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21147. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21148. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21149. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21150. if item.ChrgitmLv == "1" {
  21151. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21152. }
  21153. if item.ChrgitmLv == "2" {
  21154. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21155. }
  21156. if item.ChrgitmLv == "3" {
  21157. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21158. }
  21159. }
  21160. if item.MedChrgitmType == "05" { //治疗费
  21161. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21162. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21163. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21164. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21165. if item.ChrgitmLv == "1" {
  21166. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21167. }
  21168. if item.ChrgitmLv == "2" {
  21169. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21170. }
  21171. if item.ChrgitmLv == "3" {
  21172. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21173. }
  21174. }
  21175. if item.MedChrgitmType == "06" { //手术费
  21176. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21177. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21178. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21179. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21180. if item.ChrgitmLv == "1" {
  21181. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21182. }
  21183. if item.ChrgitmLv == "2" {
  21184. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21185. }
  21186. if item.ChrgitmLv == "3" {
  21187. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21188. }
  21189. }
  21190. if item.MedChrgitmType == "08" { //材料费
  21191. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21192. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21193. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21194. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21195. if item.ChrgitmLv == "1" {
  21196. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21197. }
  21198. if item.ChrgitmLv == "2" {
  21199. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21200. }
  21201. if item.ChrgitmLv == "3" {
  21202. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21203. }
  21204. }
  21205. if item.MedChrgitmType == "09" { //西药费
  21206. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21207. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21208. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21209. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21210. if item.ChrgitmLv == "1" {
  21211. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21212. }
  21213. if item.ChrgitmLv == "2" {
  21214. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21215. }
  21216. if item.ChrgitmLv == "3" {
  21217. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21218. }
  21219. }
  21220. if item.MedChrgitmType == "11" { //中成费
  21221. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21222. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21223. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21224. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21225. if item.ChrgitmLv == "1" {
  21226. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21227. }
  21228. if item.ChrgitmLv == "2" {
  21229. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21230. }
  21231. if item.ChrgitmLv == "3" {
  21232. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21233. }
  21234. }
  21235. if item.MedChrgitmType == "14" { //其他费
  21236. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21237. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21238. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21239. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21240. if item.ChrgitmLv == "1" {
  21241. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21242. }
  21243. if item.ChrgitmLv == "2" {
  21244. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21245. }
  21246. if item.ChrgitmLv == "3" {
  21247. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21248. }
  21249. }
  21250. }
  21251. var iteminfoStructs []service.IteminfoStruct
  21252. if bedCostTotal != 0 {
  21253. iteminfo.MedChrgitm = "01"
  21254. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21255. iteminfo.Amt = bedCostTotal
  21256. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21257. iteminfo.ClabAmt = bed_clab_amt
  21258. iteminfo.OthAmt = bed_other_amt
  21259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21260. }
  21261. if checkCostTotal != 0 {
  21262. iteminfo.MedChrgitm = "03"
  21263. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21264. iteminfo.Amt = checkCostTotal
  21265. iteminfo.ClaaSumfee = check_claa_sunmfee
  21266. iteminfo.ClabAmt = check_clab_amt
  21267. iteminfo.OthAmt = check_other_amt
  21268. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21269. }
  21270. if laboratoryCostTotal != 0 {
  21271. iteminfo.MedChrgitm = "04"
  21272. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21273. iteminfo.Amt = laboratoryCostTotal
  21274. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21275. iteminfo.ClabAmt = laboratory_clab_amt
  21276. iteminfo.OthAmt = laboratory_other_amt
  21277. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21278. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21279. }
  21280. if treatCostTotal != 0 {
  21281. iteminfo.MedChrgitm = "05"
  21282. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21283. iteminfo.Amt = treatCostTotal
  21284. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21285. iteminfo.ClabAmt = treat_clab_amt
  21286. iteminfo.OthAmt = treat_other_amt
  21287. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21288. //(struct4101.IteminfoStruct, iteminfo)
  21289. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21290. }
  21291. if operationCostTotal != 0 {
  21292. iteminfo.MedChrgitm = "06"
  21293. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21294. iteminfo.Amt = operationCostTotal
  21295. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21296. iteminfo.ClabAmt = operation_clab_amt
  21297. iteminfo.OthAmt = operation_other_amt
  21298. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21300. }
  21301. if materialCostTotal != 0 {
  21302. iteminfo.MedChrgitm = "08"
  21303. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21304. iteminfo.Amt = materialCostTotal
  21305. iteminfo.ClaaSumfee = material_claa_sunmfee
  21306. iteminfo.ClabAmt = material_clab_amt
  21307. iteminfo.OthAmt = material_other_amt
  21308. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21309. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21310. }
  21311. if westernMedicineCostTotal != 0 {
  21312. iteminfo.MedChrgitm = "09"
  21313. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21314. iteminfo.Amt = westernMedicineCostTotal
  21315. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21316. iteminfo.ClabAmt = westernMedicine_clab_amt
  21317. iteminfo.OthAmt = westernMedicine_other_amt
  21318. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21319. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21320. }
  21321. if chineseTraditionalMedicineCostTotal != 0 {
  21322. iteminfo.MedChrgitm = "11"
  21323. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21324. iteminfo.Amt = westernMedicineCostTotal
  21325. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21326. iteminfo.ClabAmt = westernMedicine_clab_amt
  21327. iteminfo.OthAmt = westernMedicine_other_amt
  21328. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21329. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21330. }
  21331. if otherCostTotal != 0 {
  21332. iteminfo.MedChrgitm = "14"
  21333. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21334. iteminfo.Amt = otherCostTotal
  21335. iteminfo.ClaaSumfee = other_claa_sunmfee
  21336. iteminfo.ClabAmt = other_clab_amt
  21337. iteminfo.OthAmt = other_other_amt
  21338. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21339. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21340. }
  21341. struct4101.IteminfoStruct = iteminfoStructs
  21342. struct4101.Ntly = "中国"
  21343. struct4101.AdmCaty = "A03.06"
  21344. var resOther ResultSeventeenOther
  21345. var res ResultSeventeen
  21346. if miConfig.MdtrtareaAdmvs == "150499" {
  21347. var pp models.PublicParams
  21348. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21349. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21350. pp.FixmedinsName = miConfig.OrgName
  21351. pp.FixmedinsCode = miConfig.Code
  21352. pp.RequestUrl = miConfig.Url
  21353. pp.Cainfo = miConfig.Cainfo
  21354. pp.SecretKey = miConfig.SecretKey
  21355. pp.AccessKey = miConfig.AccessKey
  21356. pp.OpterName = curRoles.UserName
  21357. client := &http.Client{}
  21358. var req *http.Request
  21359. data := make(map[string]interface{})
  21360. data["struct4101"] = struct4101
  21361. data["pp"] = pp
  21362. bytesData, _ := json.Marshal(data)
  21363. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21364. resp, _ := client.Do(req)
  21365. defer resp.Body.Close()
  21366. body, ioErr := ioutil.ReadAll(resp.Body)
  21367. if ioErr != nil {
  21368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21370. return
  21371. }
  21372. var respJSON map[string]interface{}
  21373. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21376. return
  21377. }
  21378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21379. userJSONBytes, _ := json.Marshal(respJSON)
  21380. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21381. utils.ErrorLog("解析失败:%v", err)
  21382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21383. return
  21384. }
  21385. res.InfRefmsgid = resOther.InfRefmsgid
  21386. res.Output = resOther.Output
  21387. res.ErrMsg = resOther.ErrMsg
  21388. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21389. res.Infcode = infocode
  21390. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21391. var pp models.PublicParams
  21392. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21394. pp.FixmedinsName = miConfig.OrgName
  21395. pp.FixmedinsCode = miConfig.Code
  21396. pp.RequestUrl = miConfig.Url
  21397. pp.Cainfo = miConfig.Cainfo
  21398. pp.SecretKey = miConfig.SecretKey
  21399. pp.AccessKey = miConfig.AccessKey
  21400. pp.OpterName = curRoles.UserName
  21401. result, _ := service.Jxyb4101(struct4101, pp)
  21402. var dat map[string]interface{}
  21403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21404. fmt.Println(dat)
  21405. } else {
  21406. fmt.Println(err)
  21407. }
  21408. userJSONBytes, _ := json.Marshal(dat)
  21409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21410. utils.ErrorLog("解析失败:%v", err)
  21411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21412. return
  21413. }
  21414. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21415. var pp models.PublicParams
  21416. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21417. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21418. pp.FixmedinsName = miConfig.OrgName
  21419. pp.FixmedinsCode = miConfig.Code
  21420. pp.RequestUrl = miConfig.Url
  21421. pp.Cainfo = miConfig.Cainfo
  21422. pp.SecretKey = miConfig.SecretKey
  21423. pp.AccessKey = miConfig.AccessKey
  21424. pp.OpterName = curRoles.UserName
  21425. result, _ := service.Jxyb4101(struct4101, pp)
  21426. var dat map[string]interface{}
  21427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21428. fmt.Println(dat)
  21429. } else {
  21430. fmt.Println(err)
  21431. }
  21432. userJSONBytes, _ := json.Marshal(dat)
  21433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21434. utils.ErrorLog("解析失败:%v", err)
  21435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21436. return
  21437. }
  21438. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21439. var pp models.PublicParams
  21440. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21441. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21442. pp.FixmedinsName = miConfig.OrgName
  21443. pp.FixmedinsCode = miConfig.Code
  21444. pp.RequestUrl = miConfig.Url
  21445. pp.Cainfo = miConfig.Cainfo
  21446. pp.SecretKey = miConfig.SecretKey
  21447. pp.AccessKey = miConfig.AccessKey
  21448. pp.OpterName = curRoles.UserName
  21449. result, _ := service.Jxyb4101(struct4101, pp)
  21450. var dat map[string]interface{}
  21451. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21452. fmt.Println(dat)
  21453. } else {
  21454. fmt.Println(err)
  21455. }
  21456. userJSONBytes, _ := json.Marshal(dat)
  21457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21458. utils.ErrorLog("解析失败:%v", err)
  21459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21460. return
  21461. }
  21462. } else {
  21463. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21464. var dat map[string]interface{}
  21465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21466. fmt.Println(dat)
  21467. } else {
  21468. fmt.Println(err)
  21469. }
  21470. userJSONBytes, _ := json.Marshal(dat)
  21471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21472. utils.ErrorLog("解析失败:%v", err)
  21473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21474. return
  21475. }
  21476. }
  21477. if res.Infcode != 0 {
  21478. c.ServeSuccessJSON(map[string]interface{}{
  21479. "failed_code": -10,
  21480. "msg": res.ErrMsg,
  21481. })
  21482. return
  21483. } else {
  21484. if miConfig.MdtrtareaAdmvs != "150499" {
  21485. order.FaPiaoNumber = zero
  21486. order.FaPiaoCode = last_order.FaPiaoCode
  21487. service.UpdateOrder(order)
  21488. }
  21489. hisFundSettleListResult := &models.HisFundSettleListResult{
  21490. Number: res.Output.SetlListId,
  21491. Status: 1,
  21492. Ctime: time.Now().Unix(),
  21493. Mtime: time.Now().Unix(),
  21494. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21495. IsUpload: 1,
  21496. OrderId: order_id,
  21497. }
  21498. service.CreateUploadRecord(hisFundSettleListResult)
  21499. c.ServeSuccessJSON(map[string]interface{}{
  21500. "msg": "上传成功",
  21501. "result": hisFundSettleListResult,
  21502. })
  21503. return
  21504. }
  21505. }
  21506. //func (c *HisApiController) GetBatchSettleList() {
  21507. // orders, _ := service.GetAllHisOrder(10106)
  21508. // for _, item := range orders {
  21509. // order_id := item.ID
  21510. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21511. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21512. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21513. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21514. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21515. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21516. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21517. //
  21518. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21519. //
  21520. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21521. //
  21522. // if order.ID == 0 {
  21523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21524. // return
  21525. // }
  21526. // if his.BalanceAccountsType == 2 {
  21527. // continue
  21528. // }
  21529. // struct4101 := service.Struct4101{
  21530. // PsnNo: order.PsnNo,
  21531. // MdtrtId: order.MdtrtId,
  21532. // SetlId: order.SetlId,
  21533. // PsnName: order.PsnName,
  21534. // Gend: order.Gend,
  21535. // Brdy: his.Brdy,
  21536. // Age: his.Age,
  21537. // Naty: order.Naty,
  21538. // PatnCertType: "01",
  21539. // Certno: order.Certno,
  21540. // Prfs: "90",
  21541. // ConerName: roles[0].UserName,
  21542. // PatnRlts: "99",
  21543. // ConerAddr: miConfig.OrgName,
  21544. // ConerTel: admin.Mobile,
  21545. // HiType: order.Insutype,
  21546. // Insuplc: his.InsuplcAdmdvs,
  21547. // MaindiagFlag: "1",
  21548. // BillCode: order.SetlId,
  21549. // BillNo: order.SetlId,
  21550. // BizSn: order.Number,
  21551. // PsnSelfPay: order.PsnPartAmt,
  21552. // PsnOwnPay: order.PsnPartAmt,
  21553. // AcctPay: order.AcctPay,
  21554. // PsnCashpay: order.PsnCashPay,
  21555. // HiPaymtd: "1",
  21556. // Hsorg: his.InsuplcAdmdvs,
  21557. // HsorgOpter: his.InsuplcAdmdvs,
  21558. // MedinsFillPsn: curRoles.UserName,
  21559. // MedinsFillDept: depart.Name,
  21560. // IptMedType: "2",
  21561. // }
  21562. // struct4101.SetlBegnDate = order.SetlTime
  21563. // struct4101.SetlEndDate = order.SetlTime
  21564. // //if order.SettleType == 1 {
  21565. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21566. // // dateStr := t.Format("2006-01-02")
  21567. // // struct4101.SetlBegnDate = dateStr
  21568. // // struct4101.SetlEndDate = dateStr
  21569. // //} else {
  21570. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21571. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21572. // // dateStartStr := t.Format("2006-01-02")
  21573. // // dateEndStr := t2.Format("2006-01-02")
  21574. // // struct4101.SetlBegnDate = dateStartStr
  21575. // // struct4101.SetlEndDate = dateEndStr
  21576. // //}
  21577. //
  21578. // var rf []CustomFundPay
  21579. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21580. //
  21581. // var tempFunPays []service.CustomStruct
  21582. // var tempFunPay610100 service.CustomStruct
  21583. //
  21584. // for _, item := range rf {
  21585. // if item.FundPayType == "610100" {
  21586. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21587. // tempFunPay610100.FundPayType = item.FundPayType
  21588. // } else {
  21589. // var tempFunPay service.CustomStruct
  21590. // tempFunPay.FundPayamt = item.FundPayamt
  21591. // tempFunPay.FundPayType = item.FundPayType
  21592. // tempFunPays = append(tempFunPays, tempFunPay)
  21593. // }
  21594. // }
  21595. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21596. // struct4101.CustomStruct = tempFunPays
  21597. //
  21598. // var tempDiaginfos []service.DiaginfoStructTwo
  21599. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21600. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21601. //
  21602. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21603. // var config []*models.HisXtDiagnoseConfig
  21604. // for _, item := range diagnosis_ids {
  21605. // id, _ := strconv.ParseInt(item, 10, 64)
  21606. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21607. // config = append(config, &diagnosisConfig)
  21608. // }
  21609. //
  21610. // for index, item := range config {
  21611. // if index == 0 {
  21612. // var tempDiaginfo service.DiaginfoStructTwo
  21613. // tempDiaginfo.DiagCode = item.CountryCode
  21614. // tempDiaginfo.DiagName = item.CountryContentName
  21615. // tempDiaginfo.DiagType = "1"
  21616. // tempDiaginfo.MaindiagFlag = "1"
  21617. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21618. // } else {
  21619. //
  21620. // var tempDiaginfo service.DiaginfoStructTwo
  21621. // tempDiaginfo.DiagCode = item.CountryCode
  21622. // tempDiaginfo.DiagName = item.CountryContentName
  21623. // tempDiaginfo.DiagType = "2"
  21624. // tempDiaginfo.MaindiagFlag = "0"
  21625. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21626. // }
  21627. // }
  21628. // struct4101.Diseinfo = tempDiaginfos
  21629. //
  21630. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21631. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21632. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21633. // tempOpspdiseinfo2.OprnOprtCode = ""
  21634. // tempOpspdiseinfo2.OprnOprtName = ""
  21635. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21636. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21637. //
  21638. // var iteminfo service.IteminfoStruct
  21639. //
  21640. // var bedCostTotal float64 = 0 //床位总费
  21641. // var bedCostSelfTotal float64 = 0 //床位自费
  21642. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21643. //
  21644. // var examineCostTotal float64 = 0 //诊查总费
  21645. // var examineCostSelfTotal float64 = 0 //诊查自费
  21646. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21647. //
  21648. // var nursingCostTotal float64 = 0 //护理总费
  21649. // var nursingCostSelfTotal float64 = 0 //护理自费
  21650. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21651. //
  21652. // var chineseMedicineCostTotal float64 = 0 //中成药
  21653. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21654. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21655. //
  21656. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21657. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21658. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21659. //
  21660. // var registerCostTotal float64 = 0 //一般诊疗费
  21661. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21662. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21663. //
  21664. // var operationCostTotal float64 = 0 //手术费
  21665. // var operationCostSelfTotal float64 = 0 //手术费
  21666. // var operationCostPartSelfTotal float64 = 0 //手术费
  21667. //
  21668. // var otherCostTotal float64 = 0 //其他费用
  21669. // var otherCostSelfTotal float64 = 0 //其他费用
  21670. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21671. //
  21672. // var materialCostTotal float64 = 0 //材料费
  21673. // var materialCostSelfTotal float64 = 0 //材料费
  21674. // var materialCostPartSelfTotal float64 = 0 //材料费
  21675. //
  21676. // var westernMedicineCostTotal float64 = 0 //西药费
  21677. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21678. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21679. //
  21680. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21681. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21682. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21683. //
  21684. // var checkCostTotal float64 = 0 //检查费
  21685. // var checkCostSelfTotal float64 = 0 //检查费
  21686. // var checkCostPartSelfTotal float64 = 0 //检查费
  21687. //
  21688. // var laboratoryCostTotal float64 = 0 //化验费
  21689. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21690. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21691. //
  21692. // var treatCostTotal float64 = 0 //治疗费用
  21693. // var treatCostSelfTotal float64 = 0 //治疗费用
  21694. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21695. //
  21696. // decimal.DivisionPrecision = 2
  21697. //
  21698. // var bed_fulamt_ownpay_amt float64 = 0
  21699. //
  21700. // var examine_fulamt_ownpay_amt float64 = 0
  21701. //
  21702. // var nursing_fulamt_ownpay_amt float64 = 0
  21703. //
  21704. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21705. //
  21706. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21707. //
  21708. // var register_fulamt_ownpay_amt float64 = 0
  21709. //
  21710. // var operation_fulamt_ownpay_amt float64 = 0
  21711. // var other_fulamt_ownpay_amt float64 = 0
  21712. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21713. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21714. // var check_fulamt_ownpay_amt float64 = 0
  21715. // var material_fulamt_ownpay_amt float64 = 0
  21716. // var laboratory_fulamt_ownpay_amt float64 = 0
  21717. // var treat_fulamt_ownpay_amt float64 = 0
  21718. //
  21719. // var bed_claa_sunmfee float64 = 0
  21720. // var bed_clab_amt float64 = 0
  21721. // var bed_other_amt float64 = 0
  21722. //
  21723. // var examine_claa_sunmfee float64 = 0
  21724. // var examine_clab_amt float64 = 0
  21725. // var examine_other_amt float64 = 0
  21726. //
  21727. // var nursing_claa_sunmfee float64 = 0
  21728. // var nursing_clab_amt float64 = 0
  21729. // var nursing_other_amt float64 = 0
  21730. //
  21731. // var chinese_medicine_claa_sunmfee float64 = 0
  21732. // var chinese_medicine_clab_amt float64 = 0
  21733. // var chinese_medicine_other_amt float64 = 0
  21734. //
  21735. // var commonly_treatment_claa_sunmfee float64 = 0
  21736. // var commonly_treatment_clab_amt float64 = 0
  21737. // var commonly_treatment_other_amt float64 = 0
  21738. //
  21739. // var operation_claa_sunmfee float64 = 0
  21740. // var operation_clab_amt float64 = 0
  21741. // var operation_other_amt float64 = 0
  21742. //
  21743. // var other_claa_sunmfee float64 = 0
  21744. // var other_clab_amt float64 = 0
  21745. // var other_other_amt float64 = 0
  21746. //
  21747. // var westernMedicine_claa_sunmfee float64 = 0
  21748. // var westernMedicine_clab_amt float64 = 0
  21749. // var westernMedicine_other_amt float64 = 0
  21750. //
  21751. // var chineseTraditional_claa_sunmfee float64 = 0
  21752. // var chineseTraditional_clab_amt float64 = 0
  21753. // var chineseTraditional_other_amt float64 = 0
  21754. //
  21755. // var check_claa_sunmfee float64 = 0
  21756. // var check_clab_amt float64 = 0
  21757. // var check_other_amt float64 = 0
  21758. //
  21759. // var material_claa_sunmfee float64 = 0
  21760. // var material_clab_amt float64 = 0
  21761. // var material_other_amt float64 = 0
  21762. //
  21763. // var laboratory_claa_sunmfee float64 = 0
  21764. // var laboratory_clab_amt float64 = 0
  21765. // var laboratory_other_amt float64 = 0
  21766. //
  21767. // var treat_claa_sunmfee float64 = 0
  21768. // var treat_clab_amt float64 = 0
  21769. // var treat_other_amt float64 = 0
  21770. //
  21771. // var register_claa_sunmfee float64 = 0
  21772. // var register_clab_amt float64 = 0
  21773. // var register_other_amt float64 = 0
  21774. //
  21775. // for _, item := range order.HisOrderInfo {
  21776. // if item.MedChrgitmType == "01" { //床位费
  21777. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21778. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21779. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21780. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21781. // if item.ChrgitmLv == "1" {
  21782. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21783. // }
  21784. // if item.ChrgitmLv == "2" {
  21785. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21786. //
  21787. // }
  21788. // if item.ChrgitmLv == "3" {
  21789. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21790. // }
  21791. //
  21792. // }
  21793. //
  21794. // if item.MedChrgitmType == "02" { //诊查
  21795. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21796. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21797. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21798. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21799. // if item.ChrgitmLv == "1" {
  21800. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21801. // }
  21802. // if item.ChrgitmLv == "2" {
  21803. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21804. //
  21805. // }
  21806. // if item.ChrgitmLv == "3" {
  21807. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21808. // }
  21809. //
  21810. // }
  21811. //
  21812. // if item.MedChrgitmType == "03" { //检查费
  21813. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21814. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21815. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21816. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21817. // if item.ChrgitmLv == "1" {
  21818. //
  21819. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21820. //
  21821. // }
  21822. // if item.ChrgitmLv == "2" {
  21823. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21824. //
  21825. // }
  21826. // if item.ChrgitmLv == "3" {
  21827. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21828. // }
  21829. // }
  21830. //
  21831. // if item.MedChrgitmType == "04" { //化验费
  21832. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21833. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21834. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21835. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21836. // if item.ChrgitmLv == "1" {
  21837. //
  21838. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21839. //
  21840. // }
  21841. // if item.ChrgitmLv == "2" {
  21842. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21843. //
  21844. // }
  21845. // if item.ChrgitmLv == "3" {
  21846. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21847. // }
  21848. // }
  21849. //
  21850. // if item.MedChrgitmType == "05" { //治疗费
  21851. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21852. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21853. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21854. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21855. // if item.ChrgitmLv == "1" {
  21856. //
  21857. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21858. //
  21859. // }
  21860. // if item.ChrgitmLv == "2" {
  21861. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21862. //
  21863. // }
  21864. // if item.ChrgitmLv == "3" {
  21865. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21866. // }
  21867. // }
  21868. //
  21869. // if item.MedChrgitmType == "06" { //手术费
  21870. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21871. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21872. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21873. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21874. //
  21875. // if item.ChrgitmLv == "1" {
  21876. //
  21877. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21878. //
  21879. // }
  21880. // if item.ChrgitmLv == "2" {
  21881. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21882. //
  21883. // }
  21884. // if item.ChrgitmLv == "3" {
  21885. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21886. // }
  21887. // }
  21888. //
  21889. // if item.MedChrgitmType == "07" { //手术费
  21890. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21891. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21892. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21893. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21894. //
  21895. // if item.ChrgitmLv == "1" {
  21896. //
  21897. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21898. //
  21899. // }
  21900. // if item.ChrgitmLv == "2" {
  21901. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21902. //
  21903. // }
  21904. // if item.ChrgitmLv == "3" {
  21905. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21906. // }
  21907. // }
  21908. //
  21909. // if item.MedChrgitmType == "08" { //材料费
  21910. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21911. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21912. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21913. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21914. // if item.ChrgitmLv == "1" {
  21915. //
  21916. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21917. //
  21918. // }
  21919. // if item.ChrgitmLv == "2" {
  21920. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21921. //
  21922. // }
  21923. // if item.ChrgitmLv == "3" {
  21924. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21925. // }
  21926. // }
  21927. // if item.MedChrgitmType == "09" { //西药费
  21928. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21929. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21930. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21931. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21932. // if item.ChrgitmLv == "1" {
  21933. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21934. // }
  21935. // if item.ChrgitmLv == "2" {
  21936. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21937. // }
  21938. // if item.ChrgitmLv == "3" {
  21939. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21940. // }
  21941. // }
  21942. // if item.MedChrgitmType == "10" { //中药饮片
  21943. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21944. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21945. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21946. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21947. // if item.ChrgitmLv == "1" {
  21948. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21949. // }
  21950. // if item.ChrgitmLv == "2" {
  21951. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21952. // }
  21953. // if item.ChrgitmLv == "3" {
  21954. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21955. // }
  21956. // }
  21957. //
  21958. // if item.MedChrgitmType == "11" { //中成费
  21959. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21960. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21961. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21962. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21963. // if item.ChrgitmLv == "1" {
  21964. //
  21965. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21966. //
  21967. // }
  21968. // if item.ChrgitmLv == "2" {
  21969. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21970. //
  21971. // }
  21972. // if item.ChrgitmLv == "3" {
  21973. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21974. // }
  21975. // }
  21976. //
  21977. // if item.MedChrgitmType == "12" { //中成费
  21978. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21979. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21980. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21981. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21982. // if item.ChrgitmLv == "1" {
  21983. //
  21984. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21985. //
  21986. // }
  21987. // if item.ChrgitmLv == "2" {
  21988. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21989. //
  21990. // }
  21991. // if item.ChrgitmLv == "3" {
  21992. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21993. // }
  21994. // }
  21995. //
  21996. // if item.MedChrgitmType == "13" { //中成费
  21997. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21998. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21999. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22000. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22001. // if item.ChrgitmLv == "1" {
  22002. //
  22003. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22004. //
  22005. // }
  22006. // if item.ChrgitmLv == "2" {
  22007. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22008. //
  22009. // }
  22010. // if item.ChrgitmLv == "3" {
  22011. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22012. // }
  22013. // }
  22014. //
  22015. // if item.MedChrgitmType == "14" { //其他费
  22016. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22017. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22018. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22019. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22020. // if item.ChrgitmLv == "1" {
  22021. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22022. //
  22023. // }
  22024. // if item.ChrgitmLv == "2" {
  22025. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22026. //
  22027. // }
  22028. // if item.ChrgitmLv == "3" {
  22029. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22030. // }
  22031. // }
  22032. //
  22033. // }
  22034. //
  22035. // var iteminfoStructs []service.IteminfoStruct
  22036. //
  22037. // if bedCostTotal != 0 {
  22038. // iteminfo.MedChrgitm = "01"
  22039. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22040. // iteminfo.Amt = bedCostTotal
  22041. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22042. // iteminfo.ClabAmt = bed_clab_amt
  22043. // iteminfo.OthAmt = bed_other_amt
  22044. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22045. // }
  22046. //
  22047. // if examineCostTotal != 0 {
  22048. // iteminfo.MedChrgitm = "02"
  22049. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22050. // iteminfo.Amt = examineCostTotal
  22051. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22052. // iteminfo.ClabAmt = examine_clab_amt
  22053. // iteminfo.OthAmt = examine_other_amt
  22054. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22055. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22056. // }
  22057. //
  22058. // if checkCostTotal != 0 {
  22059. // iteminfo.MedChrgitm = "03"
  22060. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22061. // iteminfo.Amt = checkCostTotal
  22062. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22063. // iteminfo.ClabAmt = check_clab_amt
  22064. // iteminfo.OthAmt = check_other_amt
  22065. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22066. //
  22067. // }
  22068. //
  22069. // if laboratoryCostTotal != 0 {
  22070. // iteminfo.MedChrgitm = "04"
  22071. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22072. // iteminfo.Amt = laboratoryCostTotal
  22073. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22074. // iteminfo.ClabAmt = laboratory_clab_amt
  22075. // iteminfo.OthAmt = laboratory_other_amt
  22076. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22077. //
  22078. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22079. //
  22080. // }
  22081. //
  22082. // if treatCostTotal != 0 {
  22083. // iteminfo.MedChrgitm = "05"
  22084. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22085. // iteminfo.Amt = treatCostTotal
  22086. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22087. // iteminfo.ClabAmt = treat_clab_amt
  22088. // iteminfo.OthAmt = treat_other_amt
  22089. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22090. // //(struct4101.IteminfoStruct, iteminfo)
  22091. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22092. // }
  22093. //
  22094. // if operationCostTotal != 0 {
  22095. // iteminfo.MedChrgitm = "06"
  22096. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22097. // iteminfo.Amt = operationCostTotal
  22098. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22099. // iteminfo.ClabAmt = operation_clab_amt
  22100. // iteminfo.OthAmt = operation_other_amt
  22101. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22102. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22103. // }
  22104. //
  22105. // if nursingCostTotal != 0 {
  22106. // iteminfo.MedChrgitm = "07"
  22107. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22108. // iteminfo.Amt = nursingCostTotal
  22109. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22110. // iteminfo.ClabAmt = nursing_clab_amt
  22111. // iteminfo.OthAmt = nursing_other_amt
  22112. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22113. // }
  22114. //
  22115. // if materialCostTotal != 0 {
  22116. // iteminfo.MedChrgitm = "08"
  22117. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22118. // iteminfo.Amt = materialCostTotal
  22119. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22120. // iteminfo.ClabAmt = material_clab_amt
  22121. // iteminfo.OthAmt = material_other_amt
  22122. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22123. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22124. // }
  22125. //
  22126. // if westernMedicineCostTotal != 0 {
  22127. // iteminfo.MedChrgitm = "09"
  22128. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22129. // iteminfo.Amt = westernMedicineCostTotal
  22130. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22131. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22132. // iteminfo.OthAmt = westernMedicine_other_amt
  22133. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22134. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22135. //
  22136. // }
  22137. //
  22138. // if chineseMedicineCostTotal != 0 {
  22139. // iteminfo.MedChrgitm = "10"
  22140. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22141. // iteminfo.Amt = chineseMedicineCostTotal
  22142. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22143. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22144. // iteminfo.OthAmt = chinese_medicine_other_amt
  22145. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22146. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22147. //
  22148. // }
  22149. //
  22150. // if chineseTraditionalMedicineCostTotal != 0 {
  22151. // iteminfo.MedChrgitm = "11"
  22152. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22153. // iteminfo.Amt = westernMedicineCostTotal
  22154. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22155. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22156. // iteminfo.OthAmt = westernMedicine_other_amt
  22157. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22158. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22159. //
  22160. // }
  22161. //
  22162. // if commonlyTreatmentCostTotal != 0 {
  22163. // iteminfo.MedChrgitm = "12"
  22164. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22165. // iteminfo.Amt = commonlyTreatmentCostTotal
  22166. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22167. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22168. // iteminfo.OthAmt = commonly_treatment_other_amt
  22169. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22170. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22171. //
  22172. // }
  22173. //
  22174. // if registerCostTotal != 0 {
  22175. // iteminfo.MedChrgitm = "13"
  22176. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22177. // iteminfo.Amt = registerCostTotal
  22178. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22179. // iteminfo.ClabAmt = register_clab_amt
  22180. // iteminfo.OthAmt = register_other_amt
  22181. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22182. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22183. //
  22184. // }
  22185. //
  22186. // if otherCostTotal != 0 {
  22187. // iteminfo.MedChrgitm = "14"
  22188. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22189. // iteminfo.Amt = otherCostTotal
  22190. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22191. // iteminfo.ClabAmt = other_clab_amt
  22192. // iteminfo.OthAmt = other_other_amt
  22193. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22194. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22195. //
  22196. // }
  22197. // struct4101.IteminfoStruct = iteminfoStructs
  22198. // time_arr := strings.Split(order.SetlTime, " ")
  22199. // struct4101.AdmTime = time_arr[0]
  22200. // struct4101.AdmEndTime = time_arr[0]
  22201. //
  22202. // struct4101.DoctorName = doctor.UserName
  22203. // struct4101.DoctorCode = doctor.DoctorNumber
  22204. //
  22205. // struct4101.Ntly = "中国"
  22206. // struct4101.AdmCaty = "A03.06"
  22207. // var res ResultSeventeen
  22208. // if miConfig.MdtrtareaAdmvs == "421300" {
  22209. // data := make(map[string]interface{})
  22210. // data["struct4101"] = struct4101
  22211. // data["secret_key"] = miConfig.SecretKey
  22212. // data["org_name"] = miConfig.OrgName
  22213. // data["opera"] = curRoles.UserName
  22214. // data["code"] = miConfig.Code
  22215. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22216. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22217. //
  22218. // client := &http.Client{}
  22219. // bytesData, _ := json.Marshal(data)
  22220. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22221. // resp, _ := client.Do(req)
  22222. // defer resp.Body.Close()
  22223. // body, ioErr := ioutil.ReadAll(resp.Body)
  22224. // if ioErr != nil {
  22225. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22227. // return
  22228. // }
  22229. // var respJSON map[string]interface{}
  22230. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22231. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22233. // return
  22234. // }
  22235. //
  22236. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22237. // userJSONBytes, _ := json.Marshal(respJSON)
  22238. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22239. // utils.ErrorLog("解析失败:%v", err)
  22240. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22241. // adminUser := c.GetAdminUserInfo()
  22242. // errlog := &models.HisOrderError{
  22243. // UserOrgId: adminUser.CurrentOrgId,
  22244. // Ctime: time.Now().Unix(),
  22245. // Mtime: time.Now().Unix(),
  22246. // ErrMsg: res.ErrMsg + "解析失败",
  22247. // Status: 1,
  22248. // PatientId: order_id,
  22249. // Stage: 10088,
  22250. // }
  22251. // service.CreateErrMsgLog(errlog)
  22252. // continue
  22253. // }
  22254. //
  22255. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22256. // data := make(map[string]interface{})
  22257. // data["struct4101"] = struct4101
  22258. // data["secret_key"] = miConfig.SecretKey
  22259. // data["org_name"] = miConfig.OrgName
  22260. // data["opera"] = curRoles.UserName
  22261. // data["code"] = miConfig.Code
  22262. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22263. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22264. //
  22265. // client := &http.Client{}
  22266. // bytesData, _ := json.Marshal(data)
  22267. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22268. // resp, _ := client.Do(req)
  22269. // defer resp.Body.Close()
  22270. // body, ioErr := ioutil.ReadAll(resp.Body)
  22271. // if ioErr != nil {
  22272. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22274. // return
  22275. // }
  22276. // var respJSON map[string]interface{}
  22277. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22278. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22279. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22280. // return
  22281. // }
  22282. //
  22283. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22284. // userJSONBytes, _ := json.Marshal(respJSON)
  22285. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22286. // utils.ErrorLog("解析失败:%v", err)
  22287. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22288. // adminUser := c.GetAdminUserInfo()
  22289. // errlog := &models.HisOrderError{
  22290. // UserOrgId: adminUser.CurrentOrgId,
  22291. // Ctime: time.Now().Unix(),
  22292. // Mtime: time.Now().Unix(),
  22293. // ErrMsg: res.ErrMsg + "解析失败",
  22294. // Status: 1,
  22295. // PatientId: order_id,
  22296. // Stage: 10088,
  22297. // }
  22298. // service.CreateErrMsgLog(errlog)
  22299. // continue
  22300. // }
  22301. //
  22302. // } else {
  22303. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22304. // fmt.Println(result)
  22305. //
  22306. // var dat map[string]interface{}
  22307. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22308. // fmt.Println(dat)
  22309. // } else {
  22310. // fmt.Println(err)
  22311. // }
  22312. // userJSONBytes, _ := json.Marshal(dat)
  22313. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22314. // utils.ErrorLog("解析失败:%v", err)
  22315. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22316. // adminUser := c.GetAdminUserInfo()
  22317. // errlog := &models.HisOrderError{
  22318. // UserOrgId: adminUser.CurrentOrgId,
  22319. // Ctime: time.Now().Unix(),
  22320. // Mtime: time.Now().Unix(),
  22321. // ErrMsg: res.ErrMsg + "解析失败",
  22322. // Status: 1,
  22323. // PatientId: order_id,
  22324. // Stage: 10106,
  22325. // }
  22326. // service.CreateErrMsgLog(errlog)
  22327. // continue
  22328. // }
  22329. // }
  22330. //
  22331. // if res.Infcode != 0 {
  22332. // adminUser := c.GetAdminUserInfo()
  22333. // errlog := &models.HisOrderError{
  22334. // UserOrgId: adminUser.CurrentOrgId,
  22335. // Ctime: time.Now().Unix(),
  22336. // Mtime: time.Now().Unix(),
  22337. // ErrMsg: res.ErrMsg,
  22338. // Status: 1,
  22339. // PatientId: order_id,
  22340. // Stage: 10106,
  22341. // }
  22342. // service.CreateErrMsgLog(errlog)
  22343. // continue
  22344. // } else {
  22345. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22346. // Number: res.Output.SetlListId,
  22347. // Status: 1,
  22348. // Ctime: time.Now().Unix(),
  22349. // Mtime: time.Now().Unix(),
  22350. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22351. // IsUpload: 1,
  22352. // OrderId: order_id,
  22353. // }
  22354. // service.CreateUploadRecord(hisFundSettleListResult)
  22355. // continue
  22356. // }
  22357. // }
  22358. //}
  22359. func (c *HisApiController) GetOrgInfo() {
  22360. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22361. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22362. }
  22363. func (c *HisApiController) GetHisPatientInfo() {
  22364. medical_insurance_card := c.GetString("medical_insurance_card")
  22365. id_card_type, _ := c.GetInt64("id_card_type")
  22366. id_card := c.GetString("id_card")
  22367. adminInfo := c.GetAdminUserInfo()
  22368. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22369. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22370. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22371. IdCardNo := ""
  22372. if id_card_type == 1 {
  22373. IdCardNo = medical_insurance_card
  22374. } else if id_card_type == 2 {
  22375. IdCardNo = id_card
  22376. }
  22377. if config.IsOpen == 1 {
  22378. 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
  22379. resp, requestErr := http.Get(api)
  22380. if requestErr != nil {
  22381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22382. return
  22383. }
  22384. defer resp.Body.Close()
  22385. body, ioErr := ioutil.ReadAll(resp.Body)
  22386. if ioErr != nil {
  22387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22389. return
  22390. }
  22391. var respJSON map[string]interface{}
  22392. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22395. return
  22396. }
  22397. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22398. userJSONBytes, _ := json.Marshal(userJSON)
  22399. var res ResultTwo
  22400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22401. utils.ErrorLog("解析失败:%v", err)
  22402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22403. return
  22404. }
  22405. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22406. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22407. infoStr := string(Iinfos)
  22408. idetinfoStr := string(Idetinfos)
  22409. if res.Infcode == 0 {
  22410. his := models.VMHisPatient{
  22411. Status: 1,
  22412. Ctime: time.Now().Unix(),
  22413. Mtime: time.Now().Unix(),
  22414. PsnNo: res.Output.Baseinfo.PsnNo,
  22415. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22416. Certno: res.Output.Baseinfo.Certno,
  22417. PsnName: res.Output.Baseinfo.PsnName,
  22418. Gend: res.Output.Baseinfo.Gend,
  22419. Naty: res.Output.Baseinfo.Naty,
  22420. Iinfo: infoStr,
  22421. Idetinfo: idetinfoStr,
  22422. UserOrgId: adminInfo.CurrentOrgId,
  22423. IsReturn: 1,
  22424. IdCardType: id_card_type,
  22425. }
  22426. c.ServeSuccessJSON(map[string]interface{}{
  22427. "info": his,
  22428. })
  22429. } else {
  22430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22431. return
  22432. }
  22433. }
  22434. }
  22435. //func GetBasBaseInfo() (jsonStr string, err error) {
  22436. //
  22437. // handle := syscall.NewLazyDLL("SSCard.dll")
  22438. // add := handle.NewProc("ReadCardBas")
  22439. // str := make([]byte, 1024)
  22440. // str1 := make([]byte, 1024)
  22441. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22442. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22443. //
  22444. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22445. //
  22446. // fmt.Println("> Add(4,5)的结果为:", ret)
  22447. // handle.Release()
  22448. //
  22449. // return "", nil
  22450. //
  22451. //}
  22452. //func GetQRBaseInfo() (jsonStr string, err error) {
  22453. // handle := syscall.LoadDLL("SSCard.dll")
  22454. // ReadCardBas := handle.FindProc("GetQRBase")
  22455. //
  22456. // str := make([]byte, 256)
  22457. // str1 := make([]byte, 256)
  22458. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22459. //
  22460. // fmt.Println(string(str))
  22461. // fmt.Println(r)
  22462. // return string(str), nil
  22463. //}
  22464. //func CardInit() int {
  22465. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22466. // add := DllTestDef.MustFindProc("Init")
  22467. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22468. // if err != nil {
  22469. // fmt.Println("SSCard的运算结果为:", ret)
  22470. // }
  22471. // result := int(ret)
  22472. // return result
  22473. //}
  22474. //func CardInit() int {
  22475. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22476. // if err != nil {
  22477. // fmt.Println("SSCard的运算结果为:", ret)
  22478. // }
  22479. // fmt.Println(err)
  22480. // result := int(ret)
  22481. // return result
  22482. //}
  22483. func IntPtr(n int) uintptr {
  22484. return uintptr(n)
  22485. }
  22486. func StrPtr(s string) uintptr {
  22487. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22488. }
  22489. type Result2001 struct {
  22490. Cainfo interface{} `json:"cainfo"`
  22491. ErrMsg string `json:"err_msg"`
  22492. InfRefmsgid string `json:"inf_refmsgid"`
  22493. Infcode int64 `json:"infcode"`
  22494. Output struct {
  22495. Trtinfo struct {
  22496. PsnNo string `json:"psn_no"`
  22497. TrtChkType string `json:"trt_chk_type"`
  22498. FundPayType string `json:"fund_pay_type"`
  22499. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22500. Begndate string `json:"begndate"`
  22501. Enddate string `json:"enddate"`
  22502. TrtChkRslt string `json:"trt_chk_rslt"`
  22503. } `json:"trtinfo"`
  22504. } `json:"output"`
  22505. RefmsgTime string `json:"refmsg_time"`
  22506. RespondTime string `json:"respond_time"`
  22507. Signtype interface{} `json:"signtype"`
  22508. WarnMsg interface{} `json:"warn_msg"`
  22509. }
  22510. type Result2001Org10265 struct {
  22511. Cainfo interface{} `json:"cainfo"`
  22512. ErrMsg string `json:"err_msg"`
  22513. InfRefmsgid string `json:"inf_refmsgid"`
  22514. Infcode string `json:"infcode"`
  22515. Output struct {
  22516. Trtinfo struct {
  22517. PsnNo string `json:"psn_no"`
  22518. TrtChkType string `json:"trt_chk_type"`
  22519. FundPayType string `json:"fund_pay_type"`
  22520. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22521. Begndate string `json:"begndate"`
  22522. Enddate string `json:"enddate"`
  22523. TrtChkRslt string `json:"trt_chk_rslt"`
  22524. } `json:"trtinfo"`
  22525. } `json:"output"`
  22526. RefmsgTime string `json:"refmsg_time"`
  22527. RespondTime string `json:"respond_time"`
  22528. Signtype interface{} `json:"signtype"`
  22529. WarnMsg interface{} `json:"warn_msg"`
  22530. }
  22531. type ResultTwo struct {
  22532. ErrMsg string `json:"err_msg"`
  22533. InfRefmsgid string `json:"inf_refmsgid"`
  22534. Infcode int64 `json:"infcode"`
  22535. Output struct {
  22536. Baseinfo struct {
  22537. //Brdy string `json:"brdy"`
  22538. Certno string `json:"certno"`
  22539. Gend string `json:"gend"`
  22540. Naty string `json:"naty"`
  22541. PsnCertType string `json:"psn_cert_type"`
  22542. PsnName string `json:"psn_name"`
  22543. PsnNo string `json:"psn_no"`
  22544. } `json:"baseinfo"`
  22545. Idetinfo []interface{} `json:"idetinfo"`
  22546. Iinfo []struct {
  22547. Balc float64 `json:"balc"`
  22548. CvlservFlag string `json:"cvlserv_flag"`
  22549. EmpName string `json:"emp_name"`
  22550. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22551. Insutype string `json:"insutype"`
  22552. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22553. //PausInsuDate string `json:"paus_insu_date"`
  22554. //PsnInsuDate string `json:"psn_insu_date"`
  22555. PsnInsuStas string `json:"psn_insu_stas"`
  22556. PsnType string `json:"psn_type"`
  22557. } `json:"insuinfo"`
  22558. } `json:"output"`
  22559. RefmsgTime string `json:"refmsg_time"`
  22560. RespondTime string `json:"respond_time"`
  22561. Signtype interface{} `json:"signtype"`
  22562. WarnInfo interface{} `json:"warn_info"`
  22563. }
  22564. type ResultTwo10265 struct {
  22565. ErrMsg string `json:"err_msg"`
  22566. InfRefmsgid string `json:"inf_refmsgid"`
  22567. Infcode string `json:"infcode"`
  22568. Output struct {
  22569. Baseinfo struct {
  22570. //Brdy string `json:"brdy"`
  22571. Certno string `json:"certno"`
  22572. Gend string `json:"gend"`
  22573. Naty string `json:"naty"`
  22574. PsnCertType string `json:"psn_cert_type"`
  22575. PsnName string `json:"psn_name"`
  22576. PsnNo string `json:"psn_no"`
  22577. } `json:"baseinfo"`
  22578. Idetinfo []interface{} `json:"idetinfo"`
  22579. Iinfo []struct {
  22580. Balc float64 `json:"balc"`
  22581. CvlservFlag string `json:"cvlserv_flag"`
  22582. EmpName string `json:"emp_name"`
  22583. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22584. Insutype string `json:"insutype"`
  22585. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22586. PsnInsuStas string `json:"psn_insu_stas"`
  22587. PsnType string `json:"psn_type"`
  22588. } `json:"insuinfo"`
  22589. } `json:"output"`
  22590. RefmsgTime string `json:"refmsg_time"`
  22591. RespondTime string `json:"respond_time"`
  22592. Signtype interface{} `json:"signtype"`
  22593. WarnInfo interface{} `json:"warn_info"`
  22594. }
  22595. type ResultThree struct {
  22596. Cainfo interface{} `json:"cainfo"`
  22597. ErrMsg string `json:"err_msg"`
  22598. InfRefmsgid string `json:"inf_refmsgid"`
  22599. Infcode int64 `json:"infcode"`
  22600. Output struct {
  22601. Data struct {
  22602. IptOtpNo string `json:"ipt_otp_no"`
  22603. MdtrtID string `json:"mdtrt_id"`
  22604. PsnNo string `json:"psn_no"`
  22605. } `json:"data"`
  22606. } `json:"output"`
  22607. RefmsgTime string `json:"refmsg_time"`
  22608. RespondTime string `json:"respond_time"`
  22609. Signtype interface{} `json:"signtype"`
  22610. WarnMsg interface{} `json:"warn_msg"`
  22611. }
  22612. type ResultThree10265 struct {
  22613. Cainfo interface{} `json:"cainfo"`
  22614. ErrMsg string `json:"err_msg"`
  22615. InfRefmsgid string `json:"inf_refmsgid"`
  22616. Infcode string `json:"infcode"`
  22617. Output struct {
  22618. Data struct {
  22619. IptOtpNo string `json:"ipt_otp_no"`
  22620. MdtrtID string `json:"mdtrt_id"`
  22621. PsnNo string `json:"psn_no"`
  22622. } `json:"data"`
  22623. } `json:"output"`
  22624. RefmsgTime string `json:"refmsg_time"`
  22625. RespondTime string `json:"respond_time"`
  22626. Signtype interface{} `json:"signtype"`
  22627. WarnMsg interface{} `json:"warn_msg"`
  22628. }
  22629. type ResultFour struct {
  22630. Cainfo string `json:"cainfo"`
  22631. ErrMsg string `json:"err_msg"`
  22632. InfRefmsgid string `json:"inf_refmsgid"`
  22633. Infcode int64 `json:"infcode"`
  22634. Output struct {
  22635. Result []struct {
  22636. BasMednFlag string `json:"bas_medn_flag"`
  22637. ChldMedcFlag string `json:"chld_medc_flag"`
  22638. ChrgitmLv string `json:"chrgitm_lv"`
  22639. Cnt float64 `json:"cnt"`
  22640. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22641. DrtReimFlag string `json:"drt_reim_flag"`
  22642. FeedetlSn string `json:"feedetl_sn"`
  22643. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22644. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22645. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22646. ListSpItemFlag string `json:"list_sp_item_flag"`
  22647. LmtUsedFlag string `json:"lmt_used_flag"`
  22648. MedChrgitmType string `json:"med_chrgitm_type"`
  22649. Memo string `json:"memo"`
  22650. OverlmtAmt float64 `json:"overlmt_amt"`
  22651. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22652. Pric float64 `json:"pric"`
  22653. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22654. SelfpayProp float64 `json:"selfpay_prop"`
  22655. } `json:"result"`
  22656. } `json:"output"`
  22657. RefmsgTime string `json:"refmsg_time"`
  22658. RespondTime string `json:"respond_time"`
  22659. Signtype string `json:"signtype"`
  22660. WarnMsg string `json:"warn_msg"`
  22661. }
  22662. type ResultFour10265 struct {
  22663. Cainfo string `json:"cainfo"`
  22664. ErrMsg string `json:"err_msg"`
  22665. InfRefmsgid string `json:"inf_refmsgid"`
  22666. Infcode string `json:"infcode"`
  22667. Output struct {
  22668. Result []struct {
  22669. BasMednFlag string `json:"bas_medn_flag"`
  22670. ChldMedcFlag string `json:"chld_medc_flag"`
  22671. ChrgitmLv string `json:"chrgitm_lv"`
  22672. Cnt float64 `json:"cnt"`
  22673. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22674. DrtReimFlag string `json:"drt_reim_flag"`
  22675. FeedetlSn string `json:"feedetl_sn"`
  22676. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22677. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22678. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22679. ListSpItemFlag string `json:"list_sp_item_flag"`
  22680. LmtUsedFlag string `json:"lmt_used_flag"`
  22681. MedChrgitmType string `json:"med_chrgitm_type"`
  22682. Memo string `json:"memo"`
  22683. OverlmtAmt float64 `json:"overlmt_amt"`
  22684. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22685. Pric float64 `json:"pric"`
  22686. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22687. SelfpayProp float64 `json:"selfpay_prop"`
  22688. } `json:"result"`
  22689. } `json:"output"`
  22690. RefmsgTime string `json:"refmsg_time"`
  22691. RespondTime string `json:"respond_time"`
  22692. Signtype string `json:"signtype"`
  22693. WarnMsg string `json:"warn_msg"`
  22694. }
  22695. type ResultMemo struct {
  22696. InsuAdmdvs string `json:"insuAdmdvs"`
  22697. }
  22698. // [{"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}]
  22699. type ResultIDInfo struct {
  22700. Begntime string `json:"begntime"`
  22701. Endtime string `json:"endtime"`
  22702. Memo string `json:"memo"`
  22703. }
  22704. type ResultFive struct {
  22705. Balc float64 `json:"balc"`
  22706. CvlservFlag string `json:"cvlserv_flag"`
  22707. EmpName string `json:"emp_name"`
  22708. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22709. Insutype string `json:"insutype"`
  22710. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22711. PausInsuDate string `json:"paus_insu_date"`
  22712. PsnInsuDate string `json:"psn_insu_date"`
  22713. PsnInsuStas string `json:"psn_insu_stas"`
  22714. PsnType string `json:"psn_type"`
  22715. }
  22716. type ResultSix struct {
  22717. Cainfo interface{} `json:"cainfo"`
  22718. ErrMsg string `json:"err_msg"`
  22719. InfRefmsgid string `json:"inf_refmsgid"`
  22720. Infcode int64 `json:"infcode"`
  22721. Output struct {
  22722. } `json:"output"`
  22723. RefmsgTime string `json:"refmsg_time"`
  22724. RespondTime string `json:"respond_time"`
  22725. Signtype interface{} `json:"signtype"`
  22726. WarnMsg interface{} `json:"warn_msg"`
  22727. }
  22728. type ResultSix3103 struct {
  22729. Cainfo interface{} `json:"cainfo"`
  22730. ErrMsg string `json:"err_msg"`
  22731. InfRefmsgid string `json:"inf_refmsgid"`
  22732. Infcode int64 `json:"infcode"`
  22733. RefmsgTime string `json:"refmsg_time"`
  22734. RespondTime string `json:"respond_time"`
  22735. Signtype interface{} `json:"signtype"`
  22736. WarnMsg interface{} `json:"warn_msg"`
  22737. }
  22738. type FJ3507Result struct {
  22739. Cainfo interface{} `json:"cainfo"`
  22740. ErrMsg string `json:"err_msg"`
  22741. InfRefmsgid string `json:"inf_refmsgid"`
  22742. Infcode int64 `json:"infcode"`
  22743. Output struct {
  22744. retRslt string `json:"retRslt"`
  22745. msgRslt string `json:"msgRslt"`
  22746. } `json:"output"`
  22747. RefmsgTime string `json:"refmsg_time"`
  22748. RespondTime string `json:"respond_time"`
  22749. Signtype interface{} `json:"signtype"`
  22750. WarnMsg interface{} `json:"warn_msg"`
  22751. }
  22752. type FJ3507ResultFor10188 struct {
  22753. Cainfo interface{} `json:"cainfo"`
  22754. ErrMsg string `json:"err_msg"`
  22755. InfRefmsgid string `json:"inf_refmsgid"`
  22756. Infcode string `json:"infcode"`
  22757. RefmsgTime string `json:"refmsg_time"`
  22758. RespondTime string `json:"respond_time"`
  22759. Signtype interface{} `json:"signtype"`
  22760. WarnMsg interface{} `json:"warn_msg"`
  22761. }
  22762. type Result2406 struct {
  22763. Cainfo interface{} `json:"cainfo"`
  22764. ErrMsg string `json:"err_msg"`
  22765. InfRefmsgid string `json:"inf_refmsgid"`
  22766. Infcode int64 `json:"infcode"`
  22767. Output struct {
  22768. Result struct {
  22769. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22770. } `json:"result"`
  22771. } `json:"output"`
  22772. RefmsgTime string `json:"refmsg_time"`
  22773. RespondTime string `json:"respond_time"`
  22774. Signtype interface{} `json:"signtype"`
  22775. WarnMsg interface{} `json:"warn_msg"`
  22776. }
  22777. type GZResultSix struct {
  22778. Cainfo interface{} `json:"cainfo"`
  22779. ErrMsg string `json:"err_msg"`
  22780. InfRefmsgid string `json:"inf_refmsgid"`
  22781. Infcode int64 `json:"infcode"`
  22782. Output string `json:"output"`
  22783. RefmsgTime string `json:"refmsg_time"`
  22784. RespondTime string `json:"respond_time"`
  22785. Signtype interface{} `json:"signtype"`
  22786. WarnMsg interface{} `json:"warn_msg"`
  22787. }
  22788. type ResultSix10265 struct {
  22789. Cainfo interface{} `json:"cainfo"`
  22790. ErrMsg string `json:"err_msg"`
  22791. InfRefmsgid string `json:"inf_refmsgid"`
  22792. Infcode string `json:"infcode"`
  22793. Output struct {
  22794. } `json:"output"`
  22795. RefmsgTime string `json:"refmsg_time"`
  22796. RespondTime string `json:"respond_time"`
  22797. Signtype interface{} `json:"signtype"`
  22798. WarnMsg interface{} `json:"warn_msg"`
  22799. }
  22800. type ResultSeven struct {
  22801. Cainfo string `json:"cainfo"`
  22802. ErrMsg string `json:"err_msg"`
  22803. InfRefmsgid string `json:"inf_refmsgid"`
  22804. Infcode int64 `json:"infcode"`
  22805. Output struct {
  22806. Setlinfo struct {
  22807. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22808. AcctPay float64 `json:"acct_pay"`
  22809. ActPayDedc float64 `json:"act_pay_dedc"`
  22810. Age float64 `json:"age"`
  22811. Balc float64 `json:"balc"`
  22812. Certno string `json:"certno"`
  22813. ClrOptins string `json:"clr_optins"`
  22814. ClrType string `json:"clr_type"`
  22815. ClrWay string `json:"clr_way"`
  22816. CvlservFlag string `json:"cvlserv_flag"`
  22817. CvlservPay float64 `json:"cvlserv_pay"`
  22818. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22819. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22820. Gend string `json:"gend"`
  22821. HifesPay float64 `json:"hifes_pay"`
  22822. HifmiPay float64 `json:"hifmi_pay"`
  22823. HifpPay float64 `json:"hifp_pay"`
  22824. HospPartAmt float64 `json:"hosp_part_amt"`
  22825. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22826. Insutype string `json:"insutype"`
  22827. MafPay float64 `json:"maf_pay"`
  22828. MdtrtCertType string `json:"mdtrt_cert_type"`
  22829. HifobPay float64 `json:"hifob_pay"`
  22830. MdtrtID string `json:"mdtrt_id"`
  22831. MedType string `json:"med_type"`
  22832. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22833. MedinsSetlID string `json:"medins_setl_id"`
  22834. Naty string `json:"naty"`
  22835. OthPay float64 `json:"oth_pay"`
  22836. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22837. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22838. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22839. PsnCashPay float64 `json:"psn_cash_pay"`
  22840. PsnCertType string `json:"psn_cert_type"`
  22841. PsnName string `json:"psn_name"`
  22842. PsnNo string `json:"psn_no"`
  22843. PsnPartAmt float64 `json:"psn_part_amt"`
  22844. PsnType string `json:"psn_type"`
  22845. SetlID string `json:"setl_id"`
  22846. SetlTime string `json:"setl_time"`
  22847. } `json:"setlinfo"`
  22848. Setldetail interface{} `json:"setldetail"`
  22849. } `json:"output"`
  22850. RefmsgTime string `json:"refmsg_time"`
  22851. RespondTime string `json:"respond_time"`
  22852. Signtype interface{} `json:"signtype"`
  22853. WarnMsg interface{} `json:"warn_msg"`
  22854. }
  22855. type ResultSevenAH struct {
  22856. Cainfo string `json:"cainfo"`
  22857. ErrMsg string `json:"err_msg"`
  22858. InfRefmsgid string `json:"inf_refmsgid"`
  22859. Infcode int64 `json:"infcode"`
  22860. Output struct {
  22861. Setlinfo struct {
  22862. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22863. AcctPay float64 `json:"acct_pay"`
  22864. ActPayDedc float64 `json:"act_pay_dedc"`
  22865. Age float64 `json:"age"`
  22866. Balc float64 `json:"balc"`
  22867. Certno string `json:"certno"`
  22868. ClrOptins string `json:"clr_optins"`
  22869. ClrType string `json:"clr_type"`
  22870. ClrWay string `json:"clr_way"`
  22871. CvlservFlag string `json:"cvlserv_flag"`
  22872. CvlservPay float64 `json:"cvlserv_pay"`
  22873. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22874. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22875. Gend string `json:"gend"`
  22876. HifesPay float64 `json:"hifes_pay"`
  22877. HifmiPay float64 `json:"hifmi_pay"`
  22878. HifpPay float64 `json:"hifp_pay"`
  22879. HospPartAmt float64 `json:"hosp_part_amt"`
  22880. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22881. Insutype string `json:"insutype"`
  22882. MafPay float64 `json:"maf_pay"`
  22883. MdtrtCertType string `json:"mdtrt_cert_type"`
  22884. HifobPay float64 `json:"hifob_pay"`
  22885. MdtrtID string `json:"mdtrt_id"`
  22886. MedType string `json:"med_type"`
  22887. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22888. MedinsSetlID string `json:"medins_setl_id"`
  22889. Naty string `json:"naty"`
  22890. OthPay float64 `json:"oth_pay"`
  22891. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22892. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22893. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22894. PsnCashPay float64 `json:"psn_cash_pay"`
  22895. PsnCertType string `json:"psn_cert_type"`
  22896. PsnName string `json:"psn_name"`
  22897. PsnNo string `json:"psn_no"`
  22898. PsnPartAmt float64 `json:"psn_part_amt"`
  22899. PsnType string `json:"psn_type"`
  22900. SetlID string `json:"setl_id"`
  22901. SetlTime int64 `json:"setl_time"`
  22902. } `json:"setlinfo"`
  22903. Setldetail interface{} `json:"setldetail"`
  22904. } `json:"output"`
  22905. RefmsgTime string `json:"refmsg_time"`
  22906. RespondTime string `json:"respond_time"`
  22907. Signtype interface{} `json:"signtype"`
  22908. WarnMsg interface{} `json:"warn_msg"`
  22909. }
  22910. type ResultSeven10265 struct {
  22911. Cainfo string `json:"cainfo"`
  22912. ErrMsg string `json:"err_msg"`
  22913. InfRefmsgid string `json:"inf_refmsgid"`
  22914. Infcode string `json:"infcode"`
  22915. Output struct {
  22916. Setlinfo struct {
  22917. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22918. AcctPay float64 `json:"acct_pay"`
  22919. ActPayDedc float64 `json:"act_pay_dedc"`
  22920. Age float64 `json:"age"`
  22921. Balc float64 `json:"balc"`
  22922. Certno string `json:"certno"`
  22923. ClrOptins string `json:"clr_optins"`
  22924. ClrType string `json:"clr_type"`
  22925. ClrWay string `json:"clr_way"`
  22926. CvlservFlag string `json:"cvlserv_flag"`
  22927. CvlservPay float64 `json:"cvlserv_pay"`
  22928. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22929. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22930. Gend string `json:"gend"`
  22931. HifesPay float64 `json:"hifes_pay"`
  22932. HifmiPay float64 `json:"hifmi_pay"`
  22933. HifpPay float64 `json:"hifp_pay"`
  22934. HospPartAmt float64 `json:"hosp_part_amt"`
  22935. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22936. Insutype string `json:"insutype"`
  22937. MafPay float64 `json:"maf_pay"`
  22938. MdtrtCertType string `json:"mdtrt_cert_type"`
  22939. HifobPay float64 `json:"hifob_pay"`
  22940. MdtrtID string `json:"mdtrt_id"`
  22941. MedType string `json:"med_type"`
  22942. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22943. MedinsSetlID string `json:"medins_setl_id"`
  22944. Naty string `json:"naty"`
  22945. OthPay float64 `json:"oth_pay"`
  22946. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22947. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22948. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22949. PsnCashPay float64 `json:"psn_cash_pay"`
  22950. PsnCertType string `json:"psn_cert_type"`
  22951. PsnName string `json:"psn_name"`
  22952. PsnNo string `json:"psn_no"`
  22953. PsnPartAmt float64 `json:"psn_part_amt"`
  22954. PsnType string `json:"psn_type"`
  22955. SetlID string `json:"setl_id"`
  22956. SetlTime string `json:"setl_time"`
  22957. } `json:"setlinfo"`
  22958. Setldetail interface{} `json:"setldetail"`
  22959. } `json:"output"`
  22960. RefmsgTime string `json:"refmsg_time"`
  22961. RespondTime string `json:"respond_time"`
  22962. Signtype interface{} `json:"signtype"`
  22963. WarnMsg interface{} `json:"warn_msg"`
  22964. }
  22965. type ResultSeven10265Two struct {
  22966. Cainfo string `json:"cainfo"`
  22967. ErrMsg string `json:"err_msg"`
  22968. InfRefmsgid string `json:"inf_refmsgid"`
  22969. Infcode string `json:"infcode"`
  22970. Output struct {
  22971. Setlinfo struct {
  22972. AcctMulaidPay string `json:"acct_mulaid_pay"`
  22973. AcctPay float64 `json:"acct_pay"`
  22974. ActPayDedc float64 `json:"act_pay_dedc"`
  22975. Age float64 `json:"age"`
  22976. Balc float64 `json:"balc"`
  22977. Certno string `json:"certno"`
  22978. ClrOptins string `json:"clr_optins"`
  22979. ClrType string `json:"clr_type"`
  22980. ClrWay string `json:"clr_way"`
  22981. CvlservFlag string `json:"cvlserv_flag"`
  22982. CvlservPay float64 `json:"cvlserv_pay"`
  22983. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22984. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22985. Gend string `json:"gend"`
  22986. HifesPay float64 `json:"hifes_pay"`
  22987. HifmiPay float64 `json:"hifmi_pay"`
  22988. HifpPay float64 `json:"hifp_pay"`
  22989. HospPartAmt string `json:"hosp_part_amt"`
  22990. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22991. Insutype string `json:"insutype"`
  22992. MafPay float64 `json:"maf_pay"`
  22993. MdtrtCertType string `json:"mdtrt_cert_type"`
  22994. HifobPay float64 `json:"hifob_pay"`
  22995. MdtrtID string `json:"mdtrt_id"`
  22996. MedType string `json:"med_type"`
  22997. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22998. MedinsSetlID string `json:"medins_setl_id"`
  22999. Naty string `json:"naty"`
  23000. OthPay float64 `json:"oth_pay"`
  23001. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23002. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23003. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23004. PsnCashPay float64 `json:"psn_cash_pay"`
  23005. PsnCertType string `json:"psn_cert_type"`
  23006. PsnName string `json:"psn_name"`
  23007. PsnNo string `json:"psn_no"`
  23008. PsnPartAmt float64 `json:"psn_part_amt"`
  23009. PsnType string `json:"psn_type"`
  23010. SetlID string `json:"setl_id"`
  23011. SetlTime string `json:"setl_time"`
  23012. } `json:"setlinfo"`
  23013. Setldetail interface{} `json:"setldetail"`
  23014. } `json:"output"`
  23015. RefmsgTime string `json:"refmsg_time"`
  23016. RespondTime string `json:"respond_time"`
  23017. Signtype interface{} `json:"signtype"`
  23018. WarnMsg interface{} `json:"warn_msg"`
  23019. }
  23020. type ResultSeven10633Two struct {
  23021. Cainfo string `json:"cainfo"`
  23022. ErrMsg string `json:"err_msg"`
  23023. InfRefmsgid string `json:"inf_refmsgid"`
  23024. Infcode string `json:"infcode"`
  23025. Output struct {
  23026. Setlinfo struct {
  23027. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23028. AcctPay float64 `json:"acct_pay"`
  23029. ActPayDedc float64 `json:"act_pay_dedc"`
  23030. Age float64 `json:"age"`
  23031. Balc float64 `json:"balc"`
  23032. Certno string `json:"certno"`
  23033. ClrOptins string `json:"clr_optins"`
  23034. ClrType string `json:"clr_type"`
  23035. ClrWay string `json:"clr_way"`
  23036. CvlservFlag string `json:"cvlserv_flag"`
  23037. CvlservPay float64 `json:"cvlserv_pay"`
  23038. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23039. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23040. Gend string `json:"gend"`
  23041. HifesPay float64 `json:"hifes_pay"`
  23042. HifmiPay float64 `json:"hifmi_pay"`
  23043. HifpPay float64 `json:"hifp_pay"`
  23044. HospPartAmt float64 `json:"hosp_part_amt"`
  23045. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23046. Insutype string `json:"insutype"`
  23047. MafPay float64 `json:"maf_pay"`
  23048. MdtrtCertType string `json:"mdtrt_cert_type"`
  23049. HifobPay float64 `json:"hifob_pay"`
  23050. MdtrtID string `json:"mdtrt_id"`
  23051. MedType string `json:"med_type"`
  23052. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23053. MedinsSetlID string `json:"medins_setl_id"`
  23054. Naty string `json:"naty"`
  23055. OthPay float64 `json:"oth_pay"`
  23056. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23057. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23058. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23059. PsnCashPay float64 `json:"psn_cash_pay"`
  23060. PsnCertType string `json:"psn_cert_type"`
  23061. PsnName string `json:"psn_name"`
  23062. PsnNo string `json:"psn_no"`
  23063. PsnPartAmt float64 `json:"psn_part_amt"`
  23064. PsnType string `json:"psn_type"`
  23065. SetlID string `json:"setl_id"`
  23066. SetlTime string `json:"setl_time"`
  23067. } `json:"setlinfo"`
  23068. Setldetail interface{} `json:"setldetail"`
  23069. } `json:"output"`
  23070. RefmsgTime string `json:"refmsg_time"`
  23071. RespondTime string `json:"respond_time"`
  23072. Signtype interface{} `json:"signtype"`
  23073. WarnMsg interface{} `json:"warn_msg"`
  23074. }
  23075. type ResultSeven10633Three struct {
  23076. Cainfo string `json:"cainfo"`
  23077. ErrMsg string `json:"err_msg"`
  23078. InfRefmsgid string `json:"inf_refmsgid"`
  23079. Infcode string `json:"infcode"`
  23080. Output struct {
  23081. Setlinfo struct {
  23082. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23083. AcctPay float64 `json:"acct_pay"`
  23084. ActPayDedc float64 `json:"act_pay_dedc"`
  23085. Age float64 `json:"age"`
  23086. Balc float64 `json:"balc"`
  23087. Certno string `json:"certno"`
  23088. ClrOptins string `json:"clr_optins"`
  23089. ClrType string `json:"clr_type"`
  23090. ClrWay string `json:"clr_way"`
  23091. CvlservFlag string `json:"cvlserv_flag"`
  23092. CvlservPay float64 `json:"cvlserv_pay"`
  23093. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23094. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23095. Gend string `json:"gend"`
  23096. HifesPay float64 `json:"hifes_pay"`
  23097. HifmiPay float64 `json:"hifmi_pay"`
  23098. HifpPay float64 `json:"hifp_pay"`
  23099. HospPartAmt string `json:"hosp_part_amt"`
  23100. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23101. Insutype string `json:"insutype"`
  23102. MafPay float64 `json:"maf_pay"`
  23103. MdtrtCertType string `json:"mdtrt_cert_type"`
  23104. HifobPay float64 `json:"hifob_pay"`
  23105. MdtrtID string `json:"mdtrt_id"`
  23106. MedType string `json:"med_type"`
  23107. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23108. MedinsSetlID string `json:"medins_setl_id"`
  23109. Naty string `json:"naty"`
  23110. OthPay float64 `json:"oth_pay"`
  23111. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23112. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23113. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23114. PsnCashPay float64 `json:"psn_cash_pay"`
  23115. PsnCertType string `json:"psn_cert_type"`
  23116. PsnName string `json:"psn_name"`
  23117. PsnNo string `json:"psn_no"`
  23118. PsnPartAmt float64 `json:"psn_part_amt"`
  23119. PsnType string `json:"psn_type"`
  23120. SetlID string `json:"setl_id"`
  23121. SetlTime string `json:"setl_time"`
  23122. } `json:"setlinfo"`
  23123. Setldetail interface{} `json:"setldetail"`
  23124. } `json:"output"`
  23125. RefmsgTime string `json:"refmsg_time"`
  23126. RespondTime string `json:"respond_time"`
  23127. Signtype interface{} `json:"signtype"`
  23128. WarnMsg interface{} `json:"warn_msg"`
  23129. }
  23130. type GZResultSeven10265Two struct {
  23131. Cainfo string `json:"cainfo"`
  23132. ErrMsg string `json:"err_msg"`
  23133. InfRefmsgid string `json:"inf_refmsgid"`
  23134. Infcode int64 `json:"infcode"`
  23135. Output struct {
  23136. Setlinfo struct {
  23137. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23138. AcctPay float64 `json:"acct_pay"`
  23139. ActPayDedc float64 `json:"act_pay_dedc"`
  23140. Age float64 `json:"age"`
  23141. Balc float64 `json:"balc"`
  23142. Certno string `json:"certno"`
  23143. ClrOptins string `json:"clr_optins"`
  23144. ClrType string `json:"clr_type"`
  23145. ClrWay string `json:"clr_way"`
  23146. CvlservFlag string `json:"cvlserv_flag"`
  23147. CvlservPay float64 `json:"cvlserv_pay"`
  23148. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23149. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23150. Gend string `json:"gend"`
  23151. HifesPay float64 `json:"hifes_pay"`
  23152. HifmiPay float64 `json:"hifmi_pay"`
  23153. HifpPay float64 `json:"hifp_pay"`
  23154. HospPartAmt float64 `json:"hosp_part_amt"`
  23155. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23156. Insutype string `json:"insutype"`
  23157. MafPay float64 `json:"maf_pay"`
  23158. MdtrtCertType string `json:"mdtrt_cert_type"`
  23159. HifobPay float64 `json:"hifob_pay"`
  23160. MdtrtID string `json:"mdtrt_id"`
  23161. MedType string `json:"med_type"`
  23162. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23163. MedinsSetlID string `json:"medins_setl_id"`
  23164. Naty string `json:"naty"`
  23165. OthPay float64 `json:"oth_pay"`
  23166. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23167. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23168. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23169. PsnCashPay float64 `json:"psn_cash_pay"`
  23170. PsnCertType string `json:"psn_cert_type"`
  23171. PsnName string `json:"psn_name"`
  23172. PsnNo string `json:"psn_no"`
  23173. PsnPartAmt float64 `json:"psn_part_amt"`
  23174. PsnType string `json:"psn_type"`
  23175. SetlID string `json:"setl_id"`
  23176. SetlTime string `json:"setl_time"`
  23177. } `json:"setlinfo"`
  23178. Setldetail interface{} `json:"setldetail"`
  23179. } `json:"output"`
  23180. RefmsgTime string `json:"refmsg_time"`
  23181. RespondTime string `json:"respond_time"`
  23182. Signtype interface{} `json:"signtype"`
  23183. WarnMsg interface{} `json:"warn_msg"`
  23184. }
  23185. type ResultEight struct {
  23186. Cainfo string `json:"cainfo"`
  23187. ErrMsg string `json:"err_msg"`
  23188. InfRefmsgid string `json:"inf_refmsgid"`
  23189. Infcode int64 `json:"infcode"`
  23190. Output struct {
  23191. Stmtinfo struct {
  23192. SetlOptins string `json:"setl_optins"`
  23193. StmtRslt string `json:"stmt_rslt"`
  23194. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23195. } `json:"stmtinfo"`
  23196. } `json:"output"`
  23197. RefmsgTime string `json:"refmsg_time"`
  23198. RespondTime string `json:"respond_time"`
  23199. Signtype interface{} `json:"signtype"`
  23200. WarnMsg interface{} `json:"warn_msg"`
  23201. }
  23202. type ResultEightFor10188 struct {
  23203. Cainfo string `json:"cainfo"`
  23204. ErrMsg string `json:"err_msg"`
  23205. InfRefmsgid string `json:"inf_refmsgid"`
  23206. Infcode string `json:"infcode"`
  23207. Output struct {
  23208. Stmtinfo struct {
  23209. SetlOptins string `json:"setl_optins"`
  23210. StmtRslt string `json:"stmt_rslt"`
  23211. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23212. } `json:"stmtinfo"`
  23213. } `json:"output"`
  23214. RefmsgTime string `json:"refmsg_time"`
  23215. RespondTime string `json:"respond_time"`
  23216. Signtype interface{} `json:"signtype"`
  23217. WarnMsg interface{} `json:"warn_msg"`
  23218. }
  23219. type ResultNine struct {
  23220. Cainfo string `json:"cainfo"`
  23221. ErrMsg string `json:"err_msg"`
  23222. InfRefmsgid string `json:"inf_refmsgid"`
  23223. Infcode int64 `json:"infcode"`
  23224. Output struct {
  23225. FileQuryNo string `json:"file_qury_no"`
  23226. } `json:"output"`
  23227. RefmsgTime string `json:"refmsg_time"`
  23228. RespondTime string `json:"respond_time"`
  23229. Signtype interface{} `json:"signtype"`
  23230. WarnMsg interface{} `json:"warn_msg"`
  23231. }
  23232. type ResultTen struct {
  23233. Cainfo string `json:"cainfo"`
  23234. ErrMsg string `json:"err_msg"`
  23235. InfRefmsgid string `json:"inf_refmsgid"`
  23236. Infcode int64 `json:"infcode"`
  23237. Output struct {
  23238. Fileinfo struct {
  23239. DldEndtime string `json:"dld_endtime"`
  23240. FileQuryNo string `json:"file_qury_no"`
  23241. Filename string `json:"filename"`
  23242. } `json:"fileinfo"`
  23243. } `json:"output"`
  23244. RefmsgTime string `json:"refmsg_time"`
  23245. RespondTime string `json:"respond_time"`
  23246. Signtype interface{} `json:"signtype"`
  23247. WarnMsg interface{} `json:"warn_msg"`
  23248. }
  23249. type Result5262 struct {
  23250. ErrMsg string `json:"err_msg"`
  23251. InfRefmsgid string `json:"inf_refmsgid"`
  23252. Infcode int64 `json:"infcode"`
  23253. Output struct {
  23254. PageInfo struct {
  23255. Size int `json:"size"`
  23256. RecordCounts int `json:"record_counts"`
  23257. } `json:"page_info"`
  23258. Idetinfo []interface{} `json:"idetinfo"`
  23259. Result []struct {
  23260. SetlID string `json:"setl_id"`
  23261. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23262. MdtrtID string `json:"mdtrt_id"`
  23263. InitSetlID string `json:"init_setl_id,omitempty"`
  23264. PsnNo string `json:"psn_no"`
  23265. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23266. PsnName string `json:"psn_name"`
  23267. PsnCertType string `json:"psn_cert_type"`
  23268. Certno string `json:"certno"`
  23269. Gend string `json:"gend,omitempty"`
  23270. Naty string `json:"naty,omitempty"`
  23271. Brdy string `json:"brdy,omitempty"`
  23272. Age float64 `json:"age,omitempty"`
  23273. Insutype string `json:"insutype,omitempty"`
  23274. PsnType string `json:"psn_type"`
  23275. CvlservFlag string `json:"cvlserv_flag"`
  23276. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23277. SpPsnType string `json:"sp_psn_type,omitempty"`
  23278. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23279. ClctGrde string `json:"clct_grde,omitempty"`
  23280. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23281. NwbFlag string `json:"nwb_flag,omitempty"`
  23282. InsuAdmdvs string `json:"insu_admdvs"`
  23283. EmpNo string `json:"emp_no,omitempty"`
  23284. EmpName string `json:"emp_name,omitempty"`
  23285. EmpType string `json:"emp_type,omitempty"`
  23286. EconType string `json:"econ_type,omitempty"`
  23287. AfilIndu string `json:"afil_indu,omitempty"`
  23288. AfilRlts string `json:"afil_rlts,omitempty"`
  23289. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23290. PayLoc string `json:"pay_loc,omitempty"`
  23291. FixmedinsCode string `json:"fixmedins_code"`
  23292. FixmedinsName string `json:"fixmedins_name"`
  23293. HospLv string `json:"hosp_lv,omitempty"`
  23294. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23295. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23296. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23297. Begndate string `json:"begndate"`
  23298. Enddate string `json:"enddate"`
  23299. SetlTime string `json:"setl_time"`
  23300. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23301. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23302. MedType string `json:"med_type"`
  23303. SetlType string `json:"setl_type,omitempty"`
  23304. ClrType string `json:"clr_type,omitempty"`
  23305. ClrWay string `json:"clr_way,omitempty"`
  23306. PsnSetlway string `json:"psn_setlway,omitempty"`
  23307. ClrOptins string `json:"clr_optins,omitempty"`
  23308. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23309. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23310. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23311. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23312. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23313. DedcStd float64 `json:"dedc_std,omitempty"`
  23314. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23315. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23316. HifpPay float64 `json:"hifp_pay,omitempty"`
  23317. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23318. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23319. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23320. HifesPay float64 `json:"hifes_pay,omitempty"`
  23321. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23322. HifobPay float64 `json:"hifob_pay,omitempty"`
  23323. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23324. MafPay float64 `json:"maf_pay,omitempty"`
  23325. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23326. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23327. PsnPay float64 `json:"psn_pay,omitempty"`
  23328. AcctPay float64 `json:"acct_pay,omitempty"`
  23329. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23330. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23331. Balc float64 `json:"balc,omitempty"`
  23332. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23333. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23334. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23335. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23336. Year string `json:"year,omitempty"`
  23337. DiseNo string `json:"dise_no,omitempty"`
  23338. DiseName string `json:"dise_name,omitempty"`
  23339. Invono string `json:"invono,omitempty"`
  23340. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23341. ValiFlag string `json:"vali_flag,omitempty"`
  23342. Memo string `json:"memo,omitempty"`
  23343. Rid string `json:"rid"`
  23344. UpdtTime string `json:"updt_time,omitempty"`
  23345. CrterID string `json:"crter_id,omitempty"`
  23346. CrterName string `json:"crter_name,omitempty"`
  23347. CrteTime string `json:"crte_time,omitempty"`
  23348. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23349. OpterID string `json:"opter_id,omitempty"`
  23350. OpterName string `json:"opter_name,omitempty"`
  23351. OptTime string `json:"opt_time,omitempty"`
  23352. OptinsNo string `json:"optins_no,omitempty"`
  23353. PoolareaNo string `json:"poolarea_no,omitempty"`
  23354. } `json:"result"`
  23355. } `json:"output"`
  23356. RefmsgTime string `json:"refmsg_time"`
  23357. RespondTime string `json:"respond_time"`
  23358. Signtype interface{} `json:"signtype"`
  23359. WarnInfo interface{} `json:"warn_info"`
  23360. }
  23361. type Result5267 struct {
  23362. ErrMsg string `json:"err_msg"`
  23363. InfRefmsgid string `json:"inf_refmsgid"`
  23364. Infcode int64 `json:"infcode"`
  23365. Output struct {
  23366. PageInfo struct {
  23367. Size int `json:"size"`
  23368. RecordCounts int `json:"record_counts"`
  23369. } `json:"pageinfo"`
  23370. Result []struct {
  23371. SetlID string `json:"setl_id"`
  23372. ClrOptins string `json:"clr_optins"`
  23373. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23374. MdtrtID string `json:"mdtrt_id"`
  23375. InitSetlID string `json:"init_setl_id,omitempty"`
  23376. PsnNo string `json:"psn_no"`
  23377. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23378. PsnName string `json:"psn_name"`
  23379. PsnCertType string `json:"psn_cert_type"`
  23380. Certno string `json:"certno"`
  23381. Gend string `json:"gend,omitempty"`
  23382. Naty string `json:"naty,omitempty"`
  23383. Brdy string `json:"brdy,omitempty"`
  23384. Age float64 `json:"age,omitempty"`
  23385. Insutype string `json:"insutype,omitempty"`
  23386. PsnType string `json:"psn_type"`
  23387. CvlservFlag string `json:"cvlserv_flag"`
  23388. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23389. SpPsnType string `json:"sp_psn_type,omitempty"`
  23390. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23391. ClctGrde string `json:"clct_grde,omitempty"`
  23392. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23393. NwbFlag string `json:"nwb_flag,omitempty"`
  23394. InsuAdmdvs string `json:"insu_admdvs"`
  23395. EmpNo string `json:"emp_no,omitempty"`
  23396. EmpName string `json:"emp_name,omitempty"`
  23397. EmpType string `json:"emp_type,omitempty"`
  23398. EconType string `json:"econ_type,omitempty"`
  23399. AfilIndu string `json:"afil_indu,omitempty"`
  23400. AfilRlts string `json:"afil_rlts,omitempty"`
  23401. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23402. PayLoc string `json:"pay_loc,omitempty"`
  23403. FixmedinsCode string `json:"fixmedins_code"`
  23404. FixmedinsName string `json:"fixmedins_name"`
  23405. HospLv string `json:"hosp_lv,omitempty"`
  23406. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23407. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23408. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23409. Begndate string `json:"begndate,omitempty"`
  23410. Enddate string `json:"enddate,omitempty"`
  23411. SetlTime string `json:"setl_time,omitempty"`
  23412. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23413. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23414. MedType string `json:"med_type"`
  23415. SetlType string `json:"setl_type,omitempty"`
  23416. ClrType string `json:"clr_type,omitempty"`
  23417. ClrWay string `json:"clr_way,omitempty"`
  23418. PsnSetlway string `json:"psn_setlway,omitempty"`
  23419. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23420. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23421. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23422. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23423. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23424. DedcStd float64 `json:"dedc_std,omitempty"`
  23425. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23426. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23427. HifpPay float64 `json:"hifp_pay,omitempty"`
  23428. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23429. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23430. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23431. HifesPay float64 `json:"hifes_pay,omitempty"`
  23432. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23433. HifobPay float64 `json:"hifob_pay,omitempty"`
  23434. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23435. MafPay float64 `json:"maf_pay,omitempty"`
  23436. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23437. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23438. PsnPay float64 `json:"psn_pay,omitempty"`
  23439. AcctPay float64 `json:"acct_pay,omitempty"`
  23440. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23441. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23442. Balc float64 `json:"balc,omitempty"`
  23443. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23444. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23445. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23446. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23447. Year string `json:"year,omitempty"`
  23448. DiseNo string `json:"dise_no,omitempty"`
  23449. DiseName string `json:"dise_name,omitempty"`
  23450. Invono string `json:"invono,omitempty"`
  23451. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23452. Memo string `json:"memo,omitempty"`
  23453. UpdtTime string `json:"updt_time,omitempty"`
  23454. OpterID string `json:"opter_id,omitempty"`
  23455. OpterName string `json:"opter_name,omitempty"`
  23456. OptTime string `json:"opt_time,omitempty"`
  23457. OptinsNo string `json:"optins_no,omitempty"`
  23458. PoolareaNo string `json:"poolarea_no,omitempty"`
  23459. } `json:"result"`
  23460. } `json:"output"`
  23461. RefmsgTime string `json:"refmsg_time"`
  23462. RespondTime string `json:"respond_time"`
  23463. Signtype interface{} `json:"signtype"`
  23464. WarnInfo interface{} `json:"warn_info"`
  23465. }
  23466. // type Autogenerated struct {
  23467. // Output struct {
  23468. // Setlinfo struct {
  23469. // SetlTime string `json:"setl_time"`
  23470. // CvlservPay float64 `json:"cvlserv_pay"`
  23471. // Year string `json:"year"`
  23472. // MedType string `json:"med_type"`
  23473. // PsnPay float64 `json:"psn_pay"`
  23474. // OpterID string `json:"opter_id"`
  23475. // Begndate string `json:"begndate"`
  23476. // FlxempeFlag string `json:"flxempe_flag"`
  23477. // HifmiPay float64 `json:"hifmi_pay"`
  23478. // PsnNo string `json:"psn_no"`
  23479. // ActPayDedc float64 `json:"act_pay_dedc"`
  23480. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23481. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23482. // ClrWay string `json:"clr_way"`
  23483. // OthPay float64 `json:"oth_pay"`
  23484. // Gend string `json:"gend"`
  23485. // MdtrtID string `json:"mdtrt_id"`
  23486. // AcctPay float64 `json:"acct_pay"`
  23487. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23488. // Insutype string `json:"insutype"`
  23489. // Invono interface{} `json:"invono"`
  23490. // Enddate string `json:"enddate"`
  23491. // CashPayamt float64 `json:"cash_payamt"`
  23492. // PsnType string `json:"psn_type"`
  23493. // FixmedinsName string `json:"fixmedins_name"`
  23494. // HifpPay float64 `json:"hifp_pay"`
  23495. // NewFlag interface{} `json:"new_flag"`
  23496. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23497. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23498. // PayLoc string `json:"pay_loc"`
  23499. // ClrType string `json:"clr_type"`
  23500. // RefdSetlFlag string `json:"refd_setl_flag"`
  23501. // CvlservFlag string `json:"cvlserv_flag"`
  23502. // EmpName string `json:"emp_name"`
  23503. // Brdy string `json:"brdy"`
  23504. // Naty string `json:"naty"`
  23505. // Certno string `json:"certno"`
  23506. // DiseCode string `json:"dise_code"`
  23507. // FixmedinsCode string `json:"fixmedins_code"`
  23508. // DedcHospLv string `json:"dedc_hosp_lv"`
  23509. // OpterName string `json:"opter_name"`
  23510. // Balc float64 `json:"balc"`
  23511. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23512. // PsnCertType string `json:"psn_cert_type"`
  23513. // HifobPay float64 `json:"hifob_pay"`
  23514. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23515. // HifesPay float64 `json:"hifes_pay"`
  23516. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23517. // OptTime string `json:"opt_time"`
  23518. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23519. // SetlID string `json:"setl_id"`
  23520. // MafPay float64 `json:"maf_pay"`
  23521. // PsnName string `json:"psn_name"`
  23522. // InsuOptins interface{} `json:"insu_optins"`
  23523. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23524. // ClrOptins string `json:"clr_optins"`
  23525. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23526. // DiseName string `json:"dise_name"`
  23527. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23528. // Age float64 `json:"age"`
  23529. // DtrtCertType string `json:"dtrt_cert_type"`
  23530. // HospLv string `json:"hosp_lv"`
  23531. // } `json:"setlinfo"`
  23532. // Setldetail []struct {
  23533. // FundPayType string `json:"fund_pay_type"`
  23534. // FundPayamt float64 `json:"fund_payamt"`
  23535. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23536. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23537. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23538. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23539. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23540. // } `json:"setldetail"`
  23541. // } `json:"output"`
  23542. // Infcode int `json:"infcode"`
  23543. // WarnMsg interface{} `json:"warn_msg"`
  23544. // Cainfo interface{} `json:"cainfo"`
  23545. // ErrMsg interface{} `json:"err_msg"`
  23546. // RefmsgTime string `json:"refmsg_time"`
  23547. // Signtype interface{} `json:"signtype"`
  23548. // RespondTime string `json:"respond_time"`
  23549. // InfRefmsgid string `json:"inf_refmsgid"`
  23550. // }
  23551. type Result002 struct {
  23552. Cainfo interface{} `json:"cainfo"`
  23553. ErrMsg string `json:"err_msg"`
  23554. InfRefmsgid string `json:"inf_refmsgid"`
  23555. Infcode int64 `json:"infcode"`
  23556. Output struct {
  23557. RxFile string `json:"rx_file"`
  23558. SignDigest string `json:"sign_digest"`
  23559. SignCertSn string `json:"sign_cert_sn"`
  23560. SignCertDn string `json:"sign_cert_dn"`
  23561. } `json:"output"`
  23562. RefmsgTime string `json:"refmsg_time"`
  23563. RespondTime string `json:"respond_time"`
  23564. Signtype interface{} `json:"signtype"`
  23565. WarnMsg interface{} `json:"warn_msg"`
  23566. }
  23567. type AhResult002 struct {
  23568. RxFile string `json:"rxFile"`
  23569. SignDigest string `json:"signDigest"`
  23570. SignCertSn string `json:"signCertSn"`
  23571. SignCertDn string `json:"signCertDn"`
  23572. }
  23573. type Result003 struct {
  23574. Cainfo interface{} `json:"cainfo"`
  23575. ErrMsg string `json:"err_msg"`
  23576. InfRefmsgid string `json:"inf_refmsgid"`
  23577. Infcode int64 `json:"infcode"`
  23578. Output struct {
  23579. HiRxno string `json:"hi_rxno"`
  23580. RxStasCodg string `json:"rx_stas_codg"`
  23581. RxStasName string `json:"rx_stas_name"`
  23582. } `json:"output"`
  23583. RefmsgTime string `json:"refmsg_time"`
  23584. RespondTime string `json:"respond_time"`
  23585. Signtype interface{} `json:"signtype"`
  23586. WarnMsg interface{} `json:"warn_msg"`
  23587. }
  23588. type AHResult003 struct {
  23589. HiRxno string `json:"hiRxno"`
  23590. RxStasCodg string `json:"rxStasCodg"`
  23591. RxStasName string `json:"rxStasName"`
  23592. }
  23593. type ResultEleven struct {
  23594. Cainfo string `json:"cainfo"`
  23595. ErrMsg string `json:"err_msg"`
  23596. InfRefmsgid string `json:"inf_refmsgid"`
  23597. Infcode int64 `json:"infcode"`
  23598. Output struct {
  23599. Setlinfo struct {
  23600. SetlTime string `json:"setl_time"`
  23601. CvlservPay float64 `json:"cvlserv_pay"`
  23602. Year string `json:"year"`
  23603. MedType string `json:"med_type"`
  23604. PsnPay float64 `json:"psn_pay"`
  23605. OpterID string `json:"opter_id"`
  23606. Begndate string `json:"begndate"`
  23607. FlxempeFlag string `json:"flxempe_flag"`
  23608. HifmiPay float64 `json:"hifmi_pay"`
  23609. PsnNo string `json:"psn_no"`
  23610. ActPayDedc float64 `json:"act_pay_dedc"`
  23611. MedinsSetlID interface{} `json:"medins_setl_id"`
  23612. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23613. ClrWay string `json:"clr_way"`
  23614. OthPay float64 `json:"oth_pay"`
  23615. Gend string `json:"gend"`
  23616. MdtrtID string `json:"mdtrt_id"`
  23617. AcctPay float64 `json:"acct_pay"`
  23618. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23619. Insutype string `json:"insutype"`
  23620. Invono interface{} `json:"invono"`
  23621. Enddate string `json:"enddate"`
  23622. CashPayamt float64 `json:"cash_payamt"`
  23623. PsnType string `json:"psn_type"`
  23624. FixmedinsName string `json:"fixmedins_name"`
  23625. HifpPay float64 `json:"hifp_pay"`
  23626. NewFlag interface{} `json:"new_flag"`
  23627. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23628. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23629. PayLoc string `json:"pay_loc"`
  23630. ClrType string `json:"clr_type"`
  23631. RefdSetlFlag string `json:"refd_setl_flag"`
  23632. CvlservFlag string `json:"cvlserv_flag"`
  23633. EmpName string `json:"emp_name"`
  23634. Brdy string `json:"brdy"`
  23635. Naty string `json:"naty"`
  23636. Certno string `json:"certno"`
  23637. DiseCode string `json:"dise_code"`
  23638. FixmedinsCode string `json:"fixmedins_code"`
  23639. DedcHospLv string `json:"dedc_hosp_lv"`
  23640. OpterName string `json:"opter_name"`
  23641. Balc float64 `json:"balc"`
  23642. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23643. PsnCertType string `json:"psn_cert_type"`
  23644. HifobPay float64 `json:"hifob_pay"`
  23645. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23646. HifesPay float64 `json:"hifes_pay"`
  23647. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23648. OptTime string `json:"opt_time"`
  23649. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23650. SetlID string `json:"setl_id"`
  23651. MafPay float64 `json:"maf_pay"`
  23652. PsnName string `json:"psn_name"`
  23653. InsuOptins interface{} `json:"insu_optins"`
  23654. PrefFundPay interface{} `json:"pref_fund_pay"`
  23655. ClrOptins string `json:"clr_optins"`
  23656. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23657. DiseName string `json:"dise_name"`
  23658. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23659. Age float64 `json:"age"`
  23660. DtrtCertType string `json:"dtrt_cert_type"`
  23661. HospLv string `json:"hosp_lv"`
  23662. PsnCashPay float64 `json:"psn_cash_pay"`
  23663. } `json:"setlinfo"`
  23664. } `json:"output"`
  23665. RefmsgTime string `json:"refmsg_time"`
  23666. RespondTime string `json:"respond_time"`
  23667. Signtype interface{} `json:"signtype"`
  23668. WarnMsg interface{} `json:"warn_msg"`
  23669. }
  23670. type ResultElevenah struct {
  23671. Cainfo string `json:"cainfo"`
  23672. ErrMsg string `json:"err_msg"`
  23673. InfRefmsgid string `json:"inf_refmsgid"`
  23674. Infcode int64 `json:"infcode"`
  23675. Output struct {
  23676. Setlinfo struct {
  23677. SetlTime int64 `json:"setl_time"`
  23678. CvlservPay float64 `json:"cvlserv_pay"`
  23679. Year string `json:"year"`
  23680. MedType string `json:"med_type"`
  23681. PsnPay float64 `json:"psn_pay"`
  23682. OpterID string `json:"opter_id"`
  23683. Begndate int64 `json:"begndate"`
  23684. FlxempeFlag string `json:"flxempe_flag"`
  23685. HifmiPay float64 `json:"hifmi_pay"`
  23686. PsnNo string `json:"psn_no"`
  23687. ActPayDedc float64 `json:"act_pay_dedc"`
  23688. MedinsSetlID interface{} `json:"medins_setl_id"`
  23689. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23690. ClrWay string `json:"clr_way"`
  23691. OthPay float64 `json:"oth_pay"`
  23692. Gend string `json:"gend"`
  23693. MdtrtID string `json:"mdtrt_id"`
  23694. AcctPay float64 `json:"acct_pay"`
  23695. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23696. Insutype string `json:"insutype"`
  23697. Invono interface{} `json:"invono"`
  23698. Enddate int64 `json:"enddate"`
  23699. CashPayamt float64 `json:"cash_payamt"`
  23700. PsnType string `json:"psn_type"`
  23701. FixmedinsName string `json:"fixmedins_name"`
  23702. HifpPay float64 `json:"hifp_pay"`
  23703. NewFlag interface{} `json:"new_flag"`
  23704. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23705. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23706. PayLoc string `json:"pay_loc"`
  23707. ClrType string `json:"clr_type"`
  23708. RefdSetlFlag string `json:"refd_setl_flag"`
  23709. CvlservFlag string `json:"cvlserv_flag"`
  23710. EmpName string `json:"emp_name"`
  23711. Brdy int64 `json:"brdy"`
  23712. Naty string `json:"naty"`
  23713. Certno string `json:"certno"`
  23714. DiseCode string `json:"dise_code"`
  23715. FixmedinsCode string `json:"fixmedins_code"`
  23716. DedcHospLv string `json:"dedc_hosp_lv"`
  23717. OpterName string `json:"opter_name"`
  23718. Balc float64 `json:"balc"`
  23719. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23720. PsnCertType string `json:"psn_cert_type"`
  23721. HifobPay float64 `json:"hifob_pay"`
  23722. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23723. HifesPay float64 `json:"hifes_pay"`
  23724. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23725. OptTime int64 `json:"opt_time"`
  23726. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23727. SetlID string `json:"setl_id"`
  23728. MafPay float64 `json:"maf_pay"`
  23729. PsnName string `json:"psn_name"`
  23730. InsuOptins interface{} `json:"insu_optins"`
  23731. PrefFundPay interface{} `json:"pref_fund_pay"`
  23732. ClrOptins string `json:"clr_optins"`
  23733. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23734. DiseName string `json:"dise_name"`
  23735. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23736. Age float64 `json:"age"`
  23737. DtrtCertType string `json:"dtrt_cert_type"`
  23738. HospLv string `json:"hosp_lv"`
  23739. PsnCashPay float64 `json:"psn_cash_pay"`
  23740. } `json:"setlinfo"`
  23741. } `json:"output"`
  23742. RefmsgTime string `json:"refmsg_time"`
  23743. RespondTime string `json:"respond_time"`
  23744. Signtype interface{} `json:"signtype"`
  23745. WarnMsg interface{} `json:"warn_msg"`
  23746. }
  23747. type ResultEleven10265 struct {
  23748. Cainfo string `json:"cainfo"`
  23749. ErrMsg string `json:"err_msg"`
  23750. InfRefmsgid string `json:"inf_refmsgid"`
  23751. Infcode string `json:"infcode"`
  23752. Output struct {
  23753. Setlinfo struct {
  23754. SetlTime string `json:"setl_time"`
  23755. CvlservPay float64 `json:"cvlserv_pay"`
  23756. Year string `json:"year"`
  23757. MedType string `json:"med_type"`
  23758. PsnPay float64 `json:"psn_pay"`
  23759. OpterID string `json:"opter_id"`
  23760. Begndate string `json:"begndate"`
  23761. FlxempeFlag string `json:"flxempe_flag"`
  23762. HifmiPay float64 `json:"hifmi_pay"`
  23763. PsnNo string `json:"psn_no"`
  23764. ActPayDedc float64 `json:"act_pay_dedc"`
  23765. MedinsSetlID interface{} `json:"medins_setl_id"`
  23766. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23767. ClrWay string `json:"clr_way"`
  23768. OthPay float64 `json:"oth_pay"`
  23769. Gend string `json:"gend"`
  23770. MdtrtID string `json:"mdtrt_id"`
  23771. AcctPay float64 `json:"acct_pay"`
  23772. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23773. Insutype string `json:"insutype"`
  23774. Invono interface{} `json:"invono"`
  23775. Enddate string `json:"enddate"`
  23776. CashPayamt float64 `json:"cash_payamt"`
  23777. PsnType string `json:"psn_type"`
  23778. FixmedinsName string `json:"fixmedins_name"`
  23779. HifpPay float64 `json:"hifp_pay"`
  23780. NewFlag interface{} `json:"new_flag"`
  23781. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23782. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23783. PayLoc string `json:"pay_loc"`
  23784. ClrType string `json:"clr_type"`
  23785. RefdSetlFlag string `json:"refd_setl_flag"`
  23786. CvlservFlag string `json:"cvlserv_flag"`
  23787. EmpName string `json:"emp_name"`
  23788. Brdy string `json:"brdy"`
  23789. Naty string `json:"naty"`
  23790. Certno string `json:"certno"`
  23791. DiseCode string `json:"dise_code"`
  23792. FixmedinsCode string `json:"fixmedins_code"`
  23793. DedcHospLv string `json:"dedc_hosp_lv"`
  23794. OpterName string `json:"opter_name"`
  23795. Balc float64 `json:"balc"`
  23796. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23797. PsnCertType string `json:"psn_cert_type"`
  23798. HifobPay float64 `json:"hifob_pay"`
  23799. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23800. HifesPay float64 `json:"hifes_pay"`
  23801. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23802. OptTime string `json:"opt_time"`
  23803. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23804. SetlID string `json:"setl_id"`
  23805. MafPay float64 `json:"maf_pay"`
  23806. PsnName string `json:"psn_name"`
  23807. InsuOptins interface{} `json:"insu_optins"`
  23808. PrefFundPay interface{} `json:"pref_fund_pay"`
  23809. ClrOptins string `json:"clr_optins"`
  23810. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23811. DiseName string `json:"dise_name"`
  23812. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23813. Age float64 `json:"age"`
  23814. DtrtCertType string `json:"dtrt_cert_type"`
  23815. HospLv string `json:"hosp_lv"`
  23816. PsnCashPay float64 `json:"psn_cash_pay"`
  23817. } `json:"setlinfo"`
  23818. } `json:"output"`
  23819. RefmsgTime string `json:"refmsg_time"`
  23820. RespondTime string `json:"respond_time"`
  23821. Signtype interface{} `json:"signtype"`
  23822. WarnMsg interface{} `json:"warn_msg"`
  23823. }
  23824. type ResultTwelve struct {
  23825. Cainfo string `json:"cainfo"`
  23826. ErrMsg string `json:"err_msg"`
  23827. InfRefmsgid string `json:"inf_refmsgid"`
  23828. Infcode int64 `json:"infcode"`
  23829. Output struct {
  23830. MdtrtId string `json:"mdtrt_id"`
  23831. ChrgBchno string `json:"chrg_bchno"`
  23832. PsnNo string `json:"psn_no"`
  23833. } `json:"output"`
  23834. RefmsgTime string `json:"refmsg_time"`
  23835. RespondTime string `json:"respond_time"`
  23836. Signtype interface{} `json:"signtype"`
  23837. WarnMsg interface{} `json:"warn_msg"`
  23838. }
  23839. type ResultThirteen struct {
  23840. ErrMsg string `json:"err_msg"`
  23841. InfRefmsgid string `json:"inf_refmsgid"`
  23842. Infcode int64 `json:"infcode"`
  23843. Output struct {
  23844. Result struct {
  23845. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23846. } `json:"result"`
  23847. } `json:"output"`
  23848. RefmsgTime string `json:"refmsg_time"`
  23849. RespondTime string `json:"respond_time"`
  23850. Signtype interface{} `json:"signtype"`
  23851. WarnInfo interface{} `json:"warn_info"`
  23852. }
  23853. type ResultThirteen10265 struct {
  23854. ErrMsg string `json:"err_msg"`
  23855. InfRefmsgid string `json:"inf_refmsgid"`
  23856. Infcode string `json:"infcode"`
  23857. Output struct {
  23858. Result struct {
  23859. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23860. } `json:"result"`
  23861. } `json:"output"`
  23862. RefmsgTime string `json:"refmsg_time"`
  23863. RespondTime string `json:"respond_time"`
  23864. Signtype interface{} `json:"signtype"`
  23865. WarnInfo interface{} `json:"warn_info"`
  23866. }
  23867. type ResultFourteen struct {
  23868. ErrMsg string `json:"err_msg"`
  23869. InfRefmsgid string `json:"inf_refmsgid"`
  23870. Infcode int64 `json:"infcode"`
  23871. Output struct {
  23872. } `json:"output"`
  23873. RefmsgTime string `json:"refmsg_time"`
  23874. RespondTime string `json:"respond_time"`
  23875. Signtype interface{} `json:"signtype"`
  23876. WarnInfo interface{} `json:"warn_info"`
  23877. }
  23878. type ResultCFYLJG001 struct {
  23879. ErrMsg string `json:"err_msg"`
  23880. InfRefmsgid string `json:"inf_refmsgid"`
  23881. Infcode int64 `json:"infcode"`
  23882. Output struct {
  23883. RxTraceCode string `json:"rx_trace_code"`
  23884. HiRxno string `json:"hi_rxno"`
  23885. } `json:"output"`
  23886. RefmsgTime string `json:"refmsg_time"`
  23887. RespondTime string `json:"respond_time"`
  23888. Signtype interface{} `json:"signtype"`
  23889. WarnInfo interface{} `json:"warn_info"`
  23890. }
  23891. type ResultCFYLJG001AH struct {
  23892. RxTraceCode string `json:"rxTraceCode"`
  23893. HiRxno string `json:"hiRxno"`
  23894. }
  23895. type ResultCFYLJG007 struct {
  23896. ErrMsg string `json:"err_msg"`
  23897. InfRefmsgid string `json:"inf_refmsgid"`
  23898. Infcode int64 `json:"infcode"`
  23899. Output struct {
  23900. HiRxno string `json:"hi_rxno"`
  23901. RxStasName string `json:"rx_stas_name"`
  23902. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23903. Seltdelts []interface{} `json:"seltdelts"`
  23904. RxUsedStasName string `json:"rx_used_stas_name"`
  23905. RxStasCodg string `json:"rx_stas_codg"`
  23906. } `json:"output"`
  23907. RefmsgTime string `json:"refmsg_time"`
  23908. RespondTime string `json:"respond_time"`
  23909. Signtype interface{} `json:"signtype"`
  23910. WarnInfo interface{} `json:"warn_info"`
  23911. }
  23912. type ResultCFYLJG002 struct {
  23913. ErrMsg string `json:"err_msg"`
  23914. InfRefmsgid string `json:"inf_refmsgid"`
  23915. Infcode int64 `json:"infcode"`
  23916. Output struct {
  23917. RxFile string `json:"rx_file"`
  23918. SignDigest string `json:"sign_digest"`
  23919. SignCertSn string `json:"sign_cert_sn"`
  23920. SignCertDn string `json:"sign_cert_dn"`
  23921. } `json:"output"`
  23922. RefmsgTime string `json:"refmsg_time"`
  23923. RespondTime string `json:"respond_time"`
  23924. Signtype interface{} `json:"signtype"`
  23925. WarnInfo interface{} `json:"warn_info"`
  23926. }
  23927. type ResultCFYLJG003 struct {
  23928. ErrMsg string `json:"err_msg"`
  23929. InfRefmsgid string `json:"inf_refmsgid"`
  23930. Infcode int64 `json:"infcode"`
  23931. Output struct {
  23932. HiRxno string `json:"hi_rxno"`
  23933. RxStasCodg string `json:"rx_stas_codg"`
  23934. RxStasName string `json:"rx_stas_name"`
  23935. } `json:"output"`
  23936. RefmsgTime string `json:"refmsg_time"`
  23937. RespondTime string `json:"respond_time"`
  23938. Signtype interface{} `json:"signtype"`
  23939. WarnInfo interface{} `json:"warn_info"`
  23940. }
  23941. type ResultCFYLJG004 struct {
  23942. ErrMsg string `json:"err_msg"`
  23943. InfRefmsgid string `json:"inf_refmsgid"`
  23944. Infcode int64 `json:"infcode"`
  23945. Output struct {
  23946. HiRxno string `json:"hi_rxno"`
  23947. RxStasCodg string `json:"rx_stas_codg"`
  23948. RxStasName string `json:"rx_stas_name"`
  23949. } `json:"output"`
  23950. RefmsgTime string `json:"refmsg_time"`
  23951. RespondTime string `json:"respond_time"`
  23952. Signtype interface{} `json:"signtype"`
  23953. WarnInfo interface{} `json:"warn_info"`
  23954. }
  23955. type ResultCFYLJG008 struct {
  23956. ErrMsg string `json:"err_msg"`
  23957. InfRefmsgid string `json:"inf_refmsgid"`
  23958. Infcode int64 `json:"infcode"`
  23959. Output struct {
  23960. PoolareaNo string `json:"poolareaNo"`
  23961. AdmdvsName string `json:"admdvsName"`
  23962. Count string `json:"count"`
  23963. } `json:"output"`
  23964. RefmsgTime string `json:"refmsg_time"`
  23965. RespondTime string `json:"respond_time"`
  23966. Signtype interface{} `json:"signtype"`
  23967. WarnInfo interface{} `json:"warn_info"`
  23968. }
  23969. type ResultCFYLJG005 struct {
  23970. ErrMsg string `json:"err_msg"`
  23971. InfRefmsgid string `json:"inf_refmsgid"`
  23972. Infcode int64 `json:"infcode"`
  23973. Output struct {
  23974. HiRxNo string `json:"hi_rxno"`
  23975. FixMedinsCode string `json:"fixmedins_code"`
  23976. FixMedinsName string `json:"fixmedins_name"`
  23977. RxStasCodg string `json:"rx_stas_codg"`
  23978. RxStasName string `json:"rx_stas_name"`
  23979. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23980. RxUserdStasName string `json:"rx_userd_stas_name"`
  23981. PrscTime string `json:"prsc_time"`
  23982. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23983. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23984. RxUsedWayName string `json:"rx_used_way_name"`
  23985. RxFrquCodg string `json:"rx_frqu_codg"`
  23986. RxFrquName string `json:"rx_frqu_name"`
  23987. RxDosunt string `json:"rx_dosunt"`
  23988. RxDoscnt float64 `json:"rx_doscnt"`
  23989. RxDrordDscr string `json:"rx_drord_dscr"`
  23990. ValiDays int64 `json:"vali_days"`
  23991. ValiEndTime string `json:"vali_end_time"`
  23992. ReptFlag string `json:"rept_flag"`
  23993. MaxReptCnt int64 `json:"max_rept_cnt"`
  23994. ReptdCnt int64 `json:"reptd_cnt"`
  23995. MinInrvDays int64 `json:"min_inrv_days"`
  23996. RxTypeCode string `json:"rx_type_code"`
  23997. RxTypeName string `json:"rx_type_name"`
  23998. LongRxFlag string `json:"long_rx_flag"`
  23999. RxDetlList []struct {
  24000. MedListCodg string `json:"med_list_codg"`
  24001. MedinsListCodg string `json:"medins_list_codg"`
  24002. HospPrepFlag string `json:"hosp_prep_flag"`
  24003. RxItemTypeCode string `json:"rx_item_type_code"`
  24004. RxItemTypeName string `json:"rx_item_type_name"`
  24005. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24006. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24007. TcmHerbFoote string `json:"tcmherb_foote"`
  24008. MednTypeCode string `json:"medn_type_code"`
  24009. MednTypeName string `json:"medn_type_name"`
  24010. MainMedcFlag string `json:"main_medc_flag"`
  24011. UrgtFlag string `json:"urgt_flag"`
  24012. BasMednFlag string `json:"bas_medn_flag"`
  24013. ImpDrugFlag string `json:"imp_drug_flag"`
  24014. ProdBarc string `json:"prod_barc"`
  24015. DrugProdname string `json:"drug_prodname"`
  24016. GennameCodg string `json:"genname_codg"`
  24017. DrugGenname string `json:"drug_genname"`
  24018. DrugDosform string `json:"drug_dosform"`
  24019. DrugSpec string `json:"drug_spec"`
  24020. PrdrName string `json:"prdr_name"`
  24021. MedcWayCodg string `json:"medc_way_codg"`
  24022. MedcWayDscr string `json:"medc_way_dscr"`
  24023. MedcBegntime string `json:"medc_begntime"`
  24024. MedcEndtime string `json:"medc_endtime"`
  24025. MedcDays float64 `json:"medc_days"`
  24026. DrugPric float64 `json:"drug_pric"`
  24027. DrugSumamt float64 `json:"drug_sumamt"`
  24028. DrugCnt float64 `json:"drug_cnt"`
  24029. DrugDosunt string `json:"drug_dosunt"`
  24030. SinDoscnt float64 `json:"sin_doscnt"`
  24031. SinDosunt string `json:"sin_dosunt"`
  24032. UsedFrquCodg string `json:"used_frqu_codg"`
  24033. UsedFrquName string `json:"used_frqu_name"`
  24034. DrugTotlcnt string `json:"drug_totlcnt"`
  24035. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24036. DiseCodg string `json:"dise_codg"`
  24037. HospApprFlag string `json:"hosp_appr_flag"`
  24038. } `json:"rx_detl_list"`
  24039. RxOtpinfo struct {
  24040. MedType string `json:"med_type"`
  24041. IptOtpNo string `json:"ipt_otp_no"`
  24042. OtpIptFlag string `json:"otp_ipt_flag"`
  24043. PatnName string `json:"patn_name"`
  24044. PatnAge float64 `json:"patn_age"`
  24045. PatnHgt float64 `json:"patn_hgt"`
  24046. PatnWt float64 `json:"patn_wt"`
  24047. Gend string `json:"gend"`
  24048. GesoVal float64 `json:"geso_val"`
  24049. NwbFlag string `json:"nwb_flag"`
  24050. NwbAge string `json:"nwb_age"`
  24051. SuckPrdFlag string `json:"suck_prd_flag"`
  24052. AlgsHis string `json:"algs_his"`
  24053. Insutype string `json:"insutype"`
  24054. PrscDeptName string `json:"prsc_dept_name"`
  24055. PrscDrName string `json:"prsc_dr_name"`
  24056. PharName string `json:"phar_name"`
  24057. PharChkTime string `json:"phar_chk_time"`
  24058. MdtrtTime string `json:"mdtrt_time"`
  24059. DiseCodg string `json:"dise_codg"`
  24060. DiseName string `json:"dise_name"`
  24061. SpDiseFlag string `json:"sp_dise_flag"`
  24062. MaindiagCode string `json:"maindiag_code"`
  24063. MaindiagName string `json:"maindiag_name"`
  24064. DiseCondDscr string `json:"dise_cond_dscr"`
  24065. FstdiagFlag string `json:"fstdiag_flag"`
  24066. } `json:"rx_otpinfo"`
  24067. RxDiseList []struct {
  24068. DiagType string `json:"diag_type"`
  24069. MaindiagFlag string `json:"maindiag_flag"`
  24070. DiagSrtNo string `json:"diag_srt_no"`
  24071. DiagCode string `json:"diag_code"`
  24072. DiagName string `json:"diag_name"`
  24073. DiagDept string `json:"diag_dept"`
  24074. DiagDrNo string `json:"diag_dr_no"`
  24075. DiagDrName string `json:"diag_dr_name"`
  24076. DiagTime string `json:"diag_time"`
  24077. TcmDiseCode string `json:"tcm_dise_code"`
  24078. TcmDiseName string `json:"tcm_dise_name"`
  24079. TcmSympCode string `json:"tcmsymp_code"`
  24080. TcmSymp string `json:"tcmsymp"`
  24081. } `json:"rx_dise_list"`
  24082. } `json:"output"`
  24083. RefmsgTime string `json:"refmsg_time"`
  24084. RespondTime string `json:"respond_time"`
  24085. Signtype interface{} `json:"signtype"`
  24086. WarnInfo interface{} `json:"warn_info"`
  24087. }
  24088. type ResultCFYLJG006 struct {
  24089. ErrMsg string `json:"err_msg"`
  24090. InfRefmsgid string `json:"inf_refmsgid"`
  24091. Infcode int64 `json:"infcode"`
  24092. Output struct {
  24093. HiRxNo string `json:"hi_rxno"`
  24094. PharCode string `json:"phar_code"`
  24095. PharName string `json:"phar_name"`
  24096. RxChkOpnn string `json:"rx_chk_opnn"`
  24097. RxChkTime string `json:"rx_chk_time"`
  24098. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24099. RxChkStasName string `json:"rx_chk_stas_name"`
  24100. RxStasCodg string `json:"rx_stas_codg"`
  24101. RxStasName string `json:"rx_stas_name"`
  24102. } `json:"output"`
  24103. RefmsgTime string `json:"refmsg_time"`
  24104. RespondTime string `json:"respond_time"`
  24105. Signtype interface{} `json:"signtype"`
  24106. WarnInfo interface{} `json:"warn_info"`
  24107. }
  24108. type ResultFourteen10265 struct {
  24109. ErrMsg string `json:"err_msg"`
  24110. InfRefmsgid string `json:"inf_refmsgid"`
  24111. Infcode string `json:"infcode"`
  24112. Output struct {
  24113. } `json:"output"`
  24114. RefmsgTime string `json:"refmsg_time"`
  24115. RespondTime string `json:"respond_time"`
  24116. Signtype interface{} `json:"signtype"`
  24117. WarnInfo interface{} `json:"warn_info"`
  24118. }
  24119. type ResultSixteen struct {
  24120. Cainfo string `json:"cainfo"`
  24121. ErrMsg string `json:"err_msg"`
  24122. InfRefmsgid string `json:"inf_refmsgid"`
  24123. Infcode int64 `json:"infcode"`
  24124. Output struct {
  24125. Setlinfo struct {
  24126. MdtrtID string `json:"mdtrt_id"`
  24127. SetlID string `json:"setl_id"`
  24128. ClrOptins string `json:"clr_optins"`
  24129. SetlTime string `json:"setl_time"`
  24130. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24131. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24132. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24133. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24134. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24135. ActPayDedc float64 `json:"act_pay_dedc"`
  24136. HifpPay float64 `json:"hifp_pay"`
  24137. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24138. Lfpay float64 `json:"selfpay"`
  24139. CvlservPay float64 `json:"cvlserv_pay"`
  24140. HifesPay float64 `json:"hifes_pay"`
  24141. HifmiPay float64 `json:"hifmi_pay"`
  24142. HifobPay float64 `json:"hifob_pay"`
  24143. MafPay float64 `json:"maf_pay"`
  24144. OthPay float64 `json:"oth_pay"`
  24145. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24146. PsnPartAmt float64 `json:"psn_part_amt"`
  24147. AcctPay float64 `json:"acct_pay"`
  24148. Balc float64 `json:"balc"`
  24149. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24150. HospPartAmt float64 `json:"hosp_part_amt"`
  24151. MedinsSetlID string `json:"medins_setl_id"`
  24152. PdnCashPay string `json:"pdn_cash_pay"`
  24153. } `json:"setlinfo"`
  24154. } `json:"output"`
  24155. RefmsgTime string `json:"refmsg_time"`
  24156. RespondTime string `json:"respond_time"`
  24157. Signtype interface{} `json:"signtype"`
  24158. WarnMsg interface{} `json:"warn_msg"`
  24159. }
  24160. type ResultSixteen10265 struct {
  24161. Cainfo string `json:"cainfo"`
  24162. ErrMsg string `json:"err_msg"`
  24163. InfRefmsgid string `json:"inf_refmsgid"`
  24164. Infcode string `json:"infcode"`
  24165. Output struct {
  24166. Setlinfo struct {
  24167. MdtrtID string `json:"mdtrt_id"`
  24168. SetlID string `json:"setl_id"`
  24169. ClrOptins string `json:"clr_optins"`
  24170. SetlTime string `json:"setl_time"`
  24171. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24172. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24173. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24174. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24175. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24176. ActPayDedc float64 `json:"act_pay_dedc"`
  24177. HifpPay float64 `json:"hifp_pay"`
  24178. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24179. Lfpay float64 `json:"selfpay"`
  24180. CvlservPay float64 `json:"cvlserv_pay"`
  24181. HifesPay float64 `json:"hifes_pay"`
  24182. HifmiPay float64 `json:"hifmi_pay"`
  24183. HifobPay float64 `json:"hifob_pay"`
  24184. MafPay float64 `json:"maf_pay"`
  24185. OthPay float64 `json:"oth_pay"`
  24186. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24187. PsnPartAmt float64 `json:"psn_part_amt"`
  24188. AcctPay float64 `json:"acct_pay"`
  24189. Balc float64 `json:"balc"`
  24190. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24191. HospPartAmt float64 `json:"hosp_part_amt"`
  24192. MedinsSetlID string `json:"medins_setl_id"`
  24193. PdnCashPay string `json:"pdn_cash_pay"`
  24194. } `json:"setlinfo"`
  24195. } `json:"output"`
  24196. RefmsgTime string `json:"refmsg_time"`
  24197. RespondTime string `json:"respond_time"`
  24198. Signtype interface{} `json:"signtype"`
  24199. WarnMsg interface{} `json:"warn_msg"`
  24200. }
  24201. type ResultSixteen10265Two struct {
  24202. Cainfo string `json:"cainfo"`
  24203. ErrMsg string `json:"err_msg"`
  24204. InfRefmsgid string `json:"inf_refmsgid"`
  24205. Infcode string `json:"infcode"`
  24206. Output struct {
  24207. Setlinfo interface{} `json:"setlinfo"`
  24208. } `json:"output"`
  24209. RefmsgTime string `json:"refmsg_time"`
  24210. RespondTime string `json:"respond_time"`
  24211. Signtype interface{} `json:"signtype"`
  24212. WarnMsg interface{} `json:"warn_msg"`
  24213. }
  24214. type ResultgzSixteen10265Two struct {
  24215. Cainfo string `json:"cainfo"`
  24216. ErrMsg string `json:"err_msg"`
  24217. InfRefmsgid string `json:"inf_refmsgid"`
  24218. Infcode int64 `json:"infcode"`
  24219. Output struct {
  24220. Setlinfo interface{} `json:"setlinfo"`
  24221. } `json:"output"`
  24222. RefmsgTime string `json:"refmsg_time"`
  24223. RespondTime string `json:"respond_time"`
  24224. Signtype interface{} `json:"signtype"`
  24225. WarnMsg interface{} `json:"warn_msg"`
  24226. }
  24227. type ResultSeventeen struct {
  24228. ErrMsg string `json:"err_msg"`
  24229. InfRefmsgid string `json:"inf_refmsgid"`
  24230. Infcode int64 `json:"infcode"`
  24231. Output struct {
  24232. SetlListId string `json:"setl_list_id"`
  24233. } `json:"output"`
  24234. RefmsgTime string `json:"refmsg_time"`
  24235. RespondTime string `json:"respond_time"`
  24236. Signtype string `json:"signtype"`
  24237. WarnInfo string `json:"warn_info"`
  24238. }
  24239. type ResultSeventeenOther struct {
  24240. ErrMsg string `json:"err_msg"`
  24241. InfRefmsgid string `json:"inf_refmsgid"`
  24242. Infcode string `json:"infcode"`
  24243. Output struct {
  24244. SetlListId string `json:"setl_list_id"`
  24245. } `json:"output"`
  24246. RefmsgTime string `json:"refmsg_time"`
  24247. RespondTime string `json:"respond_time"`
  24248. Signtype string `json:"signtype"`
  24249. WarnInfo string `json:"warn_info"`
  24250. }
  24251. type Result90991 struct {
  24252. ErrMsg string `json:"err_msg"`
  24253. InfRefmsgid string `json:"inf_refmsgid"`
  24254. Infcode int64 `json:"infcode"`
  24255. Output struct {
  24256. Result struct {
  24257. PsnNo string `json:"psn_no"`
  24258. CardStat string `json:"card_stat"`
  24259. Certno string `json:"certno"`
  24260. PsnName string `json:"psn_name"`
  24261. CheckStat string `json:"check_stat"`
  24262. SscnoCheckStat string `json:"sscno_check_stat"`
  24263. } `json:"result"`
  24264. } `json:"output"`
  24265. RefmsgTime string `json:"refmsg_time"`
  24266. RespondTime string `json:"respond_time"`
  24267. Signtype interface{} `json:"signtype"`
  24268. WarnInfo interface{} `json:"warn_info"`
  24269. }
  24270. type Result90100 struct {
  24271. ErrMsg string `json:"err_msg"`
  24272. InfRefmsgid string `json:"inf_refmsgid"`
  24273. Infcode int64 `json:"infcode"`
  24274. Output struct {
  24275. PoolareaNo string `json:"poolarea_no"`
  24276. PoolareaNoName string `json:"poolarea_no_name"`
  24277. Insutype string `json:"insutype"`
  24278. InsutypeName string `json:"insutype_name"`
  24279. ClctType string `json:"clct_type"`
  24280. ClctTypeName string `json:"clct_type_name"`
  24281. ClctFlag string `json:"clct_flag"`
  24282. ClctFlagName string `json:"clct_flag_name"`
  24283. AccrymBegn string `json:"accrym_begn"`
  24284. AccrymEnd string `json:"accrym_end"`
  24285. ClctTime string `json:"clct_time"`
  24286. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24287. } `json:"output"`
  24288. RefmsgTime string `json:"refmsg_time"`
  24289. RespondTime string `json:"respond_time"`
  24290. Signtype interface{} `json:"signtype"`
  24291. WarnInfo interface{} `json:"warn_info"`
  24292. }
  24293. type Custom struct {
  24294. DetItemFeeSumamt string
  24295. Cut string
  24296. FeedetlSn string
  24297. Price string
  24298. MedListCodg string
  24299. Type int64
  24300. AdviceId int64
  24301. ProjectId int64
  24302. ItemId int64
  24303. }
  24304. type Result5301 struct {
  24305. ErrMsg string `json:"err_msg"`
  24306. InfRefmsgid string `json:"inf_refmsgid"`
  24307. Infcode int64 `json:"infcode"`
  24308. Output struct {
  24309. Result []struct {
  24310. OpspDiseCode string `json:"opsp_dise_code"`
  24311. OpspDiseName string `json:"opsp_dise_name"`
  24312. Begndate string `json:"begndate"`
  24313. Enddate string `json:"enddate"`
  24314. } `json:"feedetail"`
  24315. } `json:"output"`
  24316. RefmsgTime string `json:"refmsg_time"`
  24317. RespondTime string `json:"respond_time"`
  24318. Signtype interface{} `json:"signtype"`
  24319. WarnInfo interface{} `json:"warn_info"`
  24320. }
  24321. type Result5301For10265 struct {
  24322. ErrMsg string `json:"err_msg"`
  24323. InfRefmsgid string `json:"inf_refmsgid"`
  24324. Infcode string `json:"infcode"`
  24325. Output struct {
  24326. Result []struct {
  24327. OpspDiseCode string `json:"opsp_dise_code"`
  24328. OpspDiseName string `json:"opsp_dise_name"`
  24329. Begndate string `json:"begndate"`
  24330. Enddate string `json:"enddate"`
  24331. } `json:"feedetail"`
  24332. } `json:"output"`
  24333. RefmsgTime string `json:"refmsg_time"`
  24334. RespondTime string `json:"respond_time"`
  24335. Signtype interface{} `json:"signtype"`
  24336. WarnInfo interface{} `json:"warn_info"`
  24337. }
  24338. //获取个人信息----挂号-----上传就诊信息
  24339. func (c *HisApiController) GetRegisterInfo() {
  24340. id, _ := c.GetInt64("id")
  24341. record_time := c.GetString("record_time")
  24342. settlementValue, _ := c.GetInt64("settlement_value")
  24343. medical_insurance_card := c.GetString("medical_insurance_card")
  24344. name := c.GetString("name")
  24345. id_card_type, _ := c.GetInt64("id_card_type")
  24346. certificates, _ := c.GetInt64("certificates")
  24347. medical_care, _ := c.GetInt64("medical_care")
  24348. birthday := c.GetString("birthday")
  24349. id_card := c.GetString("id_card")
  24350. register_type, _ := c.GetInt64("register")
  24351. doctor, _ := c.GetInt64("doctor")
  24352. department, _ := c.GetInt64("department")
  24353. gender, _ := c.GetInt64("sex")
  24354. registration_fee, _ := c.GetFloat("registration_fee")
  24355. medical_expenses, _ := c.GetFloat("medical_expenses")
  24356. social_type, _ := c.GetInt64("social_type")
  24357. admin_user_id, _ := c.GetInt64("admin_user_id")
  24358. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24359. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24360. mdtrt_type := c.GetString("mdtrt_type")
  24361. if id_card_type == 5 {
  24362. id_card_type = 4
  24363. }
  24364. timeLayout := "2006-01-02"
  24365. loc, _ := time.LoadLocation("Local")
  24366. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24367. birthUnix := birthdays.Unix()
  24368. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24369. if err != nil {
  24370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24371. return
  24372. }
  24373. recordDateTime := theTime.Unix()
  24374. adminInfo := c.GetAdminUserInfo()
  24375. var patient service.Patients
  24376. if id == 0 {
  24377. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24378. } else {
  24379. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24380. }
  24381. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24382. if patientPrescription.ID == 0 {
  24383. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24384. }
  24385. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24386. if patient.ID == 0 {
  24387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24388. return
  24389. }
  24390. if len(patient.IdCardNo) == 0 {
  24391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24392. return
  24393. }
  24394. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24395. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24396. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24397. //就诊结算未完成,不能进行二次挂号
  24398. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24399. if len(his) >= 1 {
  24400. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24401. if len(his) >= 1 && order.ID == 0 {
  24402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24403. return
  24404. }
  24405. }
  24406. var aaaa string
  24407. //var register_log string
  24408. if config.IsOpen == 1 {
  24409. var res ResultTwo
  24410. var res10265 ResultTwo10265
  24411. var PsnNo string
  24412. var PsnCertType string
  24413. var Certno string
  24414. var PsnName string
  24415. var Gend string
  24416. var Naty string
  24417. var Brdy string
  24418. var Age float64
  24419. var infoStr string
  24420. var idetinfoStr string
  24421. var infocode int64
  24422. var verify_number string
  24423. fmt.Println(verify_number)
  24424. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24425. psn_info, _ := service.GetPsnByPatientId(id)
  24426. PsnNo = psn_info.PsnNo
  24427. PsnCertType = psn_info.PsnCertType
  24428. Certno = psn_info.Certno
  24429. PsnName = psn_info.PsnName
  24430. Gend = psn_info.Gend
  24431. Naty = psn_info.Naty
  24432. Brdy = psn_info.Brdy
  24433. Age = psn_info.Age
  24434. infoStr = psn_info.Insuinfo
  24435. idetinfoStr = psn_info.Idetinfo
  24436. infocode = 0
  24437. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24438. psn_info, _ := service.GetPsnByPatientId(id)
  24439. PsnNo = psn_info.PsnNo
  24440. PsnCertType = psn_info.PsnCertType
  24441. Certno = psn_info.Certno
  24442. PsnName = psn_info.PsnName
  24443. Gend = psn_info.Gend
  24444. Naty = psn_info.Naty
  24445. Brdy = psn_info.Brdy
  24446. Age = psn_info.Age
  24447. infoStr = psn_info.Insuinfo
  24448. idetinfoStr = psn_info.Idetinfo
  24449. infocode = 0
  24450. verify_number = psn_info.VerifyNumber
  24451. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24452. if id_card_type == 2 {
  24453. //请求内网数据
  24454. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24455. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24456. "&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
  24457. resp, requestErr := http.Get(api)
  24458. if requestErr != nil {
  24459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24460. return
  24461. }
  24462. body, ioErr := ioutil.ReadAll(resp.Body)
  24463. if ioErr != nil {
  24464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24466. return
  24467. }
  24468. var respJSON map[string]interface{}
  24469. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24472. return
  24473. }
  24474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24475. result_byte, _ := json.Marshal(respJSON)
  24476. result := string(result_byte)
  24477. var dat map[string]interface{}
  24478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24479. fmt.Println(dat)
  24480. } else {
  24481. fmt.Println(err)
  24482. }
  24483. userJSONBytes, _ := json.Marshal(dat)
  24484. var res ResultTwo
  24485. var resTwo10265 ResultTwo10265
  24486. if miConfig.Code == "H15049901371" {
  24487. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24488. utils.ErrorLog("解析失败:%v", err)
  24489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24490. return
  24491. }
  24492. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24493. res.Infcode = Infcode
  24494. res.ErrMsg = resTwo10265.ErrMsg
  24495. res.Output = resTwo10265.Output
  24496. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24497. res.RespondTime = resTwo10265.RespondTime
  24498. res.WarnInfo = resTwo10265.WarnInfo
  24499. } else {
  24500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24501. utils.ErrorLog("解析失败:%v", err)
  24502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24503. return
  24504. }
  24505. }
  24506. //var insutypes []string
  24507. //var insutype string
  24508. //var is390 int = 0
  24509. //var is310 int = 0
  24510. //for _, item := range res.Output.Iinfo {
  24511. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24512. // insutypes = append(insutypes, item.Insutype)
  24513. // }
  24514. //}
  24515. //if len(insutypes) == 1 {
  24516. // insutype = insutypes[0]
  24517. //} else {
  24518. // for _, i := range insutypes {
  24519. // if i == "390" {
  24520. // is390 = 1
  24521. // }
  24522. //
  24523. // if i == "310" {
  24524. // is310 = 1
  24525. // }
  24526. // }
  24527. //}
  24528. //if is390 == 1 {
  24529. // insutype = "390"
  24530. //}
  24531. //if is310 == 1 {
  24532. // insutype = "310"
  24533. //}
  24534. //if len(insutypes) == 0 {
  24535. // insutype = "310"
  24536. //}
  24537. PsnNo = res.Output.Baseinfo.PsnNo
  24538. PsnCertType = res.Output.Baseinfo.PsnCertType
  24539. Certno = res.Output.Baseinfo.Certno
  24540. PsnName = res.Output.Baseinfo.PsnName
  24541. Gend = res.Output.Baseinfo.Gend
  24542. Naty = res.Output.Baseinfo.Naty
  24543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24545. infoStr = string(Iinfos)
  24546. idetinfoStr = string(Idetinfos)
  24547. infocode = res.Infcode
  24548. //infocode = 0
  24549. //verify_number = psn_info.VerifyNumber
  24550. } else {
  24551. psn_info, _ := service.GetPsnByPatientId(id)
  24552. PsnNo = psn_info.PsnNo
  24553. PsnCertType = psn_info.PsnCertType
  24554. Certno = psn_info.Certno
  24555. PsnName = psn_info.PsnName
  24556. Gend = psn_info.Gend
  24557. Naty = psn_info.Naty
  24558. Brdy = psn_info.Brdy
  24559. Age = psn_info.Age
  24560. infoStr = psn_info.Insuinfo
  24561. idetinfoStr = psn_info.Idetinfo
  24562. infocode = 0
  24563. verify_number = psn_info.VerifyNumber
  24564. }
  24565. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24566. if id_card_type == 1 {
  24567. psn_info, _ := service.GetPsnByPatientId(id)
  24568. PsnNo = psn_info.PsnNo
  24569. PsnCertType = psn_info.PsnCertType
  24570. Certno = psn_info.Certno
  24571. PsnName = psn_info.PsnName
  24572. Gend = psn_info.Gend
  24573. Naty = psn_info.Naty
  24574. Brdy = psn_info.Brdy
  24575. Age = psn_info.Age
  24576. infoStr = psn_info.Insuinfo
  24577. idetinfoStr = psn_info.Idetinfo
  24578. infocode = 0
  24579. verify_number = psn_info.VerifyNumber
  24580. } else if id_card_type == 2 {
  24581. 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)
  24582. fmt.Println(errMsgLog)
  24583. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24584. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24585. utils.ErrorLog("解析失败:%v", err)
  24586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24587. return
  24588. }
  24589. PsnNo = res.Output.Baseinfo.PsnNo
  24590. PsnCertType = res.Output.Baseinfo.PsnCertType
  24591. Certno = res.Output.Baseinfo.Certno
  24592. PsnName = res.Output.Baseinfo.PsnName
  24593. Gend = res.Output.Baseinfo.Gend
  24594. Naty = res.Output.Baseinfo.Naty
  24595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24597. infoStr = string(Iinfos)
  24598. idetinfoStr = string(Idetinfos)
  24599. infocode = res.Infcode
  24600. }
  24601. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24602. if id_card_type == 1 {
  24603. psn_info, _ := service.GetPsnByPatientId(id)
  24604. PsnNo = psn_info.PsnNo
  24605. PsnCertType = psn_info.PsnCertType
  24606. Certno = psn_info.Certno
  24607. PsnName = psn_info.PsnName
  24608. Gend = psn_info.Gend
  24609. Naty = psn_info.Naty
  24610. Brdy = psn_info.Brdy
  24611. Age = psn_info.Age
  24612. infoStr = psn_info.Insuinfo
  24613. idetinfoStr = psn_info.Idetinfo
  24614. infocode = 0
  24615. verify_number = psn_info.VerifyNumber
  24616. } else if id_card_type == 2 {
  24617. 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, "")
  24618. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24619. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24620. utils.ErrorLog("解析失败:%v", err)
  24621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24622. return
  24623. }
  24624. PsnNo = res.Output.Baseinfo.PsnNo
  24625. PsnCertType = res.Output.Baseinfo.PsnCertType
  24626. Certno = res.Output.Baseinfo.Certno
  24627. PsnName = res.Output.Baseinfo.PsnName
  24628. Gend = res.Output.Baseinfo.Gend
  24629. Naty = res.Output.Baseinfo.Naty
  24630. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24631. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24632. infoStr = string(Iinfos)
  24633. idetinfoStr = string(Idetinfos)
  24634. infocode = res.Infcode
  24635. } else {
  24636. psn_info, _ := service.GetPsnByPatientId(id)
  24637. PsnNo = psn_info.PsnNo
  24638. PsnCertType = psn_info.PsnCertType
  24639. Certno = psn_info.Certno
  24640. PsnName = psn_info.PsnName
  24641. Gend = psn_info.Gend
  24642. Naty = psn_info.Naty
  24643. Brdy = psn_info.Brdy
  24644. Age = psn_info.Age
  24645. infoStr = psn_info.Insuinfo
  24646. idetinfoStr = psn_info.Idetinfo
  24647. infocode = 0
  24648. verify_number = psn_info.VerifyNumber
  24649. }
  24650. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24651. if id_card_type == 1 {
  24652. psn_info, _ := service.GetPsnByPatientId(id)
  24653. PsnNo = psn_info.PsnNo
  24654. PsnCertType = psn_info.PsnCertType
  24655. Certno = psn_info.Certno
  24656. PsnName = psn_info.PsnName
  24657. Gend = psn_info.Gend
  24658. Naty = psn_info.Naty
  24659. Brdy = psn_info.Brdy
  24660. Age = psn_info.Age
  24661. infoStr = psn_info.Insuinfo
  24662. idetinfoStr = psn_info.Idetinfo
  24663. infocode = 0
  24664. verify_number = psn_info.VerifyNumber
  24665. } else if id_card_type == 2 {
  24666. psn_info, _ := service.GetPsnByPatientId(id)
  24667. PsnNo = psn_info.PsnNo
  24668. PsnCertType = psn_info.PsnCertType
  24669. Certno = psn_info.Certno
  24670. PsnName = psn_info.PsnName
  24671. Gend = psn_info.Gend
  24672. Naty = psn_info.Naty
  24673. Brdy = psn_info.Brdy
  24674. Age = psn_info.Age
  24675. infoStr = psn_info.Insuinfo
  24676. idetinfoStr = psn_info.Idetinfo
  24677. infocode = 0
  24678. verify_number = psn_info.VerifyNumber
  24679. } else {
  24680. psn_info, _ := service.GetPsnByPatientId(id)
  24681. PsnNo = psn_info.PsnNo
  24682. PsnCertType = psn_info.PsnCertType
  24683. Certno = psn_info.Certno
  24684. PsnName = psn_info.PsnName
  24685. Gend = psn_info.Gend
  24686. Naty = psn_info.Naty
  24687. Brdy = psn_info.Brdy
  24688. Age = psn_info.Age
  24689. infoStr = psn_info.Insuinfo
  24690. idetinfoStr = psn_info.Idetinfo
  24691. infocode = 0
  24692. verify_number = psn_info.VerifyNumber
  24693. }
  24694. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24695. if id_card_type == 1 {
  24696. psn_info, _ := service.GetPsnByPatientId(id)
  24697. PsnNo = psn_info.PsnNo
  24698. PsnCertType = psn_info.PsnCertType
  24699. Certno = psn_info.Certno
  24700. PsnName = psn_info.PsnName
  24701. Gend = psn_info.Gend
  24702. Naty = psn_info.Naty
  24703. Brdy = psn_info.Brdy
  24704. Age = psn_info.Age
  24705. infoStr = psn_info.Insuinfo
  24706. idetinfoStr = psn_info.Idetinfo
  24707. infocode = 0
  24708. verify_number = psn_info.VerifyNumber
  24709. } else if id_card_type == 2 {
  24710. psn_info, _ := service.GetPsnByPatientId(id)
  24711. PsnNo = psn_info.PsnNo
  24712. PsnCertType = psn_info.PsnCertType
  24713. Certno = psn_info.Certno
  24714. PsnName = psn_info.PsnName
  24715. Gend = psn_info.Gend
  24716. Naty = psn_info.Naty
  24717. Brdy = psn_info.Brdy
  24718. Age = psn_info.Age
  24719. infoStr = psn_info.Insuinfo
  24720. idetinfoStr = psn_info.Idetinfo
  24721. infocode = 0
  24722. verify_number = psn_info.VerifyNumber
  24723. } else {
  24724. psn_info, _ := service.GetPsnByPatientId(id)
  24725. PsnNo = psn_info.PsnNo
  24726. PsnCertType = psn_info.PsnCertType
  24727. Certno = psn_info.Certno
  24728. PsnName = psn_info.PsnName
  24729. Gend = psn_info.Gend
  24730. Naty = psn_info.Naty
  24731. Brdy = psn_info.Brdy
  24732. Age = psn_info.Age
  24733. infoStr = psn_info.Insuinfo
  24734. idetinfoStr = psn_info.Idetinfo
  24735. infocode = 0
  24736. verify_number = psn_info.VerifyNumber
  24737. }
  24738. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24739. psn_info, _ := service.GetPsnByPatientId(id)
  24740. PsnNo = psn_info.PsnNo
  24741. PsnCertType = psn_info.PsnCertType
  24742. Certno = psn_info.Certno
  24743. PsnName = psn_info.PsnName
  24744. Gend = psn_info.Gend
  24745. Naty = psn_info.Naty
  24746. Brdy = psn_info.Brdy
  24747. Age = psn_info.Age
  24748. infoStr = psn_info.Insuinfo
  24749. idetinfoStr = psn_info.Idetinfo
  24750. infocode = 0
  24751. verify_number = psn_info.VerifyNumber
  24752. idetinfoStr = psn_info.Idetinfo
  24753. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24754. if id_card_type == 1 {
  24755. psn_info, _ := service.GetPsnByPatientId(id)
  24756. PsnNo = psn_info.PsnNo
  24757. PsnCertType = psn_info.PsnCertType
  24758. Certno = psn_info.Certno
  24759. PsnName = psn_info.PsnName
  24760. Gend = psn_info.Gend
  24761. Naty = psn_info.Naty
  24762. Brdy = psn_info.Brdy
  24763. Age = psn_info.Age
  24764. infoStr = psn_info.Insuinfo
  24765. idetinfoStr = psn_info.Idetinfo
  24766. infocode = 0
  24767. verify_number = psn_info.VerifyNumber
  24768. } else if id_card_type == 2 {
  24769. 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)
  24770. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24771. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24772. utils.ErrorLog("解析失败:%v", err)
  24773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24774. return
  24775. }
  24776. PsnNo = res.Output.Baseinfo.PsnNo
  24777. PsnCertType = res.Output.Baseinfo.PsnCertType
  24778. Certno = res.Output.Baseinfo.Certno
  24779. PsnName = res.Output.Baseinfo.PsnName
  24780. Gend = res.Output.Baseinfo.Gend
  24781. Naty = res.Output.Baseinfo.Naty
  24782. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24783. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24784. infoStr = string(Iinfos)
  24785. idetinfoStr = string(Idetinfos)
  24786. infocode = res.Infcode
  24787. } else if id_card_type == 4 {
  24788. psn_info, _ := service.GetPsnByPatientId(id)
  24789. PsnNo = psn_info.PsnNo
  24790. PsnCertType = psn_info.PsnCertType
  24791. Certno = psn_info.Certno
  24792. PsnName = psn_info.PsnName
  24793. Gend = psn_info.Gend
  24794. Naty = psn_info.Naty
  24795. Brdy = psn_info.Brdy
  24796. Age = psn_info.Age
  24797. infoStr = psn_info.Insuinfo
  24798. idetinfoStr = psn_info.Idetinfo
  24799. infocode = 0
  24800. verify_number = psn_info.VerifyNumber
  24801. }
  24802. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24803. var result string
  24804. var requestLog string
  24805. 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), "")
  24806. if id_card_type == 4 {
  24807. psn_info, _ := service.GetPsnByPatientId(id)
  24808. PsnNo = psn_info.PsnNo
  24809. PsnCertType = psn_info.PsnCertType
  24810. Certno = psn_info.Certno
  24811. PsnName = psn_info.PsnName
  24812. Gend = psn_info.Gend
  24813. Naty = psn_info.Naty
  24814. Brdy = psn_info.Brdy
  24815. Age = psn_info.Age
  24816. infoStr = psn_info.Insuinfo
  24817. idetinfoStr = psn_info.Idetinfo
  24818. infocode = 0
  24819. verify_number = psn_info.VerifyNumber
  24820. } else {
  24821. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24822. if miConfig.Code == "H15049901371" {
  24823. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24824. utils.ErrorLog("解析失败:%v", err)
  24825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24826. return
  24827. }
  24828. res.ErrMsg = res10265.ErrMsg
  24829. res.Output = res10265.Output
  24830. res.InfRefmsgid = res10265.InfRefmsgid
  24831. } else {
  24832. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24833. utils.ErrorLog("解析失败:%v", err)
  24834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24835. return
  24836. }
  24837. }
  24838. PsnNo = res.Output.Baseinfo.PsnNo
  24839. PsnCertType = res.Output.Baseinfo.PsnCertType
  24840. Certno = res.Output.Baseinfo.Certno
  24841. PsnName = res.Output.Baseinfo.PsnName
  24842. Gend = res.Output.Baseinfo.Gend
  24843. Naty = res.Output.Baseinfo.Naty
  24844. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24845. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24846. infoStr = string(Iinfos)
  24847. idetinfoStr = string(Idetinfos)
  24848. if miConfig.Code == "H15049901371" {
  24849. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24850. } else {
  24851. infocode = res.Infcode
  24852. }
  24853. }
  24854. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24855. psn_info, _ := service.GetPsnByPatientId(id)
  24856. PsnNo = psn_info.PsnNo
  24857. PsnCertType = psn_info.PsnCertType
  24858. Certno = psn_info.Certno
  24859. PsnName = psn_info.PsnName
  24860. Gend = psn_info.Gend
  24861. Naty = psn_info.Naty
  24862. Brdy = psn_info.Brdy
  24863. Age = psn_info.Age
  24864. infoStr = psn_info.Insuinfo
  24865. idetinfoStr = psn_info.Idetinfo
  24866. infocode = 0
  24867. verify_number = psn_info.VerifyNumber
  24868. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24869. psn_info, _ := service.GetPsnByPatientId(id)
  24870. PsnNo = psn_info.PsnNo
  24871. PsnCertType = psn_info.PsnCertType
  24872. Certno = psn_info.Certno
  24873. PsnName = psn_info.PsnName
  24874. Gend = psn_info.Gend
  24875. Naty = psn_info.Naty
  24876. Brdy = psn_info.Brdy
  24877. Age = psn_info.Age
  24878. infoStr = psn_info.Insuinfo
  24879. idetinfoStr = psn_info.Idetinfo
  24880. infocode = 0
  24881. verify_number = psn_info.VerifyNumber
  24882. } else {
  24883. var result string
  24884. var requestLog string
  24885. //if miConfig.UserOrgId == 10138 {
  24886. if id_card_type != 4 || id_card_type != 1 {
  24887. var insa string
  24888. if len(patient.InsuplcAdmdvs) > 0 {
  24889. insa = patient.InsuplcAdmdvs
  24890. } else {
  24891. insa = miConfig.InsuplcAdmdvs
  24892. }
  24893. //psn_info, _ := service.GetPsnByPatientId(id)
  24894. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24895. 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)
  24896. }
  24897. //}
  24898. //else {
  24899. // var insa string
  24900. // if len(patient.InsuplcAdmdvs) > 0 {
  24901. // insa = patient.InsuplcAdmdvs
  24902. // } else {
  24903. // insa = miConfig.InsuplcAdmdvs
  24904. // }
  24905. // 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)
  24906. //}
  24907. if id_card_type == 4 || id_card_type == 1 {
  24908. psn_info, _ := service.GetPsnByPatientId(id)
  24909. PsnNo = psn_info.PsnNo
  24910. PsnCertType = psn_info.PsnCertType
  24911. Certno = psn_info.Certno
  24912. PsnName = psn_info.PsnName
  24913. Gend = psn_info.Gend
  24914. Naty = psn_info.Naty
  24915. Brdy = psn_info.Brdy
  24916. Age = psn_info.Age
  24917. infoStr = psn_info.Insuinfo
  24918. idetinfoStr = psn_info.Idetinfo
  24919. infocode = 0
  24920. verify_number = psn_info.VerifyNumber
  24921. } else {
  24922. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24923. if miConfig.Code == "H15049901371" {
  24924. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24925. utils.ErrorLog("解析失败:%v", err)
  24926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24927. return
  24928. }
  24929. res.ErrMsg = res10265.ErrMsg
  24930. res.Output = res10265.Output
  24931. res.InfRefmsgid = res10265.InfRefmsgid
  24932. } else {
  24933. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24934. utils.ErrorLog("解析失败:%v", err)
  24935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24936. return
  24937. }
  24938. }
  24939. PsnNo = res.Output.Baseinfo.PsnNo
  24940. PsnCertType = res.Output.Baseinfo.PsnCertType
  24941. Certno = res.Output.Baseinfo.Certno
  24942. PsnName = res.Output.Baseinfo.PsnName
  24943. Gend = res.Output.Baseinfo.Gend
  24944. Naty = res.Output.Baseinfo.Naty
  24945. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24946. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24947. infoStr = string(Iinfos)
  24948. idetinfoStr = string(Idetinfos)
  24949. if miConfig.Code == "H15049901371" {
  24950. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24951. } else {
  24952. infocode = res.Infcode
  24953. }
  24954. }
  24955. }
  24956. if infocode == 0 {
  24957. his := models.VMHisPatient{
  24958. Name: name,
  24959. Gender: gender,
  24960. Birthday: birthUnix,
  24961. MedicalTreatmentType: medical_care,
  24962. IdType: certificates,
  24963. IdCardNo: id_card,
  24964. BalanceAccountsType: settlementValue,
  24965. SocialType: social_type,
  24966. MedicalInsuranceNumber: medical_insurance_card,
  24967. RegisterType: register_type,
  24968. RegisterCost: registration_fee,
  24969. TreatmentCost: medical_expenses,
  24970. Status: 1,
  24971. Ctime: time.Now().Unix(),
  24972. Mtime: time.Now().Unix(),
  24973. PsnNo: PsnNo,
  24974. PsnCertType: PsnCertType,
  24975. Certno: Certno,
  24976. PsnName: PsnName,
  24977. Gend: Gend,
  24978. Naty: Naty,
  24979. Brdy: Brdy,
  24980. Age: Age,
  24981. Iinfo: infoStr,
  24982. Idetinfo: idetinfoStr,
  24983. PatientId: patient.ID,
  24984. RecordDate: theTime.Unix(),
  24985. UserOrgId: adminInfo.CurrentOrgId,
  24986. AdminUserId: admin_user_id,
  24987. IsReturn: 1,
  24988. IdCardType: id_card_type,
  24989. Doctor: doctor,
  24990. Departments: department,
  24991. MdtrtGrpType: mdtrt_type,
  24992. }
  24993. timestamp := time.Now().Unix()
  24994. tempTime := time.Unix(timestamp, 0)
  24995. timeFormat := tempTime.Format("20060102150405")
  24996. chrgBchno := rand.Intn(100000) + 10000
  24997. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24998. his.Number = ipt_otp_no
  24999. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25000. department, _ := service.GetDepartMentDetail(department)
  25001. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25002. IdCardNo := ""
  25003. if id_card_type == 1 {
  25004. // IdCardNo = medical_insurance_card
  25005. IdCardNo = patient.IdCardNo
  25006. } else {
  25007. IdCardNo = patient.IdCardNo
  25008. }
  25009. var rf []*ResultFive
  25010. json.Unmarshal([]byte(his.Iinfo), &rf)
  25011. var insutypes []*ResultFive
  25012. var insutype string
  25013. var insuplc_admdvs_temp string
  25014. var is390 int = 0
  25015. var is310 int = 0
  25016. for _, item := range rf {
  25017. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25018. insutypes = append(insutypes, item)
  25019. }
  25020. }
  25021. if len(insutypes) == 1 {
  25022. insutype = insutypes[0].Insutype
  25023. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25024. if insutype == "390" {
  25025. is390 = 1
  25026. }
  25027. if insutype == "310" {
  25028. is310 = 1
  25029. }
  25030. } else {
  25031. for _, i := range insutypes {
  25032. if i.Insutype == "390" {
  25033. is390 = 1
  25034. }
  25035. if i.Insutype == "310" {
  25036. is310 = 1
  25037. }
  25038. }
  25039. }
  25040. if is390 == 1 {
  25041. insutype = "390"
  25042. }
  25043. if is310 == 1 {
  25044. insutype = "310"
  25045. }
  25046. fmt.Println(social_type)
  25047. if social_type > 0 {
  25048. insutype = strconv.FormatInt(social_type, 10)
  25049. }
  25050. var infocode int64
  25051. var resThree ResultThree
  25052. var resThree10265 ResultThree10265
  25053. if len(insuplc_admdvs) == 0 {
  25054. psn_info, _ := service.GetPsnByPatientId(id)
  25055. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25056. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25057. //}
  25058. } else {
  25059. insuplc_admdvs_temp = insuplc_admdvs
  25060. }
  25061. if miConfig.MdtrtareaAdmvs == "421300" {
  25062. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25063. psn_info, _ := service.GetPsnByPatientId(id)
  25064. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25065. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25066. "&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
  25067. resp, requestErr := http.Get(api)
  25068. if requestErr != nil {
  25069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25070. return
  25071. }
  25072. body, ioErr := ioutil.ReadAll(resp.Body)
  25073. if ioErr != nil {
  25074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25076. return
  25077. }
  25078. var respJSON map[string]interface{}
  25079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25082. return
  25083. }
  25084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25085. result, _ := json.Marshal(respJSON)
  25086. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25087. utils.ErrorLog("解析失败:%v", err)
  25088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25089. return
  25090. }
  25091. infocode = resThree.Infcode
  25092. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25093. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25094. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25095. // insuplc_admdvs_temp =
  25096. //}
  25097. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25098. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25099. //}
  25100. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25101. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25102. "&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
  25103. resp, requestErr := http.Get(api)
  25104. if requestErr != nil {
  25105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25106. return
  25107. }
  25108. body, ioErr := ioutil.ReadAll(resp.Body)
  25109. if ioErr != nil {
  25110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25112. return
  25113. }
  25114. var respJSON map[string]interface{}
  25115. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25118. return
  25119. }
  25120. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25121. result, _ := json.Marshal(respJSON)
  25122. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25123. utils.ErrorLog("解析失败:%v", err)
  25124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25125. return
  25126. }
  25127. infocode = resThree.Infcode
  25128. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25129. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25130. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25131. // insuplc_admdvs_temp =
  25132. //}
  25133. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25134. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25135. //}
  25136. utils.ErrorLog("解析失败:%v", insutype)
  25137. utils.ErrorLog("解析失败:%v", PsnNo)
  25138. utils.ErrorLog("解析失败:%v", Certno)
  25139. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25140. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25141. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25142. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25143. utils.ErrorLog("解析失败:%v", PsnNo)
  25144. utils.ErrorLog("解析失败:%v", department.Number)
  25145. utils.ErrorLog("解析失败:%v", department.Name)
  25146. utils.ErrorLog("解析失败:%v", roles.UserName)
  25147. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25148. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25149. "&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
  25150. resp, requestErr := http.Get(api)
  25151. if requestErr != nil {
  25152. utils.ErrorLog("解析失败:%v", requestErr)
  25153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25154. return
  25155. }
  25156. body, ioErr := ioutil.ReadAll(resp.Body)
  25157. if ioErr != nil {
  25158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25160. return
  25161. }
  25162. var respJSON map[string]interface{}
  25163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25166. return
  25167. }
  25168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25169. result, _ := json.Marshal(respJSON)
  25170. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25171. utils.ErrorLog("解析失败:%v", err)
  25172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25173. return
  25174. }
  25175. infocode = resThree.Infcode
  25176. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25177. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25178. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25179. // insuplc_admdvs_temp =
  25180. //}
  25181. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25182. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25183. //}
  25184. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25185. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25186. "&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
  25187. resp, requestErr := http.Get(api)
  25188. if requestErr != nil {
  25189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25190. return
  25191. }
  25192. body, ioErr := ioutil.ReadAll(resp.Body)
  25193. if ioErr != nil {
  25194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25196. return
  25197. }
  25198. var respJSON map[string]interface{}
  25199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25202. return
  25203. }
  25204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25205. result, _ := json.Marshal(respJSON)
  25206. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25207. utils.ErrorLog("解析失败:%v", err)
  25208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25209. return
  25210. }
  25211. infocode = resThree.Infcode
  25212. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25213. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25214. psn_info, _ := service.GetPsnByPatientId(id)
  25215. var verify_number string
  25216. if id_card_type == 4 {
  25217. verify_number = psn_info.VerifyNumber
  25218. } else if id_card_type == 1 {
  25219. bas := strings.Split(psn_info.CardInfo, "|")
  25220. cardNumber := bas[2]
  25221. verify_number = cardNumber
  25222. }
  25223. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25224. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25225. "&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
  25226. resp, requestErr := http.Get(api)
  25227. if requestErr != nil {
  25228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25229. return
  25230. }
  25231. body, ioErr := ioutil.ReadAll(resp.Body)
  25232. if ioErr != nil {
  25233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25235. return
  25236. }
  25237. var respJSON map[string]interface{}
  25238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25241. return
  25242. }
  25243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25244. result, _ := json.Marshal(respJSON)
  25245. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25246. // utils.ErrorLog("解析失败:%v", err)
  25247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25248. // return
  25249. //}
  25250. //infocode = resThree.Infcode
  25251. //result, _ := json.Marshal(respJSON)
  25252. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25253. utils.ErrorLog("解析失败:%v", err)
  25254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25255. return
  25256. }
  25257. resThree.ErrMsg = resThree10265.ErrMsg
  25258. resThree.Output = resThree10265.Output
  25259. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25260. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25261. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25262. psn_info, _ := service.GetPsnByPatientId(id)
  25263. his.PsnNo = psn_info.PsnNo
  25264. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25265. var cert_no string
  25266. if id_card_type == 3 {
  25267. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25268. cert_no = IdCardNo
  25269. } else if id_card_type == 4 {
  25270. cert_no = IdCardNo
  25271. psn_info.VerifyNumber = psn_info.VerifyNumber
  25272. } else {
  25273. bas := strings.Split(psn_info.CardInfo, "|")
  25274. cert_no = bas[2]
  25275. }
  25276. var hisPrescription []*models.HisPrescription
  25277. fmt.Println(hisPrescription)
  25278. for _, item := range rf {
  25279. if item.Insutype == insutype {
  25280. //insuplc_admdvs = item.InsuplcAdmdvs
  25281. his.InsuplcAdmdvs = insuplc_admdvs
  25282. }
  25283. }
  25284. his.Insutype = insutype
  25285. var res3101 Result3101
  25286. res3101.Infcode = "0"
  25287. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25288. if res3101.Infcode == "0" {
  25289. fmt.Println("33333333")
  25290. if len(res3101.Output.Result) > 0 {
  25291. fmt.Println("222222")
  25292. for _, item := range res3101.Output.Result {
  25293. if len(res3101.ErrMsg) == 0 {
  25294. res3101.ErrMsg = item.VolaCont
  25295. } else {
  25296. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25297. }
  25298. }
  25299. c.ServeSuccessJSON(map[string]interface{}{
  25300. "failed_code": -10,
  25301. "msg": res3101.ErrMsg,
  25302. })
  25303. return
  25304. } else {
  25305. fmt.Println("11111")
  25306. var api string
  25307. if miConfig.MdtrtareaAdmvs == "320830" {
  25308. ipt_otp_no = timeFormat
  25309. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25310. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25311. "&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
  25312. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25313. ipt_otp_no = timeFormat
  25314. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25315. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25316. "&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
  25317. } else {
  25318. ipt_otp_no = timeFormat
  25319. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25320. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25321. "&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
  25322. }
  25323. resp, requestErr := http.Get(api)
  25324. if requestErr != nil {
  25325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25326. return
  25327. }
  25328. body, ioErr := ioutil.ReadAll(resp.Body)
  25329. if ioErr != nil {
  25330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25332. return
  25333. }
  25334. var respJSON map[string]interface{}
  25335. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25338. return
  25339. }
  25340. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25341. result, _ := json.Marshal(respJSON)
  25342. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25343. utils.ErrorLog("解析失败:%v", err)
  25344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25345. return
  25346. }
  25347. resThree.ErrMsg = resThree10265.ErrMsg
  25348. resThree.Output = resThree10265.Output
  25349. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25350. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25351. }
  25352. } else if res3101.Infcode != "0" {
  25353. c.ServeSuccessJSON(map[string]interface{}{
  25354. "failed_code": -10,
  25355. "msg": res3101.ErrMsg,
  25356. })
  25357. return
  25358. }
  25359. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25360. psn_info, _ := service.GetPsnByPatientId(id)
  25361. var cert_no string
  25362. if id_card_type == 1 {
  25363. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25364. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25365. } else if id_card_type == 4 {
  25366. cert_no = psn_info.VerifyNumber
  25367. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25368. } else {
  25369. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25370. cert_no = psn_info.VerifyNumber
  25371. }
  25372. 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)
  25373. saveLog(result, requestLog, "2201", "挂号")
  25374. if miConfig.Code == "H15049901371" {
  25375. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25376. utils.ErrorLog("解析失败:%v", err)
  25377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25378. return
  25379. }
  25380. resThree.ErrMsg = resThree10265.ErrMsg
  25381. resThree.Output = resThree10265.Output
  25382. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25383. } else {
  25384. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25385. utils.ErrorLog("解析失败:%v", err)
  25386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25387. return
  25388. }
  25389. }
  25390. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25391. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25392. psn_info, _ := service.GetPsnByPatientId(id)
  25393. var result string
  25394. var requestLog string
  25395. if id_card_type == 1 {
  25396. bas := strings.Split(psn_info.CardInfo, "|")
  25397. basNumber := bas[2]
  25398. card_sn := bas[3]
  25399. 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)
  25400. saveLog(result, requestLog, "2201A", "挂号")
  25401. } else if id_card_type == 2 {
  25402. 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, "", "", "", "", "", "")
  25403. saveLog(result, requestLog, "2201A", "挂号")
  25404. } else {
  25405. 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)
  25406. saveLog(result, requestLog, "2201A", "挂号")
  25407. }
  25408. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25409. utils.ErrorLog("解析失败:%v", err)
  25410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25411. return
  25412. }
  25413. infocode = resThree.Infcode
  25414. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25415. psn_info, _ := service.GetPsnByPatientId(id)
  25416. var result string
  25417. var requestLog string
  25418. if id_card_type == 1 {
  25419. bas := strings.Split(psn_info.CardInfo, "|")
  25420. basNumber := bas[2]
  25421. card_sn := ""
  25422. 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)
  25423. saveLog(result, requestLog, "2201A", "挂号")
  25424. } else if id_card_type == 2 {
  25425. 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, "", "", "", "", "", "")
  25426. saveLog(result, requestLog, "2201A", "挂号")
  25427. } else {
  25428. 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)
  25429. saveLog(result, requestLog, "2201A", "挂号")
  25430. }
  25431. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25432. utils.ErrorLog("解析失败:%v", err)
  25433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25434. return
  25435. }
  25436. infocode = resThree.Infcode
  25437. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25438. psn_info, _ := service.GetPsnByPatientId(id)
  25439. var result string
  25440. var requestLog string
  25441. if id_card_type == 1 {
  25442. bas := strings.Split(psn_info.CardInfo, "|")
  25443. basNumber := bas[2]
  25444. card_sn := ""
  25445. 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)
  25446. saveLog(result, requestLog, "2201A", "挂号")
  25447. } else if id_card_type == 2 {
  25448. 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, "", "", "", "", "", "")
  25449. saveLog(result, requestLog, "2201A", "挂号")
  25450. } else {
  25451. 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)
  25452. saveLog(result, requestLog, "2201A", "挂号")
  25453. }
  25454. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25455. utils.ErrorLog("解析失败:%v", err)
  25456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25457. return
  25458. }
  25459. infocode = resThree.Infcode
  25460. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25461. psn_info, _ := service.GetPsnByPatientId(id)
  25462. his.PsnNo = psn_info.PsnNo
  25463. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25464. var cert_no string
  25465. if id_card_type == 1 {
  25466. bas := strings.Split(psn_info.CardInfo, "|")
  25467. cert_no = bas[2]
  25468. } else if id_card_type == 4 {
  25469. cert_no = psn_info.VerifyNumber
  25470. psn_info.VerifyNumber = psn_info.VerifyNumber
  25471. IdCardNo = psn_info.VerifyNumber
  25472. } else {
  25473. cert_no = IdCardNo
  25474. psn_info.VerifyNumber = cert_no
  25475. }
  25476. for _, item := range rf {
  25477. if item.Insutype == insutype {
  25478. his.InsuplcAdmdvs = insuplc_admdvs
  25479. }
  25480. }
  25481. his.Insutype = insutype
  25482. var api string
  25483. ipt_otp_no = timeFormat
  25484. 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 +
  25485. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25486. "&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
  25487. resp, requestErr := http.Get(api)
  25488. if requestErr != nil {
  25489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25490. return
  25491. }
  25492. body, ioErr := ioutil.ReadAll(resp.Body)
  25493. if ioErr != nil {
  25494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25496. return
  25497. }
  25498. var respJSON map[string]interface{}
  25499. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25502. return
  25503. }
  25504. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25505. if status == "0" {
  25506. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25507. c.ServeSuccessJSON(map[string]interface{}{
  25508. "failed_code": -10,
  25509. "msg": err_msg,
  25510. })
  25511. return
  25512. }
  25513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25514. result, _ := json.Marshal(respJSON)
  25515. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25516. utils.ErrorLog("解析失败:%v", err)
  25517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25518. return
  25519. }
  25520. infocode = resThree.Infcode
  25521. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25522. psn_info, _ := service.GetPsnByPatientId(id)
  25523. his.PsnNo = psn_info.PsnNo
  25524. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25525. var cert_no string
  25526. if id_card_type == 1 {
  25527. bas := strings.Split(psn_info.CardInfo, "|")
  25528. cert_no = bas[2]
  25529. } else if id_card_type == 4 {
  25530. cert_no = psn_info.VerifyNumber
  25531. psn_info.VerifyNumber = psn_info.VerifyNumber
  25532. IdCardNo = psn_info.VerifyNumber
  25533. } else {
  25534. cert_no = IdCardNo
  25535. psn_info.VerifyNumber = cert_no
  25536. }
  25537. for _, item := range rf {
  25538. if item.Insutype == insutype {
  25539. his.InsuplcAdmdvs = insuplc_admdvs
  25540. patient.InsuplcAdmdvs = insuplc_admdvs
  25541. }
  25542. }
  25543. his.Insutype = insutype
  25544. var api string
  25545. ipt_otp_no = timeFormat
  25546. 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 +
  25547. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25548. "&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
  25549. resp, requestErr := http.Get(api)
  25550. if requestErr != nil {
  25551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25552. return
  25553. }
  25554. body, ioErr := ioutil.ReadAll(resp.Body)
  25555. if ioErr != nil {
  25556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25558. return
  25559. }
  25560. var respJSON map[string]interface{}
  25561. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25564. return
  25565. }
  25566. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25567. if status == "0" {
  25568. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25569. c.ServeSuccessJSON(map[string]interface{}{
  25570. "failed_code": -10,
  25571. "msg": err_msg,
  25572. })
  25573. return
  25574. }
  25575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25576. result, _ := json.Marshal(respJSON)
  25577. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25578. utils.ErrorLog("解析失败:%v", err)
  25579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25580. return
  25581. }
  25582. infocode = resThree.Infcode
  25583. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25584. hour := time.Now().Format("15")
  25585. min := time.Now().Format("04")
  25586. sec := time.Now().Format("05")
  25587. begin := record_time + " " + hour + ":" + min + ":" + sec
  25588. psn_info, _ := service.GetPsnByPatientId(id)
  25589. var result string
  25590. var requestLog string
  25591. if id_card_type == 1 {
  25592. bas := strings.Split(psn_info.CardInfo, "|")
  25593. basNumber := bas[2]
  25594. card_sn := bas[3]
  25595. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, begin)
  25596. saveLog(result, requestLog, "2201A", "挂号")
  25597. } else if id_card_type == 2 {
  25598. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, psn_info.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "", begin)
  25599. saveLog(result, requestLog, "2201A", "挂号")
  25600. } else {
  25601. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "", begin)
  25602. saveLog(result, requestLog, "2201A", "挂号")
  25603. }
  25604. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25605. utils.ErrorLog("解析失败:%v", err)
  25606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25607. return
  25608. }
  25609. infocode = resThree.Infcode
  25610. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25611. psn_info, _ := service.GetPsnByPatientId(id)
  25612. 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)
  25613. saveLog(result, requestLog, "2201A", "挂号")
  25614. if miConfig.Code == "H15049901371" {
  25615. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25616. utils.ErrorLog("解析失败:%v", err)
  25617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25618. return
  25619. }
  25620. resThree.ErrMsg = resThree10265.ErrMsg
  25621. resThree.Output = resThree10265.Output
  25622. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25623. } else {
  25624. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25625. utils.ErrorLog("解析失败:%v", err)
  25626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25627. return
  25628. }
  25629. }
  25630. if miConfig.Code == "H15049901371" {
  25631. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25632. } else {
  25633. infocode = resThree.Infcode
  25634. }
  25635. } else {
  25636. psn_info, _ := service.GetPsnByPatientId(id)
  25637. if id_card_type == 4 || id_card_type == 1 {
  25638. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25639. }
  25640. var rf []*ResultFive
  25641. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25642. var insutypes []*ResultFive
  25643. var insutype string
  25644. var is390 int = 0
  25645. var is310 int = 0
  25646. for _, item := range rf {
  25647. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25648. insutypes = append(insutypes, item)
  25649. }
  25650. }
  25651. if len(insutypes) == 1 {
  25652. insutype = insutypes[0].Insutype
  25653. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25654. } else {
  25655. for _, i := range insutypes {
  25656. if i.Insutype == "390" {
  25657. is390 = 1
  25658. }
  25659. if i.Insutype == "310" {
  25660. is310 = 1
  25661. }
  25662. }
  25663. }
  25664. if is390 == 1 {
  25665. insutype = "390"
  25666. }
  25667. if is310 == 1 {
  25668. insutype = "310"
  25669. }
  25670. fmt.Println(len(insutypes))
  25671. if len(insutypes) == 0 {
  25672. for index, item := range rf {
  25673. if index == 0 {
  25674. insutype = item.Insutype
  25675. insuplc_admdvs = item.InsuplcAdmdvs
  25676. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25677. }
  25678. }
  25679. fmt.Println(insutype)
  25680. fmt.Println(insuplc_admdvs)
  25681. }
  25682. if social_type > 0 {
  25683. insutype = strconv.FormatInt(social_type, 10)
  25684. }
  25685. fmt.Println("--------")
  25686. fmt.Println(psn_info)
  25687. fmt.Println(psn_info.PsnNo)
  25688. for _, item := range rf {
  25689. if item.Insutype == insutype {
  25690. insutype = item.Insutype
  25691. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25692. }
  25693. }
  25694. if miConfig.MdtrtareaAdmvs == "441202" {
  25695. var hisPrescription []*models.HisPrescription
  25696. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25697. if res3101.Infcode == 0 {
  25698. fmt.Println("33333333")
  25699. if len(res3101.Output.Result) > 0 {
  25700. fmt.Println("222222")
  25701. for _, item := range res3101.Output.Result {
  25702. if len(res3101.ErrMsg) == 0 {
  25703. res3101.ErrMsg = item.VolaCont
  25704. } else {
  25705. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25706. }
  25707. }
  25708. c.ServeSuccessJSON(map[string]interface{}{
  25709. "failed_code": -10,
  25710. "msg": res3101.ErrMsg,
  25711. })
  25712. return
  25713. } else {
  25714. hour := time.Now().Format("15")
  25715. min := time.Now().Format("04")
  25716. sec := time.Now().Format("05")
  25717. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25718. fmt.Println(record_time_two)
  25719. 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)
  25720. saveLog(result, requestLog, "2201A", "挂号")
  25721. if miConfig.Code == "H15049901371" {
  25722. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25723. utils.ErrorLog("解析失败:%v", err)
  25724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25725. return
  25726. }
  25727. resThree.ErrMsg = resThree10265.ErrMsg
  25728. resThree.Output = resThree10265.Output
  25729. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25730. } else {
  25731. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25732. utils.ErrorLog("解析失败:%v", err)
  25733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25734. return
  25735. }
  25736. }
  25737. if miConfig.Code == "H15049901371" {
  25738. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25739. } else {
  25740. infocode = resThree.Infcode
  25741. }
  25742. }
  25743. } else if res3101.Infcode != 0 {
  25744. c.ServeSuccessJSON(map[string]interface{}{
  25745. "failed_code": -10,
  25746. "msg": res3101.ErrMsg,
  25747. })
  25748. return
  25749. }
  25750. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25751. var hisPrescription []*models.HisPrescription
  25752. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25753. if res3101.Infcode == 0 {
  25754. fmt.Println("33333333")
  25755. if len(res3101.Output.Result) > 0 {
  25756. fmt.Println("222222")
  25757. for _, item := range res3101.Output.Result {
  25758. if len(res3101.ErrMsg) == 0 {
  25759. res3101.ErrMsg = item.VolaCont
  25760. } else {
  25761. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25762. }
  25763. }
  25764. c.ServeSuccessJSON(map[string]interface{}{
  25765. "failed_code": -10,
  25766. "msg": res3101.ErrMsg,
  25767. })
  25768. return
  25769. } else {
  25770. hour := time.Now().Format("15")
  25771. min := time.Now().Format("04")
  25772. sec := time.Now().Format("05")
  25773. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25774. fmt.Println(record_time_two)
  25775. 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)
  25776. saveLog(result, requestLog, "2201A", "挂号")
  25777. if miConfig.Code == "H15049901371" {
  25778. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25779. utils.ErrorLog("解析失败:%v", err)
  25780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25781. return
  25782. }
  25783. resThree.ErrMsg = resThree10265.ErrMsg
  25784. resThree.Output = resThree10265.Output
  25785. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25786. } else {
  25787. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25788. utils.ErrorLog("解析失败:%v", err)
  25789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25790. return
  25791. }
  25792. }
  25793. if miConfig.Code == "H15049901371" {
  25794. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25795. } else {
  25796. infocode = resThree.Infcode
  25797. }
  25798. }
  25799. } else if res3101.Infcode != 0 {
  25800. c.ServeSuccessJSON(map[string]interface{}{
  25801. "failed_code": -10,
  25802. "msg": res3101.ErrMsg,
  25803. })
  25804. return
  25805. }
  25806. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25807. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25808. psn_info, _ := service.GetPsnByPatientId(id)
  25809. var verify_number string
  25810. if id_card_type == 4 {
  25811. verify_number = psn_info.VerifyNumber
  25812. } else if id_card_type == 1 {
  25813. bas := strings.Split(psn_info.CardInfo, "|")
  25814. cardNumber := bas[2]
  25815. verify_number = cardNumber
  25816. } else {
  25817. verify_number = psn_info.Certno
  25818. }
  25819. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25820. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25821. "&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
  25822. resp, requestErr := http.Get(api)
  25823. if requestErr != nil {
  25824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25825. return
  25826. }
  25827. body, ioErr := ioutil.ReadAll(resp.Body)
  25828. if ioErr != nil {
  25829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25831. return
  25832. }
  25833. var respJSON map[string]interface{}
  25834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25837. return
  25838. }
  25839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25840. result, _ := json.Marshal(respJSON)
  25841. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25842. utils.ErrorLog("解析失败:%v", err)
  25843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25844. return
  25845. }
  25846. infocode = resThree.Infcode
  25847. } else {
  25848. hour := time.Now().Format("15")
  25849. min := time.Now().Format("04")
  25850. sec := time.Now().Format("05")
  25851. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25852. if id_card_type == 1 {
  25853. for _, item := range rf {
  25854. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25855. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25856. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25857. } else if strconv.FormatInt(social_type, 10) == "390" {
  25858. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25859. } else {
  25860. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25861. }
  25862. }
  25863. }
  25864. }
  25865. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25866. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25867. }
  25868. if id_card_type == 1 {
  25869. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25870. bas := strings.Split(psn_info.CardInfo, "|")
  25871. basNumber := bas[1]
  25872. IdCardNo = basNumber
  25873. }
  25874. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25875. IdCardNo = psn_info.VerifyNumber
  25876. }
  25877. if len(insuplc_admdvs_temp) == 0 {
  25878. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25879. }
  25880. var result string
  25881. var requestLog string
  25882. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  25883. var hisPrescription []*models.HisPrescription
  25884. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25885. if res3101.Infcode == 0 {
  25886. if len(res3101.Output.Result) > 0 {
  25887. if len(res3101.Output.Result) > 0 {
  25888. c.ServeSuccessJSON(map[string]interface{}{
  25889. "failed_code": -10,
  25890. "failed_type": 100,
  25891. "warm_type": 1,
  25892. "msg": res3101,
  25893. })
  25894. return
  25895. } else {
  25896. c.ServeSuccessJSON(map[string]interface{}{
  25897. "failed_code": -10,
  25898. "msg": res3101.ErrMsg,
  25899. })
  25900. return
  25901. }
  25902. } else {
  25903. hour := time.Now().Format("15")
  25904. min := time.Now().Format("04")
  25905. sec := time.Now().Format("05")
  25906. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25907. fmt.Println(record_time_two)
  25908. if his.IdCardType == 2 {
  25909. IdCardNo = psn_info.Certno
  25910. psn_info.VerifyNumber = psn_info.Certno
  25911. } else if his.IdCardType == 4 {
  25912. IdCardNo = psn_info.Certno
  25913. } else {
  25914. bas := strings.Split(psn_info.CardInfo, "|")
  25915. IdCardNo = bas[2]
  25916. }
  25917. aaaa = insutype
  25918. 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)
  25919. saveLog(result, requestLog, "2201A", "挂号")
  25920. if miConfig.Code == "H15049901371" {
  25921. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25922. utils.ErrorLog("解析失败:%v", err)
  25923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25924. return
  25925. }
  25926. resThree.ErrMsg = resThree10265.ErrMsg
  25927. resThree.Output = resThree10265.Output
  25928. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25929. } else {
  25930. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25931. utils.ErrorLog("解析失败:%v", err)
  25932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25933. return
  25934. }
  25935. }
  25936. if miConfig.Code == "H15049901371" {
  25937. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25938. } else {
  25939. infocode = resThree.Infcode
  25940. }
  25941. }
  25942. } else if res3101.Infcode != 0 {
  25943. c.ServeSuccessJSON(map[string]interface{}{
  25944. "failed_code": -10,
  25945. "msg": res3101.ErrMsg,
  25946. })
  25947. return
  25948. }
  25949. } else {
  25950. psn_info, _ := service.GetPsnByPatientId(id)
  25951. var rf []*ResultFive
  25952. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25953. //var insutypes []*ResultFive
  25954. var insutype string
  25955. var insutypes []*ResultFive
  25956. var is390 int = 0
  25957. var is310 int = 0
  25958. for _, item := range rf {
  25959. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25960. insutypes = append(insutypes, item)
  25961. }
  25962. }
  25963. if len(insutypes) == 1 {
  25964. insutype = insutypes[0].Insutype
  25965. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25966. } else {
  25967. for _, i := range insutypes {
  25968. if i.Insutype == "390" {
  25969. is390 = 1
  25970. }
  25971. if i.Insutype == "310" {
  25972. is310 = 1
  25973. }
  25974. }
  25975. }
  25976. if is390 == 1 {
  25977. insutype = "390"
  25978. }
  25979. if is310 == 1 {
  25980. insutype = "310"
  25981. }
  25982. if len(insutypes) == 0 {
  25983. insutype = "310"
  25984. }
  25985. if social_type > 0 {
  25986. insutype = strconv.FormatInt(social_type, 10)
  25987. }
  25988. for _, item := range rf {
  25989. if item.Insutype == insutype {
  25990. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25991. }
  25992. }
  25993. if len(insuplc_admdvs_tt) > 0 {
  25994. insuplc_admdvs_temp = insuplc_admdvs_tt
  25995. }
  25996. 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)
  25997. saveLog(result, requestLog, "2201A", "挂号")
  25998. }
  25999. if miConfig.Code == "H15049901371" {
  26000. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26001. utils.ErrorLog("解析失败:%v", err)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. resThree.ErrMsg = resThree10265.ErrMsg
  26006. resThree.Output = resThree10265.Output
  26007. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26008. } else {
  26009. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26010. utils.ErrorLog("解析失败:%v", err)
  26011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26012. return
  26013. }
  26014. }
  26015. if miConfig.Code == "H15049901371" {
  26016. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26017. } else {
  26018. infocode = resThree.Infcode
  26019. }
  26020. }
  26021. }
  26022. if infocode == -1 {
  26023. adminUser := c.GetAdminUserInfo()
  26024. errlog := &models.HisOrderError{
  26025. UserOrgId: adminUser.CurrentOrgId,
  26026. Ctime: time.Now().Unix(),
  26027. Mtime: time.Now().Unix(),
  26028. ErrMsg: resThree.ErrMsg,
  26029. Status: 1,
  26030. PatientId: id,
  26031. RecordTime: recordDateTime,
  26032. Stage: 2,
  26033. }
  26034. service.CreateErrMsgLog(errlog)
  26035. c.ServeSuccessJSON(map[string]interface{}{
  26036. "failed_code": -10,
  26037. "msg": resThree.ErrMsg,
  26038. })
  26039. return
  26040. }
  26041. utils.ErrorLog("解析失败:%v", insutype)
  26042. his.Number = resThree.Output.Data.MdtrtID
  26043. his.PsnNo = resThree.Output.Data.PsnNo
  26044. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26045. his.IdCardNo = patient.IdCardNo
  26046. his.PhoneNumber = patient.Phone
  26047. his.UserOrgId = adminInfo.CurrentOrgId
  26048. his.Insutype = insutype
  26049. if miConfig.Code == "H44030500255" {
  26050. his.Insutype = aaaa
  26051. }
  26052. his.Ctime = time.Now().Unix()
  26053. his.Mtime = time.Now().Unix()
  26054. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26055. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26056. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26057. }
  26058. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26059. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26060. }
  26061. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26062. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26063. }
  26064. his.Status = 1
  26065. his.MdtrtGrpType = mdtrt_type
  26066. service.UpdateHisPatientStatus(&his)
  26067. service.UpdateHisPatient123(&patient)
  26068. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26069. c.ServeSuccessJSON(map[string]interface{}{
  26070. "his_info": his,
  26071. })
  26072. } else {
  26073. adminUser := c.GetAdminUserInfo()
  26074. errlog := &models.HisOrderError{
  26075. UserOrgId: adminUser.CurrentOrgId,
  26076. Ctime: time.Now().Unix(),
  26077. Mtime: time.Now().Unix(),
  26078. ErrMsg: res.ErrMsg,
  26079. Status: 1,
  26080. PatientId: id,
  26081. RecordTime: recordDateTime,
  26082. Stage: 1,
  26083. }
  26084. service.CreateErrMsgLog(errlog)
  26085. c.ServeSuccessJSON(map[string]interface{}{
  26086. "failed_code": -10,
  26087. "msg": res.ErrMsg,
  26088. })
  26089. return
  26090. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26091. }
  26092. }
  26093. }
  26094. func (c *HisApiController) GetUploadInfo() {
  26095. id, _ := c.GetInt64("id")
  26096. record_time := c.GetString("record_time")
  26097. his_patient_id, _ := c.GetInt64("his_patient_id")
  26098. order_id, _ := c.GetInt64("order_id")
  26099. pay_way, _ := c.GetInt64("pay_way")
  26100. pay_ways := c.GetString("pay_ways")
  26101. oth_desc := c.GetString("oth_desc")
  26102. pay_price, _ := c.GetFloat("pay_price")
  26103. pay_card_no := c.GetString("pay_card_no")
  26104. discount_price, _ := c.GetFloat("discount_price")
  26105. preferential_price, _ := c.GetFloat("preferential_price")
  26106. reality_price, _ := c.GetFloat("reality_price")
  26107. found_price, _ := c.GetFloat("found_price")
  26108. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26109. private_price, _ := c.GetFloat("private_price")
  26110. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26111. admin_user_id, _ := c.GetInt64("admin_user_id")
  26112. fapiao_code := c.GetString("fapiao_code")
  26113. fapiao_number := c.GetString("fapiao_number")
  26114. diagnosis_id := c.GetString("diagnosis")
  26115. sick_type, _ := c.GetInt64("sick_type")
  26116. reg_type, _ := c.GetInt64("p_type")
  26117. begin_time := c.GetString("begin_time")
  26118. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26119. cash_pay := c.GetString("cash_pay")
  26120. band_card_pay := c.GetString("band_card_pay")
  26121. wechat_pay := c.GetString("wechat_pay")
  26122. ali_pay := c.GetString("ali_pay")
  26123. jifen_pay := c.GetString("jifen_pay")
  26124. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26125. fmt.Println(acct_used_flag)
  26126. id_str := c.GetString("ids")
  26127. ids_arr := strings.Split(id_str, ",")
  26128. timeLayout := "2006-01-02"
  26129. loc, _ := time.LoadLocation("Local")
  26130. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26131. if err != nil {
  26132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26133. return
  26134. }
  26135. recordDateTime := theTime.Unix()
  26136. adminUser := c.GetAdminUserInfo()
  26137. var tempOrder models.HisOrder
  26138. tempOrder, _ = service.GetHisOrderByID(order_id)
  26139. var prescriptions []*models.HisPrescription
  26140. var start_time int64
  26141. var end_time int64
  26142. //押金模块
  26143. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26144. tmp_decimal := c.GetString("tmp_decimal")
  26145. var decimal float64 //本次使用的押金
  26146. var errmsg error
  26147. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26148. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26149. return
  26150. }
  26151. if len(tmp_decimal) > 0 {
  26152. if tmp_decimal[0] == 45 {
  26153. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26154. return
  26155. }
  26156. }
  26157. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26158. fmt.Println(errs)
  26159. decimal = tt
  26160. //if adminUser.CurrentOrgId == 10106{
  26161. // if len(fapiao_code) == 0{
  26162. // fapiao_code = "144072080589"
  26163. // }
  26164. // if len(fapiao_number) == 0{
  26165. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26166. // if order.ID == 0{
  26167. // fapiao_number = "00001520"
  26168. // }else{
  26169. // //fapiao_code = "00001520"
  26170. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26171. // var zero string
  26172. // if fpNumber >= 1000{
  26173. // zero = "0000" + strconv.Itoa(fpNumber)
  26174. // }else if fpNumber >= 10000{
  26175. // zero = "000" + strconv.Itoa(fpNumber)
  26176. // } else if fpNumber >= 100000{
  26177. // zero = "00" + strconv.Itoa(fpNumber)
  26178. // } else if fpNumber >= 1000000{
  26179. // zero = "0" + strconv.Itoa(fpNumber)
  26180. // }else {
  26181. // zero = strconv.Itoa(fpNumber)
  26182. // }
  26183. // fapiao_number = zero
  26184. // }
  26185. // }
  26186. //}
  26187. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26188. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26189. var patientPrescription models.HisPrescriptionInfo
  26190. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26191. if patientPrescription.ID == 0 {
  26192. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26193. }
  26194. //if patientPrescription.Do
  26195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26196. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26197. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26198. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26199. var config []*models.HisXtDiagnoseConfig
  26200. for _, item := range diagnosis_ids {
  26201. id, _ := strconv.ParseInt(item, 10, 64)
  26202. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26203. config = append(config, &diagnosisConfig)
  26204. }
  26205. sickConfig, _ := service.FindSickById(sick_type)
  26206. //if tempOrder.ID == 0 {
  26207. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26208. //}
  26209. if tempOrder.ID == 0 {
  26210. var result string
  26211. var requestLog string
  26212. var res2 ResultSix
  26213. var res3 GZResultSix
  26214. var ressix10265 ResultSix10265
  26215. if miConfig.MdtrtareaAdmvs == "421300" {
  26216. data := make(map[string]interface{})
  26217. client := &http.Client{}
  26218. data["psn_no"] = his.PsnNo
  26219. data["mdtrt_id"] = his.Number
  26220. data["opter"] = roles.UserName
  26221. data["org_name"] = miConfig.OrgName
  26222. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26223. data["doctor_id"] = doctor_info.DoctorNumber
  26224. data["doctor_name"] = doctor_info.UserName
  26225. data["department"] = department.Name
  26226. data["fixmedins_code"] = miConfig.Code
  26227. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26228. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26229. data["secret_key"] = miConfig.SecretKey
  26230. data["sick_code"] = sickConfig.CountryCode
  26231. data["sick_name"] = sickConfig.ClassName
  26232. data["dept"] = strconv.FormatInt(department.ID, 10)
  26233. data["config"] = config
  26234. data["begin_time"] = begin_time
  26235. bytesData, _ := json.Marshal(data)
  26236. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26237. resp, _ := client.Do(req)
  26238. defer resp.Body.Close()
  26239. body, ioErr := ioutil.ReadAll(resp.Body)
  26240. if ioErr != nil {
  26241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26243. return
  26244. }
  26245. var respJSON map[string]interface{}
  26246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26249. return
  26250. }
  26251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26252. userJSONBytes, _ := json.Marshal(respJSON)
  26253. fmt.Println("log")
  26254. fmt.Println(string(userJSONBytes))
  26255. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26256. utils.ErrorLog("解析失败:%v", err)
  26257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26258. return
  26259. }
  26260. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26261. data := make(map[string]interface{})
  26262. client := &http.Client{}
  26263. data["psn_no"] = his.PsnNo
  26264. data["mdtrt_id"] = his.Number
  26265. data["opter"] = roles.UserName
  26266. data["org_name"] = miConfig.OrgName
  26267. if reg_type == 11 && his.Insutype == "390" {
  26268. data["med_type"] = "110104"
  26269. } else {
  26270. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26271. }
  26272. data["doctor_id"] = doctor_info.DoctorNumber
  26273. data["doctor_name"] = doctor_info.UserName
  26274. data["department"] = department.Name
  26275. data["fixmedins_code"] = miConfig.Code
  26276. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26277. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26278. data["secret_key"] = miConfig.SecretKey
  26279. data["sick_code"] = sickConfig.CountryCode
  26280. data["sick_name"] = sickConfig.ClassName
  26281. data["dept"] = strconv.FormatInt(department.ID, 10)
  26282. data["config"] = config
  26283. data["begin_time"] = begin_time
  26284. bytesData, _ := json.Marshal(data)
  26285. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26286. resp, _ := client.Do(req)
  26287. defer resp.Body.Close()
  26288. body, ioErr := ioutil.ReadAll(resp.Body)
  26289. if ioErr != nil {
  26290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26292. return
  26293. }
  26294. var respJSON map[string]interface{}
  26295. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26298. return
  26299. }
  26300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26301. userJSONBytes, _ := json.Marshal(respJSON)
  26302. fmt.Println("log")
  26303. fmt.Println(string(userJSONBytes))
  26304. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26305. utils.ErrorLog("解析失败:%v", err)
  26306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26307. return
  26308. }
  26309. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26310. data := make(map[string]interface{})
  26311. client := &http.Client{}
  26312. data["psn_no"] = his.PsnNo
  26313. data["mdtrt_id"] = his.Number
  26314. data["opter"] = roles.UserName
  26315. data["org_name"] = miConfig.OrgName
  26316. if reg_type == 11 && his.Insutype == "390" {
  26317. data["med_type"] = "110104"
  26318. } else {
  26319. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26320. }
  26321. data["doctor_id"] = doctor_info.DoctorNumber
  26322. data["doctor_name"] = doctor_info.UserName
  26323. data["department"] = department.Name
  26324. data["fixmedins_code"] = miConfig.Code
  26325. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26326. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26327. data["secret_key"] = miConfig.SecretKey
  26328. data["sick_code"] = sickConfig.CountryCode
  26329. data["sick_name"] = sickConfig.ClassName
  26330. data["dept"] = strconv.FormatInt(department.ID, 10)
  26331. data["config"] = config
  26332. data["begin_time"] = begin_time
  26333. bytesData, _ := json.Marshal(data)
  26334. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26335. resp, _ := client.Do(req)
  26336. defer resp.Body.Close()
  26337. body, ioErr := ioutil.ReadAll(resp.Body)
  26338. if ioErr != nil {
  26339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26341. return
  26342. }
  26343. var respJSON map[string]interface{}
  26344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26347. return
  26348. }
  26349. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26350. userJSONBytes, _ := json.Marshal(respJSON)
  26351. fmt.Println("log")
  26352. fmt.Println(string(userJSONBytes))
  26353. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26354. utils.ErrorLog("解析失败:%v", err)
  26355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26356. return
  26357. }
  26358. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26359. data := make(map[string]interface{})
  26360. client := &http.Client{}
  26361. data["psn_no"] = his.PsnNo
  26362. data["mdtrt_id"] = his.Number
  26363. data["opter"] = roles.UserName
  26364. data["org_name"] = miConfig.OrgName
  26365. if reg_type == 11 && his.Insutype == "390" {
  26366. data["med_type"] = "110104"
  26367. } else {
  26368. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26369. }
  26370. data["doctor_id"] = doctor_info.DoctorNumber
  26371. data["doctor_name"] = doctor_info.UserName
  26372. data["department"] = department.Name
  26373. data["fixmedins_code"] = miConfig.Code
  26374. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26376. data["secret_key"] = miConfig.SecretKey
  26377. data["sick_code"] = sickConfig.CountryCode
  26378. data["sick_name"] = sickConfig.ClassName
  26379. data["dept"] = strconv.FormatInt(department.ID, 10)
  26380. data["config"] = config
  26381. data["begin_time"] = begin_time
  26382. bytesData, _ := json.Marshal(data)
  26383. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26384. resp, _ := client.Do(req)
  26385. defer resp.Body.Close()
  26386. body, ioErr := ioutil.ReadAll(resp.Body)
  26387. if ioErr != nil {
  26388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26390. return
  26391. }
  26392. var respJSON map[string]interface{}
  26393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26396. return
  26397. }
  26398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26399. userJSONBytes, _ := json.Marshal(respJSON)
  26400. fmt.Println("log")
  26401. fmt.Println(string(userJSONBytes))
  26402. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26403. utils.ErrorLog("解析失败:%v", err)
  26404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26405. return
  26406. }
  26407. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26408. utils.ErrorLog("解析失败:%v", doctor_info)
  26409. data := make(map[string]interface{})
  26410. client := &http.Client{}
  26411. data["psn_no"] = his.PsnNo
  26412. data["mdtrt_id"] = his.Number
  26413. data["doctor"] = roles.UserName
  26414. data["department"] = department.Name
  26415. data["org_name"] = miConfig.OrgName
  26416. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26417. data["doctor_id"] = doctor_info.DoctorNumber
  26418. data["new_doctor_name"] = doctor_info.UserName
  26419. data["fixmedins_code"] = miConfig.Code
  26420. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26421. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26422. data["secret_key"] = miConfig.SecretKey
  26423. data["sick_code"] = sickConfig.CountryCode
  26424. data["sick_name"] = sickConfig.ClassName
  26425. data["url"] = miConfig.Url
  26426. data["ak"] = miConfig.AccessKey
  26427. data["begin_time"] = begin_time
  26428. data["cainfo"] = miConfig.Cainfo
  26429. data["dept"] = strconv.FormatInt(department.ID, 10)
  26430. data["config"] = config
  26431. bytesData, _ := json.Marshal(data)
  26432. var req *http.Request
  26433. if miConfig.MdtrtareaAdmvs == "320830" {
  26434. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26435. //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 +
  26436. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26437. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26438. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26439. //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 +
  26440. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26441. } else {
  26442. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26443. }
  26444. resp, _ := client.Do(req)
  26445. defer resp.Body.Close()
  26446. body, ioErr := ioutil.ReadAll(resp.Body)
  26447. if ioErr != nil {
  26448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26450. return
  26451. }
  26452. var respJSON map[string]interface{}
  26453. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26456. return
  26457. }
  26458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26459. userJSONBytes, _ := json.Marshal(respJSON)
  26460. fmt.Println("log")
  26461. fmt.Println(string(userJSONBytes))
  26462. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26463. utils.ErrorLog("解析失败:%v", err)
  26464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26465. return
  26466. }
  26467. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26468. res2.Output = ressix10265.Output
  26469. res2.ErrMsg = ressix10265.ErrMsg
  26470. res2.Cainfo = ressix10265.Cainfo
  26471. res2.WarnMsg = ressix10265.WarnMsg
  26472. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26473. res2.Infcode = infocode
  26474. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26475. data := make(map[string]interface{})
  26476. client := &http.Client{}
  26477. data["psn_no"] = his.PsnNo
  26478. data["mdtrt_id"] = his.Number
  26479. data["doctor"] = roles.UserName
  26480. data["department"] = department.Name
  26481. data["org_name"] = miConfig.OrgName
  26482. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26483. data["doctor_id"] = doctor_info.DoctorNumber
  26484. data["new_doctor_name"] = doctor_info.UserName
  26485. data["fixmedins_code"] = miConfig.Code
  26486. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26487. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26488. data["secret_key"] = miConfig.SecretKey
  26489. data["sick_code"] = sickConfig.CountryCode
  26490. data["sick_name"] = sickConfig.ClassName
  26491. data["url"] = miConfig.Url
  26492. data["ak"] = miConfig.AccessKey
  26493. data["begin_time"] = begin_time
  26494. data["cainfo"] = miConfig.Cainfo
  26495. data["dept"] = strconv.FormatInt(department.ID, 10)
  26496. data["config"] = config
  26497. bytesData, _ := json.Marshal(data)
  26498. var req *http.Request
  26499. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26500. resp, _ := client.Do(req)
  26501. defer resp.Body.Close()
  26502. body, ioErr := ioutil.ReadAll(resp.Body)
  26503. if ioErr != nil {
  26504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26506. return
  26507. }
  26508. var respJSON map[string]interface{}
  26509. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26512. return
  26513. }
  26514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26515. userJSONBytes, _ := json.Marshal(respJSON)
  26516. fmt.Println("log")
  26517. fmt.Println(string(userJSONBytes))
  26518. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26519. utils.ErrorLog("解析失败:%v", err)
  26520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26521. return
  26522. }
  26523. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26524. res2.Output = ressix10265.Output
  26525. res2.ErrMsg = ressix10265.ErrMsg
  26526. res2.Cainfo = ressix10265.Cainfo
  26527. res2.WarnMsg = ressix10265.WarnMsg
  26528. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26529. res2.Infcode = infocode
  26530. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26531. 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)
  26532. saveLog(result, requestLog, "2203", "上传就诊信息")
  26533. var respJSON2 map[string]interface{}
  26534. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26537. return
  26538. }
  26539. userJSONBytes2, _ := json.Marshal(respJSON2)
  26540. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26541. utils.ErrorLog("解析失败:%v", err)
  26542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26543. return
  26544. }
  26545. 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)
  26546. fmt.Println(result2)
  26547. fmt.Println(src_request)
  26548. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26549. data := make(map[string]interface{})
  26550. client := &http.Client{}
  26551. data["psn_no"] = his.PsnNo
  26552. data["mdtrt_id"] = his.Number
  26553. data["doctor"] = roles.UserName
  26554. data["department"] = department.Name
  26555. data["org_name"] = miConfig.OrgName
  26556. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26557. data["doctor_id"] = doctor_info.DoctorNumber
  26558. data["new_doctor_name"] = doctor_info.UserName
  26559. data["fixmedins_code"] = miConfig.Code
  26560. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26561. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26562. data["secret_key"] = miConfig.SecretKey
  26563. data["sick_code"] = sickConfig.CountryCode
  26564. data["sick_name"] = sickConfig.ClassName
  26565. data["url"] = miConfig.Url
  26566. data["ak"] = miConfig.AccessKey
  26567. data["begin_time"] = begin_time
  26568. data["cainfo"] = miConfig.Cainfo
  26569. data["dept"] = strconv.FormatInt(department.ID, 10)
  26570. data["config"] = config
  26571. bytesData, _ := json.Marshal(data)
  26572. var req *http.Request
  26573. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26574. resp, _ := client.Do(req)
  26575. defer resp.Body.Close()
  26576. body, ioErr := ioutil.ReadAll(resp.Body)
  26577. if ioErr != nil {
  26578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26580. return
  26581. }
  26582. var respJSON map[string]interface{}
  26583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26586. return
  26587. }
  26588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26589. userJSONBytes, _ := json.Marshal(respJSON)
  26590. fmt.Println("log")
  26591. fmt.Println(string(userJSONBytes))
  26592. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26593. utils.ErrorLog("解析失败:%v", err)
  26594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26595. return
  26596. }
  26597. } else {
  26598. if miConfig.MdtrtareaAdmvs == "440781" { //
  26599. 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)
  26600. } else {
  26601. if miConfig.Code == "H15049901371" {
  26602. //赤峰地区国家医保医疗类别
  26603. //职工透析:医疗类别选特殊情况门诊990502
  26604. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26605. var med_type string
  26606. if his.Insutype == "390" {
  26607. if reg_type == 14 {
  26608. med_type = "9933"
  26609. } else if reg_type == 11 {
  26610. med_type = "11"
  26611. }
  26612. } else if his.Insutype == "310" {
  26613. if reg_type == 14 {
  26614. med_type = "990502"
  26615. } else if reg_type == 11 {
  26616. med_type = "11"
  26617. }
  26618. }
  26619. 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)
  26620. } else {
  26621. 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)
  26622. }
  26623. }
  26624. saveLog(result, requestLog, "2203", "上传就诊信息")
  26625. var respJSON2 map[string]interface{}
  26626. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26629. return
  26630. }
  26631. userJSONBytes2, _ := json.Marshal(respJSON2)
  26632. if miConfig.Code == "H15049901371" {
  26633. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26634. utils.ErrorLog("解析失败:%v", err)
  26635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26636. return
  26637. }
  26638. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26639. res2.Output = ressix10265.Output
  26640. res2.ErrMsg = ressix10265.ErrMsg
  26641. res2.Cainfo = ressix10265.Cainfo
  26642. res2.WarnMsg = ressix10265.WarnMsg
  26643. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26644. res2.Infcode = infocode
  26645. } else {
  26646. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26647. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26648. utils.ErrorLog("解析失败:%v", err)
  26649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26650. return
  26651. }
  26652. res2.Infcode = res3.Infcode
  26653. } else {
  26654. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26655. utils.ErrorLog("解析失败:%v", err)
  26656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26657. return
  26658. }
  26659. }
  26660. }
  26661. }
  26662. if res2.Infcode == -1 {
  26663. adminUser := c.GetAdminUserInfo()
  26664. errlog := &models.HisOrderError{
  26665. UserOrgId: adminUser.CurrentOrgId,
  26666. Ctime: time.Now().Unix(),
  26667. Mtime: time.Now().Unix(),
  26668. ErrMsg: res2.ErrMsg,
  26669. Status: 1,
  26670. PatientId: id,
  26671. RecordTime: recordDateTime,
  26672. Stage: 3,
  26673. }
  26674. service.CreateErrMsgLog(errlog)
  26675. c.ServeSuccessJSON(map[string]interface{}{
  26676. "failed_code": -10,
  26677. "msg": res2.ErrMsg,
  26678. })
  26679. return
  26680. } else {
  26681. his.Diagnosis = diagnosis_id
  26682. his.SickType = sickConfig.ID
  26683. //var p_type int64
  26684. //if reg_type == 1111 || reg_type == 1112 {
  26685. // p_type = 11
  26686. //
  26687. //}
  26688. his.PType = fmt.Sprintf("%d", reg_type)
  26689. service.UpdateHisPatientThree(&his)
  26690. data := make(map[string]interface{})
  26691. if settle_accounts_type == 1 { //日结
  26692. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26693. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26694. } else {
  26695. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26696. }
  26697. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26698. data["pre"] = prescriptions
  26699. } else { //月结
  26700. start_time_str := c.GetString("start_time")
  26701. end_time_str := c.GetString("end_time")
  26702. timeLayout := "2006-01-02"
  26703. loc, _ := time.LoadLocation("Local")
  26704. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26705. if err != nil {
  26706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26707. return
  26708. }
  26709. recordStartTime := theStartTime.Unix()
  26710. start_time = recordStartTime
  26711. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26712. if err != nil {
  26713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26714. return
  26715. }
  26716. recordEndTime := theEndTime.Unix()
  26717. end_time = recordEndTime
  26718. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26719. data["pre"] = prescriptions
  26720. }
  26721. timestamp := time.Now().Unix()
  26722. tempTime := time.Unix(timestamp, 0)
  26723. timeFormat := tempTime.Format("20060102150405")
  26724. chrgBchno := rand.Intn(100000) + 10000
  26725. new_chrg_bchno := ""
  26726. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26727. new_chrg_bchno = chrg_bchno
  26728. strconv.FormatInt(his.PatientId, 10)
  26729. client := &http.Client{}
  26730. if adminUser.CurrentOrgId == 10265 {
  26731. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26732. new_chrg_bchno = "0000"
  26733. }
  26734. }
  26735. data["psn_no"] = his.PsnNo
  26736. data["mdtrt_id"] = his.Number
  26737. data["chrg_bchno"] = new_chrg_bchno
  26738. data["org_name"] = miConfig.OrgName
  26739. data["doctor"] = doctor_info.UserName
  26740. data["doctor_id"] = doctor_info.DoctorNumber
  26741. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26742. data["fixmedins_code"] = miConfig.Code
  26743. data["dept_code"] = department.Number
  26744. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26745. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26746. data["secret_key"] = miConfig.SecretKey
  26747. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26748. data["url"] = miConfig.Url
  26749. data["ak"] = miConfig.AccessKey
  26750. data["new_doctor_name"] = patientPrescription.Doctor
  26751. data["diag_code"] = sickConfig.CountryCode
  26752. data["cainfo"] = miConfig.Cainfo
  26753. data["opter"] = roles.UserName
  26754. var ids []int64
  26755. for _, item := range prescriptions {
  26756. ids = append(ids, item.ID)
  26757. }
  26758. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26759. if config.IsOpen == 1 { //对接了医保,走医保流程
  26760. var res ResultFour
  26761. var resFour10265 ResultFour10265
  26762. if miConfig.MdtrtareaAdmvs == "421300" {
  26763. bytesData, _ := json.Marshal(data)
  26764. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26765. resp, _ := client.Do(req)
  26766. defer resp.Body.Close()
  26767. body, ioErr := ioutil.ReadAll(resp.Body)
  26768. if ioErr != nil {
  26769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26771. return
  26772. }
  26773. var respJSON map[string]interface{}
  26774. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26777. return
  26778. }
  26779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26780. userJSONBytes, _ := json.Marshal(respJSON)
  26781. fmt.Println("log")
  26782. fmt.Println(string(userJSONBytes))
  26783. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26784. utils.ErrorLog("解析失败:%v", err)
  26785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26786. return
  26787. }
  26788. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26789. bytesData, _ := json.Marshal(data)
  26790. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26791. resp, _ := client.Do(req)
  26792. defer resp.Body.Close()
  26793. body, ioErr := ioutil.ReadAll(resp.Body)
  26794. if ioErr != nil {
  26795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26797. return
  26798. }
  26799. var respJSON map[string]interface{}
  26800. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26803. return
  26804. }
  26805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26806. userJSONBytes, _ := json.Marshal(respJSON)
  26807. fmt.Println("log")
  26808. fmt.Println(string(userJSONBytes))
  26809. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26810. utils.ErrorLog("解析失败:%v", err)
  26811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26812. return
  26813. }
  26814. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26815. bytesData, _ := json.Marshal(data)
  26816. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26817. resp, _ := client.Do(req)
  26818. defer resp.Body.Close()
  26819. body, ioErr := ioutil.ReadAll(resp.Body)
  26820. if ioErr != nil {
  26821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26823. return
  26824. }
  26825. var respJSON map[string]interface{}
  26826. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26829. return
  26830. }
  26831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26832. userJSONBytes, _ := json.Marshal(respJSON)
  26833. fmt.Println("log")
  26834. fmt.Println(string(userJSONBytes))
  26835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26836. utils.ErrorLog("解析失败:%v", err)
  26837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26838. return
  26839. }
  26840. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26841. bytesData, _ := json.Marshal(data)
  26842. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26843. resp, _ := client.Do(req)
  26844. defer resp.Body.Close()
  26845. body, ioErr := ioutil.ReadAll(resp.Body)
  26846. if ioErr != nil {
  26847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26849. return
  26850. }
  26851. var respJSON map[string]interface{}
  26852. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26855. return
  26856. }
  26857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26858. userJSONBytes, _ := json.Marshal(respJSON)
  26859. fmt.Println("log")
  26860. fmt.Println(string(userJSONBytes))
  26861. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26862. utils.ErrorLog("解析失败:%v", err)
  26863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26864. return
  26865. }
  26866. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26867. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26868. var result3101 Result3101
  26869. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26870. result3101.Infcode = "0"
  26871. if result3101.Infcode == "0" {
  26872. if len(result3101.Output.Result) > 0 {
  26873. var errMsgs []string
  26874. for _, item := range result3101.Output.Result {
  26875. errMsgs = append(errMsgs, item.VolaCont)
  26876. }
  26877. c.ServeSuccessJSON(map[string]interface{}{
  26878. "failed_code": -10,
  26879. "msg": errMsgs,
  26880. })
  26881. return
  26882. }
  26883. }
  26884. bytesData, _ := json.Marshal(data)
  26885. var req *http.Request
  26886. if miConfig.MdtrtareaAdmvs == "320830" {
  26887. data["diag_code"] = sickConfig.CountryCode
  26888. fmt.Println(data)
  26889. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  26890. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26891. data["diag_code"] = sickConfig.CountryCode
  26892. fmt.Println(data)
  26893. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26894. } else {
  26895. data["diag_code"] = sickConfig.CountryCode
  26896. fmt.Println(data)
  26897. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26898. }
  26899. resp, _ := client.Do(req)
  26900. defer resp.Body.Close()
  26901. body, ioErr := ioutil.ReadAll(resp.Body)
  26902. if ioErr != nil {
  26903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26905. return
  26906. }
  26907. var respJSON map[string]interface{}
  26908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26911. return
  26912. }
  26913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26914. userJSONBytes, _ := json.Marshal(respJSON)
  26915. fmt.Println("log")
  26916. fmt.Println(string(userJSONBytes))
  26917. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26918. utils.ErrorLog("解析失败:%v", err)
  26919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26920. return
  26921. }
  26922. res.InfRefmsgid = resFour10265.InfRefmsgid
  26923. res.Output = resFour10265.Output
  26924. res.ErrMsg = resFour10265.ErrMsg
  26925. res.Cainfo = resFour10265.Cainfo
  26926. res.WarnMsg = resFour10265.WarnMsg
  26927. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26928. res.Infcode = infocode
  26929. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26930. var pagesize int = 2
  26931. var start int = 1
  26932. var stop int
  26933. var pagecount int
  26934. var curpage int
  26935. var isSuccess bool = true
  26936. data["doctor_id"] = doctor_info.DoctorNumber
  26937. //总页数,向上取整,注意除之前要先转换类型为float64
  26938. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26939. for curpage = 1; curpage <= pagecount; curpage++ {
  26940. if curpage == 1 {
  26941. start = 1
  26942. } else {
  26943. start = (curpage-1)*pagesize + 1
  26944. }
  26945. stop = curpage * pagesize
  26946. if stop > len(prescriptions) {
  26947. stop = len(prescriptions)
  26948. }
  26949. //var requestLog string
  26950. data["pre"] = prescriptions[start-1 : stop]
  26951. fmt.Println(data["pre"])
  26952. bytesData, _ := json.Marshal(data)
  26953. var req *http.Request
  26954. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26955. resp, _ := client.Do(req)
  26956. defer resp.Body.Close()
  26957. body, ioErr := ioutil.ReadAll(resp.Body)
  26958. if ioErr != nil {
  26959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26961. return
  26962. }
  26963. var respJSON map[string]interface{}
  26964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26967. return
  26968. }
  26969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26970. userJSONBytes, _ := json.Marshal(respJSON)
  26971. fmt.Println("log")
  26972. fmt.Println(string(userJSONBytes))
  26973. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26974. utils.ErrorLog("解析失败:%v", err)
  26975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26976. return
  26977. }
  26978. res.InfRefmsgid = resFour10265.InfRefmsgid
  26979. res.Output = resFour10265.Output
  26980. res.ErrMsg = resFour10265.ErrMsg
  26981. res.Cainfo = resFour10265.Cainfo
  26982. res.WarnMsg = resFour10265.WarnMsg
  26983. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26984. res.Infcode = infocode
  26985. if infocode == 0 {
  26986. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  26987. } else {
  26988. isSuccess = false
  26989. errlog := &models.HisOrderError{
  26990. UserOrgId: adminUser.CurrentOrgId,
  26991. Ctime: time.Now().Unix(),
  26992. Mtime: time.Now().Unix(),
  26993. Number: chrg_bchno,
  26994. ErrMsg: "",
  26995. Status: 1,
  26996. PatientId: id,
  26997. RecordTime: recordDateTime,
  26998. Stage: 4,
  26999. }
  27000. service.CreateErrMsgLog(errlog)
  27001. c.ServeSuccessJSON(map[string]interface{}{
  27002. "failed_code": -10,
  27003. "msg": res.ErrMsg,
  27004. })
  27005. return
  27006. }
  27007. }
  27008. if isSuccess {
  27009. res.Infcode = 0
  27010. }
  27011. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27012. 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)
  27013. var dat map[string]interface{}
  27014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27015. fmt.Println(dat)
  27016. } else {
  27017. fmt.Println(err)
  27018. }
  27019. saveLog(result, request_log, "2204", "上传费用明细")
  27020. userJSONBytes, _ := json.Marshal(dat)
  27021. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27022. utils.ErrorLog("解析失败:%v", err)
  27023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27024. return
  27025. }
  27026. res.InfRefmsgid = resFour10265.InfRefmsgid
  27027. res.Output = resFour10265.Output
  27028. res.ErrMsg = resFour10265.ErrMsg
  27029. res.Cainfo = resFour10265.Cainfo
  27030. res.WarnMsg = resFour10265.WarnMsg
  27031. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27032. res.Infcode = infocode
  27033. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27034. bytesData, _ := json.Marshal(data)
  27035. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27036. resp, _ := client.Do(req)
  27037. defer resp.Body.Close()
  27038. body, ioErr := ioutil.ReadAll(resp.Body)
  27039. if ioErr != nil {
  27040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27042. return
  27043. }
  27044. var respJSON map[string]interface{}
  27045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27048. return
  27049. }
  27050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27051. userJSONBytes, _ := json.Marshal(respJSON)
  27052. fmt.Println("log")
  27053. fmt.Println(string(userJSONBytes))
  27054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27055. utils.ErrorLog("解析失败:%v", err)
  27056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27057. return
  27058. }
  27059. } else {
  27060. if miConfig.Code == "H15049901371" {
  27061. 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)
  27062. var dat map[string]interface{}
  27063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27064. fmt.Println(dat)
  27065. } else {
  27066. fmt.Println(err)
  27067. }
  27068. saveLog(result, request_log, "2204", "上传费用明细")
  27069. userJSONBytes, _ := json.Marshal(dat)
  27070. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27071. utils.ErrorLog("解析失败:%v", err)
  27072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27073. return
  27074. }
  27075. res.InfRefmsgid = resFour10265.InfRefmsgid
  27076. res.Output = resFour10265.Output
  27077. res.ErrMsg = resFour10265.ErrMsg
  27078. res.Cainfo = resFour10265.Cainfo
  27079. res.WarnMsg = resFour10265.WarnMsg
  27080. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27081. res.Infcode = infocode
  27082. } else {
  27083. 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)
  27084. var dat map[string]interface{}
  27085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27086. fmt.Println(dat)
  27087. } else {
  27088. fmt.Println(err)
  27089. }
  27090. saveLog(result, request_log, "2204", "上传费用明细")
  27091. userJSONBytes, _ := json.Marshal(dat)
  27092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27093. utils.ErrorLog("解析失败:%v", err)
  27094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27095. return
  27096. }
  27097. }
  27098. }
  27099. if res.Infcode == 0 {
  27100. order := &models.HisOrder{
  27101. UserOrgId: adminUser.CurrentOrgId,
  27102. HisPatientId: his.ID,
  27103. PatientId: his.PatientId,
  27104. SettleAccountsDate: recordDateTime,
  27105. MdtrtId: his.Number,
  27106. PsnNo: his.PsnNo,
  27107. MedType: strconv.FormatInt(reg_type, 10),
  27108. Ctime: time.Now().Unix(),
  27109. Mtime: time.Now().Unix(),
  27110. Status: 1,
  27111. Number: chrg_bchno,
  27112. Infcode: res.Infcode,
  27113. WarnMsg: res.WarnMsg,
  27114. Cainfo: res.Cainfo,
  27115. ErrMsg: res.ErrMsg,
  27116. RespondTime: res.RefmsgTime,
  27117. InfRefmsgid: res.InfRefmsgid,
  27118. OrderStatus: 1,
  27119. PayWay: pay_way,
  27120. PayWays: pay_ways,
  27121. OthDesc: oth_desc,
  27122. PayPrice: pay_price,
  27123. PayCardNo: pay_card_no,
  27124. DiscountPrice: discount_price,
  27125. PreferentialPrice: preferential_price,
  27126. RealityPrice: reality_price,
  27127. FoundPrice: found_price,
  27128. MedicalInsurancePrice: medical_insurance_price,
  27129. PrivatePrice: private_price,
  27130. IsMedicineInsurance: 1,
  27131. SettleType: settle_accounts_type,
  27132. SettleStartTime: start_time,
  27133. SettleEndTime: end_time,
  27134. Creator: roles.AdminUserId,
  27135. Modify: roles.AdminUserId,
  27136. FaPiaoNumber: fapiao_number,
  27137. FaPiaoCode: fapiao_code,
  27138. PType: 2,
  27139. Diagnosis: diagnosis_id,
  27140. CashPay: cash_pay,
  27141. WechatPay: wechat_pay,
  27142. AliPay: ali_pay,
  27143. JifenPay: jifen_pay,
  27144. BandCardPay: band_card_pay,
  27145. }
  27146. err = service.CreateOrder(order)
  27147. if err != nil {
  27148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27149. return
  27150. }
  27151. for _, item := range res.Output.Result {
  27152. temp := strings.Split(item.FeedetlSn, "-")
  27153. var advice_id int64 = 0
  27154. var project_id int64 = 0
  27155. var types int64 = 0
  27156. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27157. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27158. if temp[1] == "1" {
  27159. advice_id = id
  27160. project_id = 0
  27161. } else if temp[1] == "2" {
  27162. advice_id = 0
  27163. project_id = id
  27164. }
  27165. if item.MedChrgitmType == "9" {
  27166. item.MedChrgitmType = "09"
  27167. }
  27168. info := &models.HisOrderInfo{
  27169. OrderNumber: order.Number,
  27170. FeedetlSn: item.FeedetlSn,
  27171. UploadDate: time.Now().Unix(),
  27172. AdviceId: advice_id,
  27173. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27174. Cnt: item.Cnt,
  27175. Pric: float64(item.Pric),
  27176. PatientId: his.PatientId,
  27177. PricUplmtAmt: item.PricUplmtAmt,
  27178. SelfpayProp: item.SelfpayProp,
  27179. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27180. OverlmtAmt: item.OverlmtAmt,
  27181. PreselfpayAmt: item.PreselfpayAmt,
  27182. BasMednFlag: item.BasMednFlag,
  27183. MedChrgitmType: item.MedChrgitmType,
  27184. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27185. Status: 1,
  27186. Memo: item.Memo,
  27187. Mtime: time.Now().Unix(),
  27188. InscpScpAmt: item.InscpScpAmt,
  27189. DrtReimFlag: item.DrtReimFlag,
  27190. Ctime: time.Now().Unix(),
  27191. ListSpItemFlag: item.ListSpItemFlag,
  27192. ChldMedcFlag: item.ChldMedcFlag,
  27193. LmtUsedFlag: item.LmtUsedFlag,
  27194. ChrgitmLv: item.ChrgitmLv,
  27195. UserOrgId: adminUser.CurrentOrgId,
  27196. HisPatientId: his.ID,
  27197. OrderId: order.ID,
  27198. ProjectId: project_id,
  27199. Type: types,
  27200. }
  27201. service.CreateOrderInfo(info)
  27202. }
  27203. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27204. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27205. var total float64
  27206. for _, item := range prescriptions {
  27207. if item.Type == 1 { //药品
  27208. for _, subItem := range item.HisDoctorAdviceInfo {
  27209. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27210. total_one := price * subItem.PrescribingNumber
  27211. total = total + total_one
  27212. }
  27213. }
  27214. if item.Type == 2 { //项目
  27215. for _, subItem := range item.HisPrescriptionProject {
  27216. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27217. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27218. total_one := price * cnt
  27219. total = total + total_one
  27220. }
  27221. }
  27222. }
  27223. allTotal := fmt.Sprintf("%.2f", total)
  27224. //if adminUser.CurrentOrgId == 9919 {
  27225. //
  27226. // allTotal = fmt.Sprintf("%.2f", total)
  27227. //
  27228. //} else {
  27229. //
  27230. // allTotal = fmt.Sprintf("%.2f", total)
  27231. //
  27232. //}
  27233. if res.Infcode == 0 {
  27234. var rf []*ResultFive
  27235. json.Unmarshal([]byte(his.Iinfo), &rf)
  27236. chrg_bchno := chrg_bchno
  27237. cert_no := his.Certno
  27238. var insutypes []string
  27239. var insutype string
  27240. var is390 int = 0
  27241. var is310 int = 0
  27242. for _, item := range rf {
  27243. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27244. insutypes = append(insutypes, item.Insutype)
  27245. }
  27246. }
  27247. if len(insutypes) == 1 {
  27248. insutype = insutypes[0]
  27249. } else {
  27250. for _, i := range insutypes {
  27251. if i == "390" {
  27252. is390 = 1
  27253. }
  27254. if i == "310" {
  27255. is310 = 1
  27256. }
  27257. }
  27258. }
  27259. if is390 == 1 {
  27260. insutype = "390"
  27261. }
  27262. if is310 == 1 {
  27263. insutype = "310"
  27264. }
  27265. if len(insutypes) == 0 {
  27266. insutype = "310"
  27267. }
  27268. if len(insutypes) == 2 {
  27269. insutype = strconv.FormatInt(his.SocialType, 10)
  27270. }
  27271. insutype = strconv.FormatInt(his.SocialType, 10)
  27272. //insutype = "390"
  27273. if his.IdCardType == 1 {
  27274. // cert_no = his.MedicalInsuranceNumber
  27275. cert_no = his.Certno
  27276. } else {
  27277. cert_no = his.Certno
  27278. }
  27279. var res ResultSeven
  27280. var resSeven10265 ResultSeven10265
  27281. var gzresSeven10265Two GZResultSeven10265Two
  27282. var src_resquest string
  27283. var result2 string
  27284. if miConfig.MdtrtareaAdmvs == "421300" {
  27285. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27286. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27287. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27288. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27289. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27290. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27291. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27292. resp, requestErr := http.Get(api)
  27293. if requestErr != nil {
  27294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27295. return
  27296. }
  27297. body, ioErr := ioutil.ReadAll(resp.Body)
  27298. if ioErr != nil {
  27299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27301. return
  27302. }
  27303. var respJSON map[string]interface{}
  27304. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27307. return
  27308. }
  27309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27310. result, _ := json.Marshal(respJSON)
  27311. if miConfig.Code == "H15049901371" {
  27312. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27313. utils.ErrorLog("解析失败:%v", err)
  27314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27315. return
  27316. }
  27317. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27318. res.Output = resSeven10265.Output
  27319. res.ErrMsg = resSeven10265.ErrMsg
  27320. res.Cainfo = resSeven10265.Cainfo
  27321. res.WarnMsg = resSeven10265.WarnMsg
  27322. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27323. res.Infcode = infocode
  27324. } else {
  27325. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27326. utils.ErrorLog("解析失败:%v", err)
  27327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27328. return
  27329. }
  27330. }
  27331. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27332. if reg_type == 11 && his.Insutype == "390" {
  27333. reg_type = 110104
  27334. }
  27335. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27336. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27337. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27338. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27339. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27340. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27341. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27342. resp, requestErr := http.Get(api)
  27343. if requestErr != nil {
  27344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27345. return
  27346. }
  27347. body, ioErr := ioutil.ReadAll(resp.Body)
  27348. if ioErr != nil {
  27349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27351. return
  27352. }
  27353. var respJSON map[string]interface{}
  27354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27357. return
  27358. }
  27359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27360. result, _ := json.Marshal(respJSON)
  27361. if miConfig.Code == "H15049901371" {
  27362. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27363. utils.ErrorLog("解析失败:%v", err)
  27364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27365. return
  27366. }
  27367. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27368. res.Output = resSeven10265.Output
  27369. res.ErrMsg = resSeven10265.ErrMsg
  27370. res.Cainfo = resSeven10265.Cainfo
  27371. res.WarnMsg = resSeven10265.WarnMsg
  27372. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27373. res.Infcode = infocode
  27374. } else {
  27375. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27376. utils.ErrorLog("解析失败:%v", err)
  27377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27378. return
  27379. }
  27380. }
  27381. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27382. if reg_type == 11 && his.Insutype == "390" {
  27383. reg_type = 110104
  27384. }
  27385. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27386. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27387. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27388. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27389. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27390. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27391. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27392. resp, requestErr := http.Get(api)
  27393. if requestErr != nil {
  27394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27395. return
  27396. }
  27397. body, ioErr := ioutil.ReadAll(resp.Body)
  27398. if ioErr != nil {
  27399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27401. return
  27402. }
  27403. var respJSON map[string]interface{}
  27404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27407. return
  27408. }
  27409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27410. result, _ := json.Marshal(respJSON)
  27411. if miConfig.Code == "H15049901371" {
  27412. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27413. utils.ErrorLog("解析失败:%v", err)
  27414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27415. return
  27416. }
  27417. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27418. res.Output = resSeven10265.Output
  27419. res.ErrMsg = resSeven10265.ErrMsg
  27420. res.Cainfo = resSeven10265.Cainfo
  27421. res.WarnMsg = resSeven10265.WarnMsg
  27422. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27423. res.Infcode = infocode
  27424. } else {
  27425. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27426. utils.ErrorLog("解析失败:%v", err)
  27427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27428. return
  27429. }
  27430. }
  27431. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27432. if reg_type == 11 && his.Insutype == "390" {
  27433. reg_type = 110104
  27434. }
  27435. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27436. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27437. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27438. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27439. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27440. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27441. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27442. resp, requestErr := http.Get(api)
  27443. if requestErr != nil {
  27444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27445. return
  27446. }
  27447. body, ioErr := ioutil.ReadAll(resp.Body)
  27448. if ioErr != nil {
  27449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27451. return
  27452. }
  27453. var respJSON map[string]interface{}
  27454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27457. return
  27458. }
  27459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27460. result, _ := json.Marshal(respJSON)
  27461. if miConfig.Code == "H15049901371" {
  27462. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27463. utils.ErrorLog("解析失败:%v", err)
  27464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27465. return
  27466. }
  27467. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27468. res.Output = resSeven10265.Output
  27469. res.ErrMsg = resSeven10265.ErrMsg
  27470. res.Cainfo = resSeven10265.Cainfo
  27471. res.WarnMsg = resSeven10265.WarnMsg
  27472. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27473. res.Infcode = infocode
  27474. } else {
  27475. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27476. utils.ErrorLog("解析失败:%v", err)
  27477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27478. return
  27479. }
  27480. }
  27481. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27482. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27483. var result3101 Result3101
  27484. //utils.ErrorLog("解析失败:%v", result3101)
  27485. result3101.Infcode = "0"
  27486. if result3101.Infcode == "0" {
  27487. if len(result3101.Output.Result) > 0 {
  27488. var errMsgs []string
  27489. for _, item := range result3101.Output.Result {
  27490. errMsgs = append(errMsgs, item.VolaCont)
  27491. }
  27492. c.ServeSuccessJSON(map[string]interface{}{
  27493. "failed_code": -10,
  27494. "msg": errMsgs,
  27495. })
  27496. return
  27497. } else {
  27498. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27499. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27500. bas := strings.Split(psn_info.CardInfo, "|")
  27501. if his.IdCardType == 1 {
  27502. cert_no = bas[2]
  27503. } else if his.IdCardType == 3 {
  27504. cert_no = his.Certno
  27505. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27506. } else if his.IdCardType == 4 {
  27507. cert_no = his.Certno
  27508. psn_info.VerifyNumber = psn_info.VerifyNumber
  27509. }
  27510. var api string
  27511. if miConfig.MdtrtareaAdmvs == "320830" {
  27512. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27513. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27514. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27516. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27517. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27518. "&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
  27519. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27520. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27521. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27522. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27523. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27524. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27525. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27526. "&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
  27527. } else {
  27528. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27529. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27530. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27531. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27532. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27533. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27534. "&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
  27535. }
  27536. resp, requestErr := http.Get(api)
  27537. if requestErr != nil {
  27538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27539. return
  27540. }
  27541. body, ioErr := ioutil.ReadAll(resp.Body)
  27542. if ioErr != nil {
  27543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27545. return
  27546. }
  27547. var respJSON map[string]interface{}
  27548. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27551. return
  27552. }
  27553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27554. result, _ := json.Marshal(respJSON)
  27555. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27556. utils.ErrorLog("解析失败:%v", err)
  27557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27558. return
  27559. }
  27560. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27561. res.Output = resSeven10265.Output
  27562. res.ErrMsg = resSeven10265.ErrMsg
  27563. res.Cainfo = resSeven10265.Cainfo
  27564. res.WarnMsg = resSeven10265.WarnMsg
  27565. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27566. res.Infcode = infocode
  27567. }
  27568. }
  27569. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27570. psn_info, _ := service.GetPsnByPatientId(id)
  27571. var verify_number string
  27572. if psn_info.IdCardType == 4 {
  27573. verify_number = psn_info.VerifyNumber
  27574. } else if psn_info.IdCardType == 1 {
  27575. bas := strings.Split(psn_info.CardInfo, "|")
  27576. cardNumber := bas[2]
  27577. verify_number = cardNumber
  27578. } else {
  27579. psn_info.IdCardType = 2
  27580. verify_number = psn_info.Certno
  27581. }
  27582. var api string
  27583. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27584. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27585. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27586. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27587. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27588. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27589. "&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
  27590. resp, requestErr := http.Get(api)
  27591. if requestErr != nil {
  27592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27593. return
  27594. }
  27595. body, ioErr := ioutil.ReadAll(resp.Body)
  27596. if ioErr != nil {
  27597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27599. return
  27600. }
  27601. var respJSON map[string]interface{}
  27602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27605. return
  27606. }
  27607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27608. result, _ := json.Marshal(respJSON)
  27609. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27610. utils.ErrorLog("解析失败:%v", err)
  27611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27612. return
  27613. }
  27614. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27615. res.Output = resSeven10265.Output
  27616. res.ErrMsg = resSeven10265.ErrMsg
  27617. res.Cainfo = resSeven10265.Cainfo
  27618. res.WarnMsg = resSeven10265.WarnMsg
  27619. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27620. res.Infcode = infocode
  27621. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27622. var cert_no string
  27623. if his.IdCardType == 4 {
  27624. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27625. cert_no = psn_info.VerifyNumber
  27626. 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)
  27627. } else if his.IdCardType == 1 {
  27628. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27629. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27630. 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)
  27631. }
  27632. //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)
  27633. var dat map[string]interface{}
  27634. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27635. fmt.Println(dat)
  27636. } else {
  27637. fmt.Println(err)
  27638. }
  27639. saveLog(result2, src_resquest, "2207", "结算")
  27640. userJSONBytes, _ := json.Marshal(dat)
  27641. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27642. utils.ErrorLog("解析失败:%v", err)
  27643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27644. return
  27645. }
  27646. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27647. res.Output = resSeven10265.Output
  27648. res.ErrMsg = resSeven10265.ErrMsg
  27649. res.Cainfo = resSeven10265.Cainfo
  27650. res.WarnMsg = resSeven10265.WarnMsg
  27651. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27652. res.Infcode = infocode
  27653. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27654. res2 := c.GetoleInfo()
  27655. if res2.Infcode == 0 {
  27656. var result string
  27657. var request_log string
  27658. var result_log string
  27659. if res2.Output.MdtrtCertType == "02" {
  27660. 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)
  27661. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27662. } else if res2.Output.MdtrtCertType == "01" {
  27663. 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)
  27664. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27665. } else {
  27666. 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)
  27667. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27668. }
  27669. var dat map[string]interface{}
  27670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27671. fmt.Println(dat)
  27672. } else {
  27673. fmt.Println(err)
  27674. }
  27675. userJSONBytes, _ := json.Marshal(dat)
  27676. var res5 ResultTwo
  27677. //var resTwo10265 ResultTwo10265
  27678. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27679. utils.ErrorLog("解析失败:%v", err)
  27680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27681. return
  27682. }
  27683. if res5.Infcode == -1 {
  27684. c.ServeSuccessJSON(map[string]interface{}{
  27685. "failed_code": -10,
  27686. "msg": res5.ErrMsg,
  27687. })
  27688. return
  27689. }
  27690. var insutypes []string
  27691. var insutype string
  27692. var is390 int = 0
  27693. var is310 int = 0
  27694. for _, item := range res5.Output.Iinfo {
  27695. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27696. insutypes = append(insutypes, item.Insutype)
  27697. }
  27698. }
  27699. if len(insutypes) == 1 {
  27700. insutype = insutypes[0]
  27701. } else {
  27702. for _, i := range insutypes {
  27703. if i == "390" {
  27704. is390 = 1
  27705. }
  27706. if i == "310" {
  27707. is310 = 1
  27708. }
  27709. }
  27710. }
  27711. if is390 == 1 {
  27712. insutype = "390"
  27713. }
  27714. if is310 == 1 {
  27715. insutype = "310"
  27716. }
  27717. if len(insutypes) == 0 {
  27718. insutype = "310"
  27719. }
  27720. fmt.Println(insutype)
  27721. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27722. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27723. infoStr := string(Iinfos)
  27724. idetinfoStr := string(Idetinfos)
  27725. psn := &models.HisPsn{
  27726. PsnNo: res5.Output.Baseinfo.PsnNo,
  27727. PatientId: id,
  27728. Certno: res5.Output.Baseinfo.Certno,
  27729. Gend: res5.Output.Baseinfo.Gend,
  27730. Naty: res5.Output.Baseinfo.Naty,
  27731. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27732. PsnName: res5.Output.Baseinfo.PsnName,
  27733. Idetinfo: idetinfoStr,
  27734. Insuinfo: infoStr,
  27735. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27736. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27737. VerifyNumber: res2.Output.EcToken,
  27738. }
  27739. if res2.Output.MdtrtCertType == "01" {
  27740. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27741. psn.VerifyNumber = res2.Output.EcToken
  27742. } else if res2.Output.MdtrtCertType == "02" {
  27743. psn.VerifyNumber = res2.Output.CardNo
  27744. } else {
  27745. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27746. }
  27747. service.CreateHisPsn(psn)
  27748. if res2.Output.MdtrtCertType == "01" {
  27749. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27750. token := res2.Output.EcToken
  27751. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  27752. } else if res2.Output.MdtrtCertType == "02" {
  27753. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  27754. } else {
  27755. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  27756. }
  27757. var dat2 map[string]interface{}
  27758. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27759. fmt.Println(dat2)
  27760. } else {
  27761. fmt.Println(err)
  27762. }
  27763. userJSONBytes3, _ := json.Marshal(dat2)
  27764. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27765. utils.ErrorLog("解析失败:%v", err)
  27766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27767. return
  27768. }
  27769. saveLog(result2, src_resquest, "2207", "结算")
  27770. } else {
  27771. c.ServeSuccessJSON(map[string]interface{}{
  27772. "failed_code": -10,
  27773. "msg": res2.ErrMsg,
  27774. })
  27775. return
  27776. }
  27777. } else {
  27778. if miConfig.Code == "H15049901371" {
  27779. //赤峰地区国家医保医疗类别
  27780. //职工透析:医疗类别选特殊情况门诊990502
  27781. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27782. var med_type string
  27783. if his.Insutype == "390" {
  27784. if reg_type == 14 {
  27785. med_type = "9933"
  27786. } else if reg_type == 11 {
  27787. med_type = "11"
  27788. }
  27789. } else if his.Insutype == "310" {
  27790. if reg_type == 14 {
  27791. med_type = "990502"
  27792. } else if reg_type == 11 {
  27793. med_type = "11"
  27794. }
  27795. }
  27796. 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)
  27797. } else {
  27798. if his.IdCardType == 4 {
  27799. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27800. var token string
  27801. token = psn_info.VerifyNumber
  27802. 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)
  27803. } else {
  27804. if his.IdCardType == 1 {
  27805. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27806. bas := strings.Split(psn_info.CardInfo, "|")
  27807. basNumber := bas[2]
  27808. cert_no = basNumber
  27809. }
  27810. 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)
  27811. }
  27812. }
  27813. //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)
  27814. var dat map[string]interface{}
  27815. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27816. fmt.Println(dat)
  27817. } else {
  27818. fmt.Println(err)
  27819. }
  27820. saveLog(result2, src_resquest, "2207", "结算")
  27821. userJSONBytes, _ := json.Marshal(dat)
  27822. if miConfig.Code == "H15049901371" {
  27823. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27824. utils.ErrorLog("解析失败:%v", err)
  27825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27826. return
  27827. }
  27828. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27829. res.Output = resSeven10265.Output
  27830. res.ErrMsg = resSeven10265.ErrMsg
  27831. res.Cainfo = resSeven10265.Cainfo
  27832. res.WarnMsg = resSeven10265.WarnMsg
  27833. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27834. res.Infcode = infocode
  27835. } else {
  27836. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27837. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27838. utils.ErrorLog("解析失败:%v", err)
  27839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27840. return
  27841. }
  27842. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27843. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27844. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27845. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27846. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27847. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27848. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27849. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27850. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27851. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27852. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27853. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27854. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27855. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27856. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27857. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27858. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27859. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27860. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27861. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27862. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27863. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27864. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27865. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27866. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27867. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27868. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27869. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27870. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27871. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27872. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27873. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27874. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27875. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27876. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27877. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27878. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27879. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27880. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27881. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27882. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27883. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27884. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27885. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27886. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27887. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27888. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27889. res.Cainfo = gzresSeven10265Two.Cainfo
  27890. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27891. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27892. //res.Infcode = infocode
  27893. } else {
  27894. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27895. utils.ErrorLog("解析失败:%v", err)
  27896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27897. return
  27898. }
  27899. }
  27900. }
  27901. }
  27902. if res.Infcode == -1 {
  27903. errlog := &models.HisOrderError{
  27904. UserOrgId: adminUser.CurrentOrgId,
  27905. Ctime: time.Now().Unix(),
  27906. Mtime: time.Now().Unix(),
  27907. Number: chrg_bchno,
  27908. ErrMsg: res.ErrMsg,
  27909. Status: 1,
  27910. PatientId: id,
  27911. RecordTime: recordDateTime,
  27912. Stage: 6,
  27913. }
  27914. service.CreateErrMsgLog(errlog)
  27915. c.ServeSuccessJSON(map[string]interface{}{
  27916. "failed_code": -10,
  27917. "msg": res.ErrMsg,
  27918. })
  27919. return
  27920. } else {
  27921. sickConfig, _ := service.FindSickById(his.SickType)
  27922. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27923. order.OrderStatus = 2
  27924. order.Status = 1
  27925. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27926. order.SetlId = res.Output.Setlinfo.SetlID
  27927. order.PsnNo = res.Output.Setlinfo.PsnNo
  27928. order.PsnName = res.Output.Setlinfo.PsnName
  27929. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27930. order.Certno = res.Output.Setlinfo.Certno
  27931. order.Gend = res.Output.Setlinfo.Gend
  27932. order.Naty = res.Output.Setlinfo.Naty
  27933. order.Age = res.Output.Setlinfo.Age
  27934. order.Insutype = res.Output.Setlinfo.Insutype
  27935. order.PsnType = res.Output.Setlinfo.PsnType
  27936. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27937. order.SetlTime = res.Output.Setlinfo.SetlTime
  27938. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27939. if res.Output.Setlinfo.MedType == "140101" {
  27940. order.MedType = "14"
  27941. } else {
  27942. if res.Output.Setlinfo.MedType == "110104" {
  27943. order.MedType = "11"
  27944. } else {
  27945. order.MedType = res.Output.Setlinfo.MedType
  27946. }
  27947. }
  27948. if reg_type == 1112 {
  27949. order.MedType = "1112"
  27950. }
  27951. if reg_type == 1111 {
  27952. order.MedType = "1111"
  27953. }
  27954. order.ClrType = res.Output.Setlinfo.ClrType
  27955. if adminUser.CurrentOrgId == 10480 {
  27956. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27957. order.ClrType = "11"
  27958. } else {
  27959. order.ClrType = "9903"
  27960. }
  27961. }
  27962. if adminUser.CurrentOrgId == 10721 {
  27963. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27964. order.ClrType = "11"
  27965. } else {
  27966. order.ClrType = "9903"
  27967. }
  27968. }
  27969. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27970. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27971. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27972. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27973. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27974. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27975. order.HifpPay = res.Output.Setlinfo.HifpPay
  27976. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27977. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27978. order.HifesPay = res.Output.Setlinfo.HifesPay
  27979. order.HifobPay = res.Output.Setlinfo.HifobPay
  27980. order.MafPay = res.Output.Setlinfo.MafPay
  27981. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27982. order.OthPay = res.Output.Setlinfo.OthPay
  27983. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27984. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27985. order.AcctPay = res.Output.Setlinfo.AcctPay
  27986. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27987. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27988. order.Balc = res.Output.Setlinfo.Balc
  27989. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27990. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27991. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27992. //order.ClrType = res.Output.Setlinfo.ClrType
  27993. order.ClrWay = res.Output.Setlinfo.ClrWay
  27994. order.Creator = order.Creator
  27995. order.Modify = roles.AdminUserId
  27996. order.RequestLog = src_resquest
  27997. order.FaPiaoNumber = fapiao_number
  27998. order.FaPiaoCode = fapiao_code
  27999. order.SickName = sickConfig.ClassName
  28000. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28001. //detailStr := string(setlDetail)
  28002. //order.SetlDetail = detailStr
  28003. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28004. err = service.UpDateOrder(order)
  28005. if err == nil {
  28006. //判断是否使用了押金
  28007. if dec_way == "true" {
  28008. tmpstring := strconv.FormatInt(order.ID, 10)
  28009. order.Decimal = decimal
  28010. service.UpDateOrder(order)
  28011. //扣押金
  28012. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28013. if errmsg != nil {
  28014. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28015. return
  28016. }
  28017. }
  28018. c.ServeSuccessJSON(map[string]interface{}{
  28019. "msg": "结算成功",
  28020. })
  28021. } else {
  28022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28023. return
  28024. }
  28025. }
  28026. } else {
  28027. adminUser := c.GetAdminUserInfo()
  28028. errlog := &models.HisOrderError{
  28029. UserOrgId: adminUser.CurrentOrgId,
  28030. Ctime: time.Now().Unix(),
  28031. Mtime: time.Now().Unix(),
  28032. ErrMsg: res.ErrMsg,
  28033. Status: 1,
  28034. PatientId: id,
  28035. RecordTime: recordDateTime,
  28036. Stage: 4,
  28037. }
  28038. service.CreateErrMsgLog(errlog)
  28039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28040. return
  28041. }
  28042. } else {
  28043. adminUser := c.GetAdminUserInfo()
  28044. errlog := &models.HisOrderError{
  28045. UserOrgId: adminUser.CurrentOrgId,
  28046. Ctime: time.Now().Unix(),
  28047. Mtime: time.Now().Unix(),
  28048. ErrMsg: res.ErrMsg,
  28049. Status: 1,
  28050. PatientId: id,
  28051. RecordTime: recordDateTime,
  28052. Stage: 4,
  28053. }
  28054. service.CreateErrMsgLog(errlog)
  28055. c.ServeSuccessJSON(map[string]interface{}{
  28056. "failed_code": -10,
  28057. "msg": res.ErrMsg,
  28058. })
  28059. return
  28060. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28061. //return
  28062. }
  28063. }
  28064. }
  28065. } else if tempOrder.ID > 0 {
  28066. if tempOrder.IsPre == 1 {
  28067. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28068. var rf []*ResultFive
  28069. json.Unmarshal([]byte(his.Iinfo), &rf)
  28070. chrg_bchno := tempOrder.Number
  28071. cert_no := his.Certno
  28072. var insutypes []string
  28073. var insutype string
  28074. var is390 int = 0
  28075. var is310 int = 0
  28076. for _, item := range rf {
  28077. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28078. insutypes = append(insutypes, item.Insutype)
  28079. }
  28080. }
  28081. if len(insutypes) == 1 {
  28082. insutype = insutypes[0]
  28083. } else {
  28084. for _, i := range insutypes {
  28085. if i == "390" {
  28086. is390 = 1
  28087. }
  28088. if i == "310" {
  28089. is310 = 1
  28090. }
  28091. }
  28092. }
  28093. if is390 == 1 {
  28094. insutype = "390"
  28095. }
  28096. if is310 == 1 {
  28097. insutype = "310"
  28098. }
  28099. if len(insutypes) == 0 {
  28100. insutype = "310"
  28101. }
  28102. if len(insutypes) == 2 {
  28103. insutype = strconv.FormatInt(his.SocialType, 10)
  28104. }
  28105. //insutype = "390"
  28106. if his.IdCardType == 1 {
  28107. // cert_no = his.MedicalInsuranceNumber
  28108. cert_no = his.Certno
  28109. } else {
  28110. cert_no = his.Certno
  28111. }
  28112. var res ResultSeven
  28113. var ahres ResultSevenAH
  28114. var resSeven10265 ResultSeven10265
  28115. var gzresSeven10265Two GZResultSeven10265Two
  28116. var src_resquest string
  28117. var result2 string
  28118. if miConfig.MdtrtareaAdmvs == "450721" {
  28119. res2 := c.GetoleInfo()
  28120. if res2.Infcode == 0 {
  28121. var result string
  28122. var request_log string
  28123. var result_log string
  28124. if res2.Output.MdtrtCertType == "02" {
  28125. 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)
  28126. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28127. } else if res2.Output.MdtrtCertType == "01" {
  28128. 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)
  28129. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28130. } else {
  28131. 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)
  28132. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28133. }
  28134. var dat map[string]interface{}
  28135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28136. fmt.Println(dat)
  28137. } else {
  28138. fmt.Println(err)
  28139. }
  28140. userJSONBytes, _ := json.Marshal(dat)
  28141. var res5 ResultTwo
  28142. //var resTwo10265 ResultTwo10265
  28143. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28144. utils.ErrorLog("解析失败:%v", err)
  28145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28146. return
  28147. }
  28148. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28149. if res5.Infcode == -1 {
  28150. c.ServeSuccessJSON(map[string]interface{}{
  28151. "failed_code": -10,
  28152. "msg": res5.ErrMsg,
  28153. })
  28154. return
  28155. }
  28156. var insutypes []string
  28157. var insutype string
  28158. var is390 int = 0
  28159. var is310 int = 0
  28160. for _, item := range res5.Output.Iinfo {
  28161. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28162. insutypes = append(insutypes, item.Insutype)
  28163. }
  28164. }
  28165. if len(insutypes) == 1 {
  28166. insutype = insutypes[0]
  28167. } else {
  28168. for _, i := range insutypes {
  28169. if i == "390" {
  28170. is390 = 1
  28171. }
  28172. if i == "310" {
  28173. is310 = 1
  28174. }
  28175. }
  28176. }
  28177. if is390 == 1 {
  28178. insutype = "390"
  28179. }
  28180. if is310 == 1 {
  28181. insutype = "310"
  28182. }
  28183. if len(insutypes) == 0 {
  28184. insutype = "310"
  28185. }
  28186. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28187. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28188. infoStr := string(Iinfos)
  28189. idetinfoStr := string(Idetinfos)
  28190. psn := &models.HisPsn{
  28191. PsnNo: res5.Output.Baseinfo.PsnNo,
  28192. PatientId: id,
  28193. Certno: res5.Output.Baseinfo.Certno,
  28194. Gend: res5.Output.Baseinfo.Gend,
  28195. Naty: res5.Output.Baseinfo.Naty,
  28196. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28197. PsnName: res5.Output.Baseinfo.PsnName,
  28198. Idetinfo: idetinfoStr,
  28199. Insuinfo: infoStr,
  28200. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28202. VerifyNumber: res2.Output.EcToken,
  28203. }
  28204. service.CreateHisPsn(psn)
  28205. if res2.Output.MdtrtCertType == "01" {
  28206. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28207. token := res2.Output.EcToken
  28208. 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)
  28209. } else if res2.Output.MdtrtCertType == "02" {
  28210. 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)
  28211. } else {
  28212. 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)
  28213. }
  28214. var dat2 map[string]interface{}
  28215. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28216. fmt.Println(dat2)
  28217. } else {
  28218. fmt.Println(err)
  28219. }
  28220. userJSONBytes3, _ := json.Marshal(dat2)
  28221. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28222. utils.ErrorLog("解析失败:%v", err)
  28223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28224. return
  28225. }
  28226. saveLog(result2, src_resquest, "2207", "结算")
  28227. } else {
  28228. c.ServeSuccessJSON(map[string]interface{}{
  28229. "failed_code": -10,
  28230. "msg": res2.ErrMsg,
  28231. })
  28232. return
  28233. }
  28234. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28235. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28236. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28237. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28239. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28240. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28241. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28242. resp, requestErr := http.Get(api)
  28243. if requestErr != nil {
  28244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28245. return
  28246. }
  28247. body, ioErr := ioutil.ReadAll(resp.Body)
  28248. if ioErr != nil {
  28249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28251. return
  28252. }
  28253. var respJSON map[string]interface{}
  28254. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28257. return
  28258. }
  28259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28260. result, _ := json.Marshal(respJSON)
  28261. fmt.Println("log")
  28262. fmt.Println(string(result))
  28263. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28264. utils.ErrorLog("解析失败:%v", err)
  28265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28266. return
  28267. }
  28268. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28269. if reg_type == 11 && his.Insutype == "390" {
  28270. reg_type = 110104
  28271. }
  28272. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28273. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28274. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28275. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28276. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28277. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28278. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28279. resp, requestErr := http.Get(api)
  28280. if requestErr != nil {
  28281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28282. return
  28283. }
  28284. body, ioErr := ioutil.ReadAll(resp.Body)
  28285. if ioErr != nil {
  28286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28288. return
  28289. }
  28290. var respJSON map[string]interface{}
  28291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28294. return
  28295. }
  28296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28297. result, _ := json.Marshal(respJSON)
  28298. fmt.Println("log")
  28299. fmt.Println(string(result))
  28300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28301. utils.ErrorLog("解析失败:%v", err)
  28302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28303. return
  28304. }
  28305. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28306. if reg_type == 11 && his.Insutype == "390" {
  28307. reg_type = 110104
  28308. }
  28309. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28310. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28311. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28312. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28313. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28314. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28315. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28316. resp, requestErr := http.Get(api)
  28317. if requestErr != nil {
  28318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28319. return
  28320. }
  28321. body, ioErr := ioutil.ReadAll(resp.Body)
  28322. if ioErr != nil {
  28323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28325. return
  28326. }
  28327. var respJSON map[string]interface{}
  28328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28331. return
  28332. }
  28333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28334. result, _ := json.Marshal(respJSON)
  28335. fmt.Println("log")
  28336. fmt.Println(string(result))
  28337. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28338. utils.ErrorLog("解析失败:%v", err)
  28339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28340. return
  28341. }
  28342. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28343. if reg_type == 11 && his.Insutype == "390" {
  28344. reg_type = 110104
  28345. }
  28346. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28347. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28348. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28349. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28350. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28351. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28352. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28353. resp, requestErr := http.Get(api)
  28354. if requestErr != nil {
  28355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28356. return
  28357. }
  28358. body, ioErr := ioutil.ReadAll(resp.Body)
  28359. if ioErr != nil {
  28360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28362. return
  28363. }
  28364. var respJSON map[string]interface{}
  28365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28368. return
  28369. }
  28370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28371. result, _ := json.Marshal(respJSON)
  28372. fmt.Println("log")
  28373. fmt.Println(string(result))
  28374. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28375. utils.ErrorLog("解析失败:%v", err)
  28376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28377. return
  28378. }
  28379. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28380. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28381. var result3101 Result3101
  28382. //utils.ErrorLog("解析失败:%v", result3101)
  28383. result3101.Infcode = "0"
  28384. if result3101.Infcode == "0" {
  28385. if len(result3101.Output.Result) > 0 {
  28386. var errMsgs []string
  28387. for _, item := range result3101.Output.Result {
  28388. errMsgs = append(errMsgs, item.VolaCont)
  28389. }
  28390. c.ServeSuccessJSON(map[string]interface{}{
  28391. "failed_code": -10,
  28392. "msg": errMsgs,
  28393. })
  28394. return
  28395. } else {
  28396. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28397. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28398. bas := strings.Split(psn_info.CardInfo, "|")
  28399. if his.IdCardType == 1 {
  28400. cert_no = bas[2]
  28401. } else if his.IdCardType == 3 {
  28402. cert_no = his.Certno
  28403. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28404. } else if his.IdCardType == 4 {
  28405. cert_no = his.Certno
  28406. psn_info.VerifyNumber = psn_info.VerifyNumber
  28407. }
  28408. //江苏地区国家医保医疗类别
  28409. //职工透析:医疗类别选特殊情况门诊9933
  28410. //居民血透门慢: 医疗类别选门诊慢病1402
  28411. //var med_type string
  28412. //if his.Insutype == "310" {
  28413. // if reg_type == 14 {
  28414. // med_type = "9933"
  28415. // } else if reg_type == 11 {
  28416. // med_type = "11"
  28417. //
  28418. // }
  28419. //} else if his.Insutype == "390" {
  28420. // if reg_type == 14 {
  28421. // med_type = "1402"
  28422. // } else if reg_type == 11 {
  28423. // med_type = "11"
  28424. // }
  28425. //}
  28426. var api string
  28427. if miConfig.MdtrtareaAdmvs == "320830" {
  28428. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28429. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28430. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28431. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28432. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28433. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28434. "&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
  28435. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28436. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28437. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28438. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28439. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28441. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28442. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28443. "&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
  28444. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28445. } else {
  28446. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28447. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28448. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28449. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28450. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28451. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28452. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28453. "&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
  28454. }
  28455. resp, requestErr := http.Get(api)
  28456. if requestErr != nil {
  28457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28458. return
  28459. }
  28460. body, ioErr := ioutil.ReadAll(resp.Body)
  28461. if ioErr != nil {
  28462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28464. return
  28465. }
  28466. var respJSON map[string]interface{}
  28467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28470. return
  28471. }
  28472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28473. result, _ := json.Marshal(respJSON)
  28474. fmt.Println("log")
  28475. fmt.Println(string(result))
  28476. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28477. utils.ErrorLog("解析失败:%v", err)
  28478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28479. return
  28480. }
  28481. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28482. res.Output = resSeven10265.Output
  28483. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28484. res.ErrMsg = resSeven10265.ErrMsg
  28485. res.Cainfo = resSeven10265.Cainfo
  28486. res.WarnMsg = resSeven10265.WarnMsg
  28487. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28488. res.Infcode = infocode
  28489. }
  28490. }
  28491. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28492. psn_info, _ := service.GetPsnByPatientId(id)
  28493. var verify_number string
  28494. if psn_info.IdCardType == 4 {
  28495. verify_number = psn_info.VerifyNumber
  28496. } else if psn_info.IdCardType == 1 {
  28497. bas := strings.Split(psn_info.CardInfo, "|")
  28498. cardNumber := bas[2]
  28499. verify_number = cardNumber
  28500. } else {
  28501. verify_number = psn_info.Certno
  28502. psn_info.IdCardType = 2
  28503. }
  28504. var api string
  28505. new_chrg_bchno := chrg_bchno
  28506. if adminUser.CurrentOrgId == 10265 {
  28507. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28508. new_chrg_bchno = "0000"
  28509. }
  28510. }
  28511. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28512. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28517. "&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
  28518. resp, requestErr := http.Get(api)
  28519. if requestErr != nil {
  28520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28521. return
  28522. }
  28523. body, ioErr := ioutil.ReadAll(resp.Body)
  28524. if ioErr != nil {
  28525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28527. return
  28528. }
  28529. var respJSON map[string]interface{}
  28530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28536. result, _ := json.Marshal(respJSON)
  28537. fmt.Println("log")
  28538. fmt.Println(string(result))
  28539. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28540. utils.ErrorLog("解析失败:%v", err)
  28541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28542. return
  28543. }
  28544. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28545. res.Output = resSeven10265.Output
  28546. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28547. res.ErrMsg = resSeven10265.ErrMsg
  28548. res.Cainfo = resSeven10265.Cainfo
  28549. res.WarnMsg = resSeven10265.WarnMsg
  28550. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28551. res.Infcode = infocode
  28552. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28553. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28554. var cert_no string
  28555. if his.IdCardType == 1 {
  28556. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28557. } else {
  28558. cert_no = psn_info.VerifyNumber
  28559. }
  28560. 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)
  28561. var dat map[string]interface{}
  28562. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28563. fmt.Println(dat)
  28564. } else {
  28565. fmt.Println(err)
  28566. }
  28567. saveLog(result2, src_resquest, "2207", "结算")
  28568. userJSONBytes, _ := json.Marshal(dat)
  28569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28570. utils.ErrorLog("解析失败:%v", err)
  28571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28572. return
  28573. }
  28574. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28575. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28576. var cert_no string
  28577. var card_sn string
  28578. if his.IdCardType == 1 {
  28579. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28580. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28581. bas := strings.Split(psn_info.CardInfo, "|")
  28582. card_sn = bas[3]
  28583. } else if his.IdCardType == 2 {
  28584. cert_no = his.IdCardNo
  28585. } else {
  28586. cert_no = psn_info.VerifyNumber
  28587. }
  28588. var rf []*ResultFive
  28589. json.Unmarshal([]byte(his.Iinfo), &rf)
  28590. var psn_type string
  28591. for _, item := range rf {
  28592. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28593. psn_type = item.PsnType
  28594. }
  28595. }
  28596. 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)
  28597. var dat map[string]interface{}
  28598. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28599. fmt.Println(dat)
  28600. } else {
  28601. fmt.Println(err)
  28602. }
  28603. saveLog(result2, src_resquest, "2207", "结算")
  28604. userJSONBytes, _ := json.Marshal(dat)
  28605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28606. utils.ErrorLog("解析失败:%v", err)
  28607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28608. return
  28609. }
  28610. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28611. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28612. var cert_no string
  28613. var card_sn string
  28614. if his.IdCardType == 1 {
  28615. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28616. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28617. //bas := strings.Split(psn_info.CardInfo, "|")
  28618. card_sn = ""
  28619. } else if his.IdCardType == 2 {
  28620. cert_no = his.IdCardNo
  28621. } else {
  28622. cert_no = psn_info.VerifyNumber
  28623. }
  28624. var rf []*ResultFive
  28625. json.Unmarshal([]byte(his.Iinfo), &rf)
  28626. var psn_type string
  28627. for _, item := range rf {
  28628. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28629. psn_type = item.PsnType
  28630. }
  28631. }
  28632. 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)
  28633. var dat map[string]interface{}
  28634. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28635. fmt.Println(dat)
  28636. } else {
  28637. fmt.Println(err)
  28638. }
  28639. saveLog(result2, src_resquest, "2207", "结算")
  28640. userJSONBytes, _ := json.Marshal(dat)
  28641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28642. utils.ErrorLog("解析失败:%v", err)
  28643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28644. return
  28645. }
  28646. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28647. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28648. var cert_no string
  28649. var card_sn string
  28650. if his.IdCardType == 1 {
  28651. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28652. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28653. //bas := strings.Split(psn_info.CardInfo, "|")
  28654. card_sn = ""
  28655. } else if his.IdCardType == 2 {
  28656. cert_no = his.IdCardNo
  28657. } else {
  28658. cert_no = psn_info.VerifyNumber
  28659. }
  28660. var rf []*ResultFive
  28661. json.Unmarshal([]byte(his.Iinfo), &rf)
  28662. var psn_type string
  28663. for _, item := range rf {
  28664. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28665. psn_type = item.PsnType
  28666. }
  28667. }
  28668. 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)
  28669. var dat map[string]interface{}
  28670. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28671. fmt.Println(dat)
  28672. } else {
  28673. fmt.Println(err)
  28674. }
  28675. saveLog(result2, src_resquest, "2207", "结算")
  28676. userJSONBytes, _ := json.Marshal(dat)
  28677. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28678. utils.ErrorLog("解析失败:%v", err)
  28679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28680. return
  28681. }
  28682. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28683. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28684. if his.IdCardType == 1 {
  28685. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28686. bas := strings.Split(psn_info.CardInfo, "|")
  28687. cert_no = bas[2]
  28688. } else if his.IdCardType == 3 {
  28689. cert_no = his.Certno
  28690. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28691. } else if his.IdCardType == 4 {
  28692. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28693. cert_no = psn_info.VerifyNumber
  28694. psn_info.VerifyNumber = psn_info.VerifyNumber
  28695. } else {
  28696. cert_no = his.Certno
  28697. psn_info.VerifyNumber = his.Certno
  28698. }
  28699. var api string
  28700. var med_type string
  28701. if his.Insutype == "390" {
  28702. if reg_type == 992102 {
  28703. med_type = "992102"
  28704. }
  28705. if reg_type == 1104 {
  28706. med_type = "1104"
  28707. }
  28708. if reg_type == 1104 {
  28709. med_type = "1104"
  28710. }
  28711. if reg_type == 140104 {
  28712. med_type = "140104"
  28713. }
  28714. if reg_type == 140201 {
  28715. med_type = "140201"
  28716. }
  28717. if reg_type == 14 {
  28718. med_type = "14"
  28719. }
  28720. } else if his.Insutype == "310" {
  28721. if reg_type == 1104 {
  28722. med_type = "1104"
  28723. }
  28724. if reg_type == 992102 {
  28725. med_type = "992102"
  28726. }
  28727. if reg_type == 140104 {
  28728. med_type = "140104"
  28729. }
  28730. if reg_type == 140201 {
  28731. med_type = "140201"
  28732. }
  28733. if reg_type == 14 {
  28734. med_type = "14"
  28735. }
  28736. }
  28737. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28738. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28739. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28740. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28741. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28742. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28743. "&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
  28744. resp, requestErr := http.Get(api)
  28745. if requestErr != nil {
  28746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28747. return
  28748. }
  28749. body, ioErr := ioutil.ReadAll(resp.Body)
  28750. if ioErr != nil {
  28751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28753. return
  28754. }
  28755. var respJSON map[string]interface{}
  28756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28759. return
  28760. }
  28761. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28762. if status == "0" {
  28763. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28764. c.ServeSuccessJSON(map[string]interface{}{
  28765. "failed_code": -10,
  28766. "msg": err_msg,
  28767. })
  28768. return
  28769. }
  28770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28771. result, _ := json.Marshal(respJSON)
  28772. fmt.Println("log")
  28773. fmt.Println(string(result))
  28774. if err := json.Unmarshal(result, &ahres); err != nil {
  28775. utils.ErrorLog("解析失败:%v", err)
  28776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28777. return
  28778. }
  28779. res.InfRefmsgid = ahres.InfRefmsgid
  28780. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28781. // 创建对应的Time类型
  28782. t := time.UnixMilli(timestamp)
  28783. // 格式化成指定的日期字符串
  28784. str := t.Format("2006-01-02 15:04:05")
  28785. res.Output.Setlinfo.SetlTime = str
  28786. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28787. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28788. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28789. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28790. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28791. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28792. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28793. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28794. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28795. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28796. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28797. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28798. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28799. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28800. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28801. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28802. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28803. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28804. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28805. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28806. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28807. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28808. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28809. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28810. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28811. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28812. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28813. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28814. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28815. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28816. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28817. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28818. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28819. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28820. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28821. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28822. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28823. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28824. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28825. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28826. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28827. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28828. res.Output.Setldetail = ahres.Output.Setldetail
  28829. res.ErrMsg = ahres.ErrMsg
  28830. res.Cainfo = ahres.Cainfo
  28831. res.WarnMsg = ahres.WarnMsg
  28832. res.Infcode = ahres.Infcode
  28833. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28834. res.Output.Setlinfo.ClrType = "11"
  28835. } else {
  28836. res.Output.Setlinfo.ClrType = "9903"
  28837. }
  28838. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28839. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28840. if his.IdCardType == 1 {
  28841. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28842. bas := strings.Split(psn_info.CardInfo, "|")
  28843. cert_no = bas[2]
  28844. } else if his.IdCardType == 3 {
  28845. cert_no = his.Certno
  28846. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28847. } else if his.IdCardType == 4 {
  28848. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28849. cert_no = his.Certno
  28850. psn_info.VerifyNumber = psn_info.VerifyNumber
  28851. } else {
  28852. cert_no = his.Certno
  28853. psn_info.VerifyNumber = his.Certno
  28854. }
  28855. var api string
  28856. var med_type string
  28857. if his.Insutype == "390" {
  28858. if reg_type == 1104 {
  28859. med_type = "1104"
  28860. }
  28861. if reg_type == 992102 {
  28862. med_type = "992102"
  28863. }
  28864. if reg_type == 140104 {
  28865. med_type = "140104"
  28866. }
  28867. if reg_type == 14 {
  28868. med_type = "14"
  28869. }
  28870. if reg_type == 140201 {
  28871. med_type = "140201"
  28872. }
  28873. } else if his.Insutype == "310" {
  28874. if reg_type == 1104 {
  28875. med_type = "1104"
  28876. }
  28877. if reg_type == 992102 {
  28878. med_type = "992102"
  28879. }
  28880. if reg_type == 14 {
  28881. med_type = "14"
  28882. }
  28883. if reg_type == 140104 {
  28884. med_type = "140104"
  28885. }
  28886. if reg_type == 140201 {
  28887. med_type = "140201"
  28888. }
  28889. }
  28890. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28891. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28892. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28893. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28894. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28895. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28896. "&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
  28897. resp, requestErr := http.Get(api)
  28898. if requestErr != nil {
  28899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28900. return
  28901. }
  28902. body, ioErr := ioutil.ReadAll(resp.Body)
  28903. if ioErr != nil {
  28904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28906. return
  28907. }
  28908. var respJSON map[string]interface{}
  28909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28912. return
  28913. }
  28914. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28915. if status == "0" {
  28916. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28917. c.ServeSuccessJSON(map[string]interface{}{
  28918. "failed_code": -10,
  28919. "msg": err_msg,
  28920. })
  28921. return
  28922. }
  28923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28924. result, _ := json.Marshal(respJSON)
  28925. fmt.Println("log")
  28926. fmt.Println(string(result))
  28927. if err := json.Unmarshal(result, &ahres); err != nil {
  28928. utils.ErrorLog("解析失败:%v", err)
  28929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28930. return
  28931. }
  28932. res.InfRefmsgid = ahres.InfRefmsgid
  28933. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28934. // 创建对应的Time类型
  28935. t := time.UnixMilli(timestamp)
  28936. // 格式化成指定的日期字符串
  28937. str := t.Format("2006-01-02 15:04:05")
  28938. res.Output.Setlinfo.SetlTime = str
  28939. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28940. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28941. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28942. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28943. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28944. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28945. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28946. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28947. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28948. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28949. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28950. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28951. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28952. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28953. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28954. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28955. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28956. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28957. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28958. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28959. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28960. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28961. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28962. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28963. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28964. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28965. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28966. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28967. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28968. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28969. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28970. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28971. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28972. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28973. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28974. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28975. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28976. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28977. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28978. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28979. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28980. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28981. res.Output.Setldetail = ahres.Output.Setldetail
  28982. res.ErrMsg = ahres.ErrMsg
  28983. res.Cainfo = ahres.Cainfo
  28984. res.WarnMsg = ahres.WarnMsg
  28985. res.Infcode = ahres.Infcode
  28986. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28987. res.Output.Setlinfo.ClrType = "11"
  28988. } else {
  28989. res.Output.Setlinfo.ClrType = "9903"
  28990. }
  28991. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28992. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28993. var cert_no string
  28994. if his.IdCardType == 1 {
  28995. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28996. } else if his.IdCardType == 2 {
  28997. cert_no = his.IdCardNo
  28998. } else {
  28999. cert_no = psn_info.VerifyNumber
  29000. }
  29001. 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, "")
  29002. var dat map[string]interface{}
  29003. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29004. fmt.Println(dat)
  29005. } else {
  29006. fmt.Println(err)
  29007. }
  29008. saveLog(result2, src_resquest, "2207", "结算")
  29009. userJSONBytes, _ := json.Marshal(dat)
  29010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29011. utils.ErrorLog("解析失败:%v", err)
  29012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29013. return
  29014. }
  29015. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29016. psn_info, _ := service.GetPsnByPatientId(id)
  29017. var verify_number string
  29018. if psn_info.IdCardType == 4 {
  29019. verify_number = psn_info.VerifyNumber
  29020. } else if psn_info.IdCardType == 1 {
  29021. bas := strings.Split(psn_info.CardInfo, "|")
  29022. cardNumber := bas[2]
  29023. verify_number = cardNumber
  29024. } else {
  29025. verify_number = psn_info.Certno
  29026. psn_info.IdCardType = 2
  29027. }
  29028. var api string
  29029. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29030. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29031. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29033. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29034. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29035. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29036. resp, requestErr := http.Get(api)
  29037. if requestErr != nil {
  29038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29039. return
  29040. }
  29041. body, ioErr := ioutil.ReadAll(resp.Body)
  29042. if ioErr != nil {
  29043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29045. return
  29046. }
  29047. var respJSON map[string]interface{}
  29048. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29051. return
  29052. }
  29053. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29054. result, _ := json.Marshal(respJSON)
  29055. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29056. utils.ErrorLog("解析失败:%v", err)
  29057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29058. return
  29059. }
  29060. } else {
  29061. var src_resquest string
  29062. if miConfig.Code == "H15049901371" {
  29063. //赤峰地区国家医保医疗类别
  29064. //职工透析:医疗类别选特殊情况门诊990502
  29065. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29066. var med_type string
  29067. if his.Insutype == "390" {
  29068. if reg_type == 14 {
  29069. med_type = "9933"
  29070. } else if reg_type == 11 {
  29071. med_type = "11"
  29072. }
  29073. } else if his.Insutype == "310" {
  29074. if reg_type == 14 {
  29075. med_type = "990502"
  29076. } else if reg_type == 11 {
  29077. med_type = "11"
  29078. }
  29079. }
  29080. 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)
  29081. } else {
  29082. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  29083. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29084. if result3101.Infcode == 0 {
  29085. if len(result3101.Output.Result) > 0 {
  29086. c.ServeSuccessJSON(map[string]interface{}{
  29087. "failed_code": -10,
  29088. "failed_type": 100,
  29089. "warm_type": 2,
  29090. "msg": result3101,
  29091. })
  29092. return
  29093. }
  29094. } else {
  29095. c.ServeSuccessJSON(map[string]interface{}{
  29096. "failed_code": -10,
  29097. "msg": result3101.ErrMsg,
  29098. })
  29099. return
  29100. }
  29101. }
  29102. if his.IdCardType == 4 {
  29103. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29104. token := psn_info.VerifyNumber
  29105. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token, admin_user_id)
  29106. } else {
  29107. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "", admin_user_id)
  29108. }
  29109. }
  29110. var dat map[string]interface{}
  29111. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29112. fmt.Println(dat)
  29113. } else {
  29114. fmt.Println(err)
  29115. }
  29116. saveLog(result2, src_resquest, "2207", "结算")
  29117. userJSONBytes, _ := json.Marshal(dat)
  29118. if miConfig.Code == "H15049901371" {
  29119. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29120. utils.ErrorLog("解析失败:%v", err)
  29121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29122. return
  29123. }
  29124. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29125. res.Output = resSeven10265.Output
  29126. res.ErrMsg = resSeven10265.ErrMsg
  29127. res.Cainfo = resSeven10265.Cainfo
  29128. res.WarnMsg = resSeven10265.WarnMsg
  29129. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29130. res.Infcode = infocode
  29131. } else {
  29132. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29133. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29134. utils.ErrorLog("解析失败:%v", err)
  29135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29136. return
  29137. }
  29138. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29139. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29140. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29141. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29142. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29143. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29144. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29145. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29146. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29147. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29148. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29149. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29150. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29151. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29152. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29153. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29154. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29155. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29156. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29157. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29158. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29159. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29160. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29161. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29162. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29163. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29164. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29165. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29166. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29167. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29168. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29169. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29170. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29171. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29172. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29173. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29174. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29175. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29176. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29177. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29178. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29179. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29180. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29181. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29182. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29183. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29184. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29185. res.Cainfo = gzresSeven10265Two.Cainfo
  29186. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29187. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29188. //res.Infcode = infocode
  29189. } else {
  29190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29191. utils.ErrorLog("解析失败:%v", err)
  29192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29193. return
  29194. }
  29195. }
  29196. }
  29197. }
  29198. if res.Infcode == -1 {
  29199. errlog := &models.HisOrderError{
  29200. UserOrgId: adminUser.CurrentOrgId,
  29201. Ctime: time.Now().Unix(),
  29202. Mtime: time.Now().Unix(),
  29203. Number: chrg_bchno,
  29204. ErrMsg: res.ErrMsg,
  29205. Status: 1,
  29206. PatientId: id,
  29207. RecordTime: recordDateTime,
  29208. Stage: 6,
  29209. }
  29210. service.CreateErrMsgLog(errlog)
  29211. c.ServeSuccessJSON(map[string]interface{}{
  29212. "failed_code": -10,
  29213. "msg": res.ErrMsg,
  29214. })
  29215. return
  29216. } else {
  29217. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29218. order.OrderStatus = 2
  29219. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29220. order.SetlId = res.Output.Setlinfo.SetlID
  29221. order.PsnNo = res.Output.Setlinfo.PsnNo
  29222. order.PsnName = res.Output.Setlinfo.PsnName
  29223. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29224. order.Certno = res.Output.Setlinfo.Certno
  29225. order.Gend = res.Output.Setlinfo.Gend
  29226. order.Naty = res.Output.Setlinfo.Naty
  29227. order.Age = res.Output.Setlinfo.Age
  29228. order.Insutype = res.Output.Setlinfo.Insutype
  29229. order.PsnType = res.Output.Setlinfo.PsnType
  29230. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29231. order.SetlTime = res.Output.Setlinfo.SetlTime
  29232. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29233. order.PayWays = pay_ways
  29234. order.AcctUsedFlag = acct_used_flag
  29235. order.WechatPay = wechat_pay
  29236. order.AliPay = ali_pay
  29237. order.JifenPay = jifen_pay
  29238. order.BandCardPay = band_card_pay
  29239. order.CashPay = cash_pay
  29240. order.OthDesc = oth_desc
  29241. //order.MedType = res.Output.Setlinfo.MedType
  29242. if reg_type == 1112 {
  29243. order.MedType = "1112"
  29244. }
  29245. if reg_type == 1111 {
  29246. order.MedType = "1111"
  29247. }
  29248. order.ClrType = res.Output.Setlinfo.ClrType
  29249. if adminUser.CurrentOrgId == 10480 {
  29250. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29251. order.ClrType = "11"
  29252. } else {
  29253. order.ClrType = "9903"
  29254. }
  29255. }
  29256. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29257. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29258. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29259. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29260. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29261. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29262. order.HifpPay = res.Output.Setlinfo.HifpPay
  29263. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29264. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29265. order.HifesPay = res.Output.Setlinfo.HifesPay
  29266. order.HifobPay = res.Output.Setlinfo.HifobPay
  29267. order.MafPay = res.Output.Setlinfo.MafPay
  29268. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29269. order.OthPay = res.Output.Setlinfo.OthPay
  29270. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29271. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29272. order.AcctPay = res.Output.Setlinfo.AcctPay
  29273. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29274. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29275. order.Balc = res.Output.Setlinfo.Balc
  29276. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29277. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29278. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29279. order.ClrWay = res.Output.Setlinfo.ClrWay
  29280. order.Creator = order.Creator
  29281. order.Modify = roles.AdminUserId
  29282. order.RequestLog = src_resquest
  29283. order.Diagnosis = diagnosis_id
  29284. order.FaPiaoNumber = fapiao_number
  29285. order.FaPiaoCode = fapiao_code
  29286. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29287. detailStr := string(setlDetail)
  29288. order.SetlDetail = detailStr
  29289. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29290. err = service.UpDateOrder(order)
  29291. if err == nil {
  29292. //判断是否使用了押金
  29293. if dec_way == "true" {
  29294. tmpstring := strconv.FormatInt(order.ID, 10)
  29295. //扣押金
  29296. order.Decimal = decimal
  29297. service.UpDateOrder(order)
  29298. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29299. if errmsg != nil {
  29300. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29301. return
  29302. }
  29303. }
  29304. c.ServeSuccessJSON(map[string]interface{}{
  29305. "msg": "结算成功",
  29306. })
  29307. } else {
  29308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29309. return
  29310. }
  29311. }
  29312. }
  29313. }
  29314. }
  29315. // 上传明细-预结算-
  29316. func (c *HisApiController) GetPreUploadInfo() {
  29317. id, _ := c.GetInt64("id")
  29318. record_time := c.GetString("record_time")
  29319. his_patient_id, _ := c.GetInt64("his_patient_id")
  29320. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29321. admin_user_id, _ := c.GetInt64("admin_user_id")
  29322. diagnosis_id := c.GetString("diagnosis")
  29323. sick_type, _ := c.GetInt64("sick_type")
  29324. reg_type, _ := c.GetInt64("p_type")
  29325. begin_time := c.GetString("begin_time")
  29326. acct_used_flag := c.GetString("acct_used_flag")
  29327. id_str := c.GetString("ids")
  29328. ids_arr := strings.Split(id_str, ",")
  29329. timeLayout := "2006-01-02"
  29330. loc, _ := time.LoadLocation("Local")
  29331. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29332. if err != nil {
  29333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29334. return
  29335. }
  29336. recordDateTime := theTime.Unix()
  29337. adminUser := c.GetAdminUserInfo()
  29338. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29339. var config []*models.HisXtDiagnoseConfig
  29340. for _, item := range diagnosis_ids {
  29341. id, _ := strconv.ParseInt(item, 10, 64)
  29342. if id > 0 {
  29343. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29344. config = append(config, &diagnosisConfig)
  29345. }
  29346. }
  29347. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29348. sickConfig, _ := service.FindSickById(sick_type)
  29349. var prescriptions []*models.HisPrescription
  29350. var start_time int64
  29351. var end_time int64
  29352. var isSuccess bool = true
  29353. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29354. fmt.Println(his_patient_id)
  29355. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29356. timestamp := time.Now().Unix()
  29357. tempTime := time.Unix(timestamp, 0)
  29358. timeFormat := tempTime.Format("20060102150405")
  29359. chrgBchno := rand.Intn(100000) + 10000
  29360. new_chrg_bchno := ""
  29361. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29362. new_chrg_bchno = chrg_bchno
  29363. if adminUser.CurrentOrgId == 10265 {
  29364. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29365. new_chrg_bchno = "0000"
  29366. }
  29367. }
  29368. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29369. var patientPrescription models.HisPrescriptionInfo
  29370. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29371. if patientPrescription.ID == 0 {
  29372. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29373. }
  29374. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29375. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29376. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29377. strconv.FormatInt(his.PatientId, 10)
  29378. var res2406 Result2406
  29379. //安徽单病种处理
  29380. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29381. data := make(map[string]interface{})
  29382. client := &http.Client{}
  29383. data["psn_no"] = his.PsnNo
  29384. data["mdtrt_id"] = his.Number
  29385. data["operator"] = roles.UserName
  29386. data["cert_no"] = his.IdCardNo
  29387. data["org_name"] = miConfig.OrgName
  29388. data["psn_name"] = his.Name
  29389. data["ipt_otp_no"] = his.IptOtpNo
  29390. data["ipt_psn_sp_flag_type"] = "0901"
  29391. data["ipt_psn_sp_flag"] = "1"
  29392. data["fixmedins_code"] = miConfig.Code
  29393. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29394. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29395. data["url"] = miConfig.Url
  29396. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29397. bytesData, _ := json.Marshal(data)
  29398. var req *http.Request
  29399. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29400. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29401. resp, _ := client.Do(req)
  29402. defer resp.Body.Close()
  29403. body, ioErr := ioutil.ReadAll(resp.Body)
  29404. if ioErr != nil {
  29405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29407. return
  29408. }
  29409. var respJSON map[string]interface{}
  29410. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29413. return
  29414. }
  29415. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29416. if status == "0" {
  29417. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29418. c.ServeSuccessJSON(map[string]interface{}{
  29419. "failed_code": -10,
  29420. "msg": err_msg,
  29421. })
  29422. return
  29423. }
  29424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29425. userJSONBytes, _ := json.Marshal(respJSON)
  29426. fmt.Println("log")
  29427. fmt.Println(string(userJSONBytes))
  29428. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29429. utils.ErrorLog("解析失败:%v", err)
  29430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29431. return
  29432. }
  29433. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29434. data := make(map[string]interface{})
  29435. client := &http.Client{}
  29436. data["psn_no"] = his.PsnNo
  29437. data["mdtrt_id"] = his.Number
  29438. data["operator"] = roles.UserName
  29439. data["cert_no"] = his.IdCardNo
  29440. data["org_name"] = miConfig.OrgName
  29441. data["psn_name"] = his.Name
  29442. data["ipt_otp_no"] = his.IptOtpNo
  29443. data["ipt_psn_sp_flag_type"] = "0901"
  29444. data["ipt_psn_sp_flag"] = "1"
  29445. data["fixmedins_code"] = miConfig.Code
  29446. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29447. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29448. data["url"] = miConfig.Url
  29449. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29450. bytesData, _ := json.Marshal(data)
  29451. var req *http.Request
  29452. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29453. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29454. resp, _ := client.Do(req)
  29455. defer resp.Body.Close()
  29456. body, ioErr := ioutil.ReadAll(resp.Body)
  29457. if ioErr != nil {
  29458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29460. return
  29461. }
  29462. var respJSON map[string]interface{}
  29463. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29466. return
  29467. }
  29468. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29469. if status == "0" {
  29470. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29471. c.ServeSuccessJSON(map[string]interface{}{
  29472. "failed_code": -10,
  29473. "msg": err_msg,
  29474. })
  29475. return
  29476. }
  29477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29478. userJSONBytes, _ := json.Marshal(respJSON)
  29479. fmt.Println("log")
  29480. fmt.Println(string(userJSONBytes))
  29481. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29482. utils.ErrorLog("解析失败:%v", err)
  29483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29484. return
  29485. }
  29486. }
  29487. if res2406.Infcode != 0 {
  29488. adminUser := c.GetAdminUserInfo()
  29489. errlog := &models.HisOrderError{
  29490. UserOrgId: adminUser.CurrentOrgId,
  29491. Ctime: time.Now().Unix(),
  29492. Mtime: time.Now().Unix(),
  29493. ErrMsg: res2406.ErrMsg,
  29494. Status: 1,
  29495. PatientId: id,
  29496. RecordTime: recordDateTime,
  29497. Stage: 3,
  29498. }
  29499. service.CreateErrMsgLog(errlog)
  29500. c.ServeSuccessJSON(map[string]interface{}{
  29501. "failed_code": -10,
  29502. "msg": res2406.ErrMsg,
  29503. })
  29504. return
  29505. }
  29506. var res2 ResultSix
  29507. var res3 GZResultSix
  29508. var resSix10265 ResultSix10265
  29509. //var time_stamp string
  29510. if miConfig.MdtrtareaAdmvs == "421300" {
  29511. data := make(map[string]interface{})
  29512. client := &http.Client{}
  29513. data["psn_no"] = his.PsnNo
  29514. data["mdtrt_id"] = his.Number
  29515. data["department"] = department.Name
  29516. data["org_name"] = miConfig.OrgName
  29517. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29518. data["doctor_id"] = doctor_info.DoctorNumber
  29519. data["doctor_name"] = roles.UserName
  29520. data["fixmedins_code"] = miConfig.Code
  29521. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29522. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29523. data["secret_key"] = miConfig.SecretKey
  29524. data["sick_code"] = sickConfig.CountryCode
  29525. data["sick_name"] = sickConfig.ClassName
  29526. data["begin_time"] = begin_time
  29527. data["dept"] = strconv.FormatInt(department.ID, 10)
  29528. data["config"] = config
  29529. data["opter"] = roles.UserName
  29530. fmt.Println(data)
  29531. bytesData, _ := json.Marshal(data)
  29532. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29533. resp, _ := client.Do(req)
  29534. defer resp.Body.Close()
  29535. body, ioErr := ioutil.ReadAll(resp.Body)
  29536. if ioErr != nil {
  29537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29539. return
  29540. }
  29541. var respJSON map[string]interface{}
  29542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29545. return
  29546. }
  29547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29548. userJSONBytes, _ := json.Marshal(respJSON)
  29549. fmt.Println("log")
  29550. fmt.Println(string(userJSONBytes))
  29551. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29552. utils.ErrorLog("解析失败:%v", err)
  29553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29554. return
  29555. }
  29556. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29557. data := make(map[string]interface{})
  29558. client := &http.Client{}
  29559. data["psn_no"] = his.PsnNo
  29560. data["mdtrt_id"] = his.Number
  29561. data["department"] = department.Name
  29562. data["org_name"] = miConfig.OrgName
  29563. if reg_type == 11 && his.Insutype == "390" {
  29564. data["med_type"] = "110104"
  29565. } else {
  29566. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29567. }
  29568. data["doctor_id"] = doctor_info.DoctorNumber
  29569. data["doctor_name"] = roles.UserName
  29570. data["fixmedins_code"] = miConfig.Code
  29571. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29572. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29573. data["secret_key"] = miConfig.SecretKey
  29574. data["sick_code"] = sickConfig.CountryCode
  29575. data["sick_name"] = sickConfig.ClassName
  29576. data["begin_time"] = begin_time
  29577. data["dept"] = strconv.FormatInt(department.ID, 10)
  29578. data["config"] = config
  29579. data["opter"] = roles.UserName
  29580. fmt.Println(data)
  29581. bytesData, _ := json.Marshal(data)
  29582. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29583. resp, _ := client.Do(req)
  29584. defer resp.Body.Close()
  29585. body, ioErr := ioutil.ReadAll(resp.Body)
  29586. if ioErr != nil {
  29587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29589. return
  29590. }
  29591. var respJSON map[string]interface{}
  29592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29595. return
  29596. }
  29597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29598. userJSONBytes, _ := json.Marshal(respJSON)
  29599. fmt.Println("log")
  29600. fmt.Println(string(userJSONBytes))
  29601. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29602. utils.ErrorLog("解析失败:%v", err)
  29603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29604. return
  29605. }
  29606. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29607. data := make(map[string]interface{})
  29608. client := &http.Client{}
  29609. data["psn_no"] = his.PsnNo
  29610. data["mdtrt_id"] = his.Number
  29611. data["department"] = department.Name
  29612. data["org_name"] = miConfig.OrgName
  29613. if reg_type == 11 && his.Insutype == "390" {
  29614. data["med_type"] = "110104"
  29615. } else {
  29616. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29617. }
  29618. data["doctor_id"] = doctor_info.DoctorNumber
  29619. data["doctor_name"] = roles.UserName
  29620. data["fixmedins_code"] = miConfig.Code
  29621. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29622. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29623. data["secret_key"] = miConfig.SecretKey
  29624. data["sick_code"] = sickConfig.CountryCode
  29625. data["sick_name"] = sickConfig.ClassName
  29626. data["begin_time"] = begin_time
  29627. data["dept"] = strconv.FormatInt(department.ID, 10)
  29628. data["config"] = config
  29629. data["opter"] = roles.UserName
  29630. fmt.Println(data)
  29631. bytesData, _ := json.Marshal(data)
  29632. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29633. resp, _ := client.Do(req)
  29634. defer resp.Body.Close()
  29635. body, ioErr := ioutil.ReadAll(resp.Body)
  29636. if ioErr != nil {
  29637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29639. return
  29640. }
  29641. var respJSON map[string]interface{}
  29642. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29645. return
  29646. }
  29647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29648. userJSONBytes, _ := json.Marshal(respJSON)
  29649. fmt.Println("log")
  29650. fmt.Println(string(userJSONBytes))
  29651. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29652. utils.ErrorLog("解析失败:%v", err)
  29653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29654. return
  29655. }
  29656. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29657. data := make(map[string]interface{})
  29658. client := &http.Client{}
  29659. data["psn_no"] = his.PsnNo
  29660. data["mdtrt_id"] = his.Number
  29661. data["department"] = department.Name
  29662. data["org_name"] = miConfig.OrgName
  29663. if reg_type == 11 && his.Insutype == "390" {
  29664. data["med_type"] = "110104"
  29665. } else {
  29666. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29667. }
  29668. data["doctor_id"] = doctor_info.DoctorNumber
  29669. data["doctor_name"] = roles.UserName
  29670. data["fixmedins_code"] = miConfig.Code
  29671. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29672. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29673. data["secret_key"] = miConfig.SecretKey
  29674. data["sick_code"] = sickConfig.CountryCode
  29675. data["sick_name"] = sickConfig.ClassName
  29676. data["begin_time"] = begin_time
  29677. data["dept"] = strconv.FormatInt(department.ID, 10)
  29678. data["config"] = config
  29679. data["opter"] = roles.UserName
  29680. fmt.Println(data)
  29681. bytesData, _ := json.Marshal(data)
  29682. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29683. resp, _ := client.Do(req)
  29684. defer resp.Body.Close()
  29685. body, ioErr := ioutil.ReadAll(resp.Body)
  29686. if ioErr != nil {
  29687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29689. return
  29690. }
  29691. var respJSON map[string]interface{}
  29692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29695. return
  29696. }
  29697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29698. userJSONBytes, _ := json.Marshal(respJSON)
  29699. fmt.Println("log")
  29700. fmt.Println(string(userJSONBytes))
  29701. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29702. utils.ErrorLog("解析失败:%v", err)
  29703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29704. return
  29705. }
  29706. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29707. utils.ErrorLog("解析失败:%v", doctor_info)
  29708. data := make(map[string]interface{})
  29709. client := &http.Client{}
  29710. data["psn_no"] = his.PsnNo
  29711. data["mdtrt_id"] = his.Number
  29712. data["doctor"] = roles.UserName
  29713. data["department"] = department.Name
  29714. data["org_name"] = miConfig.OrgName
  29715. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29716. data["doctor_id"] = doctor_info.DoctorNumber
  29717. data["new_doctor_name"] = doctor_info.UserName
  29718. data["fixmedins_code"] = miConfig.Code
  29719. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29720. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29721. data["secret_key"] = miConfig.SecretKey
  29722. data["sick_code"] = sickConfig.CountryCode
  29723. data["sick_name"] = sickConfig.ClassName
  29724. data["url"] = miConfig.Url
  29725. data["ak"] = miConfig.AccessKey
  29726. data["begin_time"] = begin_time
  29727. data["cainfo"] = miConfig.Cainfo
  29728. data["dept"] = strconv.FormatInt(department.ID, 10)
  29729. data["config"] = config
  29730. bytesData, _ := json.Marshal(data)
  29731. var req *http.Request
  29732. if miConfig.MdtrtareaAdmvs == "320830" {
  29733. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29734. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29735. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29736. } else {
  29737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29738. }
  29739. resp, _ := client.Do(req)
  29740. defer resp.Body.Close()
  29741. body, ioErr := ioutil.ReadAll(resp.Body)
  29742. if ioErr != nil {
  29743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29745. return
  29746. }
  29747. var respJSON map[string]interface{}
  29748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29751. return
  29752. }
  29753. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29754. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29755. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29757. userJSONBytes, _ := json.Marshal(respJSON)
  29758. fmt.Println("log")
  29759. fmt.Println(string(userJSONBytes))
  29760. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29761. utils.ErrorLog("解析失败:%v", err)
  29762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29763. return
  29764. }
  29765. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29766. res2.Output = resSix10265.Output
  29767. res2.ErrMsg = resSix10265.ErrMsg
  29768. res2.Cainfo = resSix10265.Cainfo
  29769. res2.WarnMsg = resSix10265.WarnMsg
  29770. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29771. res2.Infcode = infocode
  29772. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29773. data := make(map[string]interface{})
  29774. client := &http.Client{}
  29775. data["psn_no"] = his.PsnNo
  29776. data["mdtrt_id"] = his.Number
  29777. data["doctor"] = roles.UserName
  29778. data["department"] = department.Name
  29779. data["org_name"] = miConfig.OrgName
  29780. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29781. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29782. data["fixmedins_code"] = miConfig.Code
  29783. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29784. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29785. data["secret_key"] = miConfig.SecretKey
  29786. data["sick_code"] = sickConfig.CountryCode
  29787. data["sick_name"] = sickConfig.ClassName
  29788. data["begin_time"] = begin_time
  29789. data["dept"] = strconv.FormatInt(department.ID, 10)
  29790. data["config"] = config
  29791. //data["url"] = miConfig.Url
  29792. //data["ak"] = miConfig.AccessKey
  29793. data["cainfo"] = miConfig.Cainfo
  29794. fmt.Println(data)
  29795. bytesData, _ := json.Marshal(data)
  29796. var req *http.Request
  29797. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29798. resp, _ := client.Do(req)
  29799. defer resp.Body.Close()
  29800. body, ioErr := ioutil.ReadAll(resp.Body)
  29801. if ioErr != nil {
  29802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29804. return
  29805. }
  29806. var respJSON map[string]interface{}
  29807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29810. return
  29811. }
  29812. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29813. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29814. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29816. userJSONBytes, _ := json.Marshal(respJSON)
  29817. fmt.Println("log")
  29818. fmt.Println(string(userJSONBytes))
  29819. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29820. utils.ErrorLog("解析失败:%v", err)
  29821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29822. return
  29823. }
  29824. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29825. res2.Output = resSix10265.Output
  29826. res2.ErrMsg = resSix10265.ErrMsg
  29827. res2.Cainfo = resSix10265.Cainfo
  29828. res2.WarnMsg = resSix10265.WarnMsg
  29829. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29830. res2.Infcode = infocode
  29831. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29832. 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)
  29833. saveLog(result, requestLog, "2203", "上传就诊信息")
  29834. var respJSON2 map[string]interface{}
  29835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29838. return
  29839. }
  29840. userJSONBytes2, _ := json.Marshal(respJSON2)
  29841. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29842. utils.ErrorLog("解析失败:%v", err)
  29843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29844. return
  29845. }
  29846. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29847. var result string
  29848. var requestLog string
  29849. 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, "")
  29850. saveLog(result, requestLog, "2203", "上传就诊信息")
  29851. var respJSON2 map[string]interface{}
  29852. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29855. return
  29856. }
  29857. userJSONBytes2, _ := json.Marshal(respJSON2)
  29858. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29859. utils.ErrorLog("解析失败:%v", err)
  29860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29861. return
  29862. }
  29863. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29864. var result string
  29865. var requestLog string
  29866. 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, "")
  29867. saveLog(result, requestLog, "2203", "上传就诊信息")
  29868. var respJSON2 map[string]interface{}
  29869. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29872. return
  29873. }
  29874. userJSONBytes2, _ := json.Marshal(respJSON2)
  29875. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29876. utils.ErrorLog("解析失败:%v", err)
  29877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29878. return
  29879. }
  29880. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29881. var result string
  29882. var requestLog string
  29883. 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, "")
  29884. saveLog(result, requestLog, "2203", "上传就诊信息")
  29885. var respJSON2 map[string]interface{}
  29886. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29889. return
  29890. }
  29891. userJSONBytes2, _ := json.Marshal(respJSON2)
  29892. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29893. utils.ErrorLog("解析失败:%v", err)
  29894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29895. return
  29896. }
  29897. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29898. data := make(map[string]interface{})
  29899. client := &http.Client{}
  29900. data["psn_no"] = his.PsnNo
  29901. data["mdtrt_id"] = his.Number
  29902. data["operator"] = roles.UserName
  29903. data["department"] = department.Name
  29904. data["org_name"] = miConfig.OrgName
  29905. var med_type string
  29906. if his.Insutype == "390" {
  29907. if reg_type == 992102 {
  29908. med_type = "992102"
  29909. data["sick_code"] = "ZDZ940"
  29910. data["sick_name"] = "慢性肾衰竭"
  29911. }
  29912. if reg_type == 140104 {
  29913. med_type = "140104"
  29914. data["sick_code"] = sickConfig.CountryCode
  29915. data["sick_name"] = sickConfig.ClassName
  29916. }
  29917. if reg_type == 14 {
  29918. med_type = "140104"
  29919. data["sick_code"] = sickConfig.CountryCode
  29920. data["sick_name"] = sickConfig.ClassName
  29921. }
  29922. if reg_type == 1104 {
  29923. med_type = "1104"
  29924. data["sick_code"] = sickConfig.CountryCode
  29925. data["sick_name"] = sickConfig.ClassName
  29926. }
  29927. } else if his.Insutype == "310" {
  29928. if reg_type == 992102 {
  29929. med_type = "992102"
  29930. data["sick_code"] = "ZDZ940"
  29931. data["sick_name"] = "慢性肾衰竭"
  29932. }
  29933. if reg_type == 140104 {
  29934. med_type = "140104"
  29935. data["sick_code"] = sickConfig.CountryCode
  29936. data["sick_name"] = sickConfig.ClassName
  29937. }
  29938. if reg_type == 14 {
  29939. med_type = "14"
  29940. data["sick_code"] = sickConfig.CountryCode
  29941. data["sick_name"] = sickConfig.ClassName
  29942. }
  29943. if reg_type == 1104 {
  29944. med_type = "1104"
  29945. data["sick_code"] = sickConfig.CountryCode
  29946. data["sick_name"] = sickConfig.ClassName
  29947. }
  29948. }
  29949. data["med_type"] = med_type
  29950. data["doctor_number"] = doctor_info.DoctorNumber
  29951. data["doctor_name"] = doctor_info.UserName
  29952. data["fixmedins_code"] = miConfig.Code
  29953. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29954. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29955. data["secret_key"] = miConfig.SecretKey
  29956. data["begin_time"] = begin_time
  29957. data["dept"] = strconv.FormatInt(department.ID, 10)
  29958. data["config"] = config
  29959. data["url"] = miConfig.Url
  29960. data["ak"] = miConfig.AccessKey
  29961. data["cainfo"] = miConfig.Cainfo
  29962. bytesData, _ := json.Marshal(data)
  29963. var req *http.Request
  29964. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29965. resp, _ := client.Do(req)
  29966. defer resp.Body.Close()
  29967. body, ioErr := ioutil.ReadAll(resp.Body)
  29968. if ioErr != nil {
  29969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29971. return
  29972. }
  29973. var respJSON map[string]interface{}
  29974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29977. return
  29978. }
  29979. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29980. if status == "0" {
  29981. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29982. c.ServeSuccessJSON(map[string]interface{}{
  29983. "failed_code": -10,
  29984. "msg": err_msg,
  29985. })
  29986. return
  29987. }
  29988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29989. userJSONBytes, _ := json.Marshal(respJSON)
  29990. fmt.Println("log")
  29991. fmt.Println(string(userJSONBytes))
  29992. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29993. utils.ErrorLog("解析失败:%v", err)
  29994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29995. return
  29996. }
  29997. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29998. data := make(map[string]interface{})
  29999. client := &http.Client{}
  30000. data["psn_no"] = his.PsnNo
  30001. data["mdtrt_id"] = his.Number
  30002. data["operator"] = roles.UserName
  30003. data["department"] = department.Name
  30004. data["org_name"] = miConfig.OrgName
  30005. var med_type string
  30006. if his.Insutype == "390" {
  30007. if reg_type == 992102 {
  30008. med_type = "992102"
  30009. data["sick_code"] = sickConfig.CountryCode
  30010. data["sick_name"] = sickConfig.ClassName
  30011. }
  30012. if reg_type == 140104 {
  30013. med_type = "140104"
  30014. data["sick_code"] = sickConfig.CountryCode
  30015. data["sick_name"] = sickConfig.ClassName
  30016. }
  30017. if reg_type == 140201 {
  30018. med_type = "140201"
  30019. data["sick_code"] = sickConfig.CountryCode
  30020. data["sick_name"] = sickConfig.ClassName
  30021. }
  30022. if reg_type == 14 {
  30023. med_type = "14"
  30024. data["sick_code"] = sickConfig.CountryCode
  30025. data["sick_name"] = sickConfig.ClassName
  30026. }
  30027. if reg_type == 11 {
  30028. med_type = "11"
  30029. data["sick_code"] = sickConfig.CountryCode
  30030. data["sick_name"] = sickConfig.ClassName
  30031. }
  30032. } else if his.Insutype == "310" {
  30033. if reg_type == 992102 {
  30034. med_type = "992102"
  30035. data["sick_code"] = sickConfig.CountryCode
  30036. data["sick_name"] = sickConfig.ClassName
  30037. }
  30038. if reg_type == 140104 {
  30039. med_type = "140104"
  30040. data["sick_code"] = sickConfig.CountryCode
  30041. data["sick_name"] = sickConfig.ClassName
  30042. }
  30043. if reg_type == 140201 {
  30044. med_type = "140201"
  30045. data["sick_code"] = sickConfig.CountryCode
  30046. data["sick_name"] = sickConfig.ClassName
  30047. }
  30048. if reg_type == 14 {
  30049. med_type = "14"
  30050. data["sick_code"] = sickConfig.CountryCode
  30051. data["sick_name"] = sickConfig.ClassName
  30052. }
  30053. if reg_type == 11 {
  30054. med_type = "11"
  30055. data["sick_code"] = sickConfig.CountryCode
  30056. data["sick_name"] = sickConfig.ClassName
  30057. }
  30058. }
  30059. data["med_type"] = med_type
  30060. data["doctor_number"] = doctor_info.DoctorNumber
  30061. data["doctor_name"] = doctor_info.UserName
  30062. data["fixmedins_code"] = miConfig.Code
  30063. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30064. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30065. data["secret_key"] = miConfig.SecretKey
  30066. data["begin_time"] = begin_time
  30067. data["dept"] = strconv.FormatInt(department.ID, 10)
  30068. data["config"] = config
  30069. data["url"] = miConfig.Url
  30070. data["ak"] = miConfig.AccessKey
  30071. data["cainfo"] = miConfig.Cainfo
  30072. bytesData, _ := json.Marshal(data)
  30073. var req *http.Request
  30074. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30075. resp, _ := client.Do(req)
  30076. defer resp.Body.Close()
  30077. body, ioErr := ioutil.ReadAll(resp.Body)
  30078. if ioErr != nil {
  30079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30081. return
  30082. }
  30083. var respJSON map[string]interface{}
  30084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30087. return
  30088. }
  30089. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30090. if status == "0" {
  30091. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30092. c.ServeSuccessJSON(map[string]interface{}{
  30093. "failed_code": -10,
  30094. "msg": err_msg,
  30095. })
  30096. return
  30097. }
  30098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30099. userJSONBytes, _ := json.Marshal(respJSON)
  30100. fmt.Println("log")
  30101. fmt.Println(string(userJSONBytes))
  30102. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30103. utils.ErrorLog("解析失败:%v", err)
  30104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30105. return
  30106. }
  30107. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30108. var result string
  30109. var requestLog string
  30110. result, requestLog = service.Hnyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "", begin_time)
  30111. saveLog(result, requestLog, "2203", "上传就诊信息")
  30112. var respJSON2 map[string]interface{}
  30113. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30116. return
  30117. }
  30118. userJSONBytes2, _ := json.Marshal(respJSON2)
  30119. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30120. utils.ErrorLog("解析失败:%v", err)
  30121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30122. return
  30123. }
  30124. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30125. data := make(map[string]interface{})
  30126. client := &http.Client{}
  30127. data["psn_no"] = his.PsnNo
  30128. data["mdtrt_id"] = his.Number
  30129. data["doctor"] = roles.UserName
  30130. data["department"] = department.Name
  30131. data["org_name"] = miConfig.OrgName
  30132. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30133. data["doctor_id"] = doctor_info.DoctorNumber
  30134. data["fixmedins_code"] = miConfig.Code
  30135. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30136. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30137. data["secret_key"] = miConfig.SecretKey
  30138. data["sick_code"] = sickConfig.CountryCode
  30139. data["sick_name"] = sickConfig.ClassName
  30140. data["begin_time"] = begin_time
  30141. data["new_doctor_name"] = doctor_info.UserName
  30142. data["dept"] = strconv.FormatInt(department.ID, 10)
  30143. data["config"] = config
  30144. bytesData, _ := json.Marshal(data)
  30145. var req *http.Request
  30146. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30147. resp, _ := client.Do(req)
  30148. defer resp.Body.Close()
  30149. body, ioErr := ioutil.ReadAll(resp.Body)
  30150. if ioErr != nil {
  30151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30153. return
  30154. }
  30155. var respJSON map[string]interface{}
  30156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30159. return
  30160. }
  30161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30162. userJSONBytes, _ := json.Marshal(respJSON)
  30163. fmt.Println("log")
  30164. fmt.Println(string(userJSONBytes))
  30165. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30166. utils.ErrorLog("解析失败:%v", err)
  30167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30168. return
  30169. }
  30170. } else {
  30171. var result string
  30172. var requestLog string
  30173. if miConfig.MdtrtareaAdmvs == "440781" { //
  30174. 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)
  30175. } else {
  30176. if miConfig.Code == "H15049901371" {
  30177. //赤峰地区国家医保医疗类别
  30178. //职工透析:医疗类别选特殊情况门诊990502
  30179. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30180. var med_type string
  30181. if his.Insutype == "390" {
  30182. if reg_type == 14 {
  30183. med_type = "9933"
  30184. } else if reg_type == 11 {
  30185. med_type = "11"
  30186. }
  30187. } else if his.Insutype == "310" {
  30188. if reg_type == 14 {
  30189. med_type = "990502"
  30190. } else if reg_type == 11 {
  30191. med_type = "11"
  30192. }
  30193. }
  30194. 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)
  30195. } else {
  30196. 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)
  30197. }
  30198. saveLog(result, requestLog, "2203", "上传就诊信息")
  30199. var respJSON2 map[string]interface{}
  30200. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30203. return
  30204. }
  30205. userJSONBytes2, _ := json.Marshal(respJSON2)
  30206. if miConfig.Code == "H15049901371" {
  30207. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30208. utils.ErrorLog("解析失败:%v", err)
  30209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30210. return
  30211. }
  30212. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30213. res2.Output = resSix10265.Output
  30214. res2.ErrMsg = resSix10265.ErrMsg
  30215. res2.Cainfo = resSix10265.Cainfo
  30216. res2.WarnMsg = resSix10265.WarnMsg
  30217. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30218. res2.Infcode = infocode
  30219. } else {
  30220. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30221. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30222. utils.ErrorLog("解析失败:%v", err)
  30223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30224. return
  30225. }
  30226. res2.Infcode = res3.Infcode
  30227. } else {
  30228. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30229. utils.ErrorLog("解析失败:%v", err)
  30230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30231. return
  30232. }
  30233. }
  30234. }
  30235. }
  30236. }
  30237. if res2.Infcode == -1 {
  30238. adminUser := c.GetAdminUserInfo()
  30239. errlog := &models.HisOrderError{
  30240. UserOrgId: adminUser.CurrentOrgId,
  30241. Ctime: time.Now().Unix(),
  30242. Mtime: time.Now().Unix(),
  30243. ErrMsg: res2.ErrMsg,
  30244. Status: 1,
  30245. PatientId: id,
  30246. RecordTime: recordDateTime,
  30247. Stage: 3,
  30248. }
  30249. service.CreateErrMsgLog(errlog)
  30250. c.ServeSuccessJSON(map[string]interface{}{
  30251. "failed_code": -10,
  30252. "msg": res2.ErrMsg,
  30253. })
  30254. return
  30255. }
  30256. if res2.Infcode != 0 {
  30257. adminUser := c.GetAdminUserInfo()
  30258. errlog := &models.HisOrderError{
  30259. UserOrgId: adminUser.CurrentOrgId,
  30260. Ctime: time.Now().Unix(),
  30261. Mtime: time.Now().Unix(),
  30262. ErrMsg: res2.ErrMsg,
  30263. Status: 1,
  30264. PatientId: id,
  30265. RecordTime: recordDateTime,
  30266. Stage: 3,
  30267. }
  30268. service.CreateErrMsgLog(errlog)
  30269. c.ServeSuccessJSON(map[string]interface{}{
  30270. "failed_code": -10,
  30271. "msg": res2.ErrMsg,
  30272. })
  30273. return
  30274. } else {
  30275. his.Diagnosis = diagnosis_id
  30276. his.SickType = sickConfig.ID
  30277. his.PType = fmt.Sprintf("%d", reg_type)
  30278. service.UpdateHisPatientThree(&his)
  30279. data := make(map[string]interface{})
  30280. if settle_accounts_type == 1 { //日结
  30281. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30282. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30283. } else {
  30284. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30285. }
  30286. data["pre"] = prescriptions
  30287. } else { //月结
  30288. start_time_str := c.GetString("start_time")
  30289. end_time_str := c.GetString("end_time")
  30290. timeLayout := "2006-01-02"
  30291. loc, _ := time.LoadLocation("Local")
  30292. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30293. if err != nil {
  30294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30295. return
  30296. }
  30297. recordStartTime := theStartTime.Unix()
  30298. start_time = recordStartTime
  30299. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30300. if err != nil {
  30301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30302. return
  30303. }
  30304. recordEndTime := theEndTime.Unix()
  30305. end_time = recordEndTime
  30306. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30307. data["pre"] = prescriptions
  30308. }
  30309. client := &http.Client{}
  30310. data["psn_no"] = his.PsnNo
  30311. data["mdtrt_id"] = his.Number
  30312. data["chrg_bchno"] = new_chrg_bchno
  30313. data["org_name"] = miConfig.OrgName
  30314. data["doctor"] = doctor_info.UserName
  30315. data["doctor_id"] = doctor_info.DoctorNumber
  30316. data["dept"] = department.Name
  30317. data["fixmedins_code"] = miConfig.Code
  30318. data["opter"] = roles.UserName
  30319. data["dept_code"] = department.Number
  30320. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30321. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30322. data["secret_key"] = miConfig.SecretKey
  30323. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30324. data["url"] = miConfig.Url
  30325. data["ak"] = miConfig.AccessKey
  30326. data["new_doctor_name"] = patientPrescription.Doctor
  30327. if his.Insutype == "390" {
  30328. if reg_type == 992102 {
  30329. data["diag_code"] = "ZDZ940"
  30330. }
  30331. if reg_type == 140104 {
  30332. data["diag_code"] = sickConfig.CountryCode
  30333. }
  30334. if reg_type == 140201 {
  30335. data["diag_code"] = sickConfig.CountryCode
  30336. }
  30337. if reg_type == 14 {
  30338. data["diag_code"] = sickConfig.CountryCode
  30339. }
  30340. if reg_type == 1104 {
  30341. data["diag_code"] = sickConfig.CountryCode
  30342. }
  30343. } else if his.Insutype == "310" {
  30344. if miConfig.MdtrtareaAdmvs == "341203" {
  30345. if reg_type == 992102 {
  30346. data["diag_code"] = "ZDZ940"
  30347. }
  30348. if reg_type != 992102 {
  30349. data["diag_code"] = sickConfig.CountryCode
  30350. }
  30351. } else {
  30352. data["diag_code"] = sickConfig.CountryCode
  30353. }
  30354. }
  30355. data["cainfo"] = miConfig.Cainfo
  30356. data["opter"] = roles.UserName
  30357. var ids []int64
  30358. for _, item := range prescriptions {
  30359. ids = append(ids, item.ID)
  30360. }
  30361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30362. if config.IsOpen == 1 { //对接了医保,走医保流程
  30363. var res ResultFour
  30364. var resFour10265 ResultFour10265
  30365. if miConfig.MdtrtareaAdmvs == "421300" {
  30366. bytesData, _ := json.Marshal(data)
  30367. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30368. resp, _ := client.Do(req)
  30369. defer resp.Body.Close()
  30370. body, ioErr := ioutil.ReadAll(resp.Body)
  30371. if ioErr != nil {
  30372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30374. return
  30375. }
  30376. var respJSON map[string]interface{}
  30377. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30380. return
  30381. }
  30382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30383. userJSONBytes, _ := json.Marshal(respJSON)
  30384. fmt.Println("log")
  30385. fmt.Println(string(userJSONBytes))
  30386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30387. utils.ErrorLog("解析失败:%v", err)
  30388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30389. return
  30390. }
  30391. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30392. bytesData, _ := json.Marshal(data)
  30393. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30394. resp, _ := client.Do(req)
  30395. defer resp.Body.Close()
  30396. body, ioErr := ioutil.ReadAll(resp.Body)
  30397. if ioErr != nil {
  30398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30400. return
  30401. }
  30402. var respJSON map[string]interface{}
  30403. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30406. return
  30407. }
  30408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30409. userJSONBytes, _ := json.Marshal(respJSON)
  30410. fmt.Println("log")
  30411. fmt.Println(string(userJSONBytes))
  30412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30413. utils.ErrorLog("解析失败:%v", err)
  30414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30415. return
  30416. }
  30417. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30418. bytesData, _ := json.Marshal(data)
  30419. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30420. resp, _ := client.Do(req)
  30421. defer resp.Body.Close()
  30422. body, ioErr := ioutil.ReadAll(resp.Body)
  30423. if ioErr != nil {
  30424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30426. return
  30427. }
  30428. var respJSON map[string]interface{}
  30429. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30432. return
  30433. }
  30434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30435. userJSONBytes, _ := json.Marshal(respJSON)
  30436. fmt.Println("log")
  30437. fmt.Println(string(userJSONBytes))
  30438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30439. utils.ErrorLog("解析失败:%v", err)
  30440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30441. return
  30442. }
  30443. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30444. bytesData, _ := json.Marshal(data)
  30445. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30446. resp, _ := client.Do(req)
  30447. defer resp.Body.Close()
  30448. body, ioErr := ioutil.ReadAll(resp.Body)
  30449. if ioErr != nil {
  30450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30452. return
  30453. }
  30454. var respJSON map[string]interface{}
  30455. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30458. return
  30459. }
  30460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30461. userJSONBytes, _ := json.Marshal(respJSON)
  30462. fmt.Println("log")
  30463. fmt.Println(string(userJSONBytes))
  30464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30465. utils.ErrorLog("解析失败:%v", err)
  30466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30467. return
  30468. }
  30469. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30470. var result3101 Result3101
  30471. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30472. result3101.Infcode = "0"
  30473. if result3101.Infcode == "0" {
  30474. if len(result3101.Output.Result) > 0 {
  30475. var errMsgs []string
  30476. for _, item := range result3101.Output.Result {
  30477. errMsgs = append(errMsgs, item.VolaCont)
  30478. }
  30479. c.ServeSuccessJSON(map[string]interface{}{
  30480. "failed_code": -10,
  30481. "msg": errMsgs,
  30482. })
  30483. return
  30484. } else {
  30485. if miConfig.MdtrtareaAdmvs == "320921" {
  30486. data["doctor_id"] = doctor_info.DoctorNumber
  30487. } else {
  30488. data["doctor_id"] = doctor_info.DoctorNumber
  30489. }
  30490. bytesData, _ := json.Marshal(data)
  30491. var req *http.Request
  30492. if miConfig.MdtrtareaAdmvs == "320830" {
  30493. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30494. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30495. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30496. } else {
  30497. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30498. }
  30499. resp, _ := client.Do(req)
  30500. defer resp.Body.Close()
  30501. body, ioErr := ioutil.ReadAll(resp.Body)
  30502. if ioErr != nil {
  30503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30505. return
  30506. }
  30507. var respJSON map[string]interface{}
  30508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30511. return
  30512. }
  30513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30514. userJSONBytes, _ := json.Marshal(respJSON)
  30515. fmt.Println("log")
  30516. fmt.Println(string(userJSONBytes))
  30517. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30518. utils.ErrorLog("解析失败:%v", err)
  30519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30520. return
  30521. }
  30522. res.InfRefmsgid = resFour10265.InfRefmsgid
  30523. res.Output = resFour10265.Output
  30524. res.ErrMsg = resFour10265.ErrMsg
  30525. res.Cainfo = resFour10265.Cainfo
  30526. res.WarnMsg = resFour10265.WarnMsg
  30527. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30528. res.Infcode = infocode
  30529. }
  30530. }
  30531. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30532. var pagesize int = 5
  30533. var start int = 1
  30534. var stop int
  30535. var pagecount int
  30536. var curpage int
  30537. data["doctor_id"] = doctor_info.DoctorNumber
  30538. var res2 ResultFour
  30539. //var result res.
  30540. //总页数,向上取整,注意除之前要先转换类型为float64
  30541. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30542. for curpage = 1; curpage <= pagecount; curpage++ {
  30543. if curpage == 1 {
  30544. start = 1
  30545. } else {
  30546. start = (curpage-1)*pagesize + 1
  30547. }
  30548. stop = curpage * pagesize
  30549. if stop > len(prescriptions) {
  30550. stop = len(prescriptions)
  30551. }
  30552. //var requestLog string
  30553. data["pre"] = prescriptions[start-1 : stop]
  30554. fmt.Println(data["pre"])
  30555. bytesData, _ := json.Marshal(data)
  30556. var req *http.Request
  30557. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30558. resp, _ := client.Do(req)
  30559. defer resp.Body.Close()
  30560. body, ioErr := ioutil.ReadAll(resp.Body)
  30561. if ioErr != nil {
  30562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30564. return
  30565. }
  30566. var respJSON map[string]interface{}
  30567. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30570. return
  30571. }
  30572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30573. userJSONBytes, _ := json.Marshal(respJSON)
  30574. fmt.Println("log")
  30575. fmt.Println(string(userJSONBytes))
  30576. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30577. utils.ErrorLog("解析失败:%v", err)
  30578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30579. return
  30580. }
  30581. res.InfRefmsgid = resFour10265.InfRefmsgid
  30582. res.Output = resFour10265.Output
  30583. res.ErrMsg = resFour10265.ErrMsg
  30584. res.Cainfo = resFour10265.Cainfo
  30585. res.WarnMsg = resFour10265.WarnMsg
  30586. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30587. res.Infcode = infocode
  30588. if infocode == 0 {
  30589. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30590. } else {
  30591. isSuccess = false
  30592. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30593. res.Infcode = -1
  30594. res.ErrMsg = resFour10265.ErrMsg
  30595. errlog := &models.HisOrderError{
  30596. UserOrgId: adminUser.CurrentOrgId,
  30597. Ctime: time.Now().Unix(),
  30598. Mtime: time.Now().Unix(),
  30599. Number: chrg_bchno,
  30600. ErrMsg: "",
  30601. Status: 1,
  30602. PatientId: id,
  30603. RecordTime: recordDateTime,
  30604. Stage: 4,
  30605. }
  30606. service.CreateErrMsgLog(errlog)
  30607. }
  30608. }
  30609. if isSuccess {
  30610. res.Infcode = 0
  30611. res.Output.Result = res2.Output.Result
  30612. } else {
  30613. order := &models.HisOrder{
  30614. UserOrgId: adminUser.CurrentOrgId,
  30615. HisPatientId: his.ID,
  30616. PatientId: his.PatientId,
  30617. SettleAccountsDate: recordDateTime,
  30618. Ctime: time.Now().Unix(),
  30619. Mtime: time.Now().Unix(),
  30620. MdtrtId: his.Number,
  30621. PsnNo: his.PsnNo,
  30622. MedType: strconv.FormatInt(reg_type, 10),
  30623. Status: 1,
  30624. Number: chrg_bchno,
  30625. Infcode: res.Infcode,
  30626. WarnMsg: res.WarnMsg,
  30627. Cainfo: res.Cainfo,
  30628. ErrMsg: res.ErrMsg,
  30629. RespondTime: res.RefmsgTime,
  30630. InfRefmsgid: res.InfRefmsgid,
  30631. OrderStatus: 1,
  30632. IsMedicineInsurance: 1,
  30633. SettleType: settle_accounts_type,
  30634. SettleStartTime: start_time,
  30635. SettleEndTime: end_time,
  30636. Creator: roles.AdminUserId,
  30637. Modify: roles.AdminUserId,
  30638. PType: 2,
  30639. Diagnosis: diagnosis_id,
  30640. }
  30641. err = service.CreateOrder(order)
  30642. if err != nil {
  30643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30644. return
  30645. }
  30646. c.ServeSuccessJSON(map[string]interface{}{
  30647. "failed_code": -10,
  30648. "msg": res2.ErrMsg,
  30649. })
  30650. return
  30651. }
  30652. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30653. 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)
  30654. var dat map[string]interface{}
  30655. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30656. fmt.Println(dat)
  30657. } else {
  30658. fmt.Println(err)
  30659. }
  30660. saveLog(result, request_log, "2204", "上传费用明细")
  30661. userJSONBytes, _ := json.Marshal(dat)
  30662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30663. utils.ErrorLog("解析失败:%v", err)
  30664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30665. return
  30666. }
  30667. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30668. 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, "", "")
  30669. var dat map[string]interface{}
  30670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30671. fmt.Println(dat)
  30672. } else {
  30673. fmt.Println(err)
  30674. }
  30675. saveLog(result, request_log, "2204", "上传费用明细")
  30676. userJSONBytes, _ := json.Marshal(dat)
  30677. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30678. utils.ErrorLog("解析失败:%v", err)
  30679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30680. return
  30681. }
  30682. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30683. 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, "", "")
  30684. var dat map[string]interface{}
  30685. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30686. fmt.Println(dat)
  30687. } else {
  30688. fmt.Println(err)
  30689. }
  30690. saveLog(result, request_log, "2204", "上传费用明细")
  30691. userJSONBytes, _ := json.Marshal(dat)
  30692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30693. utils.ErrorLog("解析失败:%v", err)
  30694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30695. return
  30696. }
  30697. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30698. 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, "", "")
  30699. var dat map[string]interface{}
  30700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30701. fmt.Println(dat)
  30702. } else {
  30703. fmt.Println(err)
  30704. }
  30705. saveLog(result, request_log, "2204", "上传费用明细")
  30706. userJSONBytes, _ := json.Marshal(dat)
  30707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30708. utils.ErrorLog("解析失败:%v", err)
  30709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30710. return
  30711. }
  30712. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30713. bytesData, _ := json.Marshal(data)
  30714. var req *http.Request
  30715. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30716. resp, _ := client.Do(req)
  30717. defer resp.Body.Close()
  30718. body, ioErr := ioutil.ReadAll(resp.Body)
  30719. if ioErr != nil {
  30720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30722. return
  30723. }
  30724. var respJSON map[string]interface{}
  30725. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30728. return
  30729. }
  30730. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30731. if status == "0" {
  30732. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30733. c.ServeSuccessJSON(map[string]interface{}{
  30734. "failed_code": -10,
  30735. "msg": err_msg,
  30736. })
  30737. return
  30738. }
  30739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30740. userJSONBytes, _ := json.Marshal(respJSON)
  30741. fmt.Println("log")
  30742. fmt.Println(string(userJSONBytes))
  30743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30744. utils.ErrorLog("解析失败:%v", err)
  30745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30746. return
  30747. }
  30748. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30749. bytesData, _ := json.Marshal(data)
  30750. var req *http.Request
  30751. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30752. resp, _ := client.Do(req)
  30753. defer resp.Body.Close()
  30754. body, ioErr := ioutil.ReadAll(resp.Body)
  30755. if ioErr != nil {
  30756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30758. return
  30759. }
  30760. var respJSON map[string]interface{}
  30761. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30764. return
  30765. }
  30766. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30767. if status == "0" {
  30768. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30769. c.ServeSuccessJSON(map[string]interface{}{
  30770. "failed_code": -10,
  30771. "msg": err_msg,
  30772. })
  30773. return
  30774. }
  30775. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30776. userJSONBytes, _ := json.Marshal(respJSON)
  30777. fmt.Println("log")
  30778. fmt.Println(string(userJSONBytes))
  30779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30780. utils.ErrorLog("解析失败:%v", err)
  30781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30782. return
  30783. }
  30784. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30785. 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, "", "")
  30786. var dat map[string]interface{}
  30787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30788. fmt.Println(dat)
  30789. } else {
  30790. fmt.Println(err)
  30791. }
  30792. saveLog(result, request_log, "2204", "上传费用明细")
  30793. userJSONBytes, _ := json.Marshal(dat)
  30794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30795. utils.ErrorLog("解析失败:%v", err)
  30796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30797. return
  30798. }
  30799. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30800. bytesData, _ := json.Marshal(data)
  30801. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30802. resp, _ := client.Do(req)
  30803. defer resp.Body.Close()
  30804. body, ioErr := ioutil.ReadAll(resp.Body)
  30805. if ioErr != nil {
  30806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30808. return
  30809. }
  30810. var respJSON map[string]interface{}
  30811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30814. return
  30815. }
  30816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30817. userJSONBytes, _ := json.Marshal(respJSON)
  30818. fmt.Println("log")
  30819. fmt.Println(string(userJSONBytes))
  30820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30821. utils.ErrorLog("解析失败:%v", err)
  30822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30823. return
  30824. }
  30825. } else {
  30826. if miConfig.MdtrtareaAdmvs == "441202" {
  30827. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30828. if result3101.Infcode == 0 {
  30829. if len(result3101.Output.Result) > 0 {
  30830. var errMsgs []string
  30831. for _, item := range result3101.Output.Result {
  30832. errMsgs = append(errMsgs, item.VolaCont)
  30833. }
  30834. c.ServeSuccessJSON(map[string]interface{}{
  30835. "failed_code": -10,
  30836. "msg": errMsgs,
  30837. })
  30838. return
  30839. } else {
  30840. 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)
  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, "2204", "上传费用明细")
  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. }
  30855. } else {
  30856. c.ServeSuccessJSON(map[string]interface{}{
  30857. "failed_code": -10,
  30858. "msg": result3101.ErrMsg,
  30859. })
  30860. return
  30861. }
  30862. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30863. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30864. if result3101.Infcode == 0 {
  30865. if len(result3101.Output.Result) > 0 {
  30866. var errMsgs []string
  30867. for _, item := range result3101.Output.Result {
  30868. errMsgs = append(errMsgs, item.VolaCont)
  30869. }
  30870. c.ServeSuccessJSON(map[string]interface{}{
  30871. "failed_code": -10,
  30872. "msg": errMsgs,
  30873. })
  30874. return
  30875. } else {
  30876. 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)
  30877. var dat map[string]interface{}
  30878. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30879. fmt.Println(dat)
  30880. } else {
  30881. fmt.Println(err)
  30882. }
  30883. saveLog(result, request_log, "2204", "上传费用明细")
  30884. userJSONBytes, _ := json.Marshal(dat)
  30885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30886. utils.ErrorLog("解析失败:%v", err)
  30887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30888. return
  30889. }
  30890. }
  30891. } else {
  30892. c.ServeSuccessJSON(map[string]interface{}{
  30893. "failed_code": -10,
  30894. "msg": result3101.ErrMsg,
  30895. })
  30896. return
  30897. }
  30898. } else {
  30899. if miConfig.Code == "H15049901371" {
  30900. 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)
  30901. var dat map[string]interface{}
  30902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30903. fmt.Println(dat)
  30904. } else {
  30905. fmt.Println(err)
  30906. }
  30907. saveLog(result, request_log, "2204", "上传费用明细")
  30908. userJSONBytes, _ := json.Marshal(dat)
  30909. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30910. utils.ErrorLog("解析失败:%v", err)
  30911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30912. return
  30913. }
  30914. res.InfRefmsgid = resFour10265.InfRefmsgid
  30915. res.Output = resFour10265.Output
  30916. res.ErrMsg = resFour10265.ErrMsg
  30917. res.Cainfo = resFour10265.Cainfo
  30918. res.WarnMsg = resFour10265.WarnMsg
  30919. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30920. res.Infcode = infocode
  30921. } else {
  30922. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  30923. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30924. if result3101.Infcode == 0 {
  30925. if len(result3101.Output.Result) > 0 {
  30926. c.ServeSuccessJSON(map[string]interface{}{
  30927. "failed_code": -10,
  30928. "failed_type": 100,
  30929. "warm_type": 1,
  30930. "msg": result3101,
  30931. })
  30932. return
  30933. } else {
  30934. 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)
  30935. var dat map[string]interface{}
  30936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30937. fmt.Println(dat)
  30938. } else {
  30939. fmt.Println(err)
  30940. }
  30941. saveLog(result, request_log, "2204", "上传费用明细")
  30942. userJSONBytes, _ := json.Marshal(dat)
  30943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30944. utils.ErrorLog("解析失败:%v", err)
  30945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30946. return
  30947. }
  30948. }
  30949. } else {
  30950. c.ServeSuccessJSON(map[string]interface{}{
  30951. "failed_code": -10,
  30952. "msg": result3101.ErrMsg,
  30953. })
  30954. return
  30955. }
  30956. } else {
  30957. 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)
  30958. var dat map[string]interface{}
  30959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30960. fmt.Println(dat)
  30961. } else {
  30962. fmt.Println(err)
  30963. }
  30964. saveLog(result, request_log, "2204", "上传费用明细")
  30965. userJSONBytes, _ := json.Marshal(dat)
  30966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30967. utils.ErrorLog("解析失败:%v", err)
  30968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30969. return
  30970. }
  30971. }
  30972. }
  30973. }
  30974. }
  30975. var total_two float64
  30976. if res.Infcode == -1 {
  30977. errlog := &models.HisOrderError{
  30978. UserOrgId: adminUser.CurrentOrgId,
  30979. Ctime: time.Now().Unix(),
  30980. Mtime: time.Now().Unix(),
  30981. Number: chrg_bchno,
  30982. ErrMsg: res.ErrMsg,
  30983. Status: 1,
  30984. PatientId: id,
  30985. RecordTime: recordDateTime,
  30986. Stage: 4,
  30987. }
  30988. service.CreateErrMsgLog(errlog)
  30989. c.ServeSuccessJSON(map[string]interface{}{
  30990. "failed_code": -10,
  30991. "msg": res.ErrMsg,
  30992. })
  30993. return
  30994. }
  30995. if res.Infcode == 0 {
  30996. order := &models.HisOrder{
  30997. UserOrgId: adminUser.CurrentOrgId,
  30998. HisPatientId: his.ID,
  30999. PatientId: his.PatientId,
  31000. SettleAccountsDate: recordDateTime,
  31001. Ctime: time.Now().Unix(),
  31002. Mtime: time.Now().Unix(),
  31003. MdtrtId: his.Number,
  31004. PsnNo: his.PsnNo,
  31005. MedType: strconv.FormatInt(reg_type, 10),
  31006. Status: 1,
  31007. Number: chrg_bchno,
  31008. Infcode: res.Infcode,
  31009. WarnMsg: res.WarnMsg,
  31010. Cainfo: res.Cainfo,
  31011. ErrMsg: res.ErrMsg,
  31012. RespondTime: res.RefmsgTime,
  31013. InfRefmsgid: res.InfRefmsgid,
  31014. OrderStatus: 1,
  31015. IsMedicineInsurance: 1,
  31016. SettleType: settle_accounts_type,
  31017. SettleStartTime: start_time,
  31018. SettleEndTime: end_time,
  31019. Creator: roles.AdminUserId,
  31020. Modify: roles.AdminUserId,
  31021. PType: 2,
  31022. Diagnosis: diagnosis_id,
  31023. }
  31024. err = service.CreateOrder(order)
  31025. if err != nil {
  31026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31027. return
  31028. }
  31029. for _, item := range res.Output.Result {
  31030. temp := strings.Split(item.FeedetlSn, "-")
  31031. var advice_id int64 = 0
  31032. var project_id int64 = 0
  31033. var types int64 = 0
  31034. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31035. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31036. if temp[1] == "1" {
  31037. advice_id = id
  31038. project_id = 0
  31039. } else if temp[1] == "2" {
  31040. advice_id = 0
  31041. project_id = id
  31042. }
  31043. total_two = total_two + item.DetItemFeeSumamt
  31044. info := &models.HisOrderInfo{
  31045. OrderNumber: order.Number,
  31046. FeedetlSn: item.FeedetlSn,
  31047. UploadDate: time.Now().Unix(),
  31048. AdviceId: advice_id,
  31049. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31050. Cnt: item.Cnt,
  31051. Pric: float64(item.Pric),
  31052. PatientId: his.PatientId,
  31053. PricUplmtAmt: item.PricUplmtAmt,
  31054. SelfpayProp: item.SelfpayProp,
  31055. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31056. OverlmtAmt: item.OverlmtAmt,
  31057. PreselfpayAmt: item.PreselfpayAmt,
  31058. BasMednFlag: item.BasMednFlag,
  31059. MedChrgitmType: item.MedChrgitmType,
  31060. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31061. Status: 1,
  31062. Memo: item.Memo,
  31063. Mtime: time.Now().Unix(),
  31064. InscpScpAmt: item.InscpScpAmt,
  31065. DrtReimFlag: item.DrtReimFlag,
  31066. Ctime: time.Now().Unix(),
  31067. ListSpItemFlag: item.ListSpItemFlag,
  31068. ChldMedcFlag: item.ChldMedcFlag,
  31069. LmtUsedFlag: item.LmtUsedFlag,
  31070. ChrgitmLv: item.ChrgitmLv,
  31071. UserOrgId: adminUser.CurrentOrgId,
  31072. HisPatientId: his.ID,
  31073. OrderId: order.ID,
  31074. ProjectId: project_id,
  31075. Type: types,
  31076. }
  31077. service.CreateOrderInfo(info)
  31078. }
  31079. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31080. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31081. var total float64
  31082. for _, item := range prescriptions {
  31083. if item.Type == 1 { //药品
  31084. for _, subItem := range item.HisDoctorAdviceInfo {
  31085. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31086. total_one := price * subItem.PrescribingNumber
  31087. fmt.Println("subItem")
  31088. fmt.Println(subItem.Price)
  31089. fmt.Println("price")
  31090. fmt.Println(price)
  31091. fmt.Println("total_one")
  31092. fmt.Println(total_one)
  31093. total = total + total_one
  31094. fmt.Println(total)
  31095. }
  31096. }
  31097. if item.Type == 2 { //项目
  31098. for _, subItem := range item.HisPrescriptionProject {
  31099. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31100. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31101. total_one := price * cnt
  31102. total = total + total_one
  31103. }
  31104. }
  31105. }
  31106. allTotal := fmt.Sprintf("%.2f", total)
  31107. if res.Infcode == 0 {
  31108. var rf []*ResultFive
  31109. json.Unmarshal([]byte(his.Iinfo), &rf)
  31110. chrg_bchno := chrg_bchno
  31111. cert_no := his.Certno
  31112. var insutypes []string
  31113. var insutype string
  31114. var is390 int = 0
  31115. var is310 int = 0
  31116. for _, item := range rf {
  31117. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31118. insutypes = append(insutypes, item.Insutype)
  31119. }
  31120. }
  31121. if len(insutypes) == 1 {
  31122. insutype = insutypes[0]
  31123. } else {
  31124. for _, i := range insutypes {
  31125. if i == "390" {
  31126. is390 = 1
  31127. }
  31128. if i == "310" {
  31129. is310 = 1
  31130. }
  31131. }
  31132. }
  31133. if is390 == 1 {
  31134. insutype = "390"
  31135. }
  31136. if is310 == 1 {
  31137. insutype = "310"
  31138. }
  31139. if len(insutypes) == 0 {
  31140. insutype = "390"
  31141. }
  31142. if len(insutypes) == 2 {
  31143. insutype = strconv.FormatInt(his.SocialType, 10)
  31144. }
  31145. //insutype = "390"
  31146. if his.IdCardType == 1 {
  31147. cert_no = his.MedicalInsuranceNumber
  31148. } else {
  31149. cert_no = his.Certno
  31150. }
  31151. var res ResultSeven
  31152. var ahres ResultSevenAH
  31153. var resSeven10265 ResultSeven10265
  31154. var resSeven10265Two ResultSeven10265Two
  31155. var resSeven10633Three ResultSeven10633Three
  31156. var gzresSeven10265Two GZResultSeven10265Two
  31157. if miConfig.MdtrtareaAdmvs == "421300" {
  31158. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31159. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31160. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31161. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31162. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31163. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31164. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31165. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31166. resp, requestErr := http.Get(api)
  31167. if requestErr != nil {
  31168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31169. return
  31170. }
  31171. body, ioErr := ioutil.ReadAll(resp.Body)
  31172. if ioErr != nil {
  31173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31175. return
  31176. }
  31177. var respJSON map[string]interface{}
  31178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31181. return
  31182. }
  31183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31184. result, _ := json.Marshal(respJSON)
  31185. fmt.Println("log")
  31186. fmt.Println(string(result))
  31187. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31188. utils.ErrorLog("解析失败:%v", err)
  31189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31190. return
  31191. }
  31192. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31193. if reg_type == 11 && his.Insutype == "390" {
  31194. reg_type = 110104
  31195. }
  31196. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31197. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31198. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31199. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31200. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31201. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31202. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31203. resp, requestErr := http.Get(api)
  31204. if requestErr != nil {
  31205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31206. return
  31207. }
  31208. body, ioErr := ioutil.ReadAll(resp.Body)
  31209. if ioErr != nil {
  31210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31212. return
  31213. }
  31214. var respJSON map[string]interface{}
  31215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31218. return
  31219. }
  31220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31221. result, _ := json.Marshal(respJSON)
  31222. fmt.Println("log")
  31223. fmt.Println(string(result))
  31224. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31225. utils.ErrorLog("解析失败:%v", err)
  31226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31227. return
  31228. }
  31229. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31230. if reg_type == 11 && his.Insutype == "390" {
  31231. reg_type = 110104
  31232. }
  31233. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31234. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31235. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31236. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31237. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31238. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31239. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31240. resp, requestErr := http.Get(api)
  31241. if requestErr != nil {
  31242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31243. return
  31244. }
  31245. body, ioErr := ioutil.ReadAll(resp.Body)
  31246. if ioErr != nil {
  31247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31249. return
  31250. }
  31251. var respJSON map[string]interface{}
  31252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31255. return
  31256. }
  31257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31258. result, _ := json.Marshal(respJSON)
  31259. fmt.Println("log")
  31260. fmt.Println(string(result))
  31261. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31262. utils.ErrorLog("解析失败:%v", err)
  31263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31264. return
  31265. }
  31266. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31267. if reg_type == 11 && his.Insutype == "390" {
  31268. reg_type = 110104
  31269. }
  31270. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31271. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31272. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31273. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31274. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31275. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31276. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31277. resp, requestErr := http.Get(api)
  31278. if requestErr != nil {
  31279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31280. return
  31281. }
  31282. body, ioErr := ioutil.ReadAll(resp.Body)
  31283. if ioErr != nil {
  31284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31286. return
  31287. }
  31288. var respJSON map[string]interface{}
  31289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31292. return
  31293. }
  31294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31295. result, _ := json.Marshal(respJSON)
  31296. fmt.Println("log")
  31297. fmt.Println(string(result))
  31298. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31299. utils.ErrorLog("解析失败:%v", err)
  31300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31301. return
  31302. }
  31303. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31304. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31305. var result3101 Result3101
  31306. //utils.ErrorLog("解析失败:%v", result3101)
  31307. result3101.Infcode = "0"
  31308. if result3101.Infcode == "0" {
  31309. if len(result3101.Output.Result) > 0 {
  31310. var errMsgs []string
  31311. for _, item := range result3101.Output.Result {
  31312. errMsgs = append(errMsgs, item.VolaCont)
  31313. }
  31314. c.ServeSuccessJSON(map[string]interface{}{
  31315. "failed_code": -10,
  31316. "msg": errMsgs,
  31317. })
  31318. return
  31319. } else {
  31320. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31321. if his.IdCardType != 4 {
  31322. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31323. bas := strings.Split(psn_info.CardInfo, "|")
  31324. if his.IdCardType == 1 {
  31325. cert_no = bas[2]
  31326. } else {
  31327. cert_no = bas[1]
  31328. }
  31329. } else {
  31330. cert_no = his.Certno
  31331. }
  31332. //江苏地区国家医保医疗类别
  31333. //职工透析:医疗类别选特殊情况门诊9933
  31334. //居民血透门慢: 医疗类别选门诊慢病1402
  31335. //var med_type string
  31336. //if his.Insutype == "310" {
  31337. // if reg_type == 14 {
  31338. // med_type = "9933"
  31339. // } else if reg_type == 11 {
  31340. // med_type = "11"
  31341. //
  31342. // }
  31343. //} else if his.Insutype == "390" {
  31344. // if reg_type == 14 {
  31345. // med_type = "1402"
  31346. // } else if reg_type == 11 {
  31347. // med_type = "11"
  31348. // }
  31349. //}
  31350. var api string
  31351. if miConfig.MdtrtareaAdmvs == "320830" {
  31352. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31353. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31354. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31355. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31356. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31357. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31358. "&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
  31359. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31360. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31361. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31362. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31363. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31364. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31365. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31366. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31367. "&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
  31368. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31369. } else {
  31370. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31371. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31372. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31373. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31374. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31375. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31376. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31377. "&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
  31378. }
  31379. resp, requestErr := http.Get(api)
  31380. if requestErr != nil {
  31381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31382. return
  31383. }
  31384. body, ioErr := ioutil.ReadAll(resp.Body)
  31385. if ioErr != nil {
  31386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31388. return
  31389. }
  31390. var respJSON map[string]interface{}
  31391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31394. return
  31395. }
  31396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31397. result, _ := json.Marshal(respJSON)
  31398. fmt.Println("log")
  31399. fmt.Println(string(result))
  31400. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31401. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31402. utils.ErrorLog("解析失败:%v", err)
  31403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31404. return
  31405. }
  31406. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31407. res.Output = resSeven10265.Output
  31408. res.ErrMsg = resSeven10265.ErrMsg
  31409. res.Cainfo = resSeven10265.Cainfo
  31410. res.WarnMsg = resSeven10265.WarnMsg
  31411. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31412. res.Infcode = infocode
  31413. } else {
  31414. if miConfig.MdtrtareaAdmvs == "320830"{
  31415. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208"){
  31416. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31417. utils.ErrorLog("解析失败:%v", err)
  31418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31419. return
  31420. }
  31421. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31422. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31423. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31424. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31425. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31426. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31427. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31428. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31429. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31430. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31431. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31432. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31433. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31434. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31435. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31436. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31437. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31438. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31439. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31440. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31441. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31442. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31443. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31444. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31445. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31446. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31447. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31448. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31449. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31450. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31451. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31452. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31453. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31454. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31455. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31456. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31457. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31458. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31459. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31460. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31461. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31462. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31463. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31464. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31465. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31466. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31467. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31468. res.ErrMsg = resSeven10633Three.ErrMsg
  31469. res.Cainfo = resSeven10633Three.Cainfo
  31470. res.WarnMsg = resSeven10633Three.WarnMsg
  31471. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31472. res.Infcode = infocode
  31473. }else {
  31474. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31475. utils.ErrorLog("解析失败:%v", err)
  31476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31477. return
  31478. }
  31479. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31480. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31481. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31482. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31483. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31484. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31485. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31486. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31487. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31488. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31489. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31490. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31491. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31492. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31493. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31494. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31495. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31496. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31497. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31498. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31499. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31500. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31501. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31502. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31503. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31504. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31505. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31506. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31507. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31508. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31509. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31510. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31511. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31512. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31513. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31514. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31515. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31516. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31517. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31518. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31519. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31520. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31521. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31522. res.ErrMsg = resSeven10265Two.ErrMsg
  31523. res.Cainfo = resSeven10265Two.Cainfo
  31524. res.WarnMsg = resSeven10265Two.WarnMsg
  31525. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31526. res.Infcode = infocode
  31527. }
  31528. } else {
  31529. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209"){
  31530. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31531. utils.ErrorLog("解析失败:%v", err)
  31532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31533. return
  31534. }
  31535. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31536. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31537. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31538. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31539. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31540. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31541. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31542. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31543. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31544. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31545. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31546. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31547. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31548. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31549. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31550. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31551. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31552. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31553. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31554. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31555. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31556. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31557. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31558. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31559. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31560. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31561. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31562. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31563. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31564. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31565. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31566. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31567. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31568. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31569. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31570. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31571. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31572. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31573. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31574. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31575. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31576. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31577. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31578. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31579. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31580. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31581. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31582. res.ErrMsg = resSeven10633Three.ErrMsg
  31583. res.Cainfo = resSeven10633Three.Cainfo
  31584. res.WarnMsg = resSeven10633Three.WarnMsg
  31585. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31586. res.Infcode = infocode
  31587. }else {
  31588. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31589. utils.ErrorLog("解析失败:%v", err)
  31590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31591. return
  31592. }
  31593. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31594. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31595. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31596. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31597. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31598. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31599. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31600. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31601. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31602. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31603. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31604. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31605. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31606. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31607. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31608. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31609. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31610. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31611. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31612. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31613. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31614. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31615. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31616. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31617. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31618. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31619. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31620. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31621. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31622. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31623. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31624. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31625. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31626. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31627. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31628. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31629. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31630. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31631. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31632. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31633. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31634. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31635. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31636. res.ErrMsg = resSeven10265Two.ErrMsg
  31637. res.Cainfo = resSeven10265Two.Cainfo
  31638. res.WarnMsg = resSeven10265Two.WarnMsg
  31639. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31640. res.Infcode = infocode
  31641. }
  31642. }
  31643. }
  31644. }
  31645. }
  31646. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31647. psn_info, _ := service.GetPsnByPatientId(id)
  31648. var verify_number string
  31649. if psn_info.IdCardType == 4 {
  31650. verify_number = psn_info.VerifyNumber
  31651. } else if psn_info.IdCardType == 1 {
  31652. bas := strings.Split(psn_info.CardInfo, "|")
  31653. cardNumber := bas[2]
  31654. verify_number = cardNumber
  31655. } else {
  31656. psn_info.IdCardType = 2
  31657. verify_number = psn_info.Certno
  31658. }
  31659. var api string
  31660. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31661. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31662. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31663. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31664. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31665. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31666. "&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
  31667. resp, requestErr := http.Get(api)
  31668. if requestErr != nil {
  31669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31670. return
  31671. }
  31672. body, ioErr := ioutil.ReadAll(resp.Body)
  31673. if ioErr != nil {
  31674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31676. return
  31677. }
  31678. var respJSON map[string]interface{}
  31679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31682. return
  31683. }
  31684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31685. result, _ := json.Marshal(respJSON)
  31686. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31687. utils.ErrorLog("解析失败:%v", err)
  31688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31689. return
  31690. }
  31691. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31692. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31693. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31694. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31695. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31696. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31697. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31698. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31699. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31700. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31701. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31702. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31703. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31704. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31705. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31706. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31707. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31708. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31709. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31710. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31711. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31712. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31713. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31714. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31715. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31716. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31717. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31718. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31719. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31720. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31721. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31722. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31723. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31724. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31725. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31726. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31727. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31728. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31729. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31730. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31731. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31732. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31733. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31734. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31735. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31736. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31737. res.ErrMsg = resSeven10265.ErrMsg
  31738. res.Cainfo = resSeven10265.Cainfo
  31739. res.WarnMsg = resSeven10265.WarnMsg
  31740. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31741. res.Infcode = infocode
  31742. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31743. acct_used_flag := "1"
  31744. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31745. var result string
  31746. var request_log string
  31747. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31748. 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)
  31749. } else {
  31750. 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)
  31751. }
  31752. var dat map[string]interface{}
  31753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31754. fmt.Println(dat)
  31755. } else {
  31756. fmt.Println(err)
  31757. }
  31758. saveLog(result, request_log, "2206", "预结算")
  31759. userJSONBytes, _ := json.Marshal(dat)
  31760. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31761. utils.ErrorLog("解析失败:%v", err)
  31762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31763. return
  31764. }
  31765. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31766. var result string
  31767. var request_log string
  31768. if his.IdCardType == 2 {
  31769. insutype = strconv.FormatInt(his.SocialType, 10)
  31770. 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, "")
  31771. } else if his.IdCardType == 1 {
  31772. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31773. bas := strings.Split(psn_info.CardInfo, "|")
  31774. basNumber := bas[2]
  31775. card_sn := bas[3]
  31776. var rf []*ResultFive
  31777. json.Unmarshal([]byte(his.Iinfo), &rf)
  31778. var psn_type string
  31779. for _, item := range rf {
  31780. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31781. psn_type = item.PsnType
  31782. }
  31783. }
  31784. insutype = strconv.FormatInt(his.SocialType, 10)
  31785. 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)
  31786. } else {
  31787. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31788. //bas := strings.Split(psn_info.CardInfo, "|")
  31789. //basNumber := bas[2]
  31790. //card_sn := bas[3]
  31791. var rf []*ResultFive
  31792. json.Unmarshal([]byte(his.Iinfo), &rf)
  31793. var psn_type string
  31794. for _, item := range rf {
  31795. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31796. psn_type = item.PsnType
  31797. }
  31798. }
  31799. insutype = strconv.FormatInt(his.SocialType, 10)
  31800. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31801. 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)
  31802. }
  31803. var dat map[string]interface{}
  31804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31805. fmt.Println(dat)
  31806. } else {
  31807. fmt.Println(err)
  31808. }
  31809. saveLog(result, request_log, "2206", "预结算")
  31810. userJSONBytes, _ := json.Marshal(dat)
  31811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31812. utils.ErrorLog("解析失败:%v", err)
  31813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31814. return
  31815. }
  31816. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31817. var result string
  31818. var request_log string
  31819. if his.IdCardType == 2 {
  31820. insutype = strconv.FormatInt(his.SocialType, 10)
  31821. 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, "")
  31822. } else if his.IdCardType == 1 {
  31823. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31824. bas := strings.Split(psn_info.CardInfo, "|")
  31825. basNumber := bas[0]
  31826. card_sn := ""
  31827. var rf []*ResultFive
  31828. json.Unmarshal([]byte(his.Iinfo), &rf)
  31829. var psn_type string
  31830. for _, item := range rf {
  31831. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31832. psn_type = item.PsnType
  31833. }
  31834. }
  31835. insutype = strconv.FormatInt(his.SocialType, 10)
  31836. 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)
  31837. } else {
  31838. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31839. //bas := strings.Split(psn_info.CardInfo, "|")
  31840. //basNumber := bas[2]
  31841. //card_sn := bas[3]
  31842. var rf []*ResultFive
  31843. json.Unmarshal([]byte(his.Iinfo), &rf)
  31844. var psn_type string
  31845. for _, item := range rf {
  31846. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31847. psn_type = item.PsnType
  31848. }
  31849. }
  31850. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31851. 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)
  31852. }
  31853. var dat map[string]interface{}
  31854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31855. fmt.Println(dat)
  31856. } else {
  31857. fmt.Println(err)
  31858. }
  31859. saveLog(result, request_log, "2206", "预结算")
  31860. userJSONBytes, _ := json.Marshal(dat)
  31861. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31862. utils.ErrorLog("解析失败:%v", err)
  31863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31864. return
  31865. }
  31866. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31867. var result string
  31868. var request_log string
  31869. if his.IdCardType == 2 {
  31870. insutype = strconv.FormatInt(his.SocialType, 10)
  31871. 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, "")
  31872. } else if his.IdCardType == 1 {
  31873. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31874. bas := strings.Split(psn_info.CardInfo, "|")
  31875. basNumber := bas[0]
  31876. card_sn := ""
  31877. var rf []*ResultFive
  31878. json.Unmarshal([]byte(his.Iinfo), &rf)
  31879. var psn_type string
  31880. for _, item := range rf {
  31881. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31882. psn_type = item.PsnType
  31883. }
  31884. }
  31885. insutype = strconv.FormatInt(his.SocialType, 10)
  31886. 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)
  31887. } else {
  31888. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31889. //bas := strings.Split(psn_info.CardInfo, "|")
  31890. //basNumber := bas[2]
  31891. //card_sn := bas[3]
  31892. var rf []*ResultFive
  31893. json.Unmarshal([]byte(his.Iinfo), &rf)
  31894. var psn_type string
  31895. for _, item := range rf {
  31896. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31897. psn_type = item.PsnType
  31898. }
  31899. }
  31900. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31901. 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)
  31902. }
  31903. var dat map[string]interface{}
  31904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31905. fmt.Println(dat)
  31906. } else {
  31907. fmt.Println(err)
  31908. }
  31909. saveLog(result, request_log, "2206", "预结算")
  31910. userJSONBytes, _ := json.Marshal(dat)
  31911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31912. utils.ErrorLog("解析失败:%v", err)
  31913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31914. return
  31915. }
  31916. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31917. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31918. if his.IdCardType == 4 {
  31919. psn_info.VerifyNumber = psn_info.VerifyNumber
  31920. cert_no = psn_info.VerifyNumber
  31921. } else if his.IdCardType == 2 {
  31922. cert_no = psn_info.Certno
  31923. psn_info.VerifyNumber = psn_info.Certno
  31924. } else {
  31925. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31926. bas := strings.Split(psn_info.CardInfo, "|")
  31927. if his.IdCardType == 1 {
  31928. cert_no = bas[2]
  31929. } else {
  31930. cert_no = bas[1]
  31931. }
  31932. }
  31933. var api string
  31934. var med_type string
  31935. if his.Insutype == "390" {
  31936. if reg_type == 992102 {
  31937. med_type = "992102"
  31938. }
  31939. if reg_type == 140104 {
  31940. med_type = "140104"
  31941. }
  31942. if reg_type == 140201 {
  31943. med_type = "140201"
  31944. }
  31945. if reg_type == 14 {
  31946. med_type = "140104"
  31947. }
  31948. if reg_type == 1104 {
  31949. med_type = "1104"
  31950. }
  31951. } else if his.Insutype == "310" {
  31952. if reg_type == 1104 {
  31953. med_type = "1104"
  31954. }
  31955. if reg_type == 992102 {
  31956. med_type = "992102"
  31957. }
  31958. if reg_type == 140104 {
  31959. med_type = "140104"
  31960. }
  31961. if reg_type == 140201 {
  31962. med_type = "140201"
  31963. }
  31964. if reg_type == 14 {
  31965. med_type = "140104"
  31966. }
  31967. }
  31968. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31969. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31970. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31971. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31972. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31973. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31974. "&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
  31975. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31976. resp, requestErr := http.Get(api)
  31977. if requestErr != nil {
  31978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31979. return
  31980. }
  31981. body, ioErr := ioutil.ReadAll(resp.Body)
  31982. if ioErr != nil {
  31983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31985. return
  31986. }
  31987. var respJSON map[string]interface{}
  31988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31991. return
  31992. }
  31993. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31994. if status == "0" {
  31995. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31996. c.ServeSuccessJSON(map[string]interface{}{
  31997. "failed_code": -10,
  31998. "msg": err_msg,
  31999. })
  32000. return
  32001. }
  32002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32003. result, _ := json.Marshal(respJSON)
  32004. fmt.Println("log")
  32005. fmt.Println(string(result))
  32006. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32007. utils.ErrorLog("解析失败:%v", err)
  32008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32009. return
  32010. }
  32011. res.InfRefmsgid = ahres.InfRefmsgid
  32012. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32013. // 创建对应的Time类型
  32014. t := time.UnixMilli(timestamp)
  32015. // 格式化成指定的日期字符串
  32016. str := t.Format("2006-01-02 15:04:05")
  32017. res.Output.Setlinfo.SetlTime = str
  32018. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32019. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32020. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32021. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32022. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32023. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32024. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32025. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32026. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32027. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32028. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32029. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32030. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32031. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32032. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32033. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32034. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32035. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32036. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32037. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32038. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32039. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32040. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32041. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32042. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32043. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32044. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32045. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32046. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32047. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32048. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32049. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32050. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32051. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32052. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32053. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32054. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32055. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32056. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32057. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32058. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32059. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32060. //res.Output.Setldetail = ahres.Output.Setldetail
  32061. res.ErrMsg = ahres.ErrMsg
  32062. res.Cainfo = ahres.Cainfo
  32063. res.WarnMsg = ahres.WarnMsg
  32064. res.Infcode = ahres.Infcode
  32065. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32066. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32067. if his.IdCardType == 4 {
  32068. psn_info.VerifyNumber = psn_info.VerifyNumber
  32069. cert_no = psn_info.Certno
  32070. } else if his.IdCardType == 2 {
  32071. cert_no = psn_info.Certno
  32072. psn_info.VerifyNumber = psn_info.Certno
  32073. } else {
  32074. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32075. bas := strings.Split(psn_info.CardInfo, "|")
  32076. if his.IdCardType == 1 {
  32077. cert_no = bas[2]
  32078. } else {
  32079. cert_no = bas[1]
  32080. }
  32081. }
  32082. var api string
  32083. var med_type string
  32084. if his.Insutype == "390" {
  32085. if reg_type == 992102 {
  32086. med_type = "992102"
  32087. }
  32088. if reg_type == 140104 {
  32089. med_type = "140104"
  32090. }
  32091. if reg_type == 140201 {
  32092. med_type = "140201"
  32093. }
  32094. if reg_type == 14 {
  32095. med_type = "14"
  32096. }
  32097. } else if his.Insutype == "310" {
  32098. if reg_type == 992102 {
  32099. med_type = "992102"
  32100. }
  32101. if reg_type == 140104 {
  32102. med_type = "140104"
  32103. }
  32104. if reg_type == 140201 {
  32105. med_type = "140201"
  32106. }
  32107. if reg_type == 14 {
  32108. med_type = "14"
  32109. }
  32110. }
  32111. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32112. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32113. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32115. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32116. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32117. "&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
  32118. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32119. resp, requestErr := http.Get(api)
  32120. if requestErr != nil {
  32121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32122. return
  32123. }
  32124. body, ioErr := ioutil.ReadAll(resp.Body)
  32125. if ioErr != nil {
  32126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32128. return
  32129. }
  32130. var respJSON map[string]interface{}
  32131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32134. return
  32135. }
  32136. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32137. if status == "0" {
  32138. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32139. c.ServeSuccessJSON(map[string]interface{}{
  32140. "failed_code": -10,
  32141. "msg": err_msg,
  32142. })
  32143. return
  32144. }
  32145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32146. result, _ := json.Marshal(respJSON)
  32147. fmt.Println("log")
  32148. fmt.Println(string(result))
  32149. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32150. utils.ErrorLog("解析失败:%v", err)
  32151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32152. return
  32153. }
  32154. res.InfRefmsgid = ahres.InfRefmsgid
  32155. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32156. // 创建对应的Time类型
  32157. t := time.UnixMilli(timestamp)
  32158. // 格式化成指定的日期字符串
  32159. str := t.Format("2006-01-02 15:04:05")
  32160. res.Output.Setlinfo.SetlTime = str
  32161. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32162. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32163. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32164. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32165. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32166. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32167. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32168. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32169. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32170. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32171. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32172. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32173. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32174. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32175. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32176. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32177. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32178. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32179. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32180. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32181. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32182. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32183. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32184. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32185. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32186. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32187. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32188. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32189. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32190. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32191. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32192. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32193. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32194. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32195. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32196. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32197. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32198. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32199. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32200. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32201. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32202. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32203. //res.Output.Setldetail = ahres.Output.Setldetail
  32204. res.ErrMsg = ahres.ErrMsg
  32205. res.Cainfo = ahres.Cainfo
  32206. res.WarnMsg = ahres.WarnMsg
  32207. res.Infcode = ahres.Infcode
  32208. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32209. var result string
  32210. var request_log string
  32211. if his.IdCardType == 2 {
  32212. 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")
  32213. } else if his.IdCardType == 1 {
  32214. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32215. bas := strings.Split(psn_info.CardInfo, "|")
  32216. basNumber := bas[2]
  32217. card_sn := bas[3]
  32218. 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")
  32219. } else {
  32220. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32221. 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")
  32222. }
  32223. var dat map[string]interface{}
  32224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32225. fmt.Println(dat)
  32226. } else {
  32227. fmt.Println(err)
  32228. }
  32229. saveLog(result, request_log, "2206", "预结算")
  32230. userJSONBytes, _ := json.Marshal(dat)
  32231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32232. utils.ErrorLog("解析失败:%v", err)
  32233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32234. return
  32235. }
  32236. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32237. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32238. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32239. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32241. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32242. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32243. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32244. resp, requestErr := http.Get(api)
  32245. if requestErr != nil {
  32246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32247. return
  32248. }
  32249. body, ioErr := ioutil.ReadAll(resp.Body)
  32250. if ioErr != nil {
  32251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32253. return
  32254. }
  32255. var respJSON map[string]interface{}
  32256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32259. return
  32260. }
  32261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32262. result, _ := json.Marshal(respJSON)
  32263. fmt.Println("log")
  32264. fmt.Println(string(result))
  32265. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32266. utils.ErrorLog("解析失败:%v", err)
  32267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32268. return
  32269. }
  32270. } else {
  32271. if miConfig.MdtrtareaAdmvs == "441202" {
  32272. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32273. if result3101.Infcode == 0 {
  32274. if len(result3101.Output.Result) > 0 {
  32275. c.ServeSuccessJSON(map[string]interface{}{
  32276. "failed_code": -10,
  32277. "failed_type": 100,
  32278. "msg": result3101.Output.Result,
  32279. })
  32280. return
  32281. } else {
  32282. var result string
  32283. var request_log string
  32284. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32285. allTotal = fmt.Sprintf("%.2f", total_two)
  32286. if his.IdCardType == 4 {
  32287. 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)
  32288. } else {
  32289. 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)
  32290. }
  32291. var dat map[string]interface{}
  32292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32293. fmt.Println(dat)
  32294. } else {
  32295. fmt.Println(err)
  32296. }
  32297. saveLog(result, request_log, "2206", "预结算")
  32298. //userJSONBytes, _ := json.Marshal(dat)
  32299. //
  32300. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32301. // utils.ErrorLog("解析失败:%v", err)
  32302. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. // return
  32304. //}
  32305. userJSONBytes, _ := json.Marshal(dat)
  32306. if miConfig.Code == "H15049901371" {
  32307. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32308. utils.ErrorLog("解析失败:%v", err)
  32309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32310. return
  32311. }
  32312. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32313. res.Output = resSeven10265.Output
  32314. res.ErrMsg = resSeven10265.ErrMsg
  32315. res.Cainfo = resSeven10265.Cainfo
  32316. res.WarnMsg = resSeven10265.WarnMsg
  32317. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32318. res.Infcode = infocode
  32319. } else {
  32320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32321. utils.ErrorLog("解析失败:%v", err)
  32322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32323. return
  32324. }
  32325. }
  32326. }
  32327. } else {
  32328. c.ServeSuccessJSON(map[string]interface{}{
  32329. "failed_code": -10,
  32330. "msg": result3101.ErrMsg,
  32331. })
  32332. return
  32333. }
  32334. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32335. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32336. if result3101.Infcode == 0 {
  32337. if len(result3101.Output.Result) > 0 {
  32338. var errMsgs []string
  32339. for _, item := range result3101.Output.Result {
  32340. errMsgs = append(errMsgs, item.VolaCont)
  32341. }
  32342. c.ServeSuccessJSON(map[string]interface{}{
  32343. "failed_code": -10,
  32344. "msg": errMsgs,
  32345. })
  32346. return
  32347. } else {
  32348. var result string
  32349. var request_log string
  32350. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32351. allTotal = fmt.Sprintf("%.2f", total_two)
  32352. if his.IdCardType == 4 {
  32353. 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)
  32354. } else {
  32355. 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)
  32356. }
  32357. var dat map[string]interface{}
  32358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32359. fmt.Println(dat)
  32360. } else {
  32361. fmt.Println(err)
  32362. }
  32363. saveLog(result, request_log, "2206", "预结算")
  32364. //userJSONBytes, _ := json.Marshal(dat)
  32365. //
  32366. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32367. // utils.ErrorLog("解析失败:%v", err)
  32368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32369. // return
  32370. //}
  32371. userJSONBytes, _ := json.Marshal(dat)
  32372. if miConfig.Code == "H15049901371" {
  32373. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32374. utils.ErrorLog("解析失败:%v", err)
  32375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32376. return
  32377. }
  32378. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32379. res.Output = resSeven10265.Output
  32380. res.ErrMsg = resSeven10265.ErrMsg
  32381. res.Cainfo = resSeven10265.Cainfo
  32382. res.WarnMsg = resSeven10265.WarnMsg
  32383. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32384. res.Infcode = infocode
  32385. } else {
  32386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32387. utils.ErrorLog("解析失败:%v", err)
  32388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32389. return
  32390. }
  32391. }
  32392. }
  32393. } else {
  32394. c.ServeSuccessJSON(map[string]interface{}{
  32395. "failed_code": -10,
  32396. "msg": result3101.ErrMsg,
  32397. })
  32398. return
  32399. }
  32400. } else {
  32401. var result string
  32402. var request_log string
  32403. var dat map[string]interface{}
  32404. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32405. allTotal = fmt.Sprintf("%.2f", total_two)
  32406. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  32407. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32408. if result3101.Infcode == 0 {
  32409. if len(result3101.Output.Result) > 0 {
  32410. c.ServeSuccessJSON(map[string]interface{}{
  32411. "failed_code": -10,
  32412. "failed_type": 100,
  32413. "warm_type": 2,
  32414. "msg": result3101,
  32415. })
  32416. return
  32417. } else {
  32418. var result string
  32419. var request_log string
  32420. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32421. allTotal = fmt.Sprintf("%.2f", total_two)
  32422. if his.IdCardType == 4 {
  32423. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32424. } else {
  32425. if his.IdCardType == 2 {
  32426. cert_no = psn_info.Certno
  32427. psn_info.VerifyNumber = psn_info.Certno
  32428. } else {
  32429. bas := strings.Split(psn_info.CardInfo, "|")
  32430. cert_no = bas[2]
  32431. }
  32432. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32433. }
  32434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32435. fmt.Println(dat)
  32436. } else {
  32437. fmt.Println(err)
  32438. }
  32439. saveLog(result, request_log, "2206", "预结算")
  32440. }
  32441. } else {
  32442. c.ServeSuccessJSON(map[string]interface{}{
  32443. "failed_code": -10,
  32444. "msg": result3101.ErrMsg,
  32445. })
  32446. return
  32447. }
  32448. } else {
  32449. if his.IdCardType == 4 {
  32450. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32451. } else {
  32452. if his.IdCardType == 2 {
  32453. cert_no = psn_info.Certno
  32454. psn_info.VerifyNumber = psn_info.Certno
  32455. } else {
  32456. bas := strings.Split(psn_info.CardInfo, "|")
  32457. cert_no = bas[2]
  32458. }
  32459. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32460. }
  32461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32462. fmt.Println(dat)
  32463. } else {
  32464. fmt.Println(err)
  32465. }
  32466. saveLog(result, request_log, "2206", "预结算")
  32467. }
  32468. //userJSONBytes, _ := json.Marshal(dat)
  32469. //
  32470. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32471. // utils.ErrorLog("解析失败:%v", err)
  32472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32473. // return
  32474. //}
  32475. userJSONBytes, _ := json.Marshal(dat)
  32476. if miConfig.Code == "H15049901371" {
  32477. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32478. utils.ErrorLog("解析失败:%v", err)
  32479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32480. return
  32481. }
  32482. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32483. res.Output = resSeven10265.Output
  32484. res.ErrMsg = resSeven10265.ErrMsg
  32485. res.Cainfo = resSeven10265.Cainfo
  32486. res.WarnMsg = resSeven10265.WarnMsg
  32487. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32488. res.Infcode = infocode
  32489. } else {
  32490. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32491. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32492. utils.ErrorLog("解析失败:%v", err)
  32493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32494. return
  32495. }
  32496. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32497. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32498. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32499. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32500. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32501. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32502. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32503. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32504. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32505. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32506. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32507. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32508. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32509. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32510. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32511. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32512. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32513. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32514. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32515. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32516. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32517. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32518. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32519. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32520. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32521. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32522. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32523. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32524. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32525. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32526. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32527. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32528. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32529. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32530. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32531. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32532. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32533. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32534. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32535. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32536. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32537. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32538. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32539. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32540. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32541. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32542. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32543. res.Cainfo = gzresSeven10265Two.Cainfo
  32544. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32545. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32546. //res.Infcode = infocode
  32547. } else {
  32548. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32549. utils.ErrorLog("解析失败:%v", err)
  32550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32551. return
  32552. }
  32553. }
  32554. }
  32555. }
  32556. }
  32557. utils.ErrorLog("解析失败:%v", res.Infcode)
  32558. if res.Infcode == -1 {
  32559. errlog := &models.HisOrderError{
  32560. UserOrgId: adminUser.CurrentOrgId,
  32561. Ctime: time.Now().Unix(),
  32562. Mtime: time.Now().Unix(),
  32563. Number: chrg_bchno,
  32564. ErrMsg: res.ErrMsg,
  32565. Status: 1,
  32566. PatientId: id,
  32567. RecordTime: recordDateTime,
  32568. Stage: 20,
  32569. }
  32570. service.CreateErrMsgLog(errlog)
  32571. c.ServeSuccessJSON(map[string]interface{}{
  32572. "failed_code": -10,
  32573. "msg": res.ErrMsg,
  32574. })
  32575. return
  32576. }
  32577. if res.Infcode != 0 {
  32578. errlog := &models.HisOrderError{
  32579. UserOrgId: adminUser.CurrentOrgId,
  32580. Ctime: time.Now().Unix(),
  32581. Mtime: time.Now().Unix(),
  32582. Number: chrg_bchno,
  32583. ErrMsg: res.ErrMsg,
  32584. Status: 1,
  32585. PatientId: id,
  32586. RecordTime: recordDateTime,
  32587. Stage: 20,
  32588. }
  32589. service.CreateErrMsgLog(errlog)
  32590. c.ServeSuccessJSON(map[string]interface{}{
  32591. "failed_code": -10,
  32592. "msg": res.ErrMsg,
  32593. })
  32594. return
  32595. } else {
  32596. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32597. order.OrderStatus = 1
  32598. order.IsPre = 1
  32599. order.Status = 1
  32600. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32601. order.SetlId = res.Output.Setlinfo.SetlID
  32602. order.PsnNo = res.Output.Setlinfo.PsnNo
  32603. order.PsnName = res.Output.Setlinfo.PsnName
  32604. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32605. order.Certno = res.Output.Setlinfo.Certno
  32606. order.Gend = res.Output.Setlinfo.Gend
  32607. order.Naty = res.Output.Setlinfo.Naty
  32608. order.Age = res.Output.Setlinfo.Age
  32609. order.Insutype = res.Output.Setlinfo.Insutype
  32610. order.PsnType = res.Output.Setlinfo.PsnType
  32611. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32612. order.SetlTime = res.Output.Setlinfo.SetlTime
  32613. order.AcctUsedFlag = acct_used_flag
  32614. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32615. if res.Output.Setlinfo.MedType == "140101" {
  32616. order.MedType = "14"
  32617. } else {
  32618. if res.Output.Setlinfo.MedType == "110104" {
  32619. order.MedType = "11"
  32620. } else {
  32621. order.MedType = res.Output.Setlinfo.MedType
  32622. }
  32623. }
  32624. if res.Output.Setlinfo.MedType == "992102" {
  32625. order.MedType = "992102"
  32626. }
  32627. if res.Output.Setlinfo.MedType == "140104" {
  32628. order.MedType = "140104"
  32629. }
  32630. if res.Output.Setlinfo.MedType == "1104" {
  32631. order.MedType = "1104"
  32632. }
  32633. if res.Output.Setlinfo.MedType == "140201" {
  32634. order.MedType = "140201"
  32635. }
  32636. if res.Output.Setlinfo.MedType == "14" {
  32637. order.MedType = "14"
  32638. }
  32639. if reg_type == 1112 {
  32640. order.MedType = "1112"
  32641. }
  32642. if reg_type == 1111 {
  32643. order.MedType = "1111"
  32644. }
  32645. order.ClrType = res.Output.Setlinfo.ClrType
  32646. if adminUser.CurrentOrgId == 10480 {
  32647. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32648. order.ClrType = "11"
  32649. } else {
  32650. order.ClrType = "9903"
  32651. }
  32652. }
  32653. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32654. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32655. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32656. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32657. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32658. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32659. order.HifpPay = res.Output.Setlinfo.HifpPay
  32660. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32661. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32662. order.HifesPay = res.Output.Setlinfo.HifesPay
  32663. order.HifobPay = res.Output.Setlinfo.HifobPay
  32664. order.MafPay = res.Output.Setlinfo.MafPay
  32665. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32666. order.OthPay = res.Output.Setlinfo.OthPay
  32667. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32668. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32669. order.AcctPay = res.Output.Setlinfo.AcctPay
  32670. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32671. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32672. order.Balc = res.Output.Setlinfo.Balc
  32673. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32674. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32675. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32676. order.ClrWay = res.Output.Setlinfo.ClrWay
  32677. order.Creator = order.Creator
  32678. order.Modify = roles.AdminUserId
  32679. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32680. //detailStr := string(setlDetail)
  32681. //order.SetlDetail = detailStr
  32682. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32683. err = service.UpDateOrder(order)
  32684. if err == nil {
  32685. c.ServeSuccessJSON(map[string]interface{}{
  32686. "msg": "预结算成功",
  32687. })
  32688. } else {
  32689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32690. return
  32691. }
  32692. }
  32693. } else {
  32694. adminUser := c.GetAdminUserInfo()
  32695. errlog := &models.HisOrderError{
  32696. UserOrgId: adminUser.CurrentOrgId,
  32697. Ctime: time.Now().Unix(),
  32698. Mtime: time.Now().Unix(),
  32699. ErrMsg: res.ErrMsg,
  32700. Status: 1,
  32701. PatientId: id,
  32702. RecordTime: recordDateTime,
  32703. Stage: 4,
  32704. }
  32705. service.CreateErrMsgLog(errlog)
  32706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32707. return
  32708. }
  32709. } else {
  32710. if miConfig.MdtrtareaAdmvs == "150499" {
  32711. order := &models.HisOrder{
  32712. UserOrgId: adminUser.CurrentOrgId,
  32713. HisPatientId: his.ID,
  32714. PatientId: his.PatientId,
  32715. SettleAccountsDate: recordDateTime,
  32716. Ctime: time.Now().Unix(),
  32717. Mtime: time.Now().Unix(),
  32718. MdtrtId: his.Number,
  32719. PsnNo: his.PsnNo,
  32720. MedType: strconv.FormatInt(reg_type, 10),
  32721. Status: 1,
  32722. Number: chrg_bchno,
  32723. Infcode: res.Infcode,
  32724. WarnMsg: res.WarnMsg,
  32725. Cainfo: res.Cainfo,
  32726. ErrMsg: res.ErrMsg,
  32727. RespondTime: res.RefmsgTime,
  32728. InfRefmsgid: res.InfRefmsgid,
  32729. OrderStatus: 1,
  32730. IsMedicineInsurance: 1,
  32731. SettleType: settle_accounts_type,
  32732. SettleStartTime: start_time,
  32733. SettleEndTime: end_time,
  32734. Creator: roles.AdminUserId,
  32735. Modify: roles.AdminUserId,
  32736. PType: 2,
  32737. Diagnosis: diagnosis_id,
  32738. }
  32739. err = service.CreateOrder(order)
  32740. if err != nil {
  32741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32742. return
  32743. }
  32744. }
  32745. adminUser := c.GetAdminUserInfo()
  32746. errlog := &models.HisOrderError{
  32747. UserOrgId: adminUser.CurrentOrgId,
  32748. Ctime: time.Now().Unix(),
  32749. Mtime: time.Now().Unix(),
  32750. ErrMsg: res.ErrMsg,
  32751. Status: 1,
  32752. PatientId: id,
  32753. RecordTime: recordDateTime,
  32754. Stage: 4,
  32755. }
  32756. service.CreateErrMsgLog(errlog)
  32757. c.ServeSuccessJSON(map[string]interface{}{
  32758. "failed_code": -10,
  32759. "msg": res.ErrMsg,
  32760. })
  32761. return
  32762. }
  32763. }
  32764. }
  32765. }
  32766. // 退款
  32767. func (c *HisApiController) Refund() {
  32768. order_id, _ := c.GetInt64("order_id")
  32769. admin_user_id, _ := c.GetInt64("admin_user_id")
  32770. adminUser := c.GetAdminUserInfo()
  32771. var order models.HisOrder
  32772. order, _ = service.GetHisOrderByID(order_id)
  32773. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32774. if fapiao.ID > 0 {
  32775. c.ServeSuccessJSON(map[string]interface{}{
  32776. "failed_code": -10,
  32777. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32778. })
  32779. return
  32780. }
  32781. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32782. if order.ID == 0 {
  32783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32784. return
  32785. }
  32786. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32789. if config.IsOpen == 1 { //对接了医保,走医保流程
  32790. var res ResultSixteen
  32791. var ahres ResultSevenAH
  32792. var resSixteen10265 ResultSixteen10265
  32793. var resSixteen10265Two ResultSixteen10265Two
  32794. var gz ResultgzSixteen10265Two
  32795. var src_resquest string
  32796. var result string
  32797. if miConfig.MdtrtareaAdmvs == "421300" {
  32798. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32799. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32800. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32801. resp3, requestErr3 := http.Get(api3)
  32802. if requestErr3 != nil {
  32803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32804. return
  32805. }
  32806. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32807. if ioErr3 != nil {
  32808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32810. return
  32811. }
  32812. var respJSON3 map[string]interface{}
  32813. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32816. return
  32817. }
  32818. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32819. userJSONBytes3, _ := json.Marshal(respJSON3)
  32820. fmt.Println("log")
  32821. fmt.Println(string(userJSONBytes3))
  32822. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32823. utils.ErrorLog("解析失败:%v", err)
  32824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32825. return
  32826. }
  32827. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32828. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32829. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32830. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32831. resp3, requestErr3 := http.Get(api3)
  32832. if requestErr3 != nil {
  32833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32834. return
  32835. }
  32836. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32837. if ioErr3 != nil {
  32838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32840. return
  32841. }
  32842. var respJSON3 map[string]interface{}
  32843. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32846. return
  32847. }
  32848. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32849. userJSONBytes3, _ := json.Marshal(respJSON3)
  32850. fmt.Println("log")
  32851. fmt.Println(string(userJSONBytes3))
  32852. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32853. utils.ErrorLog("解析失败:%v", err)
  32854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32855. return
  32856. }
  32857. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32858. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32859. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32860. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32861. resp3, requestErr3 := http.Get(api3)
  32862. if requestErr3 != nil {
  32863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32864. return
  32865. }
  32866. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32867. if ioErr3 != nil {
  32868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32870. return
  32871. }
  32872. var respJSON3 map[string]interface{}
  32873. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32876. return
  32877. }
  32878. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32879. userJSONBytes3, _ := json.Marshal(respJSON3)
  32880. fmt.Println("log")
  32881. fmt.Println(string(userJSONBytes3))
  32882. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32883. utils.ErrorLog("解析失败:%v", err)
  32884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32885. return
  32886. }
  32887. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32888. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32889. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32891. resp3, requestErr3 := http.Get(api3)
  32892. if requestErr3 != nil {
  32893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32894. return
  32895. }
  32896. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32897. if ioErr3 != nil {
  32898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32900. return
  32901. }
  32902. var respJSON3 map[string]interface{}
  32903. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32906. return
  32907. }
  32908. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32909. userJSONBytes3, _ := json.Marshal(respJSON3)
  32910. fmt.Println("log")
  32911. fmt.Println(string(userJSONBytes3))
  32912. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32913. utils.ErrorLog("解析失败:%v", err)
  32914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32915. return
  32916. }
  32917. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32918. var api3 string
  32919. if miConfig.MdtrtareaAdmvs == "320830" {
  32920. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  32921. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32922. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32923. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32924. } else if miConfig.MdtrtareaAdmvs == "320921" {
  32925. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32926. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32927. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32928. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32929. } else {
  32930. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32931. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32932. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32933. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32934. }
  32935. resp3, requestErr3 := http.Get(api3)
  32936. if requestErr3 != nil {
  32937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32938. return
  32939. }
  32940. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32941. if ioErr3 != nil {
  32942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32944. return
  32945. }
  32946. var respJSON3 map[string]interface{}
  32947. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32950. return
  32951. }
  32952. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32953. userJSONBytes3, _ := json.Marshal(respJSON3)
  32954. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32955. utils.ErrorLog("解析失败:%v", err)
  32956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32957. return
  32958. }
  32959. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32960. res.Output = resSixteen10265.Output
  32961. res.ErrMsg = resSixteen10265.ErrMsg
  32962. res.Cainfo = resSixteen10265.Cainfo
  32963. res.WarnMsg = resSixteen10265.WarnMsg
  32964. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32965. res.Infcode = infocode
  32966. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32967. var api3 string
  32968. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  32969. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32971. resp3, requestErr3 := http.Get(api3)
  32972. if requestErr3 != nil {
  32973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32974. return
  32975. }
  32976. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32977. if ioErr3 != nil {
  32978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32980. return
  32981. }
  32982. var respJSON3 map[string]interface{}
  32983. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32986. return
  32987. }
  32988. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32989. userJSONBytes3, _ := json.Marshal(respJSON3)
  32990. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32991. utils.ErrorLog("解析失败:%v", err)
  32992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32993. return
  32994. }
  32995. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32996. res.Output = resSixteen10265.Output
  32997. res.ErrMsg = resSixteen10265.ErrMsg
  32998. res.Cainfo = resSixteen10265.Cainfo
  32999. res.WarnMsg = resSixteen10265.WarnMsg
  33000. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33001. res.Infcode = infocode
  33002. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33003. 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)
  33004. var dat map[string]interface{}
  33005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33006. fmt.Println(dat)
  33007. } else {
  33008. fmt.Println(err)
  33009. }
  33010. saveLog(result, src_resquest, "2208", "退费")
  33011. userJSONBytes, _ := json.Marshal(dat)
  33012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33013. utils.ErrorLog("解析失败:%v", err)
  33014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33015. return
  33016. }
  33017. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33018. 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, "")
  33019. var dat map[string]interface{}
  33020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33021. fmt.Println(dat)
  33022. } else {
  33023. fmt.Println(err)
  33024. }
  33025. saveLog(result, src_resquest, "2208", "退费")
  33026. userJSONBytes, _ := json.Marshal(dat)
  33027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33028. utils.ErrorLog("解析失败:%v", err)
  33029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33030. return
  33031. }
  33032. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33033. 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, "")
  33034. var dat map[string]interface{}
  33035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33036. fmt.Println(dat)
  33037. } else {
  33038. fmt.Println(err)
  33039. }
  33040. saveLog(result, src_resquest, "2208", "退费")
  33041. userJSONBytes, _ := json.Marshal(dat)
  33042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33043. utils.ErrorLog("解析失败:%v", err)
  33044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33045. return
  33046. }
  33047. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33048. 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, "")
  33049. var dat map[string]interface{}
  33050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33051. fmt.Println(dat)
  33052. } else {
  33053. fmt.Println(err)
  33054. }
  33055. saveLog(result, src_resquest, "2208", "退费")
  33056. userJSONBytes, _ := json.Marshal(dat)
  33057. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33058. utils.ErrorLog("解析失败:%v", err)
  33059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33060. return
  33061. }
  33062. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33063. var api3 string
  33064. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33065. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33067. resp3, requestErr3 := http.Get(api3)
  33068. if requestErr3 != nil {
  33069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33070. return
  33071. }
  33072. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33073. if ioErr3 != nil {
  33074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33076. return
  33077. }
  33078. var respJSON3 map[string]interface{}
  33079. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33082. return
  33083. }
  33084. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33085. if status == "0" {
  33086. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33087. c.ServeSuccessJSON(map[string]interface{}{
  33088. "failed_code": -10,
  33089. "msg": err_msg,
  33090. })
  33091. return
  33092. }
  33093. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33094. userJSONBytes3, _ := json.Marshal(respJSON3)
  33095. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33096. // utils.ErrorLog("解析失败:%v", err)
  33097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33098. // return
  33099. //}
  33100. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33101. utils.ErrorLog("解析失败:%v", err)
  33102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33103. return
  33104. }
  33105. res.InfRefmsgid = ahres.InfRefmsgid
  33106. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33107. // 创建对应的Time类型
  33108. t := time.UnixMilli(timestamp)
  33109. // 格式化成指定的日期字符串
  33110. str := t.Format("2006-01-02 15:04:05")
  33111. res.Output.Setlinfo.SetlTime = str
  33112. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33113. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33114. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33115. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33116. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33117. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33118. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33119. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33120. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33121. //
  33122. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33123. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33124. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33125. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33126. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33127. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33128. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33129. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33130. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33131. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33132. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33133. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33134. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33135. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33136. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33137. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33138. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33139. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33140. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33141. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33142. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33143. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33144. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33145. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33146. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33147. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33148. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33149. //res.Output.Setldetail = ahres.Output.Setldetail
  33150. res.ErrMsg = ahres.ErrMsg
  33151. res.Cainfo = ahres.Cainfo
  33152. res.WarnMsg = ahres.WarnMsg
  33153. res.Infcode = ahres.Infcode
  33154. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33155. var api3 string
  33156. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33157. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33159. resp3, requestErr3 := http.Get(api3)
  33160. if requestErr3 != nil {
  33161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33162. return
  33163. }
  33164. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33165. if ioErr3 != nil {
  33166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33168. return
  33169. }
  33170. var respJSON3 map[string]interface{}
  33171. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33174. return
  33175. }
  33176. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33177. if status == "0" {
  33178. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33179. c.ServeSuccessJSON(map[string]interface{}{
  33180. "failed_code": -10,
  33181. "msg": err_msg,
  33182. })
  33183. return
  33184. }
  33185. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33186. userJSONBytes3, _ := json.Marshal(respJSON3)
  33187. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33188. // utils.ErrorLog("解析失败:%v", err)
  33189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33190. // return
  33191. //}
  33192. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33193. utils.ErrorLog("解析失败:%v", err)
  33194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33195. return
  33196. }
  33197. res.InfRefmsgid = ahres.InfRefmsgid
  33198. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33199. // 创建对应的Time类型
  33200. t := time.UnixMilli(timestamp)
  33201. // 格式化成指定的日期字符串
  33202. str := t.Format("2006-01-02 15:04:05")
  33203. res.Output.Setlinfo.SetlTime = str
  33204. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33205. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33206. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33207. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33208. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33209. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33210. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33211. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33212. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33213. //
  33214. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33215. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33216. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33217. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33218. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33219. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33220. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33221. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33222. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33223. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33224. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33225. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33226. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33227. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33228. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33229. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33230. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33231. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33232. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33233. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33234. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33235. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33236. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33237. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33238. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33239. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33240. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33241. //res.Output.Setldetail = ahres.Output.Setldetail
  33242. res.ErrMsg = ahres.ErrMsg
  33243. res.Cainfo = ahres.Cainfo
  33244. res.WarnMsg = ahres.WarnMsg
  33245. res.Infcode = ahres.Infcode
  33246. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33247. 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, "")
  33248. var dat map[string]interface{}
  33249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33250. fmt.Println(dat)
  33251. } else {
  33252. fmt.Println(err)
  33253. }
  33254. saveLog(result, src_resquest, "2208", "退费")
  33255. userJSONBytes, _ := json.Marshal(dat)
  33256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33257. utils.ErrorLog("解析失败:%v", err)
  33258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33259. return
  33260. }
  33261. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33262. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33263. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33264. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33265. resp3, requestErr3 := http.Get(api3)
  33266. if requestErr3 != nil {
  33267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33268. return
  33269. }
  33270. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33271. if ioErr3 != nil {
  33272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33274. return
  33275. }
  33276. var respJSON3 map[string]interface{}
  33277. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33280. return
  33281. }
  33282. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33283. userJSONBytes3, _ := json.Marshal(respJSON3)
  33284. fmt.Println("log")
  33285. fmt.Println(string(userJSONBytes3))
  33286. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33287. utils.ErrorLog("解析失败:%v", err)
  33288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33289. return
  33290. }
  33291. } else {
  33292. if miConfig.Code == "H15049901371" {
  33293. 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)
  33294. var dat map[string]interface{}
  33295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33296. fmt.Println(dat)
  33297. } else {
  33298. fmt.Println(err)
  33299. }
  33300. saveLog(result, src_resquest, "2208", "退费")
  33301. if strings.Contains(result, "Post") {
  33302. res.Infcode = -1
  33303. res.ErrMsg = result
  33304. }
  33305. userJSONBytes, _ := json.Marshal(dat)
  33306. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33307. utils.ErrorLog("解析失败:%v", err)
  33308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33309. return
  33310. }
  33311. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33312. res.Output = resSixteen10265.Output
  33313. res.ErrMsg = resSixteen10265.ErrMsg
  33314. res.Cainfo = resSixteen10265.Cainfo
  33315. res.WarnMsg = resSixteen10265.WarnMsg
  33316. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33317. res.Infcode = infocode
  33318. } else {
  33319. 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)
  33320. var dat map[string]interface{}
  33321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33322. fmt.Println(dat)
  33323. } else {
  33324. fmt.Println(err)
  33325. }
  33326. saveLog(result, src_resquest, "2208", "退费")
  33327. userJSONBytes, _ := json.Marshal(dat)
  33328. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33329. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33330. utils.ErrorLog("解析失败:%v", err)
  33331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33332. return
  33333. }
  33334. res.Infcode = gz.Infcode
  33335. } else {
  33336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33337. utils.ErrorLog("解析失败:%v", err)
  33338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33339. return
  33340. }
  33341. }
  33342. if strings.Contains(result, "Post") {
  33343. res.Infcode = -1
  33344. res.ErrMsg = result
  33345. }
  33346. }
  33347. }
  33348. if res.Infcode == -1 {
  33349. c.ServeSuccessJSON(map[string]interface{}{
  33350. "failed_code": -10,
  33351. "msg": res.ErrMsg,
  33352. })
  33353. return
  33354. }
  33355. if res.Infcode != -1 {
  33356. var res2 ResultSix
  33357. var resSix10265 ResultSix10265
  33358. if miConfig.MdtrtareaAdmvs == "421300" {
  33359. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33360. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33361. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33362. resp3, requestErr3 := http.Get(api3)
  33363. if requestErr3 != nil {
  33364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33365. return
  33366. }
  33367. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33368. if ioErr3 != nil {
  33369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33371. return
  33372. }
  33373. var respJSON3 map[string]interface{}
  33374. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33377. return
  33378. }
  33379. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33380. userJSONBytes3, _ := json.Marshal(respJSON3)
  33381. fmt.Println("log")
  33382. fmt.Println(string(userJSONBytes3))
  33383. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33384. utils.ErrorLog("解析失败:%v", err)
  33385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33386. return
  33387. }
  33388. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33389. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33390. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33391. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33392. resp3, requestErr3 := http.Get(api3)
  33393. if requestErr3 != nil {
  33394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33395. return
  33396. }
  33397. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33398. if ioErr3 != nil {
  33399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33401. return
  33402. }
  33403. var respJSON3 map[string]interface{}
  33404. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33407. return
  33408. }
  33409. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33410. userJSONBytes3, _ := json.Marshal(respJSON3)
  33411. fmt.Println("log")
  33412. fmt.Println(string(userJSONBytes3))
  33413. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33414. utils.ErrorLog("解析失败:%v", err)
  33415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33416. return
  33417. }
  33418. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33419. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33420. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33421. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33422. resp3, requestErr3 := http.Get(api3)
  33423. if requestErr3 != nil {
  33424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33425. return
  33426. }
  33427. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33428. if ioErr3 != nil {
  33429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33431. return
  33432. }
  33433. var respJSON3 map[string]interface{}
  33434. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33437. return
  33438. }
  33439. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33440. userJSONBytes3, _ := json.Marshal(respJSON3)
  33441. fmt.Println("log")
  33442. fmt.Println(string(userJSONBytes3))
  33443. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33444. utils.ErrorLog("解析失败:%v", err)
  33445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33446. return
  33447. }
  33448. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33449. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33450. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33451. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33452. resp3, requestErr3 := http.Get(api3)
  33453. if requestErr3 != nil {
  33454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33455. return
  33456. }
  33457. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33458. if ioErr3 != nil {
  33459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33461. return
  33462. }
  33463. var respJSON3 map[string]interface{}
  33464. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33467. return
  33468. }
  33469. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33470. userJSONBytes3, _ := json.Marshal(respJSON3)
  33471. fmt.Println("log")
  33472. fmt.Println(string(userJSONBytes3))
  33473. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33474. utils.ErrorLog("解析失败:%v", err)
  33475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33476. return
  33477. }
  33478. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33479. var api3 string
  33480. if miConfig.MdtrtareaAdmvs == "320830" {
  33481. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33482. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33483. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33484. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33485. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33486. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33487. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33488. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33489. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33490. } else {
  33491. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33492. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33493. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33495. }
  33496. resp3, requestErr3 := http.Get(api3)
  33497. if requestErr3 != nil {
  33498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33499. return
  33500. }
  33501. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33502. if ioErr3 != nil {
  33503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33505. return
  33506. }
  33507. var respJSON3 map[string]interface{}
  33508. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33511. return
  33512. }
  33513. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33514. userJSONBytes3, _ := json.Marshal(respJSON3)
  33515. fmt.Println("log")
  33516. fmt.Println(string(userJSONBytes3))
  33517. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33518. utils.ErrorLog("解析失败:%v", err)
  33519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33520. return
  33521. }
  33522. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33523. res2.Output = resSix10265.Output
  33524. res2.ErrMsg = resSix10265.ErrMsg
  33525. res2.Cainfo = resSix10265.Cainfo
  33526. res2.WarnMsg = resSix10265.WarnMsg
  33527. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33528. res2.Infcode = infocode
  33529. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33530. var api3 string
  33531. new_chrg_bchno := order.Number
  33532. if adminUser.CurrentOrgId == 10265 {
  33533. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33534. new_chrg_bchno = "0000"
  33535. }
  33536. }
  33537. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33538. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33540. resp3, requestErr3 := http.Get(api3)
  33541. if requestErr3 != nil {
  33542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33543. return
  33544. }
  33545. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33546. if ioErr3 != nil {
  33547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33549. return
  33550. }
  33551. var respJSON3 map[string]interface{}
  33552. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33555. return
  33556. }
  33557. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33558. userJSONBytes3, _ := json.Marshal(respJSON3)
  33559. fmt.Println("log")
  33560. fmt.Println(string(userJSONBytes3))
  33561. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33562. utils.ErrorLog("解析失败:%v", err)
  33563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33564. return
  33565. }
  33566. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33567. res2.Output = resSix10265.Output
  33568. res2.ErrMsg = resSix10265.ErrMsg
  33569. res2.Cainfo = resSix10265.Cainfo
  33570. res2.WarnMsg = resSix10265.WarnMsg
  33571. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33572. res2.Infcode = infocode
  33573. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33574. 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)
  33575. var dat map[string]interface{}
  33576. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33577. fmt.Println(dat)
  33578. } else {
  33579. fmt.Println(err)
  33580. }
  33581. saveLog(result2, src_request, "2205", "撤销明细")
  33582. userJSONBytes, _ := json.Marshal(dat)
  33583. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33584. utils.ErrorLog("解析失败:%v", err)
  33585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33586. return
  33587. }
  33588. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33589. 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, "")
  33590. var dat map[string]interface{}
  33591. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33592. fmt.Println(dat)
  33593. } else {
  33594. fmt.Println(err)
  33595. }
  33596. saveLog(result2, src_request, "2205", "撤销明细")
  33597. userJSONBytes, _ := json.Marshal(dat)
  33598. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33599. utils.ErrorLog("解析失败:%v", err)
  33600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33601. return
  33602. }
  33603. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33604. 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, "")
  33605. var dat map[string]interface{}
  33606. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33607. fmt.Println(dat)
  33608. } else {
  33609. fmt.Println(err)
  33610. }
  33611. saveLog(result2, src_request, "2205", "撤销明细")
  33612. userJSONBytes, _ := json.Marshal(dat)
  33613. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33614. utils.ErrorLog("解析失败:%v", err)
  33615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33616. return
  33617. }
  33618. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33619. 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, "")
  33620. var dat map[string]interface{}
  33621. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33622. fmt.Println(dat)
  33623. } else {
  33624. fmt.Println(err)
  33625. }
  33626. saveLog(result2, src_request, "2205", "撤销明细")
  33627. userJSONBytes, _ := json.Marshal(dat)
  33628. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33629. utils.ErrorLog("解析失败:%v", err)
  33630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33631. return
  33632. }
  33633. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33634. var api3 string
  33635. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33636. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33638. resp3, requestErr3 := http.Get(api3)
  33639. if requestErr3 != nil {
  33640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33641. return
  33642. }
  33643. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33644. if ioErr3 != nil {
  33645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33647. return
  33648. }
  33649. var respJSON3 map[string]interface{}
  33650. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33653. return
  33654. }
  33655. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33656. if status == "0" {
  33657. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33658. c.ServeSuccessJSON(map[string]interface{}{
  33659. "failed_code": -10,
  33660. "msg": err_msg,
  33661. })
  33662. return
  33663. }
  33664. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33665. userJSONBytes3, _ := json.Marshal(respJSON3)
  33666. fmt.Println("log")
  33667. fmt.Println(string(userJSONBytes3))
  33668. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33669. utils.ErrorLog("解析失败:%v", err)
  33670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33671. return
  33672. }
  33673. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33674. 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, "")
  33675. var dat map[string]interface{}
  33676. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33677. fmt.Println(dat)
  33678. } else {
  33679. fmt.Println(err)
  33680. }
  33681. saveLog(result2, src_request, "2205", "撤销明细")
  33682. userJSONBytes, _ := json.Marshal(dat)
  33683. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33684. utils.ErrorLog("解析失败:%v", err)
  33685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33686. return
  33687. }
  33688. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33689. 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, "")
  33690. var dat map[string]interface{}
  33691. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33692. fmt.Println(dat)
  33693. } else {
  33694. fmt.Println(err)
  33695. }
  33696. saveLog(result2, src_request, "2205", "撤销明细")
  33697. userJSONBytes, _ := json.Marshal(dat)
  33698. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33699. utils.ErrorLog("解析失败:%v", err)
  33700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33701. return
  33702. }
  33703. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33704. 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, "")
  33705. var dat map[string]interface{}
  33706. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33707. fmt.Println(dat)
  33708. } else {
  33709. fmt.Println(err)
  33710. }
  33711. saveLog(result2, src_request, "2205", "撤销明细")
  33712. userJSONBytes, _ := json.Marshal(dat)
  33713. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33714. utils.ErrorLog("解析失败:%v", err)
  33715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33716. return
  33717. }
  33718. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33719. var api3 string
  33720. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33721. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33722. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33723. resp3, requestErr3 := http.Get(api3)
  33724. if requestErr3 != nil {
  33725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33726. return
  33727. }
  33728. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33729. if ioErr3 != nil {
  33730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33732. return
  33733. }
  33734. var respJSON3 map[string]interface{}
  33735. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33738. return
  33739. }
  33740. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33741. if status == "0" {
  33742. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33743. c.ServeSuccessJSON(map[string]interface{}{
  33744. "failed_code": -10,
  33745. "msg": err_msg,
  33746. })
  33747. return
  33748. }
  33749. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33750. userJSONBytes3, _ := json.Marshal(respJSON3)
  33751. fmt.Println("log")
  33752. fmt.Println(string(userJSONBytes3))
  33753. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33754. utils.ErrorLog("解析失败:%v", err)
  33755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33756. return
  33757. }
  33758. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33759. 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, "")
  33760. var dat map[string]interface{}
  33761. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33762. fmt.Println(dat)
  33763. } else {
  33764. fmt.Println(err)
  33765. }
  33766. saveLog(result2, src_request, "2205", "撤销明细")
  33767. userJSONBytes, _ := json.Marshal(dat)
  33768. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33769. utils.ErrorLog("解析失败:%v", err)
  33770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33771. return
  33772. }
  33773. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33774. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33775. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33776. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33777. resp3, requestErr3 := http.Get(api3)
  33778. if requestErr3 != nil {
  33779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33780. return
  33781. }
  33782. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33783. if ioErr3 != nil {
  33784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33786. return
  33787. }
  33788. var respJSON3 map[string]interface{}
  33789. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33792. return
  33793. }
  33794. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33795. userJSONBytes3, _ := json.Marshal(respJSON3)
  33796. fmt.Println("log")
  33797. fmt.Println(string(userJSONBytes3))
  33798. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33799. utils.ErrorLog("解析失败:%v", err)
  33800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33801. return
  33802. }
  33803. } else {
  33804. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33805. res2.Infcode = 0
  33806. } else {
  33807. 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)
  33808. var dat map[string]interface{}
  33809. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33810. fmt.Println(dat)
  33811. } else {
  33812. fmt.Println(err)
  33813. }
  33814. saveLog(result2, src_request, "2205", "撤销明细")
  33815. userJSONBytes, _ := json.Marshal(dat)
  33816. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33817. utils.ErrorLog("解析失败:%v", err)
  33818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33819. return
  33820. }
  33821. }
  33822. }
  33823. if res2.Infcode == -1 {
  33824. c.ServeSuccessJSON(map[string]interface{}{
  33825. "failed_code": -10,
  33826. "msg": res2.ErrMsg,
  33827. })
  33828. return
  33829. }
  33830. if res2.Infcode == 0 {
  33831. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  33832. if err == nil {
  33833. //当押金不为零时产生退费记录
  33834. if order.Decimal != 0 {
  33835. tmp := strconv.FormatInt(order.ID, 10)
  33836. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  33837. if err != nil {
  33838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33839. return
  33840. }
  33841. }
  33842. c.ServeSuccessJSON(map[string]interface{}{
  33843. "msg": "退费成功",
  33844. })
  33845. } else {
  33846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33847. return
  33848. }
  33849. } else {
  33850. c.ServeSuccessJSON(map[string]interface{}{
  33851. "failed_code": -10,
  33852. "msg": res2.ErrMsg,
  33853. })
  33854. }
  33855. } else {
  33856. c.ServeSuccessJSON(map[string]interface{}{
  33857. "failed_code": -10,
  33858. "msg": res.ErrMsg,
  33859. })
  33860. }
  33861. }
  33862. }
  33863. func (c *HisApiController) RefundNumber() {
  33864. record_time := c.GetString("record_time")
  33865. //patient_id, _ := c.GetInt64("patient_id")
  33866. admin_user_id, _ := c.GetInt64("admin_user_id")
  33867. his_patient_id, _ := c.GetInt64("id")
  33868. timeLayout := "2006-01-02"
  33869. loc, _ := time.LoadLocation("Local")
  33870. adminUser := c.GetAdminUserInfo()
  33871. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33872. fmt.Println(err)
  33873. if err != nil {
  33874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33875. return
  33876. }
  33877. recordDateTime := theTime.Unix()
  33878. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33879. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  33880. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33881. //order, _ := service.GetHisOrderByID(order_id)
  33882. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33883. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33884. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33885. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  33886. if count > 0 {
  33887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  33888. return
  33889. }
  33890. if config.IsOpen == 1 { //对接了医保,走医保流程
  33891. var res2 ResultSix
  33892. var res3 GZResultSix
  33893. var resSix10265 ResultSix10265
  33894. if miConfig.MdtrtareaAdmvs == "421300" {
  33895. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33896. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33898. resp3, requestErr3 := http.Get(api3)
  33899. if requestErr3 != nil {
  33900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33901. return
  33902. }
  33903. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33904. if ioErr3 != nil {
  33905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33907. return
  33908. }
  33909. var respJSON3 map[string]interface{}
  33910. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33913. return
  33914. }
  33915. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33916. userJSONBytes3, _ := json.Marshal(respJSON3)
  33917. fmt.Println("log")
  33918. fmt.Println(string(userJSONBytes3))
  33919. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33920. utils.ErrorLog("解析失败:%v", err)
  33921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33922. return
  33923. }
  33924. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33925. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33926. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33927. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33928. resp3, requestErr3 := http.Get(api3)
  33929. if requestErr3 != nil {
  33930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33931. return
  33932. }
  33933. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33934. if ioErr3 != nil {
  33935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33937. return
  33938. }
  33939. var respJSON3 map[string]interface{}
  33940. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33943. return
  33944. }
  33945. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33946. userJSONBytes3, _ := json.Marshal(respJSON3)
  33947. fmt.Println("log")
  33948. fmt.Println(string(userJSONBytes3))
  33949. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33950. utils.ErrorLog("解析失败:%v", err)
  33951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33952. return
  33953. }
  33954. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33955. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33956. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33958. resp3, requestErr3 := http.Get(api3)
  33959. if requestErr3 != nil {
  33960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33961. return
  33962. }
  33963. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33964. if ioErr3 != nil {
  33965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33967. return
  33968. }
  33969. var respJSON3 map[string]interface{}
  33970. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33973. return
  33974. }
  33975. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33976. userJSONBytes3, _ := json.Marshal(respJSON3)
  33977. fmt.Println("log")
  33978. fmt.Println(string(userJSONBytes3))
  33979. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33980. utils.ErrorLog("解析失败:%v", err)
  33981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33982. return
  33983. }
  33984. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33985. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33986. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33987. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33988. resp3, requestErr3 := http.Get(api3)
  33989. if requestErr3 != nil {
  33990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33991. return
  33992. }
  33993. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33994. if ioErr3 != nil {
  33995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33997. return
  33998. }
  33999. var respJSON3 map[string]interface{}
  34000. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34003. return
  34004. }
  34005. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34006. userJSONBytes3, _ := json.Marshal(respJSON3)
  34007. fmt.Println("log")
  34008. fmt.Println(string(userJSONBytes3))
  34009. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34010. utils.ErrorLog("解析失败:%v", err)
  34011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34012. return
  34013. }
  34014. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34015. var api3 string
  34016. if miConfig.MdtrtareaAdmvs == "320830" {
  34017. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34018. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34019. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34020. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34021. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34022. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34023. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34024. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34025. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34026. } else {
  34027. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34028. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34029. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34030. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34031. }
  34032. resp3, requestErr3 := http.Get(api3)
  34033. if requestErr3 != nil {
  34034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34035. return
  34036. }
  34037. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34038. if ioErr3 != nil {
  34039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34041. return
  34042. }
  34043. var respJSON3 map[string]interface{}
  34044. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34047. return
  34048. }
  34049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34050. userJSONBytes3, _ := json.Marshal(respJSON3)
  34051. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34052. utils.ErrorLog("解析失败:%v", err)
  34053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34054. return
  34055. }
  34056. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34057. res2.Output = resSix10265.Output
  34058. res2.ErrMsg = resSix10265.ErrMsg
  34059. res2.Cainfo = resSix10265.Cainfo
  34060. res2.WarnMsg = resSix10265.WarnMsg
  34061. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34062. res2.Infcode = infocode
  34063. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34064. var api3 string
  34065. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34066. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34068. resp3, requestErr3 := http.Get(api3)
  34069. if requestErr3 != nil {
  34070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34071. return
  34072. }
  34073. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34074. if ioErr3 != nil {
  34075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34077. return
  34078. }
  34079. var respJSON3 map[string]interface{}
  34080. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34083. return
  34084. }
  34085. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34086. userJSONBytes3, _ := json.Marshal(respJSON3)
  34087. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34088. utils.ErrorLog("解析失败:%v", err)
  34089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34090. return
  34091. }
  34092. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34093. res2.Output = resSix10265.Output
  34094. res2.ErrMsg = resSix10265.ErrMsg
  34095. res2.Cainfo = resSix10265.Cainfo
  34096. res2.WarnMsg = resSix10265.WarnMsg
  34097. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34098. res2.Infcode = infocode
  34099. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34100. 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)
  34101. var dat map[string]interface{}
  34102. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34103. fmt.Println(dat)
  34104. } else {
  34105. fmt.Println(err)
  34106. }
  34107. saveLog(result, request, "2202", "退号")
  34108. userJSONBytes, _ := json.Marshal(dat)
  34109. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34110. utils.ErrorLog("解析失败:%v", err)
  34111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34112. return
  34113. }
  34114. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34115. 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, "")
  34116. var dat map[string]interface{}
  34117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34118. fmt.Println(dat)
  34119. } else {
  34120. fmt.Println(err)
  34121. }
  34122. saveLog(result, request, "2202", "退号")
  34123. userJSONBytes, _ := json.Marshal(dat)
  34124. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34125. utils.ErrorLog("解析失败:%v", err)
  34126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34127. return
  34128. }
  34129. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34130. 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, "")
  34131. var dat map[string]interface{}
  34132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34133. fmt.Println(dat)
  34134. } else {
  34135. fmt.Println(err)
  34136. }
  34137. saveLog(result, request, "2202", "退号")
  34138. userJSONBytes, _ := json.Marshal(dat)
  34139. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34140. utils.ErrorLog("解析失败:%v", err)
  34141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34142. return
  34143. }
  34144. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34145. 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, "")
  34146. var dat map[string]interface{}
  34147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34148. fmt.Println(dat)
  34149. } else {
  34150. fmt.Println(err)
  34151. }
  34152. saveLog(result, request, "2202", "退号")
  34153. userJSONBytes, _ := json.Marshal(dat)
  34154. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34155. utils.ErrorLog("解析失败:%v", err)
  34156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34157. return
  34158. }
  34159. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34160. var api3 string
  34161. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34162. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34163. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34164. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34165. resp3, requestErr3 := http.Get(api3)
  34166. if requestErr3 != nil {
  34167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34168. return
  34169. }
  34170. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34171. if ioErr3 != nil {
  34172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34174. return
  34175. }
  34176. var respJSON3 map[string]interface{}
  34177. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34180. return
  34181. }
  34182. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34183. if status == "0" {
  34184. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34185. c.ServeSuccessJSON(map[string]interface{}{
  34186. "failed_code": -10,
  34187. "msg": err_msg,
  34188. })
  34189. return
  34190. }
  34191. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34192. userJSONBytes3, _ := json.Marshal(respJSON3)
  34193. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34194. utils.ErrorLog("解析失败:%v", err)
  34195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34196. return
  34197. }
  34198. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34199. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34200. var api3 string
  34201. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34202. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34203. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34204. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34205. resp3, requestErr3 := http.Get(api3)
  34206. if requestErr3 != nil {
  34207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34208. return
  34209. }
  34210. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34211. if ioErr3 != nil {
  34212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34214. return
  34215. }
  34216. var respJSON3 map[string]interface{}
  34217. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34220. return
  34221. }
  34222. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34223. if status == "0" {
  34224. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34225. c.ServeSuccessJSON(map[string]interface{}{
  34226. "failed_code": -10,
  34227. "msg": err_msg,
  34228. })
  34229. return
  34230. }
  34231. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34232. userJSONBytes3, _ := json.Marshal(respJSON3)
  34233. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34234. utils.ErrorLog("解析失败:%v", err)
  34235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34236. return
  34237. }
  34238. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34239. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34240. 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, "")
  34241. var dat map[string]interface{}
  34242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34243. fmt.Println(dat)
  34244. } else {
  34245. fmt.Println(err)
  34246. }
  34247. saveLog(result, request, "2202", "退号")
  34248. userJSONBytes, _ := json.Marshal(dat)
  34249. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34250. utils.ErrorLog("解析失败:%v", err)
  34251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34252. return
  34253. }
  34254. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34255. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34256. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34258. resp3, requestErr3 := http.Get(api3)
  34259. if requestErr3 != nil {
  34260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34261. return
  34262. }
  34263. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34264. if ioErr3 != nil {
  34265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34267. return
  34268. }
  34269. var respJSON3 map[string]interface{}
  34270. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34273. return
  34274. }
  34275. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34276. userJSONBytes3, _ := json.Marshal(respJSON3)
  34277. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34278. utils.ErrorLog("解析失败:%v", err)
  34279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34280. return
  34281. }
  34282. } else {
  34283. var api3 string
  34284. if miConfig.Code == "H15049901371" {
  34285. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34286. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34287. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34288. } else {
  34289. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34290. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34291. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34292. }
  34293. resp3, requestErr3 := http.Get(api3)
  34294. if requestErr3 != nil {
  34295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34296. return
  34297. }
  34298. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34299. if ioErr3 != nil {
  34300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34302. return
  34303. }
  34304. var respJSON3 map[string]interface{}
  34305. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34308. return
  34309. }
  34310. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34311. userJSONBytes3, _ := json.Marshal(respJSON3)
  34312. if miConfig.Code == "H15049901371" {
  34313. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34314. utils.ErrorLog("解析失败:%v", err)
  34315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34316. return
  34317. }
  34318. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34319. res2.Output = resSix10265.Output
  34320. res2.ErrMsg = resSix10265.ErrMsg
  34321. res2.Cainfo = resSix10265.Cainfo
  34322. res2.WarnMsg = resSix10265.WarnMsg
  34323. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34324. res2.Infcode = infocode
  34325. } else {
  34326. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34327. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34328. utils.ErrorLog("解析失败:%v", err)
  34329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34330. return
  34331. }
  34332. res2.Infcode = res3.Infcode
  34333. } else {
  34334. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34335. utils.ErrorLog("解析失败:%v", err)
  34336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34337. return
  34338. }
  34339. }
  34340. }
  34341. }
  34342. if res2.Infcode == -1 {
  34343. c.ServeSuccessJSON(map[string]interface{}{
  34344. "failed_code": -10,
  34345. "msg": res2.ErrMsg,
  34346. })
  34347. return
  34348. }
  34349. if res2.Infcode == 0 {
  34350. if err == nil {
  34351. c.ServeSuccessJSON(map[string]interface{}{
  34352. "msg": "退号成功",
  34353. })
  34354. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34355. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34356. } else {
  34357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34358. return
  34359. }
  34360. }
  34361. } else {
  34362. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34363. //if err == nil {
  34364. // c.ServeSuccessJSON(map[string]interface{}{
  34365. // "msg": "退费成功",
  34366. // })
  34367. //} else {
  34368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34369. // return
  34370. //}
  34371. }
  34372. }
  34373. func (c *HisApiController) RefundDetail() {
  34374. order_id, _ := c.GetInt64("order_id")
  34375. admin_user_id, _ := c.GetInt64("admin_user_id")
  34376. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34377. number := c.GetString("number")
  34378. record_time := c.GetString("record_time")
  34379. patient_id, _ := c.GetInt64("patient_id")
  34380. //med_type, _ := c.GetInt64("med_type")
  34381. timeLayout := "2006-01-02"
  34382. loc, _ := time.LoadLocation("Local")
  34383. adminUser := c.GetAdminUserInfo()
  34384. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34385. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34386. fmt.Println(err)
  34387. if err != nil {
  34388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34389. return
  34390. }
  34391. recordDateTime := theTime.Unix()
  34392. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34393. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34394. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34395. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34396. var order models.HisOrder
  34397. order, _ = service.GetHisOrderByID(order_id)
  34398. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34399. if config.IsOpen == 1 { //对接了医保,走医保流程
  34400. var res2 ResultSix
  34401. if miConfig.MdtrtareaAdmvs == "421300" {
  34402. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34403. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34404. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34405. resp3, requestErr3 := http.Get(api3)
  34406. if requestErr3 != nil {
  34407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34408. return
  34409. }
  34410. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34411. if ioErr3 != nil {
  34412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34414. return
  34415. }
  34416. var respJSON3 map[string]interface{}
  34417. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34420. return
  34421. }
  34422. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34423. userJSONBytes3, _ := json.Marshal(respJSON3)
  34424. fmt.Println("log")
  34425. fmt.Println(string(userJSONBytes3))
  34426. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34427. utils.ErrorLog("解析失败:%v", err)
  34428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34429. return
  34430. }
  34431. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34432. if err == nil {
  34433. c.ServeSuccessJSON(map[string]interface{}{
  34434. "msg": "撤销明细成功",
  34435. })
  34436. return
  34437. } else {
  34438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34439. return
  34440. }
  34441. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34442. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34443. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34444. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34445. resp3, requestErr3 := http.Get(api3)
  34446. if requestErr3 != nil {
  34447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34448. return
  34449. }
  34450. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34451. if ioErr3 != nil {
  34452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34454. return
  34455. }
  34456. var respJSON3 map[string]interface{}
  34457. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34460. return
  34461. }
  34462. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34463. userJSONBytes3, _ := json.Marshal(respJSON3)
  34464. fmt.Println("log")
  34465. fmt.Println(string(userJSONBytes3))
  34466. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34467. utils.ErrorLog("解析失败:%v", err)
  34468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34469. return
  34470. }
  34471. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34472. if err == nil {
  34473. c.ServeSuccessJSON(map[string]interface{}{
  34474. "msg": "撤销明细成功",
  34475. })
  34476. return
  34477. } else {
  34478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34479. return
  34480. }
  34481. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34482. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34483. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34485. resp3, requestErr3 := http.Get(api3)
  34486. if requestErr3 != nil {
  34487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34488. return
  34489. }
  34490. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34491. if ioErr3 != nil {
  34492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34494. return
  34495. }
  34496. var respJSON3 map[string]interface{}
  34497. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34500. return
  34501. }
  34502. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34503. userJSONBytes3, _ := json.Marshal(respJSON3)
  34504. fmt.Println("log")
  34505. fmt.Println(string(userJSONBytes3))
  34506. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34507. utils.ErrorLog("解析失败:%v", err)
  34508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34509. return
  34510. }
  34511. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34512. if err == nil {
  34513. c.ServeSuccessJSON(map[string]interface{}{
  34514. "msg": "撤销明细成功",
  34515. })
  34516. return
  34517. } else {
  34518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34519. return
  34520. }
  34521. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34522. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34523. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34525. resp3, requestErr3 := http.Get(api3)
  34526. if requestErr3 != nil {
  34527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34528. return
  34529. }
  34530. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34531. if ioErr3 != nil {
  34532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34534. return
  34535. }
  34536. var respJSON3 map[string]interface{}
  34537. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34540. return
  34541. }
  34542. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34543. userJSONBytes3, _ := json.Marshal(respJSON3)
  34544. fmt.Println("log")
  34545. fmt.Println(string(userJSONBytes3))
  34546. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34547. utils.ErrorLog("解析失败:%v", err)
  34548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34549. return
  34550. }
  34551. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34552. if err == nil {
  34553. c.ServeSuccessJSON(map[string]interface{}{
  34554. "msg": "撤销明细成功",
  34555. })
  34556. return
  34557. } else {
  34558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34559. return
  34560. }
  34561. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34562. var resSix10265 ResultSix10265
  34563. var api3 string
  34564. if miConfig.MdtrtareaAdmvs == "320830" {
  34565. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34566. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" +"0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34568. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34569. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34570. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34571. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34572. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34573. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34574. } else {
  34575. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34576. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34577. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34578. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34579. }
  34580. resp3, requestErr3 := http.Get(api3)
  34581. utils.ErrorLog("接口: %v", requestErr3)
  34582. if requestErr3 != nil {
  34583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34584. return
  34585. }
  34586. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34587. if ioErr3 != nil {
  34588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34590. return
  34591. }
  34592. var respJSON3 map[string]interface{}
  34593. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34596. return
  34597. }
  34598. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34599. userJSONBytes3, _ := json.Marshal(respJSON3)
  34600. fmt.Println("log")
  34601. fmt.Println(string(userJSONBytes3))
  34602. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34603. utils.ErrorLog("解析失败:%v", err)
  34604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34605. return
  34606. }
  34607. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34608. res2.Output = resSix10265.Output
  34609. res2.ErrMsg = resSix10265.ErrMsg
  34610. res2.Cainfo = resSix10265.Cainfo
  34611. res2.WarnMsg = resSix10265.WarnMsg
  34612. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34613. res2.Infcode = infocode
  34614. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34615. if err == nil {
  34616. c.ServeSuccessJSON(map[string]interface{}{
  34617. "msg": "撤销明细成功",
  34618. })
  34619. return
  34620. } else {
  34621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34622. return
  34623. }
  34624. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34625. var api3 string
  34626. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34627. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34628. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34629. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34630. resp3, requestErr3 := http.Get(api3)
  34631. utils.ErrorLog("接口: %v", requestErr3)
  34632. if requestErr3 != nil {
  34633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34634. return
  34635. }
  34636. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34637. if ioErr3 != nil {
  34638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34640. return
  34641. }
  34642. var respJSON3 map[string]interface{}
  34643. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34646. return
  34647. }
  34648. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34649. if status == "0" {
  34650. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34651. c.ServeSuccessJSON(map[string]interface{}{
  34652. "failed_code": -10,
  34653. "msg": err_msg,
  34654. })
  34655. return
  34656. }
  34657. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34658. userJSONBytes3, _ := json.Marshal(respJSON3)
  34659. fmt.Println("log")
  34660. fmt.Println(string(userJSONBytes3))
  34661. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34662. utils.ErrorLog("解析失败:%v", err)
  34663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34664. return
  34665. }
  34666. fmt.Println(res2.Infcode)
  34667. if res2.Infcode == -1 {
  34668. c.ServeSuccessJSON(map[string]interface{}{
  34669. "failed_code": -10,
  34670. "msg": res2.ErrMsg,
  34671. })
  34672. return
  34673. }
  34674. if res2.Infcode == 0 {
  34675. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34676. if err == nil {
  34677. c.ServeSuccessJSON(map[string]interface{}{
  34678. "msg": "撤销明细成功",
  34679. })
  34680. return
  34681. } else {
  34682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34683. return
  34684. }
  34685. } else {
  34686. c.ServeSuccessJSON(map[string]interface{}{
  34687. "failed_code": -10,
  34688. "msg": res2.ErrMsg,
  34689. })
  34690. }
  34691. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34692. if err == nil {
  34693. c.ServeSuccessJSON(map[string]interface{}{
  34694. "msg": "撤销明细成功",
  34695. })
  34696. return
  34697. } else {
  34698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34699. return
  34700. }
  34701. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34702. var api3 string
  34703. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34704. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34706. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34707. resp3, requestErr3 := http.Get(api3)
  34708. utils.ErrorLog("接口: %v", requestErr3)
  34709. if requestErr3 != nil {
  34710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34711. return
  34712. }
  34713. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34714. if ioErr3 != nil {
  34715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34717. return
  34718. }
  34719. var respJSON3 map[string]interface{}
  34720. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34723. return
  34724. }
  34725. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34726. if status == "0" {
  34727. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34728. c.ServeSuccessJSON(map[string]interface{}{
  34729. "failed_code": -10,
  34730. "msg": err_msg,
  34731. })
  34732. return
  34733. }
  34734. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34735. userJSONBytes3, _ := json.Marshal(respJSON3)
  34736. fmt.Println("log")
  34737. fmt.Println(string(userJSONBytes3))
  34738. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34739. utils.ErrorLog("解析失败:%v", err)
  34740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34741. return
  34742. }
  34743. fmt.Println(res2.Infcode)
  34744. if res2.Infcode == -1 {
  34745. c.ServeSuccessJSON(map[string]interface{}{
  34746. "failed_code": -10,
  34747. "msg": res2.ErrMsg,
  34748. })
  34749. return
  34750. }
  34751. if res2.Infcode == 0 {
  34752. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34753. if err == nil {
  34754. c.ServeSuccessJSON(map[string]interface{}{
  34755. "msg": "撤销明细成功",
  34756. })
  34757. return
  34758. } else {
  34759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34760. return
  34761. }
  34762. } else {
  34763. c.ServeSuccessJSON(map[string]interface{}{
  34764. "failed_code": -10,
  34765. "msg": res2.ErrMsg,
  34766. })
  34767. }
  34768. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34769. if err == nil {
  34770. c.ServeSuccessJSON(map[string]interface{}{
  34771. "msg": "撤销明细成功",
  34772. })
  34773. return
  34774. } else {
  34775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34776. return
  34777. }
  34778. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34779. var resSix10265 ResultSix10265
  34780. new_chrg_bchno := order.Number
  34781. if adminUser.CurrentOrgId == 10265 {
  34782. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34783. new_chrg_bchno = "0000"
  34784. }
  34785. }
  34786. var api3 string
  34787. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34788. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34790. resp3, requestErr3 := http.Get(api3)
  34791. if requestErr3 != nil {
  34792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34793. return
  34794. }
  34795. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34796. if ioErr3 != nil {
  34797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34799. return
  34800. }
  34801. var respJSON3 map[string]interface{}
  34802. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34805. return
  34806. }
  34807. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34808. userJSONBytes3, _ := json.Marshal(respJSON3)
  34809. fmt.Println("log")
  34810. fmt.Println(string(userJSONBytes3))
  34811. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34812. utils.ErrorLog("解析失败:%v", err)
  34813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34814. return
  34815. }
  34816. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34817. res2.Output = resSix10265.Output
  34818. res2.ErrMsg = resSix10265.ErrMsg
  34819. res2.Cainfo = resSix10265.Cainfo
  34820. res2.WarnMsg = resSix10265.WarnMsg
  34821. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34822. res2.Infcode = infocode
  34823. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34824. if err == nil {
  34825. c.ServeSuccessJSON(map[string]interface{}{
  34826. "msg": "撤销明细成功",
  34827. })
  34828. return
  34829. } else {
  34830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34831. return
  34832. }
  34833. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34834. 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)
  34835. var dat map[string]interface{}
  34836. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34837. fmt.Println(dat)
  34838. } else {
  34839. fmt.Println(err)
  34840. }
  34841. saveLog(result2, src_request, "2205", "撤销明细")
  34842. userJSONBytes, _ := json.Marshal(dat)
  34843. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34844. utils.ErrorLog("解析失败:%v", err)
  34845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34846. return
  34847. }
  34848. if res2.Infcode == 0 {
  34849. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34850. if err == nil {
  34851. c.ServeSuccessJSON(map[string]interface{}{
  34852. "msg": "撤销明细成功",
  34853. })
  34854. return
  34855. } else {
  34856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34857. return
  34858. }
  34859. } else {
  34860. c.ServeSuccessJSON(map[string]interface{}{
  34861. "failed_code": -10,
  34862. "msg": res2.ErrMsg,
  34863. })
  34864. }
  34865. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34866. 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, "")
  34867. var dat map[string]interface{}
  34868. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34869. fmt.Println(dat)
  34870. } else {
  34871. fmt.Println(err)
  34872. }
  34873. saveLog(result2, src_request, "2205", "撤销明细")
  34874. userJSONBytes, _ := json.Marshal(dat)
  34875. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34876. utils.ErrorLog("解析失败:%v", err)
  34877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34878. return
  34879. }
  34880. if res2.Infcode == 0 {
  34881. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34882. if err == nil {
  34883. c.ServeSuccessJSON(map[string]interface{}{
  34884. "msg": "撤销明细成功",
  34885. })
  34886. return
  34887. } else {
  34888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34889. return
  34890. }
  34891. } else {
  34892. c.ServeSuccessJSON(map[string]interface{}{
  34893. "failed_code": -10,
  34894. "msg": res2.ErrMsg,
  34895. })
  34896. }
  34897. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34898. 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, "")
  34899. var dat map[string]interface{}
  34900. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34901. fmt.Println(dat)
  34902. } else {
  34903. fmt.Println(err)
  34904. }
  34905. saveLog(result2, src_request, "2205", "撤销明细")
  34906. userJSONBytes, _ := json.Marshal(dat)
  34907. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34908. utils.ErrorLog("解析失败:%v", err)
  34909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34910. return
  34911. }
  34912. if res2.Infcode == 0 {
  34913. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34914. if err == nil {
  34915. c.ServeSuccessJSON(map[string]interface{}{
  34916. "msg": "撤销明细成功",
  34917. })
  34918. return
  34919. } else {
  34920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34921. return
  34922. }
  34923. } else {
  34924. c.ServeSuccessJSON(map[string]interface{}{
  34925. "failed_code": -10,
  34926. "msg": res2.ErrMsg,
  34927. })
  34928. }
  34929. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34930. 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, "")
  34931. var dat map[string]interface{}
  34932. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34933. fmt.Println(dat)
  34934. } else {
  34935. fmt.Println(err)
  34936. }
  34937. saveLog(result2, src_request, "2205", "撤销明细")
  34938. userJSONBytes, _ := json.Marshal(dat)
  34939. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34940. utils.ErrorLog("解析失败:%v", err)
  34941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34942. return
  34943. }
  34944. if res2.Infcode == 0 {
  34945. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34946. if err == nil {
  34947. c.ServeSuccessJSON(map[string]interface{}{
  34948. "msg": "撤销明细成功",
  34949. })
  34950. return
  34951. } else {
  34952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34953. return
  34954. }
  34955. } else {
  34956. c.ServeSuccessJSON(map[string]interface{}{
  34957. "failed_code": -10,
  34958. "msg": res2.ErrMsg,
  34959. })
  34960. }
  34961. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34962. 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, "")
  34963. var dat map[string]interface{}
  34964. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34965. fmt.Println(dat)
  34966. } else {
  34967. fmt.Println(err)
  34968. }
  34969. saveLog(result2, src_request, "2205", "撤销明细")
  34970. userJSONBytes, _ := json.Marshal(dat)
  34971. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34972. utils.ErrorLog("解析失败:%v", err)
  34973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34974. return
  34975. }
  34976. if res2.Infcode == 0 {
  34977. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34978. if err == nil {
  34979. c.ServeSuccessJSON(map[string]interface{}{
  34980. "msg": "撤销明细成功",
  34981. })
  34982. return
  34983. } else {
  34984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34985. return
  34986. }
  34987. } else {
  34988. c.ServeSuccessJSON(map[string]interface{}{
  34989. "failed_code": -10,
  34990. "msg": res2.ErrMsg,
  34991. })
  34992. }
  34993. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34994. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  34995. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34996. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34997. resp2, requestErr2 := http.Get(api2)
  34998. if requestErr2 != nil {
  34999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35000. return
  35001. }
  35002. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35003. if ioErr2 != nil {
  35004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35006. return
  35007. }
  35008. var respJSON2 map[string]interface{}
  35009. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35012. return
  35013. }
  35014. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35015. userJSONBytes3, _ := json.Marshal(respJSON2)
  35016. fmt.Println("log")
  35017. fmt.Println(string(userJSONBytes3))
  35018. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35019. utils.ErrorLog("解析失败:%v", err)
  35020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35021. return
  35022. }
  35023. if res2.Infcode == 0 {
  35024. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35025. if err == nil {
  35026. c.ServeSuccessJSON(map[string]interface{}{
  35027. "msg": "撤销明细成功",
  35028. })
  35029. return
  35030. } else {
  35031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35032. return
  35033. }
  35034. } else {
  35035. c.ServeSuccessJSON(map[string]interface{}{
  35036. "failed_code": -10,
  35037. "msg": res2.ErrMsg,
  35038. })
  35039. }
  35040. } else {
  35041. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35042. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35044. resp2, requestErr2 := http.Get(api2)
  35045. if requestErr2 != nil {
  35046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35047. return
  35048. }
  35049. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35050. if ioErr2 != nil {
  35051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35053. return
  35054. }
  35055. var respJSON2 map[string]interface{}
  35056. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35059. return
  35060. }
  35061. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35062. userJSONBytes3, _ := json.Marshal(respJSON2)
  35063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35064. utils.ErrorLog("解析失败:%v", err)
  35065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35066. return
  35067. }
  35068. if res2.Infcode == -1 {
  35069. c.ServeSuccessJSON(map[string]interface{}{
  35070. "failed_code": -10,
  35071. "msg": res2.ErrMsg,
  35072. })
  35073. return
  35074. } else {
  35075. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35076. if err == nil {
  35077. c.ServeSuccessJSON(map[string]interface{}{
  35078. "msg": "撤销明细成功",
  35079. })
  35080. return
  35081. } else {
  35082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35083. return
  35084. }
  35085. }
  35086. }
  35087. } else {
  35088. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35089. if err == nil {
  35090. c.ServeSuccessJSON(map[string]interface{}{
  35091. "msg": "退费成功",
  35092. })
  35093. } else {
  35094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35095. return
  35096. }
  35097. }
  35098. }
  35099. // 对账
  35100. func (c *HisApiController) GetCheckAccount() {
  35101. start_time := c.GetString("start_time")
  35102. end_time := c.GetString("end_time")
  35103. insutype := c.GetString("insutype")
  35104. clr_type := c.GetString("clr_type")
  35105. clr_org := c.GetString("clr_optins")
  35106. admin_user_id, _ := c.GetInt64("admin_user_id")
  35107. adminUser := c.GetAdminUserInfo()
  35108. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35109. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35110. if len(clr_org) == 0 {
  35111. clr_org = miConfig.InsuplcAdmdvs
  35112. }
  35113. timeLayout := "2006-01-02"
  35114. loc, _ := time.LoadLocation("Local")
  35115. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35116. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35117. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35118. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35119. fixmedins_setl_cnt := int64(len(orders))
  35120. var medfee_sumamt float64
  35121. var acct_pay float64
  35122. var fund_pay_sumamt float64
  35123. for _, item := range orders {
  35124. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35125. acct_pay = acct_pay + item.AcctPay
  35126. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35127. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35128. } else {
  35129. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35130. }
  35131. }
  35132. var user_name string
  35133. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35134. if role.ID == 0 {
  35135. user_name = "xxx"
  35136. } else {
  35137. user_name = role.UserName
  35138. }
  35139. var res ResultEight
  35140. var res10188 ResultEightFor10188
  35141. if config.IsOpen == 1 {
  35142. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35143. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  35144. "insutype=" + insutype +
  35145. "&clr_type=" + clr_type +
  35146. "&setl_optins=" + clr_org +
  35147. "&stmt_begndate=" + start_time +
  35148. "&stm_enddate=" + end_time +
  35149. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35150. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35151. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35152. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35153. "&fixmedins_code=" + miConfig.Code +
  35154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35155. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35156. "&secret_key=" + miConfig.SecretKey +
  35157. "&org_name=" + miConfig.OrgName +
  35158. "&doctor=" + user_name +
  35159. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35160. fmt.Println(api)
  35161. resp, requestErr := http.Get(api)
  35162. if requestErr != nil {
  35163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35164. return
  35165. }
  35166. body, ioErr := ioutil.ReadAll(resp.Body)
  35167. fmt.Println(body)
  35168. if ioErr != nil {
  35169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35171. return
  35172. }
  35173. var respJSON map[string]interface{}
  35174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35177. return
  35178. }
  35179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35180. userJSONBytes, _ := json.Marshal(respJSON)
  35181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35182. utils.ErrorLog("解析失败:%v", err)
  35183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35184. return
  35185. }
  35186. res.InfRefmsgid = res10188.InfRefmsgid
  35187. res.Output = res10188.Output
  35188. res.ErrMsg = res10188.ErrMsg
  35189. res.Cainfo = res10188.Cainfo
  35190. res.WarnMsg = res10188.WarnMsg
  35191. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35192. res.Infcode = infocode
  35193. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35194. if clr_type != "9903" {
  35195. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35196. }
  35197. if clr_type == "9903" {
  35198. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35199. }
  35200. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35201. "insutype=" + insutype +
  35202. "&clr_type=" + clr_type +
  35203. "&setl_optins=" + clr_org +
  35204. "&stmt_begndate=" + start_time +
  35205. "&stm_enddate=" + end_time +
  35206. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35207. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35208. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35209. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35210. "&fixmedins_code=" + miConfig.Code +
  35211. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35212. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35213. "&secret_key=" + miConfig.SecretKey +
  35214. "&org_name=" + miConfig.OrgName +
  35215. "&doctor=" + user_name
  35216. resp, requestErr := http.Get(api)
  35217. if requestErr != nil {
  35218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35219. return
  35220. }
  35221. body, ioErr := ioutil.ReadAll(resp.Body)
  35222. if ioErr != nil {
  35223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35225. return
  35226. }
  35227. var respJSON map[string]interface{}
  35228. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35231. return
  35232. }
  35233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35234. result, _ := json.Marshal(respJSON)
  35235. fmt.Println("log")
  35236. fmt.Println(string(result))
  35237. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35238. utils.ErrorLog("解析失败:%v", err)
  35239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35240. return
  35241. }
  35242. res.InfRefmsgid = res10188.InfRefmsgid
  35243. res.Output = res10188.Output
  35244. res.ErrMsg = res10188.ErrMsg
  35245. res.Cainfo = res10188.Cainfo
  35246. res.WarnMsg = res10188.WarnMsg
  35247. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35248. res.Infcode = infocode
  35249. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35250. var baseParams models.BaseParams
  35251. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35252. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35253. baseParams.SecretKey = miConfig.SecretKey
  35254. baseParams.OrgName = miConfig.OrgName
  35255. baseParams.FixmedinsCode = miConfig.Code
  35256. baseParams.EncKey = miConfig.EncKey
  35257. baseParams.AppSecret = miConfig.AppSecret
  35258. baseParams.SignKey = miConfig.SignKey
  35259. baseParams.AppID = miConfig.Code
  35260. baseParams.Doctor = role.UserName
  35261. baseParams.RequestUrl = miConfig.Url
  35262. businessParams := models.BusinessParams{
  35263. Insutype: insutype,
  35264. ClrType: clr_type,
  35265. SetlOptins: clr_org,
  35266. StmtBegndate: start_time,
  35267. StmtEnddate: end_time,
  35268. MedfeeSumamt: medfee_sumamt,
  35269. FundPaySumamt: fund_pay_sumamt,
  35270. AcctPay: acct_pay,
  35271. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35272. }
  35273. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35274. fmt.Println(requestLog)
  35275. fmt.Println(result)
  35276. fmt.Println(err_msg)
  35277. var dat map[string]interface{}
  35278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35279. fmt.Println(dat)
  35280. } else {
  35281. fmt.Println(err)
  35282. }
  35283. userJSONBytes, _ := json.Marshal(dat)
  35284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35285. utils.ErrorLog("解析失败:%v", err)
  35286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35287. return
  35288. }
  35289. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35290. var baseParams models.BaseParams
  35291. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35292. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35293. baseParams.SecretKey = miConfig.SecretKey
  35294. baseParams.OrgName = miConfig.OrgName
  35295. baseParams.FixmedinsCode = miConfig.Code
  35296. baseParams.EncKey = miConfig.EncKey
  35297. baseParams.AppSecret = miConfig.AppSecret
  35298. baseParams.SignKey = miConfig.SignKey
  35299. baseParams.AppID = miConfig.Code
  35300. baseParams.Doctor = role.UserName
  35301. baseParams.RequestUrl = miConfig.Url
  35302. baseParams.AccessKey = miConfig.AccessKey
  35303. businessParams := models.BusinessParams{
  35304. Insutype: insutype,
  35305. ClrType: clr_type,
  35306. SetlOptins: "430822",
  35307. StmtBegndate: start_time,
  35308. StmtEnddate: end_time,
  35309. MedfeeSumamt: medfee_sumamt,
  35310. FundPaySumamt: fund_pay_sumamt,
  35311. AcctPay: acct_pay,
  35312. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35313. }
  35314. 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)
  35315. fmt.Println(requestLog)
  35316. fmt.Println(result)
  35317. var dat map[string]interface{}
  35318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35319. fmt.Println(dat)
  35320. } else {
  35321. fmt.Println(err)
  35322. }
  35323. userJSONBytes, _ := json.Marshal(dat)
  35324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35325. utils.ErrorLog("解析失败:%v", err)
  35326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35327. return
  35328. }
  35329. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35330. var baseParams models.BaseParams
  35331. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35332. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35333. baseParams.SecretKey = miConfig.SecretKey
  35334. baseParams.OrgName = miConfig.OrgName
  35335. baseParams.FixmedinsCode = miConfig.Code
  35336. baseParams.EncKey = miConfig.EncKey
  35337. baseParams.AppSecret = miConfig.AppSecret
  35338. baseParams.SignKey = miConfig.SignKey
  35339. baseParams.AppID = miConfig.Code
  35340. baseParams.Doctor = role.UserName
  35341. baseParams.RequestUrl = miConfig.Url
  35342. businessParams := models.BusinessParams{
  35343. Insutype: insutype,
  35344. ClrType: clr_type,
  35345. SetlOptins: clr_org,
  35346. StmtBegndate: start_time,
  35347. StmtEnddate: end_time,
  35348. MedfeeSumamt: medfee_sumamt,
  35349. FundPaySumamt: fund_pay_sumamt,
  35350. AcctPay: acct_pay,
  35351. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35352. }
  35353. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35354. fmt.Println(requestLog)
  35355. fmt.Println(result)
  35356. fmt.Println(err_msg)
  35357. var dat map[string]interface{}
  35358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35359. fmt.Println(dat)
  35360. } else {
  35361. fmt.Println(err)
  35362. }
  35363. userJSONBytes, _ := json.Marshal(dat)
  35364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35365. utils.ErrorLog("解析失败:%v", err)
  35366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35367. return
  35368. }
  35369. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35370. if len(clr_type) == 0 {
  35371. clr_type = "11"
  35372. }
  35373. api := miConfig.Url + "gdyb/ten?" +
  35374. "insutype=" + insutype +
  35375. "&clr_type=" + clr_type +
  35376. "&setl_optins=" + clr_org +
  35377. "&stmt_begndate=" + start_time +
  35378. "&stm_enddate=" + end_time +
  35379. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35380. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35381. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35382. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35383. "&fixmedins_code=" + miConfig.Code +
  35384. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35385. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35386. "&secret_key=" + miConfig.SecretKey +
  35387. "&org_name=" + miConfig.OrgName +
  35388. "&doctor=" + user_name
  35389. fmt.Println(api)
  35390. resp, requestErr := http.Get(api)
  35391. if requestErr != nil {
  35392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35393. return
  35394. }
  35395. body, ioErr := ioutil.ReadAll(resp.Body)
  35396. fmt.Println(body)
  35397. if ioErr != nil {
  35398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35400. return
  35401. }
  35402. var respJSON map[string]interface{}
  35403. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35406. return
  35407. }
  35408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35409. userJSONBytes, _ := json.Marshal(respJSON)
  35410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35411. utils.ErrorLog("解析失败:%v", err)
  35412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35413. return
  35414. }
  35415. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35416. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35417. //fixmedins_setl_cnt := int64(len(orders_two))
  35418. //var medfee_sumamt float64
  35419. //var acct_pay float64
  35420. //var fund_pay_sumamt float64
  35421. //for _, item := range orders_two {
  35422. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35423. // acct_pay = acct_pay + item.AcctPay
  35424. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35425. //}
  35426. var baseParams models.BaseParams
  35427. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35428. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35429. baseParams.SecretKey = miConfig.SecretKey
  35430. baseParams.OrgName = miConfig.OrgName
  35431. baseParams.FixmedinsCode = miConfig.Code
  35432. baseParams.EncKey = miConfig.EncKey
  35433. baseParams.AppSecret = miConfig.AppSecret
  35434. baseParams.SignKey = miConfig.SignKey
  35435. baseParams.AppID = miConfig.Code
  35436. baseParams.Doctor = role.UserName
  35437. baseParams.RequestUrl = miConfig.Url
  35438. if clr_type == "9903" {
  35439. clr_type = "9901"
  35440. }
  35441. businessParams := models.BusinessParams{
  35442. Insutype: insutype,
  35443. ClrType: clr_type,
  35444. SetlOptins: "360302",
  35445. StmtBegndate: start_time,
  35446. StmtEnddate: end_time,
  35447. MedfeeSumamt: 0,
  35448. FundPaySumamt: 0,
  35449. AcctPay: 0,
  35450. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35451. }
  35452. 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))
  35453. fmt.Println(requestLog)
  35454. fmt.Println(result)
  35455. var dat map[string]interface{}
  35456. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35457. fmt.Println(dat)
  35458. } else {
  35459. fmt.Println(err)
  35460. }
  35461. userJSONBytes, _ := json.Marshal(dat)
  35462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35463. utils.ErrorLog("解析失败:%v", err)
  35464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35465. return
  35466. }
  35467. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35468. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35469. //fixmedins_setl_cnt := int64(len(orders_two))
  35470. //var medfee_sumamt float64
  35471. //var acct_pay float64
  35472. //var fund_pay_sumamt float64
  35473. //for _, item := range orders_two {
  35474. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35475. // acct_pay = acct_pay + item.AcctPay
  35476. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35477. //}
  35478. var baseParams models.BaseParams
  35479. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35480. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35481. baseParams.SecretKey = miConfig.SecretKey
  35482. baseParams.OrgName = miConfig.OrgName
  35483. baseParams.FixmedinsCode = miConfig.Code
  35484. baseParams.EncKey = miConfig.EncKey
  35485. baseParams.AppSecret = miConfig.AppSecret
  35486. baseParams.SignKey = miConfig.SignKey
  35487. baseParams.AppID = miConfig.Code
  35488. baseParams.Doctor = role.UserName
  35489. baseParams.RequestUrl = miConfig.Url
  35490. if clr_type == "9903" {
  35491. clr_type = "9994"
  35492. }
  35493. businessParams := models.BusinessParams{
  35494. Insutype: insutype,
  35495. ClrType: clr_type,
  35496. SetlOptins: "361025",
  35497. StmtBegndate: start_time,
  35498. StmtEnddate: end_time,
  35499. MedfeeSumamt: 0,
  35500. FundPaySumamt: 0,
  35501. AcctPay: 0,
  35502. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35503. }
  35504. 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))
  35505. fmt.Println(requestLog)
  35506. fmt.Println(result)
  35507. var dat map[string]interface{}
  35508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35509. fmt.Println(dat)
  35510. } else {
  35511. fmt.Println(err)
  35512. }
  35513. userJSONBytes, _ := json.Marshal(dat)
  35514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35515. utils.ErrorLog("解析失败:%v", err)
  35516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35517. return
  35518. }
  35519. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35520. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35521. //fixmedins_setl_cnt := int64(len(orders_two))
  35522. //var medfee_sumamt float64
  35523. //var acct_pay float64
  35524. //var fund_pay_sumamt float64
  35525. //for _, item := range orders_two {
  35526. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35527. // acct_pay = acct_pay + item.AcctPay
  35528. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35529. //}
  35530. var baseParams models.BaseParams
  35531. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35532. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35533. baseParams.SecretKey = miConfig.SecretKey
  35534. baseParams.OrgName = miConfig.OrgName
  35535. baseParams.FixmedinsCode = miConfig.Code
  35536. baseParams.EncKey = miConfig.EncKey
  35537. baseParams.AppSecret = miConfig.AppSecret
  35538. baseParams.SignKey = miConfig.SignKey
  35539. baseParams.AppID = miConfig.Code
  35540. baseParams.Doctor = role.UserName
  35541. baseParams.RequestUrl = miConfig.Url
  35542. if clr_type == "9903" {
  35543. clr_type = "9994"
  35544. }
  35545. businessParams := models.BusinessParams{
  35546. Insutype: insutype,
  35547. ClrType: clr_type,
  35548. SetlOptins: "360100",
  35549. StmtBegndate: start_time,
  35550. StmtEnddate: end_time,
  35551. MedfeeSumamt: 0,
  35552. FundPaySumamt: 0,
  35553. AcctPay: 0,
  35554. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35555. }
  35556. 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))
  35557. fmt.Println(requestLog)
  35558. fmt.Println(result)
  35559. var dat map[string]interface{}
  35560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35561. fmt.Println(dat)
  35562. } else {
  35563. fmt.Println(err)
  35564. }
  35565. userJSONBytes, _ := json.Marshal(dat)
  35566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35567. utils.ErrorLog("解析失败:%v", err)
  35568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35569. return
  35570. }
  35571. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35572. var api string
  35573. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35574. "&clr_type=" + clr_type +
  35575. "&setl_optins=" + clr_org +
  35576. "&stmt_begndate=" + start_time +
  35577. "&stm_enddate=" + end_time +
  35578. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35579. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35580. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35581. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35582. "&fixmedins_code=" + miConfig.Code +
  35583. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35584. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35585. "&secret_key=" + miConfig.SecretKey +
  35586. "&org_name=" + miConfig.OrgName +
  35587. "&doctor=" + user_name + "&url=" + miConfig.Url
  35588. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35589. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35590. resp, requestErr := http.Get(api)
  35591. if requestErr != nil {
  35592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35593. return
  35594. }
  35595. body, ioErr := ioutil.ReadAll(resp.Body)
  35596. if ioErr != nil {
  35597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35599. return
  35600. }
  35601. var respJSON map[string]interface{}
  35602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35605. return
  35606. }
  35607. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35608. if status == "0" {
  35609. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35610. c.ServeSuccessJSON(map[string]interface{}{
  35611. "failed_code": -10,
  35612. "msg": err_msg,
  35613. })
  35614. return
  35615. }
  35616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35617. userJSONBytes, _ := json.Marshal(respJSON)
  35618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35619. utils.ErrorLog("解析失败:%v", err)
  35620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35621. return
  35622. }
  35623. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35624. var api string
  35625. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35626. "&clr_type=" + clr_type +
  35627. "&setl_optins=" + clr_org +
  35628. "&stmt_begndate=" + start_time +
  35629. "&stm_enddate=" + end_time +
  35630. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35631. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35632. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35633. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35634. "&fixmedins_code=" + miConfig.Code +
  35635. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35636. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35637. "&secret_key=" + miConfig.SecretKey +
  35638. "&org_name=" + miConfig.OrgName +
  35639. "&doctor=" + user_name + "&url=" + miConfig.Url
  35640. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35641. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35642. resp, requestErr := http.Get(api)
  35643. if requestErr != nil {
  35644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35645. return
  35646. }
  35647. body, ioErr := ioutil.ReadAll(resp.Body)
  35648. if ioErr != nil {
  35649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35651. return
  35652. }
  35653. var respJSON map[string]interface{}
  35654. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35657. return
  35658. }
  35659. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35660. if status == "0" {
  35661. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35662. c.ServeSuccessJSON(map[string]interface{}{
  35663. "failed_code": -10,
  35664. "msg": err_msg,
  35665. })
  35666. return
  35667. }
  35668. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35669. userJSONBytes, _ := json.Marshal(respJSON)
  35670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35671. utils.ErrorLog("解析失败:%v", err)
  35672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35673. return
  35674. }
  35675. } else {
  35676. if len(clr_type) == 0 {
  35677. clr_type = "11"
  35678. }
  35679. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35680. "insutype=" + insutype +
  35681. "&clr_type=" + clr_type +
  35682. "&setl_optins=" + clr_org +
  35683. "&stmt_begndate=" + start_time +
  35684. "&stm_enddate=" + end_time +
  35685. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35686. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35687. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35688. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35689. "&fixmedins_code=" + miConfig.Code +
  35690. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35691. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35692. "&secret_key=" + miConfig.SecretKey +
  35693. "&org_name=" + miConfig.OrgName +
  35694. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35695. fmt.Println(api)
  35696. resp, requestErr := http.Get(api)
  35697. if requestErr != nil {
  35698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35699. return
  35700. }
  35701. body, ioErr := ioutil.ReadAll(resp.Body)
  35702. fmt.Println(body)
  35703. if ioErr != nil {
  35704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35706. return
  35707. }
  35708. var respJSON map[string]interface{}
  35709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35712. return
  35713. }
  35714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35715. userJSONBytes, _ := json.Marshal(respJSON)
  35716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35717. utils.ErrorLog("解析失败:%v", err)
  35718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35719. return
  35720. }
  35721. }
  35722. if res.Infcode == 0 {
  35723. if res.Output.Stmtinfo.StmtRslt == "0" {
  35724. micc := &models.MedicalInsuranceCostCompare{
  35725. StartTime: startime.Unix(),
  35726. EndTime: endtime.Unix(),
  35727. Insutype: insutype,
  35728. CheckType: 1,
  35729. Num: fixmedins_setl_cnt,
  35730. Mtime: time.Now().Unix(),
  35731. Status: 1,
  35732. UserOrgId: adminUser.CurrentOrgId,
  35733. CostTotal: medfee_sumamt,
  35734. FuncTotal: fund_pay_sumamt,
  35735. PsnPay: acct_pay,
  35736. Creator: admin_user_id,
  35737. Ctime: time.Now().Unix(),
  35738. ClrType: clr_type,
  35739. }
  35740. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35741. if err == nil {
  35742. c.ServeSuccessJSON(map[string]interface{}{
  35743. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35744. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35745. })
  35746. } else {
  35747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35748. }
  35749. } else {
  35750. c.ServeSuccessJSON(map[string]interface{}{
  35751. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35752. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35753. })
  35754. }
  35755. } else {
  35756. c.ServeSuccessJSON(map[string]interface{}{
  35757. "failed_code": -10,
  35758. "msg": res.ErrMsg,
  35759. })
  35760. }
  35761. }
  35762. }
  35763. func (c *HisApiController) Check310() {
  35764. adminUser := c.GetAdminUserInfo()
  35765. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35766. var user_name string
  35767. user_name = "高慧裕"
  35768. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35769. "insutype=" + "310" +
  35770. "&clr_type=" + "" +
  35771. "&setl_optins=" + "441202" +
  35772. "&stmt_begndate=" + "2022-03-01" +
  35773. "&stm_enddate=" + "2022-03-31" +
  35774. "&medfee_sumamt=" + "194930.12" +
  35775. "&fund_pay_sumamt=" + "188741.46" +
  35776. "&acct_pay=" + "0" +
  35777. "&fixmedins_setl_cnt=" + "452" +
  35778. "&fixmedins_code=" + miConfig.Code +
  35779. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35780. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35781. "&secret_key=" + miConfig.SecretKey +
  35782. "&org_name=" + miConfig.OrgName +
  35783. "&doctor=" + user_name
  35784. fmt.Println(api)
  35785. resp, requestErr := http.Get(api)
  35786. if requestErr != nil {
  35787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35788. return
  35789. }
  35790. body, ioErr := ioutil.ReadAll(resp.Body)
  35791. fmt.Println(body)
  35792. if ioErr != nil {
  35793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35795. return
  35796. }
  35797. var respJSON map[string]interface{}
  35798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35801. return
  35802. }
  35803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35804. userJSONBytes, _ := json.Marshal(respJSON)
  35805. var res ResultEight
  35806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35807. utils.ErrorLog("解析失败:%v", err)
  35808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35809. return
  35810. }
  35811. }
  35812. func (c *HisApiController) Check390() {
  35813. adminUser := c.GetAdminUserInfo()
  35814. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35815. var user_name string
  35816. user_name = "高慧裕"
  35817. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35818. "insutype=" + "390" +
  35819. "&clr_type=" + "" +
  35820. "&setl_optins=" + "441202" +
  35821. "&stmt_begndate=" + "2022-03-01" +
  35822. "&stm_enddate=" + "2022-03-31" +
  35823. "&medfee_sumamt=" + "1068448.89" +
  35824. "&fund_pay_sumamt=" + "1014677.62" +
  35825. "&acct_pay=" + "0" +
  35826. "&fixmedins_setl_cnt=" + "1950" +
  35827. "&fixmedins_code=" + miConfig.Code +
  35828. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35829. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35830. "&secret_key=" + miConfig.SecretKey +
  35831. "&org_name=" + miConfig.OrgName +
  35832. "&doctor=" + user_name
  35833. fmt.Println(api)
  35834. resp, requestErr := http.Get(api)
  35835. if requestErr != nil {
  35836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35837. return
  35838. }
  35839. body, ioErr := ioutil.ReadAll(resp.Body)
  35840. fmt.Println(body)
  35841. if ioErr != nil {
  35842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35844. return
  35845. }
  35846. var respJSON map[string]interface{}
  35847. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35850. return
  35851. }
  35852. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35853. userJSONBytes, _ := json.Marshal(respJSON)
  35854. var res ResultEight
  35855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35856. utils.ErrorLog("解析失败:%v", err)
  35857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35858. return
  35859. }
  35860. }
  35861. // 对账明细
  35862. func (c *HisApiController) GetCheckDetailAccount() {
  35863. start_time := c.GetString("start_time")
  35864. end_time := c.GetString("end_time")
  35865. admin_user_id, _ := c.GetInt64("admin_user_id")
  35866. adminUser := c.GetAdminUserInfo()
  35867. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35868. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35869. timeLayout := "2006-01-02"
  35870. loc, _ := time.LoadLocation("Local")
  35871. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35872. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35873. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35874. rand.Seed(time.Now().UnixNano())
  35875. num := rand.Intn(30000)
  35876. Mkdir(miConfig.OrgName)
  35877. file := strconv.FormatInt(int64(num), 10)
  35878. file_name := file + ".txt"
  35879. zip_name := file + ".zip"
  35880. zip_path := miConfig.OrgName + "/" + zip_name
  35881. file_path := miConfig.OrgName + "/" + file_name
  35882. decimal.DivisionPrecision = 2
  35883. var medfee_sumamt float64
  35884. var psn_cash_pay float64
  35885. var fund_pay_sumamt float64
  35886. fixmedins_setl_cnt := int64(len(orders))
  35887. for _, item := range orders {
  35888. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35889. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  35890. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35891. }
  35892. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  35893. defer f.Close()
  35894. if err != nil {
  35895. fmt.Println(err.Error())
  35896. } else {
  35897. for _, item := range orders {
  35898. var refd_setl_flag string
  35899. if item.OrderStatus == 2 {
  35900. refd_setl_flag = "0"
  35901. var str string
  35902. str = item.SetlId + " " +
  35903. item.MdtrtId + " " +
  35904. item.PsnNo + " " +
  35905. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35906. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35907. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  35908. _, err = f.Write([]byte(str))
  35909. }
  35910. if item.OrderStatus == 3 {
  35911. var str string
  35912. str = item.SetlId + " " +
  35913. item.MdtrtId + " " +
  35914. item.PsnNo + " " +
  35915. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35916. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35917. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  35918. _, err = f.Write([]byte(str))
  35919. var str2 string
  35920. str2 = item.SetlId + " " +
  35921. item.MdtrtId + " " +
  35922. item.PsnNo + " " +
  35923. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  35924. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  35925. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  35926. _, err = f.Write([]byte(str2))
  35927. }
  35928. }
  35929. }
  35930. Zip(file_path, zip_path)
  35931. fmt.Println(ReadFile(zip_path))
  35932. fmt.Println(string(ReadFile(zip_path)))
  35933. if config.IsOpen == 1 {
  35934. var user_name string
  35935. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35936. if role.ID == 0 {
  35937. user_name = "管理员"
  35938. } else {
  35939. user_name = role.UserName
  35940. }
  35941. baseParams := models.BaseParams{
  35942. SecretKey: miConfig.SecretKey,
  35943. FixmedinsCode: miConfig.Code,
  35944. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35945. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35946. OrgName: miConfig.OrgName,
  35947. Doctor: user_name,
  35948. }
  35949. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  35950. var dat map[string]interface{}
  35951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35952. fmt.Println(dat)
  35953. } else {
  35954. fmt.Println(err)
  35955. }
  35956. userJSONBytes, _ := json.Marshal(dat)
  35957. var res ResultNine
  35958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35959. utils.ErrorLog("解析失败:%v", err)
  35960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35961. return
  35962. }
  35963. if res.Infcode == 0 {
  35964. fileNo := res.Output.FileQuryNo
  35965. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  35966. "file_qury_no=" + fileNo +
  35967. "&setl_optins=" + "定点医保中心" +
  35968. "&stmt_begndate=" + start_time +
  35969. "&stm_enddate=" + end_time +
  35970. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35971. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35972. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  35973. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35974. "&fixmedins_code=" + miConfig.Code +
  35975. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35976. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35977. "&secret_key=" + miConfig.SecretKey +
  35978. "&org_name=" + miConfig.OrgName +
  35979. "&doctor=" + user_name
  35980. resp, requestErr := http.Get(api)
  35981. if requestErr != nil {
  35982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35983. return
  35984. }
  35985. body, ioErr := ioutil.ReadAll(resp.Body)
  35986. if ioErr != nil {
  35987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35989. return
  35990. }
  35991. var respJSON map[string]interface{}
  35992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35995. return
  35996. }
  35997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35998. userJSONBytes, _ := json.Marshal(respJSON)
  35999. var res ResultTen
  36000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36001. utils.ErrorLog("解析失败:%v", err)
  36002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36003. return
  36004. }
  36005. if res.Infcode == 0 {
  36006. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36007. micc := &models.MedicalInsuranceCostCompare{
  36008. StartTime: startime.Unix(),
  36009. EndTime: endtime.Unix(),
  36010. Insutype: "0",
  36011. CheckType: 2,
  36012. Num: fixmedins_setl_cnt,
  36013. Mtime: time.Now().Unix(),
  36014. Status: 1,
  36015. UserOrgId: adminUser.CurrentOrgId,
  36016. CostTotal: medfee_sumamt,
  36017. FuncTotal: fund_pay_sumamt,
  36018. PsnPay: psn_cash_pay,
  36019. Creator: admin_user_id,
  36020. Ctime: time.Now().Unix(),
  36021. }
  36022. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36023. c.ServeSuccessJSON(map[string]interface{}{
  36024. "msg": "明细对账成功",
  36025. })
  36026. }
  36027. } else {
  36028. }
  36029. }
  36030. }
  36031. type CustomOrderInfo struct {
  36032. Name string
  36033. Spec string
  36034. Unit string
  36035. Count float64
  36036. Price float64
  36037. Total float64
  36038. }
  36039. func (c *HisApiController) GetBatchSettleAccounts() {
  36040. admin_user_id, _ := c.GetInt64("admin_user_id")
  36041. order_ids := c.GetString("order_ids")
  36042. order_ids_arr := strings.Split(order_ids, ",")
  36043. data3 := []map[string]interface{}{}
  36044. for _, item := range order_ids_arr {
  36045. id, _ := strconv.ParseInt(item, 10, 64)
  36046. order_id := id
  36047. adminUser := c.GetAdminUserInfo()
  36048. order, _ := service.GetHisOrderByID(order_id)
  36049. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36050. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36051. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36052. orderInfos = append(orderInfos, orderInfos_two...)
  36053. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36054. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36055. var diagnosis_ids []string
  36056. if his.ID > 0 {
  36057. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36058. } else {
  36059. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36060. }
  36061. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36062. var dia_config []*models.HisXtDiagnoseConfig
  36063. var name string
  36064. for _, item := range diagnosis_ids {
  36065. id, _ := strconv.ParseInt(item, 10, 64)
  36066. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36067. dia_config = append(dia_config, &diagnosisConfig)
  36068. if len(name) == 0 {
  36069. name = diagnosisConfig.ClassName
  36070. }
  36071. //} else {
  36072. // name = name + "," + diagnosisConfig.ClassName
  36073. //}
  36074. }
  36075. var bedCostTotal float64 = 0 //床位总费
  36076. var bedCostSelfTotal float64 = 0 //床位自费
  36077. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36078. var bedSelfTotal float64 = 0 //床位部分项目自费
  36079. var bedInscpTotal float64 = 0 //床位部分项目自费
  36080. var operationCostTotal float64 = 0 //手术费
  36081. var operationCostSelfTotal float64 = 0 //手术费
  36082. var operationCostPartSelfTotal float64 = 0 //手术费
  36083. var operationSelfTotal float64 = 0 //床位部分项目自费
  36084. var operationInscpTotal float64 = 0 //床位部分项目自费
  36085. var otherCostTotal float64 = 0 //其他费用
  36086. var otherCostSelfTotal float64 = 0 //其他费用
  36087. var otherCostPartSelfTotal float64 = 0 //其他费用
  36088. var otherSelfTotal float64 = 0 //床位部分项目自费
  36089. var otherInscpTotal float64 = 0 //床位部分项目自费
  36090. var materialCostTotal float64 = 0 //材料费
  36091. var materialCostSelfTotal float64 = 0 //材料费
  36092. var materialCostPartSelfTotal float64 = 0 //材料费
  36093. var materialSelfTotal float64 = 0 //床位部分项目自费
  36094. var materialInscpTotal float64 = 0 //床位部分项目自费
  36095. var westernMedicineCostTotal float64 = 0 //西药费
  36096. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36097. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36098. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36099. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36100. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36101. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36102. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36103. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36104. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36105. var checkCostTotal float64 = 0 //检查费
  36106. var checkCostSelfTotal float64 = 0 //检查费
  36107. var checkCostPartSelfTotal float64 = 0 //检查费
  36108. var checkSelfTotal float64 = 0 //床位部分项目自费
  36109. var checkInscpTotal float64 = 0 //床位部分项目自费
  36110. var laboratoryCostTotal float64 = 0 //化验费
  36111. var laboratoryCostSelfTotal float64 = 0 //化验费
  36112. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36113. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36114. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36115. var treatCostTotal float64 = 0 //治疗费用
  36116. var treatCostSelfTotal float64 = 0 //治疗费用
  36117. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36118. var treatSelfTotal float64 = 0 //床位部分项目自费
  36119. var treatInscpTotal float64 = 0 //床位部分项目自费
  36120. decimal.DivisionPrecision = 2
  36121. for _, item := range orderInfos {
  36122. if item.MedChrgitmType == "01" { //床位费
  36123. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36124. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36125. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36126. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36127. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36128. }
  36129. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36130. if item.MedChrgitmType == "03" { //检查费
  36131. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36132. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36133. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36134. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36135. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36136. }
  36137. } else {
  36138. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36139. fmt.Println("------------")
  36140. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36141. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36142. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36143. }
  36144. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36145. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36146. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36147. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36148. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36149. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36150. }
  36151. }
  36152. if item.MedChrgitmType == "04" { //化验费
  36153. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36154. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36155. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36156. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36157. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36158. }
  36159. if item.MedChrgitmType == "05" { //治疗费
  36160. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36161. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36162. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36163. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36164. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36165. }
  36166. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36167. fmt.Println("------------")
  36168. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36169. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36170. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36171. }
  36172. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36173. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36174. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36175. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36176. }
  36177. //if item.MedChrgitmType == "06" { //手术费
  36178. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36179. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36180. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36181. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36182. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36183. //
  36184. //}
  36185. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36186. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36187. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36188. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36189. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36190. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36191. }
  36192. if item.MedChrgitmType == "09" { //西药费
  36193. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36194. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36195. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36196. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36197. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36198. }
  36199. if item.MedChrgitmType == "11" { //中成费
  36200. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36201. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36202. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36203. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36204. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36205. }
  36206. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36207. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36208. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36209. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36210. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36211. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36212. }
  36213. }
  36214. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36215. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36216. var user_name string
  36217. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36218. if role.ID == 0 {
  36219. user_name = "管理员"
  36220. } else {
  36221. user_name = role.UserName
  36222. }
  36223. baseParams := models.BaseParams{
  36224. SecretKey: miConfig.SecretKey,
  36225. FixmedinsCode: miConfig.Code,
  36226. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36227. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36228. OrgName: miConfig.OrgName,
  36229. Doctor: user_name,
  36230. RequestUrl: miConfig.Url,
  36231. AccessKey: miConfig.AccessKey,
  36232. }
  36233. businessParams := models.BusinessParams{
  36234. PsnNo: order.PsnNo,
  36235. MdtrtId: order.MdtrtId,
  36236. SetlId: order.SetlId,
  36237. }
  36238. var res ResultEleven
  36239. var resEleven10265 ResultEleven10265
  36240. if config.IsOpen == 1 {
  36241. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36242. result := service.Gdyb5203(baseParams, businessParams)
  36243. service.Gdyb5204(baseParams, businessParams)
  36244. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36245. var dat map[string]interface{}
  36246. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36247. fmt.Println(dat)
  36248. } else {
  36249. fmt.Println(err)
  36250. }
  36251. userJSONBytes, _ := json.Marshal(dat)
  36252. if miConfig.Code == "H15049901371" {
  36253. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36254. utils.ErrorLog("解析失败:%v", err)
  36255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36256. return
  36257. }
  36258. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36259. res.Output = resEleven10265.Output
  36260. res.ErrMsg = resEleven10265.ErrMsg
  36261. res.Cainfo = resEleven10265.Cainfo
  36262. res.WarnMsg = resEleven10265.WarnMsg
  36263. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36264. res.Infcode = infocode
  36265. } else {
  36266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36267. utils.ErrorLog("解析失败:%v", err)
  36268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36269. return
  36270. }
  36271. }
  36272. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36273. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36274. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36275. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36276. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36277. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36278. var doctor_name string
  36279. if roles.ID == 0 {
  36280. doctor_name = "管理员"
  36281. } else {
  36282. doctor_name = roles.UserName
  36283. }
  36284. yiliao_leibie := ""
  36285. switch order.MedType {
  36286. case "11":
  36287. yiliao_leibie = "普通门诊"
  36288. break
  36289. case "12":
  36290. yiliao_leibie = "门诊挂号"
  36291. break
  36292. case "13":
  36293. yiliao_leibie = "急诊"
  36294. break
  36295. case "14":
  36296. yiliao_leibie = "门诊特殊病"
  36297. break
  36298. case "15":
  36299. yiliao_leibie = "门诊统筹"
  36300. break
  36301. case "16":
  36302. yiliao_leibie = "门诊慢性病"
  36303. break
  36304. case "21":
  36305. yiliao_leibie = "普通住院"
  36306. break
  36307. }
  36308. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36309. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36310. if res.Infcode == 0 {
  36311. data2 := map[string]interface{}{
  36312. "diagnosis": name,
  36313. "order_infos": orderInfos,
  36314. "number": order.MdtrtId,
  36315. "date": order.SettleAccountsDate,
  36316. "charge_admin": charge_admin,
  36317. "printor_admin": printor_admin,
  36318. "info": res.Output.Setlinfo,
  36319. "order": order,
  36320. "bedCostTotal": bedCostTotal,
  36321. "bedCostSelfTotal": bedCostSelfTotal,
  36322. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36323. "bedSelfTotal": bedSelfTotal,
  36324. "bedInscpTotal": bedInscpTotal,
  36325. "operationCostTotal": operationCostTotal,
  36326. "operationCostSelfTotal": operationCostSelfTotal,
  36327. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36328. "operationSelfTotal": operationSelfTotal,
  36329. "operationInscpTotal": operationInscpTotal,
  36330. "otherCostTotal": otherCostTotal,
  36331. "otherCostSelfTotal": otherCostSelfTotal,
  36332. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36333. "otherSelfTotal": otherSelfTotal,
  36334. "otherInscpTotal": otherInscpTotal,
  36335. "materialCostTotal": materialCostTotal,
  36336. "materialCostSelfTotal": materialCostSelfTotal,
  36337. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36338. "materialSelfTotal": materialSelfTotal,
  36339. "materialInscpTotal": materialInscpTotal,
  36340. "westernMedicineCostTotal": westernMedicineCostTotal,
  36341. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36342. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36343. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36344. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36345. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36346. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36347. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36348. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36349. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36350. "checkCostTotal": checkCostTotal,
  36351. "checkCostSelfTotal": checkCostSelfTotal,
  36352. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36353. "checkSelfTotal": checkSelfTotal,
  36354. "checkInscpTotal": checkInscpTotal,
  36355. "laboratoryCostTotal": laboratoryCostTotal,
  36356. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36357. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36358. "laboratorySelfTotal": laboratorySelfTotal,
  36359. "laboratoryInscpTotal": laboratoryInscpTotal,
  36360. "treatCostTotal": treatCostTotal,
  36361. "treatCostSelfTotal": treatCostSelfTotal,
  36362. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36363. "treatSelfTotal": treatSelfTotal,
  36364. "treatInscpTotal": treatInscpTotal,
  36365. "doctor_info": doctor_info,
  36366. "doctor_code": adminRole_two.DoctorCode,
  36367. "doctor_name": doctor_name,
  36368. "health_card_no": order.PsnNo,
  36369. "department": departments.Name,
  36370. "yiliao_leibie": yiliao_leibie,
  36371. "after_money": order.AccountPrice,
  36372. "patient": patient,
  36373. "org_name": miConfig.OrgName,
  36374. "org_code": miConfig.Code,
  36375. "order_number": order.Number,
  36376. "his_hospital": his_hospital,
  36377. "his": his,
  36378. "dia_config": dia_config,
  36379. "psn_cash_pay": order.PsnCashPay,
  36380. //"check_order_info": cus_slice,
  36381. }
  36382. data3 = append(data3, data2)
  36383. }
  36384. }
  36385. }
  36386. c.ServeSuccessJSON(map[string]interface{}{
  36387. "infos": data3,
  36388. })
  36389. }
  36390. func (c *HisApiController) GetSettleAccounts() {
  36391. //id, _ := c.GetInt64("id")
  36392. //record_time := c.GetString("record_time")
  36393. order_id, _ := c.GetInt64("order_id")
  36394. admin_user_id, _ := c.GetInt64("admin_user_id")
  36395. //timeLayout := "2006-01-02"
  36396. //loc, _ := time.LoadLocation("Local")
  36397. //
  36398. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36399. //if err != nil {
  36400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36401. // return
  36402. //}Hbyb5203
  36403. //recordDateTime := theTime.Unix()
  36404. adminUser := c.GetAdminUserInfo()
  36405. order, _ := service.GetHisOrderByID(order_id)
  36406. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36407. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36408. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36409. orderInfos = append(orderInfos, orderInfos_two...)
  36410. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36411. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36412. var diagnosis_ids []string
  36413. if his.ID > 0 {
  36414. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36415. } else {
  36416. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36417. }
  36418. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36419. var dia_config []*models.HisXtDiagnoseConfig
  36420. var name string
  36421. for _, item := range diagnosis_ids {
  36422. id, _ := strconv.ParseInt(item, 10, 64)
  36423. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36424. dia_config = append(dia_config, &diagnosisConfig)
  36425. if len(name) == 0 {
  36426. name = diagnosisConfig.ClassName
  36427. } else {
  36428. name = name + "," + diagnosisConfig.ClassName
  36429. }
  36430. }
  36431. if patient.UserOrgId == 10215 {
  36432. name = "慢性肾功能不全(血透治疗)"
  36433. }
  36434. var bedCostTotal float64 = 0 //床位总费
  36435. var bedCostSelfTotal float64 = 0 //床位自费
  36436. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36437. var bedSelfTotal float64 = 0 //床位部分项目自费
  36438. var bedInscpTotal float64 = 0 //床位部分项目自费
  36439. var operationCostTotal float64 = 0 //手术费
  36440. var operationCostSelfTotal float64 = 0 //手术费
  36441. var operationCostPartSelfTotal float64 = 0 //手术费
  36442. var operationSelfTotal float64 = 0 //床位部分项目自费
  36443. var operationInscpTotal float64 = 0 //床位部分项目自费
  36444. var otherCostTotal float64 = 0 //其他费用
  36445. var otherCostSelfTotal float64 = 0 //其他费用
  36446. var otherCostPartSelfTotal float64 = 0 //其他费用
  36447. var otherSelfTotal float64 = 0 //床位部分项目自费
  36448. var otherInscpTotal float64 = 0 //床位部分项目自费
  36449. var materialCostTotal float64 = 0 //材料费
  36450. var materialCostSelfTotal float64 = 0 //材料费
  36451. var materialCostPartSelfTotal float64 = 0 //材料费
  36452. var materialSelfTotal float64 = 0 //床位部分项目自费
  36453. var materialInscpTotal float64 = 0 //床位部分项目自费
  36454. var westernMedicineCostTotal float64 = 0 //西药费
  36455. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36456. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36457. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36458. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36459. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36460. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36461. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36462. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36463. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36464. var checkCostTotal float64 = 0 //检查费
  36465. var checkCostSelfTotal float64 = 0 //检查费
  36466. var checkCostPartSelfTotal float64 = 0 //检查费
  36467. var checkSelfTotal float64 = 0 //床位部分项目自费
  36468. var checkInscpTotal float64 = 0 //床位部分项目自费
  36469. var laboratoryCostTotal float64 = 0 //化验费
  36470. var laboratoryCostSelfTotal float64 = 0 //化验费
  36471. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36472. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36473. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36474. var treatCostTotal float64 = 0 //治疗费用
  36475. var treatCostSelfTotal float64 = 0 //治疗费用
  36476. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36477. var treatSelfTotal float64 = 0 //床位部分项目自费
  36478. var treatInscpTotal float64 = 0 //床位部分项目自费
  36479. var zcCostTotal float64 = 0 //治疗费用
  36480. var zcCostSelfTotal float64 = 0 //治疗费用
  36481. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36482. var zcSelfTotal float64 = 0 //床位部分项目自费
  36483. var zcInscpTotal float64 = 0 //床位部分项目自费
  36484. var huliCostTotal float64 = 0 //治疗费用
  36485. var huliCostSelfTotal float64 = 0 //治疗费用
  36486. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36487. var huliSelfTotal float64 = 0 //床位部分项目自费
  36488. var huliInscpTotal float64 = 0 //床位部分项目自费
  36489. decimal.DivisionPrecision = 2
  36490. for _, item := range orderInfos {
  36491. if item.MedChrgitmType == "01" { //床位费
  36492. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36493. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36494. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36495. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36496. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36497. }
  36498. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36499. if item.MedChrgitmType == "03" { //检查费
  36500. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36501. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36502. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36503. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36504. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36505. }
  36506. } else {
  36507. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36508. fmt.Println("------------")
  36509. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36510. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36511. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36512. }
  36513. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36514. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36515. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36516. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36517. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36518. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36519. }
  36520. }
  36521. if item.MedChrgitmType == "04" { //化验费
  36522. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36523. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36524. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36525. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36526. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36527. }
  36528. if item.MedChrgitmType == "05" { //治疗费
  36529. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36530. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36531. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36532. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36533. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36534. }
  36535. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36536. fmt.Println("------------")
  36537. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36538. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36539. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36540. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36541. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36542. }
  36543. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36544. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36545. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36546. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36547. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36548. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36549. }
  36550. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36551. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36552. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36553. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36554. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36555. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36556. }
  36557. if item.MedChrgitmType == "09" { //西药费
  36558. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36559. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36560. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36561. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36562. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36563. }
  36564. if item.MedChrgitmType == "11" { //中成费
  36565. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36566. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36567. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36568. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36569. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36570. }
  36571. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36572. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36573. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36574. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36575. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36576. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36577. }
  36578. if item.MedChrgitmType == "02" { //其他费
  36579. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36580. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36581. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36582. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36583. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36584. }
  36585. if item.MedChrgitmType == "07" { //其他费
  36586. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36587. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36588. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36589. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36590. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36591. }
  36592. }
  36593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36594. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36595. var user_name string
  36596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36597. if role.ID == 0 {
  36598. user_name = "管理员"
  36599. } else {
  36600. user_name = role.UserName
  36601. }
  36602. baseParams := models.BaseParams{
  36603. SecretKey: miConfig.SecretKey,
  36604. FixmedinsCode: miConfig.Code,
  36605. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36606. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36607. OrgName: miConfig.OrgName,
  36608. Doctor: user_name,
  36609. RequestUrl: miConfig.Url,
  36610. AccessKey: miConfig.AccessKey,
  36611. }
  36612. businessParams := models.BusinessParams{
  36613. PsnNo: order.PsnNo,
  36614. MdtrtId: order.MdtrtId,
  36615. SetlId: order.SetlId,
  36616. }
  36617. var res ResultEleven
  36618. var resah ResultElevenah
  36619. var resEleven10265 ResultEleven10265
  36620. if config.IsOpen == 1 {
  36621. if miConfig.MdtrtareaAdmvs == "421300" {
  36622. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36623. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36624. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36625. resp, requestErr := http.Get(api)
  36626. if requestErr != nil {
  36627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36628. return
  36629. }
  36630. body, ioErr := ioutil.ReadAll(resp.Body)
  36631. if ioErr != nil {
  36632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36634. return
  36635. }
  36636. var respJSON map[string]interface{}
  36637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36640. return
  36641. }
  36642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36643. result, _ := json.Marshal(respJSON)
  36644. fmt.Println("log")
  36645. fmt.Println(string(result))
  36646. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36647. utils.ErrorLog("解析失败:%v", err)
  36648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36649. return
  36650. }
  36651. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36652. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36653. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36655. resp, requestErr := http.Get(api)
  36656. if requestErr != nil {
  36657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36658. return
  36659. }
  36660. body, ioErr := ioutil.ReadAll(resp.Body)
  36661. if ioErr != nil {
  36662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36664. return
  36665. }
  36666. var respJSON map[string]interface{}
  36667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36670. return
  36671. }
  36672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36673. result, _ := json.Marshal(respJSON)
  36674. fmt.Println("log")
  36675. fmt.Println(string(result))
  36676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36677. utils.ErrorLog("解析失败:%v", err)
  36678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36679. return
  36680. }
  36681. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36682. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36683. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36684. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36685. resp, requestErr := http.Get(api)
  36686. if requestErr != nil {
  36687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36688. return
  36689. }
  36690. body, ioErr := ioutil.ReadAll(resp.Body)
  36691. if ioErr != nil {
  36692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36694. return
  36695. }
  36696. var respJSON map[string]interface{}
  36697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36700. return
  36701. }
  36702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36703. result, _ := json.Marshal(respJSON)
  36704. fmt.Println("log")
  36705. fmt.Println(string(result))
  36706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36707. utils.ErrorLog("解析失败:%v", err)
  36708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36709. return
  36710. }
  36711. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36712. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36713. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36714. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36715. resp, requestErr := http.Get(api)
  36716. if requestErr != nil {
  36717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36718. return
  36719. }
  36720. body, ioErr := ioutil.ReadAll(resp.Body)
  36721. if ioErr != nil {
  36722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36724. return
  36725. }
  36726. var respJSON map[string]interface{}
  36727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36730. return
  36731. }
  36732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36733. result, _ := json.Marshal(respJSON)
  36734. fmt.Println("log")
  36735. fmt.Println(string(result))
  36736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36737. utils.ErrorLog("解析失败:%v", err)
  36738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36739. return
  36740. }
  36741. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  36742. var api string
  36743. if miConfig.MdtrtareaAdmvs == "320830" {
  36744. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36745. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36747. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36748. } else if miConfig.MdtrtareaAdmvs == "320921" {
  36749. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36750. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36751. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36752. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36753. } else {
  36754. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36755. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36756. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36757. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36758. }
  36759. resp, requestErr := http.Get(api)
  36760. if requestErr != nil {
  36761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36762. return
  36763. }
  36764. body, ioErr := ioutil.ReadAll(resp.Body)
  36765. if ioErr != nil {
  36766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36768. return
  36769. }
  36770. var respJSON map[string]interface{}
  36771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36774. return
  36775. }
  36776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36777. result, _ := json.Marshal(respJSON)
  36778. fmt.Println("log")
  36779. fmt.Println(string(result))
  36780. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36781. utils.ErrorLog("解析失败:%v", err)
  36782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36783. return
  36784. }
  36785. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36786. res.Output = resEleven10265.Output
  36787. res.ErrMsg = resEleven10265.ErrMsg
  36788. res.Cainfo = resEleven10265.Cainfo
  36789. res.WarnMsg = resEleven10265.WarnMsg
  36790. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36791. res.Infcode = infocode
  36792. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36793. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36794. saveLog(result, requestLog, "5203", "结算单")
  36795. var dat map[string]interface{}
  36796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36797. fmt.Println(dat)
  36798. } else {
  36799. fmt.Println(err)
  36800. }
  36801. userJSONBytes, _ := json.Marshal(dat)
  36802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36803. utils.ErrorLog("解析失败:%v", err)
  36804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36805. return
  36806. }
  36807. } else if miConfig.MdtrtareaAdmvs == "360302" {
  36808. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36809. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36810. saveLog(result, requestLog, "5203", "结算单")
  36811. var dat map[string]interface{}
  36812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36813. fmt.Println(dat)
  36814. } else {
  36815. fmt.Println(err)
  36816. }
  36817. userJSONBytes, _ := json.Marshal(dat)
  36818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36819. utils.ErrorLog("解析失败:%v", err)
  36820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36821. return
  36822. }
  36823. } else if miConfig.MdtrtareaAdmvs == "361025" {
  36824. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36825. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36826. saveLog(result, requestLog, "5203", "结算单")
  36827. var dat map[string]interface{}
  36828. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36829. fmt.Println(dat)
  36830. } else {
  36831. fmt.Println(err)
  36832. }
  36833. userJSONBytes, _ := json.Marshal(dat)
  36834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36835. utils.ErrorLog("解析失败:%v", err)
  36836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36837. return
  36838. }
  36839. } else if miConfig.MdtrtareaAdmvs == "360100" {
  36840. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36841. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36842. saveLog(result, requestLog, "5203", "结算单")
  36843. var dat map[string]interface{}
  36844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36845. fmt.Println(dat)
  36846. } else {
  36847. fmt.Println(err)
  36848. }
  36849. userJSONBytes, _ := json.Marshal(dat)
  36850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36851. utils.ErrorLog("解析失败:%v", err)
  36852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36853. return
  36854. }
  36855. } else if miConfig.MdtrtareaAdmvs == "341203" {
  36856. var api string
  36857. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36858. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36859. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36860. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36861. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36862. resp, requestErr := http.Get(api)
  36863. if requestErr != nil {
  36864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36865. return
  36866. }
  36867. body, ioErr := ioutil.ReadAll(resp.Body)
  36868. if ioErr != nil {
  36869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36871. return
  36872. }
  36873. var respJSON map[string]interface{}
  36874. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36877. return
  36878. }
  36879. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36880. if status == "0" {
  36881. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36882. c.ServeSuccessJSON(map[string]interface{}{
  36883. "failed_code": -10,
  36884. "msg": err_msg,
  36885. })
  36886. return
  36887. }
  36888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36889. result, _ := json.Marshal(respJSON)
  36890. fmt.Println("log")
  36891. fmt.Println(string(result))
  36892. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36893. utils.ErrorLog("解析失败:%v", err)
  36894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36895. return
  36896. }
  36897. res.InfRefmsgid = resah.InfRefmsgid
  36898. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36899. // 创建对应的Time类型
  36900. t := time.UnixMilli(timestamp)
  36901. // 格式化成指定的日期字符串
  36902. str := t.Format("2006-01-02 15:04:05")
  36903. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36904. // 创建对应的Time类型
  36905. t3 := time.UnixMilli(timestamp2)
  36906. // 格式化成指定的日期字符串
  36907. str2 := t3.Format("2006-01-02 15:04:05")
  36908. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36909. // 创建对应的Time类型
  36910. t4 := time.UnixMilli(timestamp3)
  36911. // 格式化成指定的日期字符串
  36912. str3 := t4.Format("2006-01-02 15:04:05")
  36913. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36914. // 创建对应的Time类型
  36915. t5 := time.UnixMilli(timestamp4)
  36916. // 格式化成指定的日期字符串
  36917. str5 := t5.Format("2006-01-02 15:04:05")
  36918. res.Output.Setlinfo.Brdy = str2
  36919. res.Output.Setlinfo.SetlTime = str
  36920. res.Output.Setlinfo.Begndate = str3
  36921. res.Output.Setlinfo.Enddate = str5
  36922. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36923. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36924. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36925. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36926. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36927. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36928. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36929. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36930. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36931. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36932. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36933. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36934. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36935. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36936. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36937. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36938. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36939. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36940. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36941. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36942. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36943. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36944. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  36945. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  36946. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  36947. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  36948. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  36949. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  36950. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  36951. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  36952. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  36953. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  36954. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36955. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  36956. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  36957. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  36958. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  36959. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  36960. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  36961. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  36962. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  36963. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  36964. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  36965. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  36966. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  36967. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  36968. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  36969. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  36970. //res.Output.Setldetail = resah.Output.Setldetail
  36971. res.ErrMsg = resah.ErrMsg
  36972. res.Cainfo = resah.Cainfo
  36973. res.WarnMsg = resah.WarnMsg
  36974. } else if miConfig.MdtrtareaAdmvs == "340699" {
  36975. var api string
  36976. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36977. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36978. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36979. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36980. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36981. resp, requestErr := http.Get(api)
  36982. if requestErr != nil {
  36983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36984. return
  36985. }
  36986. body, ioErr := ioutil.ReadAll(resp.Body)
  36987. if ioErr != nil {
  36988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36990. return
  36991. }
  36992. var respJSON map[string]interface{}
  36993. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36996. return
  36997. }
  36998. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36999. if status == "0" {
  37000. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37001. c.ServeSuccessJSON(map[string]interface{}{
  37002. "failed_code": -10,
  37003. "msg": err_msg,
  37004. })
  37005. return
  37006. }
  37007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37008. result, _ := json.Marshal(respJSON)
  37009. fmt.Println("log")
  37010. fmt.Println(string(result))
  37011. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37012. utils.ErrorLog("解析失败:%v", err)
  37013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37014. return
  37015. }
  37016. res.InfRefmsgid = resah.InfRefmsgid
  37017. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37018. // 创建对应的Time类型
  37019. t := time.UnixMilli(timestamp)
  37020. // 格式化成指定的日期字符串
  37021. str := t.Format("2006-01-02 15:04:05")
  37022. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37023. // 创建对应的Time类型
  37024. t3 := time.UnixMilli(timestamp2)
  37025. // 格式化成指定的日期字符串
  37026. str2 := t3.Format("2006-01-02 15:04:05")
  37027. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37028. // 创建对应的Time类型
  37029. t4 := time.UnixMilli(timestamp3)
  37030. // 格式化成指定的日期字符串
  37031. str3 := t4.Format("2006-01-02 15:04:05")
  37032. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37033. // 创建对应的Time类型
  37034. t5 := time.UnixMilli(timestamp4)
  37035. // 格式化成指定的日期字符串
  37036. str5 := t5.Format("2006-01-02 15:04:05")
  37037. res.Output.Setlinfo.Brdy = str2
  37038. res.Output.Setlinfo.SetlTime = str
  37039. res.Output.Setlinfo.Begndate = str3
  37040. res.Output.Setlinfo.Enddate = str5
  37041. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37042. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37043. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37044. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37045. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37046. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37047. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37048. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37049. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37050. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37051. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37052. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37053. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37054. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37055. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37056. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37057. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37058. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37059. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37060. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37061. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37062. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37063. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37064. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37065. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37066. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37067. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37068. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37069. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37070. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37071. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37072. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37073. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37074. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37075. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37076. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37077. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37078. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37079. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37080. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37081. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37082. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37083. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37084. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37085. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37086. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37087. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37088. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37089. //res.Output.Setldetail = resah.Output.Setldetail
  37090. res.ErrMsg = resah.ErrMsg
  37091. res.Cainfo = resah.Cainfo
  37092. res.WarnMsg = resah.WarnMsg
  37093. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37094. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37095. saveLog(result, requestLog, "5203", "结算单")
  37096. var dat map[string]interface{}
  37097. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37098. fmt.Println(dat)
  37099. } else {
  37100. fmt.Println(err)
  37101. }
  37102. userJSONBytes, _ := json.Marshal(dat)
  37103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37104. utils.ErrorLog("解析失败:%v", err)
  37105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37106. return
  37107. }
  37108. } else if miConfig.MdtrtareaAdmvs == "150499" {
  37109. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37110. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37111. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37112. resp, requestErr := http.Get(api)
  37113. if requestErr != nil {
  37114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37115. return
  37116. }
  37117. body, ioErr := ioutil.ReadAll(resp.Body)
  37118. if ioErr != nil {
  37119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37121. return
  37122. }
  37123. var respJSON map[string]interface{}
  37124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37127. return
  37128. }
  37129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37130. result, _ := json.Marshal(respJSON)
  37131. fmt.Println("log")
  37132. fmt.Println(string(result))
  37133. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37134. utils.ErrorLog("解析失败:%v", err)
  37135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37136. return
  37137. }
  37138. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37139. res.Output = resEleven10265.Output
  37140. res.ErrMsg = resEleven10265.ErrMsg
  37141. res.Cainfo = resEleven10265.Cainfo
  37142. res.WarnMsg = resEleven10265.WarnMsg
  37143. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37144. res.Infcode = infocode
  37145. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37146. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37147. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37149. resp, requestErr := http.Get(api)
  37150. if requestErr != nil {
  37151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37152. return
  37153. }
  37154. body, ioErr := ioutil.ReadAll(resp.Body)
  37155. if ioErr != nil {
  37156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37158. return
  37159. }
  37160. var respJSON map[string]interface{}
  37161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37164. return
  37165. }
  37166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37167. result, _ := json.Marshal(respJSON)
  37168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37169. utils.ErrorLog("解析失败:%v", err)
  37170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37171. return
  37172. }
  37173. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37174. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37175. //return
  37176. } else {
  37177. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37178. if len(his.InsuplcAdmdvs) == 0 {
  37179. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37180. } else {
  37181. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37182. }
  37183. result := service.Gdyb5203(baseParams, businessParams)
  37184. //service.Gdyb5204(baseParams, businessParams)
  37185. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37186. var dat map[string]interface{}
  37187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37188. fmt.Println(dat)
  37189. } else {
  37190. fmt.Println(err)
  37191. }
  37192. userJSONBytes, _ := json.Marshal(dat)
  37193. if miConfig.Code == "H15049901371" {
  37194. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37195. utils.ErrorLog("解析失败:%v", err)
  37196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37197. return
  37198. }
  37199. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37200. res.Output = resEleven10265.Output
  37201. res.ErrMsg = resEleven10265.ErrMsg
  37202. res.Cainfo = resEleven10265.Cainfo
  37203. res.WarnMsg = resEleven10265.WarnMsg
  37204. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37205. res.Infcode = infocode
  37206. } else {
  37207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37208. utils.ErrorLog("解析失败:%v", err)
  37209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37210. return
  37211. }
  37212. }
  37213. }
  37214. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37215. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37216. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37217. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37218. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37219. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37220. var doctor_name string
  37221. if roles.ID == 0 {
  37222. doctor_name = "管理员"
  37223. } else {
  37224. doctor_name = roles.UserName
  37225. }
  37226. yiliao_leibie := ""
  37227. switch order.MedType {
  37228. case "11":
  37229. yiliao_leibie = "普通门诊"
  37230. break
  37231. case "12":
  37232. yiliao_leibie = "门诊挂号"
  37233. break
  37234. case "13":
  37235. yiliao_leibie = "急诊"
  37236. break
  37237. case "14":
  37238. yiliao_leibie = "门诊特殊病"
  37239. break
  37240. case "15":
  37241. yiliao_leibie = "门诊统筹"
  37242. break
  37243. case "16":
  37244. yiliao_leibie = "门诊慢性病"
  37245. break
  37246. case "21":
  37247. yiliao_leibie = "普通住院"
  37248. break
  37249. }
  37250. //var rf []CustomFundPay
  37251. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37252. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37253. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37254. if res.Infcode == 0 {
  37255. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 || adminUser.CurrentOrgId == 10210 || adminUser.CurrentOrgId == 10571 || adminUser.CurrentOrgId == 10752 {
  37256. c.ServeSuccessJSON(map[string]interface{}{
  37257. "diagnosis": name,
  37258. "order_infos": orderInfos,
  37259. "number": order.MdtrtId,
  37260. "date": order.SettleAccountsDate,
  37261. "charge_admin": charge_admin,
  37262. "printor_admin": printor_admin,
  37263. "info": res.Output.Setlinfo,
  37264. "order": order,
  37265. "bedCostTotal": bedCostTotal,
  37266. "bedCostSelfTotal": bedCostSelfTotal,
  37267. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37268. "bedSelfTotal": bedSelfTotal,
  37269. "bedInscpTotal": bedInscpTotal,
  37270. "operationCostTotal": operationCostTotal,
  37271. "operationCostSelfTotal": operationCostSelfTotal,
  37272. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37273. "operationSelfTotal": operationSelfTotal,
  37274. "operationInscpTotal": operationInscpTotal,
  37275. "otherCostTotal": otherCostTotal,
  37276. "otherCostSelfTotal": otherCostSelfTotal,
  37277. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37278. "otherSelfTotal": otherSelfTotal,
  37279. "otherInscpTotal": otherInscpTotal,
  37280. "materialCostTotal": materialCostTotal,
  37281. "materialCostSelfTotal": materialCostSelfTotal,
  37282. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37283. "materialSelfTotal": materialSelfTotal,
  37284. "materialInscpTotal": materialInscpTotal,
  37285. "westernMedicineCostTotal": westernMedicineCostTotal,
  37286. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37287. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37288. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37289. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37290. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37291. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37292. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37293. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37294. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37295. "checkCostTotal": checkCostTotal,
  37296. "checkCostSelfTotal": checkCostSelfTotal,
  37297. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37298. "checkSelfTotal": checkSelfTotal,
  37299. "checkInscpTotal": checkInscpTotal,
  37300. "laboratoryCostTotal": laboratoryCostTotal,
  37301. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37302. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37303. "laboratorySelfTotal": laboratorySelfTotal,
  37304. "laboratoryInscpTotal": laboratoryInscpTotal,
  37305. "treatCostTotal": treatCostTotal,
  37306. "treatCostSelfTotal": treatCostSelfTotal,
  37307. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37308. "treatSelfTotal": treatSelfTotal,
  37309. "treatInscpTotal": treatInscpTotal,
  37310. "doctor_info": doctor_info,
  37311. "doctor_code": adminRole_two.DoctorCode,
  37312. "doctor_name": doctor_name,
  37313. "health_card_no": order.PsnNo,
  37314. "department": departments.Name,
  37315. "yiliao_leibie": yiliao_leibie,
  37316. "after_money": order.AccountPrice,
  37317. "patient": patient,
  37318. "org_name": miConfig.OrgName,
  37319. "org_code": miConfig.Code,
  37320. "order_number": order.Number,
  37321. "his_hospital": his_hospital,
  37322. "his": his,
  37323. "dia_config": dia_config,
  37324. "psn_cash_pay": order.PsnCashPay,
  37325. "zcCostTotal": zcCostTotal,
  37326. "zcCostSelfTotal": zcCostSelfTotal,
  37327. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37328. "zcSelfTotal": zcSelfTotal,
  37329. "zcInscpTotal": zcInscpTotal,
  37330. "huliCostTotal": huliCostTotal,
  37331. "huliCostSelfTotal": huliCostSelfTotal,
  37332. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37333. "huliSelfTotal": huliSelfTotal,
  37334. "huliInscpTotal": huliInscpTotal,
  37335. //"funds": rf,
  37336. //"check_order_info": cus_slice,
  37337. })
  37338. } else {
  37339. c.ServeSuccessJSON(map[string]interface{}{
  37340. "diagnosis": name,
  37341. "order_infos": orderInfos,
  37342. "number": order.MdtrtId,
  37343. "date": order.SettleAccountsDate,
  37344. "charge_admin": charge_admin,
  37345. "printor_admin": printor_admin,
  37346. "info": order,
  37347. "order": order,
  37348. "bedCostTotal": bedCostTotal,
  37349. "bedCostSelfTotal": bedCostSelfTotal,
  37350. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37351. "bedSelfTotal": bedSelfTotal,
  37352. "bedInscpTotal": bedInscpTotal,
  37353. "operationCostTotal": operationCostTotal,
  37354. "operationCostSelfTotal": operationCostSelfTotal,
  37355. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37356. "operationSelfTotal": operationSelfTotal,
  37357. "operationInscpTotal": operationInscpTotal,
  37358. "otherCostTotal": otherCostTotal,
  37359. "otherCostSelfTotal": otherCostSelfTotal,
  37360. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37361. "otherSelfTotal": otherSelfTotal,
  37362. "otherInscpTotal": otherInscpTotal,
  37363. "materialCostTotal": materialCostTotal,
  37364. "materialCostSelfTotal": materialCostSelfTotal,
  37365. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37366. "materialSelfTotal": materialSelfTotal,
  37367. "materialInscpTotal": materialInscpTotal,
  37368. "westernMedicineCostTotal": westernMedicineCostTotal,
  37369. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37370. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37371. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37372. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37373. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37374. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37375. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37376. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37377. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37378. "checkCostTotal": checkCostTotal,
  37379. "checkCostSelfTotal": checkCostSelfTotal,
  37380. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37381. "checkSelfTotal": checkSelfTotal,
  37382. "checkInscpTotal": checkInscpTotal,
  37383. "laboratoryCostTotal": laboratoryCostTotal,
  37384. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37385. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37386. "laboratorySelfTotal": laboratorySelfTotal,
  37387. "laboratoryInscpTotal": laboratoryInscpTotal,
  37388. "treatCostTotal": treatCostTotal,
  37389. "treatCostSelfTotal": treatCostSelfTotal,
  37390. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37391. "treatSelfTotal": treatSelfTotal,
  37392. "treatInscpTotal": treatInscpTotal,
  37393. "doctor_info": doctor_info,
  37394. "doctor_code": adminRole_two.DoctorCode,
  37395. "doctor_name": doctor_name,
  37396. "health_card_no": order.PsnNo,
  37397. "department": departments.Name,
  37398. "yiliao_leibie": yiliao_leibie,
  37399. "after_money": order.AccountPrice,
  37400. "patient": patient,
  37401. "org_name": miConfig.OrgName,
  37402. "org_code": miConfig.Code,
  37403. "order_number": order.Number,
  37404. "his_hospital": his_hospital,
  37405. "his": his,
  37406. "dia_config": dia_config,
  37407. "psn_cash_pay": order.PsnCashPay,
  37408. "zcCostTotal": zcCostTotal,
  37409. "zcCostSelfTotal": zcCostSelfTotal,
  37410. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37411. "zcSelfTotal": zcSelfTotal,
  37412. "zcInscpTotal": zcInscpTotal,
  37413. "huliCostTotal": huliCostTotal,
  37414. "huliCostSelfTotal": huliCostSelfTotal,
  37415. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37416. "huliSelfTotal": huliSelfTotal,
  37417. "huliInscpTotal": huliInscpTotal,
  37418. //"funds": rf,
  37419. //"check_order_info": cus_slice,
  37420. })
  37421. }
  37422. }
  37423. }
  37424. }
  37425. //func (c *HisApiController) CheckTreatment() {
  37426. // patient_id, _ := c.GetInt64("patient_id")
  37427. // id_card_no := c.GetString("id_card_no")
  37428. // insutype := c.GetString("insutype")
  37429. // med_type := c.GetString("med_type")
  37430. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37431. //
  37432. // adminUser := c.GetAdminUserInfo()
  37433. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37434. //
  37435. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37436. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37437. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37438. //
  37439. // if miConfig.MdtrtareaAdmvs == "421300" {
  37440. // var res ResultTwo
  37441. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37442. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37443. // "&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)
  37444. // resp, requestErr := http.Get(api)
  37445. // if requestErr != nil {
  37446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37447. // return
  37448. // }
  37449. //
  37450. // body, ioErr := ioutil.ReadAll(resp.Body)
  37451. // if ioErr != nil {
  37452. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37454. // return
  37455. // }
  37456. // var respJSON map[string]interface{}
  37457. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37458. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37460. // return
  37461. // }
  37462. //
  37463. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37464. // result, _ := json.Marshal(respJSON)
  37465. //
  37466. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37467. // utils.ErrorLog("解析失败:%v", err)
  37468. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37469. // return
  37470. // }
  37471. //
  37472. // if res.Infcode == 0 {
  37473. //
  37474. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37475. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37476. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37477. // resp, requestErr := http.Get(api)
  37478. // if requestErr != nil {
  37479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37480. // return
  37481. // }
  37482. //
  37483. // body, ioErr := ioutil.ReadAll(resp.Body)
  37484. // if ioErr != nil {
  37485. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37487. // return
  37488. // }
  37489. // var respJSON map[string]interface{}
  37490. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37491. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37493. // return
  37494. // }
  37495. // var res Result2001
  37496. //
  37497. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37498. // result2, _ := json.Marshal(respJSON)
  37499. //
  37500. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37501. // utils.ErrorLog("解析失败:%v", err)
  37502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37503. // return
  37504. // }
  37505. //
  37506. // if res.Infcode == 0 {
  37507. // c.ServeSuccessJSON(map[string]interface{}{
  37508. // "msg": res.Output.Trtinfo,
  37509. // })
  37510. // }
  37511. //
  37512. // } else {
  37513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37514. // return
  37515. // }
  37516. //
  37517. // } else {
  37518. //
  37519. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37520. // var dat map[string]interface{}
  37521. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37522. // fmt.Println(dat)
  37523. // } else {
  37524. // fmt.Println(err)
  37525. // }
  37526. // userJSONBytes, _ := json.Marshal(dat)
  37527. // var res ResultTwo
  37528. // var res10265 ResultTwo10265
  37529. // if miConfig.Code == "H15049901371" {
  37530. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37531. // utils.ErrorLog("解析失败:%v", err)
  37532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37533. // return
  37534. // }
  37535. // res.ErrMsg = res10265.ErrMsg
  37536. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37537. // res.Infcode = infocode
  37538. // res.Output = res10265.Output
  37539. // res.InfRefmsgid = res10265.InfRefmsgid
  37540. // } else {
  37541. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37542. // utils.ErrorLog("解析失败:%v", err)
  37543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37544. // return
  37545. // }
  37546. // }
  37547. //
  37548. // var user_name string
  37549. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37550. // if role.ID == 0 {
  37551. // user_name = "xxx"
  37552. // } else {
  37553. // user_name = role.UserName
  37554. // }
  37555. //
  37556. // baseParams := models.BaseParams{
  37557. // SecretKey: miConfig.SecretKey,
  37558. // FixmedinsCode: miConfig.Code,
  37559. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37560. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37561. // OrgName: miConfig.OrgName,
  37562. // Doctor: user_name,
  37563. // }
  37564. //
  37565. // if config.IsOpen == 1 {
  37566. // if miConfig.Code == "H15049901371" {
  37567. // if med_type == "14" {
  37568. // if insutype == "390" {
  37569. // med_type = "9933"
  37570. // } else if insutype == "310" {
  37571. // med_type = "990502"
  37572. // }
  37573. // } else if med_type == "11" {
  37574. // med_type = "11"
  37575. // }
  37576. // }
  37577. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37578. // var dat map[string]interface{}
  37579. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37580. // fmt.Println(dat)
  37581. // } else {
  37582. // fmt.Println(err)
  37583. // }
  37584. // var res Result2001
  37585. // var res10265 Result2001Org10265
  37586. // if miConfig.Code == "H15049901371" {
  37587. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37588. // utils.ErrorLog("解析失败:%v", err)
  37589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37590. // return
  37591. // }
  37592. // res.ErrMsg = res10265.ErrMsg
  37593. // res.Output = res10265.Output
  37594. // res.InfRefmsgid = res10265.InfRefmsgid
  37595. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37596. // res.Infcode = infocode
  37597. // } else {
  37598. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37599. // utils.ErrorLog("解析失败:%v", err)
  37600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37601. // return
  37602. // }
  37603. // }
  37604. // if res.Infcode == 0 {
  37605. // c.ServeSuccessJSON(map[string]interface{}{
  37606. // "msg": res.Output.Trtinfo,
  37607. // })
  37608. // }
  37609. // }
  37610. // }
  37611. //}
  37612. //func (c *HisApiController) PutRecord() {
  37613. // id, _ := c.GetInt64("id")
  37614. // record_time := c.GetString("record_time")
  37615. // timeLayout := "2006-01-02"
  37616. // loc, _ := time.LoadLocation("Local")
  37617. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37618. // if err != nil {
  37619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37620. // return
  37621. // }
  37622. // recordDateTime := theTime.Unix()
  37623. //
  37624. // adminInfo := c.GetAdminUserInfo()
  37625. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37626. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37627. //
  37628. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37629. //
  37630. // fmt.Println(miConfig.SecretKey)
  37631. //
  37632. // if patient == nil {
  37633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37634. // return
  37635. // }
  37636. // if len(patient.IdCardNo) == 0 {
  37637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37638. // return
  37639. // }
  37640. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37641. // if config.IsOpen == 1 {
  37642. // 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
  37643. // resp, requestErr := http.Get(api)
  37644. // if requestErr != nil {
  37645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37646. // return
  37647. // }
  37648. // defer resp.Body.Close()
  37649. // body, ioErr := ioutil.ReadAll(resp.Body)
  37650. // if ioErr != nil {
  37651. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37653. // return
  37654. // }
  37655. // var respJSON map[string]interface{}
  37656. //
  37657. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37658. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37660. // return
  37661. // }
  37662. //
  37663. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37664. // userJSONBytes, _ := json.Marshal(userJSON)
  37665. // var res ResultTwo
  37666. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37667. // utils.ErrorLog("解析失败:%v", err)
  37668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37669. // return
  37670. // }
  37671. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37672. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37673. // infoStr := string(Iinfos)
  37674. // idetinfoStr := string(Idetinfos)
  37675. //
  37676. // if res.Infcode == 0 {
  37677. // his := models.VMHisPatient{
  37678. // Status: 1,
  37679. // Ctime: time.Now().Unix(),
  37680. // Mtime: time.Now().Unix(),
  37681. // PsnNo: res.Output.Baseinfo.PsnNo,
  37682. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37683. // Certno: res.Output.Baseinfo.Certno,
  37684. // PsnName: res.Output.Baseinfo.PsnName,
  37685. // Gend: res.Output.Baseinfo.Gend,
  37686. // Naty: res.Output.Baseinfo.Naty,
  37687. // Brdy: res.Output.Baseinfo.Brdy,
  37688. // Age: res.Output.Baseinfo.Age,
  37689. // Iinfo: infoStr,
  37690. // Idetinfo: idetinfoStr,
  37691. // PatientId: patient.ID,
  37692. // RecordDate: theTime.Unix(),
  37693. // UserOrgId: adminInfo.CurrentOrgId,
  37694. // AdminUserId: adminInfo.AdminUser.Id,
  37695. // IsReturn: 1,
  37696. // }
  37697. //
  37698. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37699. // //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")
  37700. // //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")
  37701. //
  37702. // //var dat map[string]interface{}
  37703. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37704. // // fmt.Println(dat)
  37705. // //} else {
  37706. // // fmt.Println(err)
  37707. // //}
  37708. //
  37709. // var dat2 map[string]interface{}
  37710. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37711. // fmt.Println(dat2)
  37712. // } else {
  37713. // fmt.Println(err)
  37714. // }
  37715. //
  37716. // } else {
  37717. // adminUser := c.GetAdminUserInfo()
  37718. // errlog := &models.HisOrderError{
  37719. // UserOrgId: adminUser.CurrentOrgId,
  37720. // Ctime: time.Now().Unix(),
  37721. // Mtime: time.Now().Unix(),
  37722. // ErrMsg: res.ErrMsg,
  37723. // Status: 1,
  37724. // PatientId: id,
  37725. // RecordTime: recordDateTime,
  37726. // Stage: 1,
  37727. // }
  37728. // service.CreateErrMsgLog(errlog)
  37729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37730. // return
  37731. // }
  37732. // }
  37733. //
  37734. //}
  37735. //func (c *HisApiController) GetUploadDiag() {
  37736. // id, _ := c.GetInt64("id")
  37737. // record_time := c.GetString("record_time")
  37738. //
  37739. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37740. // sick_type, _ := c.GetInt64("sick_type")
  37741. // reg_type, _ := c.GetInt64("reg_type")
  37742. //
  37743. // timeLayout := "2006-01-02"
  37744. // loc, _ := time.LoadLocation("Local")
  37745. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37746. // if err != nil {
  37747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37748. // return
  37749. // }
  37750. //
  37751. // var patientPrescription models.HisPrescriptionInfo
  37752. // recordDateTime := theTime.Unix()
  37753. // adminInfo := c.GetAdminUserInfo()
  37754. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37755. //
  37756. // if patientPrescription.ID == 0 {
  37757. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37758. // }
  37759. //
  37760. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37761. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37762. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37763. // sickConfig, _ := service.FindSickById(sick_type)
  37764. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37765. //
  37766. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37767. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37768. // "&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 +
  37769. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37770. // resp2, requestErr2 := http.Get(api2)
  37771. // if requestErr2 != nil {
  37772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37773. // return
  37774. // }
  37775. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37776. // if ioErr2 != nil {
  37777. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37779. // return
  37780. // }
  37781. // var respJSON2 map[string]interface{}
  37782. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37783. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37785. // return
  37786. // }
  37787. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37788. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37789. //
  37790. // var res2 ResultSix
  37791. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37792. // utils.ErrorLog("解析失败:%v", err)
  37793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37794. // return
  37795. // }
  37796. // if res2.Infcode != 0 {
  37797. // adminUser := c.GetAdminUserInfo()
  37798. // errlog := &models.HisOrderError{
  37799. // UserOrgId: adminUser.CurrentOrgId,
  37800. // Ctime: time.Now().Unix(),
  37801. // Mtime: time.Now().Unix(),
  37802. // ErrMsg: res2.ErrMsg,
  37803. // Status: 1,
  37804. // PatientId: id,
  37805. // RecordTime: recordDateTime,
  37806. // Stage: 3,
  37807. // }
  37808. // service.CreateErrMsgLog(errlog)
  37809. //
  37810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  37811. // return
  37812. // }
  37813. //
  37814. // c.ServeSuccessJSON(map[string]interface{}{
  37815. // "msg": "上传成功",
  37816. // })
  37817. //
  37818. //}
  37819. type QueryResult struct {
  37820. ID int64
  37821. Name string
  37822. Code string
  37823. List_type_code string
  37824. }
  37825. func (c *HisApiController) GetCheckCode() {
  37826. ids_str := c.GetString("ids")
  37827. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37828. ids_arr := strings.Split(ids_str, ",")
  37829. var queryResult []QueryResult
  37830. ids := make([]int64, 0)
  37831. for _, item := range ids_arr {
  37832. id, _ := strconv.ParseInt(item, 10, 64)
  37833. ids = append(ids, id)
  37834. }
  37835. if record_type == 1 {
  37836. drugs, _ := service.GetBatchDrugList(ids)
  37837. for _, item := range drugs {
  37838. result := QueryResult{
  37839. ID: item.ID,
  37840. Name: item.DrugName,
  37841. Code: item.MedicalInsuranceNumber,
  37842. List_type_code: "101",
  37843. }
  37844. queryResult = append(queryResult, result)
  37845. }
  37846. } else if record_type == 2 {
  37847. goods, _ := service.GetBatchGoodInformationList(ids)
  37848. fmt.Println(goods)
  37849. for _, item := range goods {
  37850. result := QueryResult{
  37851. ID: item.ID,
  37852. Name: item.GoodName,
  37853. Code: item.SocialSecurityDirectoryCode,
  37854. List_type_code: "301",
  37855. }
  37856. queryResult = append(queryResult, result)
  37857. }
  37858. } else if record_type == 3 {
  37859. projects, _ := service.GetBathchMyPorjecgList(ids)
  37860. for _, item := range projects {
  37861. result := QueryResult{
  37862. ID: item.ID,
  37863. Name: item.ProjectName,
  37864. Code: item.MedicalCode,
  37865. List_type_code: "201",
  37866. }
  37867. queryResult = append(queryResult, result)
  37868. }
  37869. }
  37870. admin_user_id, _ := c.GetInt64("admin_user_id")
  37871. adminUser := c.GetAdminUserInfo()
  37872. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37873. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37874. var user_name string
  37875. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37876. if role.ID == 0 {
  37877. user_name = "管理员"
  37878. } else {
  37879. user_name = role.UserName
  37880. }
  37881. baseParams := models.BaseParams{
  37882. SecretKey: miConfig.SecretKey,
  37883. FixmedinsCode: miConfig.Code,
  37884. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37885. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37886. OrgName: miConfig.OrgName,
  37887. Doctor: user_name,
  37888. }
  37889. var result string
  37890. if miConfig.MdtrtareaAdmvs == "430800" {
  37891. for _, item := range queryResult {
  37892. if record_type == 1 {
  37893. 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)
  37894. } else if record_type == 2 {
  37895. fmt.Println(item.Code)
  37896. 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)
  37897. } else if record_type == 3 {
  37898. 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)
  37899. }
  37900. var dat map[string]interface{}
  37901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37902. fmt.Println(dat)
  37903. } else {
  37904. fmt.Println(err)
  37905. }
  37906. userJSONBytes, _ := json.Marshal(dat)
  37907. var res ResultSix
  37908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37909. utils.ErrorLog("解析失败:%v", err)
  37910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37911. return
  37912. }
  37913. if res.Infcode == 0 {
  37914. if record_type == 1 {
  37915. service.UpdateBaseDrugById(item.ID)
  37916. } else if record_type == 2 {
  37917. service.UpdateGoodInformaitonByDetail(item.ID)
  37918. } else if record_type == 3 {
  37919. service.UpdateProjectById(item.ID)
  37920. }
  37921. c.ServeSuccessJSON(map[string]interface{}{
  37922. "failed_code": 0,
  37923. "msg": "目录对照成功",
  37924. })
  37925. } else {
  37926. c.ServeSuccessJSON(map[string]interface{}{
  37927. "failed_code": -10,
  37928. "msg": res.ErrMsg,
  37929. })
  37930. }
  37931. }
  37932. } else {
  37933. for _, item := range queryResult {
  37934. var result string
  37935. if record_type == 1 {
  37936. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37937. } else if record_type == 2 {
  37938. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37939. } else if record_type == 3 {
  37940. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37941. }
  37942. var dat map[string]interface{}
  37943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37944. fmt.Println(dat)
  37945. } else {
  37946. fmt.Println(err)
  37947. }
  37948. userJSONBytes, _ := json.Marshal(dat)
  37949. var res ResultSix
  37950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37951. utils.ErrorLog("解析失败:%v", err)
  37952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37953. return
  37954. }
  37955. if res.Infcode == 0 {
  37956. if record_type == 1 {
  37957. service.UpdateBaseDrugById(item.ID)
  37958. } else if record_type == 2 {
  37959. service.UpdateGoodInformaitonByDetail(item.ID)
  37960. } else if record_type == 3 {
  37961. service.UpdateProjectById(item.ID)
  37962. }
  37963. c.ServeSuccessJSON(map[string]interface{}{
  37964. "failed_code": 0,
  37965. "msg": "目录对照成功",
  37966. })
  37967. } else {
  37968. c.ServeSuccessJSON(map[string]interface{}{
  37969. "failed_code": -10,
  37970. "msg": res.ErrMsg,
  37971. })
  37972. }
  37973. }
  37974. }
  37975. }
  37976. func (c *HisApiController) UnCheckCode() {
  37977. ids_str := c.GetString("ids")
  37978. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37979. admin_user_id, _ := c.GetInt64("admin_user_id")
  37980. ids_arr := strings.Split(ids_str, ",")
  37981. var queryResult []QueryResult
  37982. ids := make([]int64, 0)
  37983. for _, item := range ids_arr {
  37984. id, _ := strconv.ParseInt(item, 10, 64)
  37985. ids = append(ids, id)
  37986. }
  37987. if record_type == 1 {
  37988. drugs, _ := service.GetBatchDrugList(ids)
  37989. for _, item := range drugs {
  37990. result := QueryResult{
  37991. ID: item.ID,
  37992. Name: item.DrugName,
  37993. Code: item.MedicalInsuranceNumber,
  37994. List_type_code: "101",
  37995. }
  37996. queryResult = append(queryResult, result)
  37997. }
  37998. } else if record_type == 2 {
  37999. goods, _ := service.GetBatchGoodInformationList(ids)
  38000. for _, item := range goods {
  38001. result := QueryResult{
  38002. ID: item.ID,
  38003. Name: item.GoodName,
  38004. Code: item.SocialSecurityDirectoryCode,
  38005. List_type_code: "301",
  38006. }
  38007. queryResult = append(queryResult, result)
  38008. }
  38009. } else if record_type == 3 {
  38010. projects, _ := service.GetBathchMyPorjecgList(ids)
  38011. for _, item := range projects {
  38012. result := QueryResult{
  38013. ID: item.ID,
  38014. Name: item.ProjectName,
  38015. Code: item.MedicalCode,
  38016. List_type_code: "201",
  38017. }
  38018. queryResult = append(queryResult, result)
  38019. }
  38020. }
  38021. adminUser := c.GetAdminUserInfo()
  38022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38024. var user_name string
  38025. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38026. if role.ID == 0 {
  38027. user_name = "xxx"
  38028. } else {
  38029. user_name = role.UserName
  38030. }
  38031. baseParams := &models.BaseParams{
  38032. SecretKey: miConfig.SecretKey,
  38033. FixmedinsCode: miConfig.Code,
  38034. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38035. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38036. OrgName: miConfig.OrgName,
  38037. Doctor: user_name,
  38038. }
  38039. if config.IsOpen == 1 {
  38040. if miConfig.MdtrtareaAdmvs == "430800" {
  38041. for _, item := range queryResult {
  38042. var result string
  38043. if record_type == 1 {
  38044. 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)
  38045. } else if record_type == 2 {
  38046. fmt.Println(item.Code)
  38047. 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)
  38048. } else if record_type == 3 {
  38049. 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)
  38050. }
  38051. var dat map[string]interface{}
  38052. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38053. fmt.Println(dat)
  38054. } else {
  38055. fmt.Println(err)
  38056. }
  38057. userJSONBytes, _ := json.Marshal(dat)
  38058. var res ResultSix
  38059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38060. utils.ErrorLog("解析失败:%v", err)
  38061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38062. return
  38063. }
  38064. if res.Infcode == 0 {
  38065. if record_type == 1 {
  38066. service.UpdateBaseDrugById(item.ID)
  38067. } else if record_type == 2 {
  38068. service.UpdateGoodInformaitonByDetail(item.ID)
  38069. } else if record_type == 3 {
  38070. service.UpdateProjectById(item.ID)
  38071. }
  38072. c.ServeSuccessJSON(map[string]interface{}{
  38073. "failed_code": 0,
  38074. "msg": "目录对照成功",
  38075. })
  38076. } else {
  38077. c.ServeSuccessJSON(map[string]interface{}{
  38078. "failed_code": -10,
  38079. "msg": res.ErrMsg,
  38080. })
  38081. }
  38082. }
  38083. } else {
  38084. for _, item := range queryResult {
  38085. var result string
  38086. if record_type == 1 {
  38087. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38088. } else if record_type == 2 {
  38089. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38090. } else if record_type == 3 {
  38091. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38092. }
  38093. var dat2 map[string]interface{}
  38094. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38095. fmt.Println(dat2)
  38096. } else {
  38097. fmt.Println(err)
  38098. }
  38099. userJSONBytes, _ := json.Marshal(dat2)
  38100. var res ResultSix
  38101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38102. utils.ErrorLog("解析失败:%v", err)
  38103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38104. return
  38105. }
  38106. if res.Infcode == 0 {
  38107. if record_type == 1 {
  38108. service.UpdateDrugByIdDetail(item.ID)
  38109. } else if record_type == 2 {
  38110. service.UpdateGoodInfoById(item.ID)
  38111. } else if record_type == 3 {
  38112. service.UpdateMyProjectById(item.ID)
  38113. }
  38114. c.ServeSuccessJSON(map[string]interface{}{
  38115. "failed_code": 0,
  38116. "msg": "撤销目录对照成功",
  38117. })
  38118. } else {
  38119. c.ServeSuccessJSON(map[string]interface{}{
  38120. "failed_code": -10,
  38121. "msg": res.ErrMsg,
  38122. })
  38123. }
  38124. }
  38125. }
  38126. }
  38127. }
  38128. func (c *HisApiController) GetPatientInfo() {
  38129. id_card_no := c.GetString("id_card_no")
  38130. admin_user_id, _ := c.GetInt64("admin_user_id")
  38131. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38132. if patient.ID == 0 {
  38133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38134. return
  38135. }
  38136. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38137. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38138. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38139. var res ResultTwo
  38140. var res10265 ResultTwo10265
  38141. if config.IsOpen == 1 {
  38142. if miConfig.MdtrtareaAdmvs == "150499" {
  38143. //请求内网数据
  38144. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38145. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38146. "&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
  38147. resp, requestErr := http.Get(api)
  38148. if requestErr != nil {
  38149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38150. return
  38151. }
  38152. body, ioErr := ioutil.ReadAll(resp.Body)
  38153. if ioErr != nil {
  38154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38156. return
  38157. }
  38158. var respJSON map[string]interface{}
  38159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38162. return
  38163. }
  38164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38165. result_byte, _ := json.Marshal(respJSON)
  38166. result := string(result_byte)
  38167. var dat map[string]interface{}
  38168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38169. fmt.Println(dat)
  38170. } else {
  38171. fmt.Println(err)
  38172. }
  38173. userJSONBytes, _ := json.Marshal(dat)
  38174. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38175. utils.ErrorLog("解析失败:%v", err)
  38176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38177. return
  38178. }
  38179. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38180. res.Infcode = Infcode
  38181. res.ErrMsg = res10265.ErrMsg
  38182. res.Output = res10265.Output
  38183. res.InfRefmsgid = res10265.InfRefmsgid
  38184. res.RespondTime = res10265.RespondTime
  38185. res.WarnInfo = res10265.WarnInfo
  38186. } else {
  38187. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38188. var dat map[string]interface{}
  38189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38190. fmt.Println(dat)
  38191. } else {
  38192. fmt.Println(err)
  38193. }
  38194. userJSONBytes, _ := json.Marshal(dat)
  38195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38196. utils.ErrorLog("解析失败:%v", err)
  38197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38198. return
  38199. }
  38200. }
  38201. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38202. // utils.ErrorLog("解析失败:%v", err)
  38203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38204. // return
  38205. //}
  38206. for index, item := range res.Output.Iinfo {
  38207. if item.PsnInsuStas == "2" {
  38208. fmt.Println("--------")
  38209. res.Output.Iinfo[index].Insutype = "300"
  38210. res.Output.Iinfo[index].PsnInsuStas = "1"
  38211. }
  38212. }
  38213. fmt.Println(res.Output.Iinfo)
  38214. if res.Infcode != 0 {
  38215. c.ServeSuccessJSON(map[string]interface{}{
  38216. "failed_code": -10,
  38217. "msg": res.ErrMsg,
  38218. })
  38219. } else {
  38220. c.ServeSuccessJSON(map[string]interface{}{
  38221. "failed_code": 0,
  38222. "info": res,
  38223. })
  38224. }
  38225. }
  38226. }
  38227. func (c *HisApiController) PsnPutOnRecord() {
  38228. record_type, _ := c.GetInt64("type")
  38229. patient_id, _ := c.GetInt64("patient_id")
  38230. admin_user_id, _ := c.GetInt64("admin_user_id")
  38231. start_time := c.GetString("start_time")
  38232. end_time := c.GetString("end_time")
  38233. adminUser := c.GetAdminUserInfo()
  38234. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38235. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38236. var patients []*models.Patients
  38237. if record_type == 1 { //全部备案
  38238. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38239. patients = append(patients, patient...)
  38240. } else { //单个备案
  38241. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38242. patients = append(patients, patient)
  38243. }
  38244. var user_name string
  38245. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38246. if role.ID == 0 {
  38247. user_name = "xxx"
  38248. } else {
  38249. user_name = role.UserName
  38250. }
  38251. if config.IsOpen == 1 {
  38252. for _, item := range patients {
  38253. 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
  38254. resp, requestErr := http.Get(api)
  38255. if requestErr != nil {
  38256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38257. return
  38258. }
  38259. defer resp.Body.Close()
  38260. body, ioErr := ioutil.ReadAll(resp.Body)
  38261. if ioErr != nil {
  38262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38264. return
  38265. }
  38266. var respJSON map[string]interface{}
  38267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38270. return
  38271. }
  38272. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38273. userJSONBytes, _ := json.Marshal(userJSON)
  38274. var res ResultTwo
  38275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38276. utils.ErrorLog("解析失败:%v", err)
  38277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38278. return
  38279. }
  38280. if res.Infcode == 0 {
  38281. 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)
  38282. var dat map[string]interface{}
  38283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38284. fmt.Println(dat)
  38285. } else {
  38286. fmt.Println(err)
  38287. }
  38288. userJSONBytes, _ := json.Marshal(dat)
  38289. var res2 ResultThirteen
  38290. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38291. utils.ErrorLog("解析失败:%v", err)
  38292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38293. return
  38294. }
  38295. if res2.Infcode == 0 {
  38296. psnResult := &models.GdybPsnRecord{
  38297. UserOrgId: adminUser.CurrentOrgId,
  38298. PatientId: item.ID,
  38299. PsnNo: res.Output.Baseinfo.PsnNo,
  38300. Ctime: time.Now().Unix(),
  38301. Mtime: time.Now().Unix(),
  38302. Status: 1,
  38303. IsCancel: 1,
  38304. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38305. }
  38306. service.CreatePsnRecord(psnResult)
  38307. } else {
  38308. c.ServeSuccessJSON(map[string]interface{}{
  38309. "failed_code": -10,
  38310. "msg": res2.ErrMsg,
  38311. })
  38312. return
  38313. }
  38314. }
  38315. }
  38316. }
  38317. }
  38318. func (c *HisApiController) PsnUnPutOnRecord() {
  38319. id, _ := c.GetInt64("id")
  38320. //record_type, _ := c.GetInt64("type")
  38321. admin_user_id, _ := c.GetInt64("admin_user_id")
  38322. adminUser := c.GetAdminUserInfo()
  38323. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38324. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38325. var user_name string
  38326. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38327. if role.ID == 0 {
  38328. user_name = "xxx"
  38329. } else {
  38330. user_name = role.UserName
  38331. }
  38332. psn_record, _ := service.GetPsnRecordById(id)
  38333. if psn_record.ID == 0 {
  38334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38335. return
  38336. }
  38337. if config.IsOpen == 1 {
  38338. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38339. var dat map[string]interface{}
  38340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38341. fmt.Println(dat)
  38342. } else {
  38343. fmt.Println(err)
  38344. }
  38345. userJSONBytes, _ := json.Marshal(dat)
  38346. var res ResultFourteen
  38347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38348. utils.ErrorLog("解析失败:%v", err)
  38349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38350. return
  38351. }
  38352. if res.Infcode == 0 {
  38353. psn_record.IsCancel = 2
  38354. service.CreatePsnRecord(&psn_record)
  38355. } else {
  38356. c.ServeSuccessJSON(map[string]interface{}{
  38357. "failed_code": -10,
  38358. "msg": res.ErrMsg,
  38359. })
  38360. return
  38361. }
  38362. }
  38363. }
  38364. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38365. patient_id, _ := c.GetInt64("patient_id")
  38366. insutype_two := c.GetString("insutype")
  38367. psn_no := c.GetString("psn_no")
  38368. doctor_id, _ := c.GetInt64("doctor_id")
  38369. sick_id, _ := c.GetInt64("sick_id")
  38370. department_id, _ := c.GetInt64("department_id")
  38371. start_time := c.GetString("start_time")
  38372. end_time := c.GetString("end_time")
  38373. check_time := c.GetString("check_time")
  38374. hospital_code := c.GetString("hospital_code")
  38375. hospital_name := c.GetString("hospital_name")
  38376. adminUser := c.GetAdminUserInfo()
  38377. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38378. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38379. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38380. sick, _ := service.FindSickById(sick_id)
  38381. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38382. if len(hospital_code) == 0 {
  38383. hospital_code = miConfig.Code
  38384. }
  38385. if len(hospital_name) == 0 {
  38386. hospital_name = miConfig.OrgName
  38387. }
  38388. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38389. var res ResultTwo
  38390. var res10265 ResultTwo10265
  38391. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38392. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38393. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38394. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38395. "&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
  38396. resp, requestErr := http.Get(api)
  38397. if requestErr != nil {
  38398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38399. return
  38400. }
  38401. body, ioErr := ioutil.ReadAll(resp.Body)
  38402. if ioErr != nil {
  38403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38405. return
  38406. }
  38407. var respJSON map[string]interface{}
  38408. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38411. return
  38412. }
  38413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38414. result, _ := json.Marshal(respJSON)
  38415. fmt.Println("log")
  38416. fmt.Println(string(result))
  38417. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38418. utils.ErrorLog("解析失败:%v", err)
  38419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38420. return
  38421. }
  38422. res.ErrMsg = res10265.ErrMsg
  38423. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38424. res.Infcode = infocode
  38425. res.Output = res10265.Output
  38426. res.InfRefmsgid = res10265.InfRefmsgid
  38427. } else {
  38428. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38429. if miConfig.Code == "H15049901371" {
  38430. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38431. utils.ErrorLog("解析失败:%v", err)
  38432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38433. return
  38434. }
  38435. res.ErrMsg = res10265.ErrMsg
  38436. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38437. res.Infcode = infocode
  38438. res.Output = res10265.Output
  38439. res.InfRefmsgid = res10265.InfRefmsgid
  38440. } else {
  38441. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38442. utils.ErrorLog("解析失败:%v", err)
  38443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38444. return
  38445. }
  38446. }
  38447. }
  38448. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38449. infoStr := string(Iinfos)
  38450. var rf []*ResultFive
  38451. json.Unmarshal([]byte(infoStr), &rf)
  38452. var insuplc_admdvs string
  38453. var insutype string
  38454. var is390 int = 0
  38455. var is310 int = 0
  38456. var insutypes []*ResultFive
  38457. for _, item := range rf {
  38458. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38459. insutypes = append(insutypes, item)
  38460. }
  38461. }
  38462. if len(insutypes) == 1 {
  38463. insutype = insutypes[0].Insutype
  38464. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38465. } else {
  38466. for _, i := range insutypes {
  38467. if i.Insutype == "390" {
  38468. is390 = 1
  38469. }
  38470. if i.Insutype == "310" {
  38471. is310 = 1
  38472. }
  38473. }
  38474. }
  38475. if is390 == 1 {
  38476. insutype = "390"
  38477. }
  38478. if is310 == 1 {
  38479. insutype = "310"
  38480. }
  38481. if len(insutypes) == 2 {
  38482. insutype = insutype_two
  38483. }
  38484. if len(insutypes) == 0 {
  38485. insutype = "310"
  38486. }
  38487. insutype = insutype_two
  38488. fmt.Println(insutype)
  38489. for _, item := range rf {
  38490. fmt.Println(item.Insutype)
  38491. fmt.Println(insutype)
  38492. if item.Insutype == insutype {
  38493. fmt.Println(item.Insutype)
  38494. fmt.Println(insutype)
  38495. insuplc_admdvs = item.InsuplcAdmdvs
  38496. }
  38497. }
  38498. fmt.Println(insuplc_admdvs)
  38499. var res2 ResultThirteen
  38500. var res10265_2 ResultThirteen10265
  38501. if config.IsOpen == 1 {
  38502. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38503. } else {
  38504. if miConfig.MdtrtareaAdmvs == "150499" {
  38505. //
  38506. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38507. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38508. // "&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
  38509. //resp, requestErr := http.Get(api)
  38510. //if requestErr != nil {
  38511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38512. // return
  38513. //}
  38514. //
  38515. //body, ioErr := ioutil.ReadAll(resp.Body)
  38516. //if ioErr != nil {
  38517. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38519. // return
  38520. //}
  38521. //var respJSON map[string]interface{}
  38522. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38523. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38525. // return
  38526. //}
  38527. //
  38528. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38529. //result, _ := json.Marshal(respJSON)
  38530. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38531. // utils.ErrorLog("解析失败:%v", err)
  38532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38533. // return
  38534. //}
  38535. //infocode = resThree.Infcode
  38536. //result, _ := json.Marshal(respJSON)
  38537. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38538. // utils.ErrorLog("解析失败:%v", err)
  38539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38540. // return
  38541. //}
  38542. //
  38543. //resThree.ErrMsg = resThree10265.ErrMsg
  38544. //
  38545. //resThree.Output = resThree10265.Output
  38546. //
  38547. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38548. //
  38549. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38550. //
  38551. } else {
  38552. 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)
  38553. var dat map[string]interface{}
  38554. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38555. fmt.Println(dat)
  38556. } else {
  38557. fmt.Println(err)
  38558. }
  38559. userJSONBytes, _ := json.Marshal(dat)
  38560. if miConfig.Code == "H15049901371" {
  38561. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38562. utils.ErrorLog("解析失败:%v", err)
  38563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38564. return
  38565. }
  38566. res2.ErrMsg = res10265_2.ErrMsg
  38567. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38568. res2.Infcode = infocode
  38569. res2.Output = res10265_2.Output
  38570. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38571. } else {
  38572. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38573. utils.ErrorLog("解析失败:%v", err)
  38574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38575. return
  38576. }
  38577. }
  38578. }
  38579. }
  38580. if res2.Infcode == 0 {
  38581. psnResult := &models.GdybPsnNcdsRecord{
  38582. UserOrgId: adminUser.CurrentOrgId,
  38583. PatientId: patient.ID,
  38584. PsnNo: psn_no,
  38585. DoctorId: doctor.AdminUserId,
  38586. DepartmentId: department_id,
  38587. SickType: sick_id,
  38588. Insutype: insutype,
  38589. Ctime: time.Now().Unix(),
  38590. Mtime: time.Now().Unix(),
  38591. Status: 1,
  38592. IsCancel: 1,
  38593. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38594. }
  38595. service.CreatePsnNCDSRecord(psnResult)
  38596. c.ServeSuccessJSON(map[string]interface{}{
  38597. "failed_code": 0,
  38598. "msg": "备案成功",
  38599. "result": psnResult,
  38600. })
  38601. } else {
  38602. c.ServeSuccessJSON(map[string]interface{}{
  38603. "failed_code": -10,
  38604. "msg": res2.ErrMsg,
  38605. })
  38606. return
  38607. }
  38608. }
  38609. }
  38610. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38611. id, _ := c.GetInt64("id")
  38612. admin_user_id, _ := c.GetInt64("admin_user_id")
  38613. adminUser := c.GetAdminUserInfo()
  38614. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38615. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38616. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38617. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38618. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38619. //var user_name string
  38620. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38621. //if role.ID == 0 {
  38622. // user_name = "xxx"
  38623. //} else {
  38624. // user_name = role.UserName
  38625. //}
  38626. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38627. if psn_record.ID == 0 {
  38628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38629. return
  38630. }
  38631. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38632. var res ResultTwo
  38633. var res10265 ResultTwo10265
  38634. if miConfig.Code == "H15049901371" {
  38635. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38636. utils.ErrorLog("解析失败:%v", err)
  38637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38638. return
  38639. }
  38640. res.ErrMsg = res10265.ErrMsg
  38641. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38642. res.Infcode = infocode
  38643. res.Output = res10265.Output
  38644. res.InfRefmsgid = res10265.InfRefmsgid
  38645. } else {
  38646. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38647. utils.ErrorLog("解析失败:%v", err)
  38648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38649. return
  38650. }
  38651. }
  38652. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38653. infoStr := string(Iinfos)
  38654. var rf []*ResultFive
  38655. json.Unmarshal([]byte(infoStr), &rf)
  38656. var insuplc_admdvs string
  38657. var insutype string
  38658. var is390 int = 0
  38659. var is310 int = 0
  38660. var insutypes []*ResultFive
  38661. for _, item := range rf {
  38662. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38663. insutypes = append(insutypes, item)
  38664. }
  38665. }
  38666. if len(insutypes) == 1 {
  38667. insutype = insutypes[0].Insutype
  38668. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38669. } else {
  38670. for _, i := range insutypes {
  38671. if i.Insutype == "390" {
  38672. is390 = 1
  38673. }
  38674. if i.Insutype == "310" {
  38675. is310 = 1
  38676. }
  38677. }
  38678. }
  38679. if is390 == 1 {
  38680. insutype = "390"
  38681. }
  38682. if is310 == 1 {
  38683. insutype = "310"
  38684. }
  38685. if len(insutypes) == 0 {
  38686. insutype = "310"
  38687. }
  38688. insutype = psn_record.Insutype
  38689. for _, item := range rf {
  38690. if item.Insutype == insutype {
  38691. insuplc_admdvs = item.InsuplcAdmdvs
  38692. }
  38693. }
  38694. if config.IsOpen == 1 {
  38695. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38696. var dat map[string]interface{}
  38697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38698. fmt.Println(dat)
  38699. } else {
  38700. fmt.Println(err)
  38701. }
  38702. userJSONBytes, _ := json.Marshal(dat)
  38703. var res ResultFourteen
  38704. var res10265 ResultFourteen10265
  38705. if miConfig.Code == "H15049901371" {
  38706. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38707. utils.ErrorLog("解析失败:%v", err)
  38708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38709. return
  38710. }
  38711. res.ErrMsg = res10265.ErrMsg
  38712. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38713. res.Infcode = infocode
  38714. res.Output = res10265.Output
  38715. res.InfRefmsgid = res10265.InfRefmsgid
  38716. } else {
  38717. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38718. utils.ErrorLog("解析失败:%v", err)
  38719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38720. return
  38721. }
  38722. }
  38723. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38724. // utils.ErrorLog("解析失败:%v", err)
  38725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38726. // return
  38727. //}
  38728. if res.Infcode == 0 {
  38729. psn_record.IsCancel = 2
  38730. service.CreatePsnNCDSRecord(&psn_record)
  38731. c.ServeSuccessJSON(map[string]interface{}{
  38732. "failed_code": 0,
  38733. "msg": "撤销备案成功",
  38734. })
  38735. } else {
  38736. c.ServeSuccessJSON(map[string]interface{}{
  38737. "failed_code": -10,
  38738. "msg": res.ErrMsg,
  38739. })
  38740. return
  38741. }
  38742. }
  38743. }
  38744. func (c *HisApiController) TestTest() {
  38745. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38746. fmt.Println(patient.Iinfo)
  38747. }
  38748. type CustomData struct {
  38749. MsgId string
  38750. PsnNo string
  38751. Info string
  38752. }
  38753. func (c *HisApiController) ReversalData() {
  38754. var customData []*CustomData
  38755. custom := &CustomData{
  38756. MsgId: "H44022900158202103301714472004",
  38757. PsnNo: "44020000001101329945",
  38758. Info: "2207",
  38759. }
  38760. customData = append(customData, custom)
  38761. custom1 := &CustomData{
  38762. MsgId: "H4402290015820210330172057803",
  38763. PsnNo: "44020000001101161813",
  38764. Info: "2207",
  38765. }
  38766. customData = append(customData, custom1)
  38767. custom2 := &CustomData{
  38768. MsgId: "H44022900158202103301705198813",
  38769. PsnNo: "44190000133097375417",
  38770. Info: "2207",
  38771. }
  38772. customData = append(customData, custom2)
  38773. custom3 := &CustomData{
  38774. MsgId: "H44022900158202103301715524756",
  38775. PsnNo: "44020000001100187221",
  38776. Info: "2207",
  38777. }
  38778. customData = append(customData, custom3)
  38779. custom4 := &CustomData{
  38780. MsgId: "H44022900158202103301730376224",
  38781. PsnNo: "44020000001101959155",
  38782. Info: "2207",
  38783. }
  38784. customData = append(customData, custom4)
  38785. custom5 := &CustomData{
  38786. MsgId: "H44022900158202103301748008725",
  38787. PsnNo: "44020000001104246641",
  38788. Info: "2207",
  38789. }
  38790. customData = append(customData, custom5)
  38791. custom6 := &CustomData{
  38792. MsgId: "H44022900158202103301718096755",
  38793. PsnNo: "44020000001102211860",
  38794. Info: "2207",
  38795. }
  38796. customData = append(customData, custom6)
  38797. custom7 := &CustomData{
  38798. MsgId: "H44022900158202103301736551640",
  38799. PsnNo: "44020000001102687718",
  38800. Info: "2207",
  38801. }
  38802. customData = append(customData, custom7)
  38803. custom8 := &CustomData{
  38804. MsgId: "H44022900158202103301743097676",
  38805. PsnNo: "44020000001102127785",
  38806. Info: "2207",
  38807. }
  38808. customData = append(customData, custom8)
  38809. custom9 := &CustomData{
  38810. MsgId: "H44022900158202103301712304203",
  38811. PsnNo: "44020000001101518097",
  38812. Info: "2207",
  38813. }
  38814. customData = append(customData, custom9)
  38815. custom10 := &CustomData{
  38816. MsgId: "H44022900158202103301738448785",
  38817. PsnNo: "44020000001100500813",
  38818. Info: "2207",
  38819. }
  38820. customData = append(customData, custom10)
  38821. custom11 := &CustomData{
  38822. MsgId: "H44022900158202103301732455843",
  38823. PsnNo: "44020000001102690557",
  38824. Info: "2207",
  38825. }
  38826. customData = append(customData, custom11)
  38827. custom12 := &CustomData{
  38828. MsgId: "H44022900158202103301745421708",
  38829. PsnNo: "44020000001102211928",
  38830. Info: "2207",
  38831. }
  38832. customData = append(customData, custom12)
  38833. custom1212 := &CustomData{
  38834. MsgId: "H440229001582021033017351627",
  38835. PsnNo: "44020000001102481733",
  38836. Info: "2207",
  38837. }
  38838. customData = append(customData, custom1212)
  38839. custom13 := &CustomData{
  38840. MsgId: "H44022900158202103301740327951",
  38841. PsnNo: "44020000001103174866",
  38842. Info: "2207",
  38843. }
  38844. customData = append(customData, custom13)
  38845. custom14 := &CustomData{
  38846. MsgId: "H4402290015820210330174922668",
  38847. PsnNo: "44020000001102927272",
  38848. Info: "2207",
  38849. }
  38850. customData = append(customData, custom14)
  38851. custom15 := &CustomData{
  38852. MsgId: "H44022900158202103301752362273",
  38853. PsnNo: "44020000001102942890",
  38854. Info: "2207",
  38855. }
  38856. customData = append(customData, custom15)
  38857. custom16 := &CustomData{
  38858. MsgId: "H44022900158202103301751082917",
  38859. PsnNo: "44020000001101662162",
  38860. Info: "2207",
  38861. }
  38862. customData = append(customData, custom16)
  38863. custom17 := &CustomData{
  38864. MsgId: "H44022900158202103301754147728",
  38865. PsnNo: "44020000000229014511",
  38866. Info: "2207",
  38867. }
  38868. customData = append(customData, custom17)
  38869. adminUser := c.GetAdminUserInfo()
  38870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38871. for _, item := range customData {
  38872. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38873. fmt.Println(result)
  38874. }
  38875. }
  38876. func (c *HisApiController) GetAllopatry() {
  38877. year := c.GetString("year")
  38878. month := c.GetString("month")
  38879. admin_user_id, _ := c.GetInt64("admin_user_id")
  38880. adminUser := c.GetAdminUserInfo()
  38881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38882. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38883. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38884. var dat map[string]interface{}
  38885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38886. fmt.Println(dat)
  38887. } else {
  38888. fmt.Println(err)
  38889. }
  38890. userJSONBytes, _ := json.Marshal(dat)
  38891. var res models.Result9001
  38892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38893. utils.ErrorLog("解析失败:%v", err)
  38894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38895. return
  38896. }
  38897. fmt.Println(res.Output.Signinoutb)
  38898. fmt.Println(res.Output.Signinoutb.SignNo)
  38899. fmt.Println(string(userJSONBytes))
  38900. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38901. var dat3 map[string]interface{}
  38902. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  38903. fmt.Println(dat3)
  38904. } else {
  38905. fmt.Println(err)
  38906. }
  38907. userJSONBytes3, _ := json.Marshal(dat3)
  38908. var res3 models.Result3260
  38909. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  38910. utils.ErrorLog("解析失败:%v", err)
  38911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38912. return
  38913. }
  38914. var curpage int
  38915. var pagesize int = 100
  38916. var start int = 1
  38917. //var stop int
  38918. //pagecount := 10
  38919. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  38920. var res22 []models.Result3260
  38921. for curpage = 1; curpage <= pagecount; curpage++ {
  38922. if curpage == 1 {
  38923. start = 0
  38924. } else {
  38925. start = (curpage-1)*pagesize + 1
  38926. }
  38927. fmt.Println(start)
  38928. //stop = curpage * pagesize
  38929. //if stop > int(res3.Output.Totalrow) {
  38930. // stop =int(res3.Output.Totalrow)
  38931. //}
  38932. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  38933. var dat2 map[string]interface{}
  38934. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38935. fmt.Println(dat)
  38936. } else {
  38937. fmt.Println(err)
  38938. }
  38939. userJSONBytes2, _ := json.Marshal(dat2)
  38940. var res2 models.Result3260
  38941. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38942. utils.ErrorLog("解析失败:%v", err)
  38943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38944. return
  38945. }
  38946. if res2.Infcode == 0 {
  38947. res22 = append(res22, res2)
  38948. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38949. //var dat2 map[string]interface{}
  38950. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38951. // fmt.Println(dat)
  38952. //} else {
  38953. // fmt.Println(err)
  38954. //}
  38955. //c.ServeSuccessJSON(map[string]interface{}{
  38956. // "list": res2.Output.Data,
  38957. //})
  38958. //continue
  38959. }
  38960. }
  38961. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38962. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38963. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  38964. //var dat2 map[string]interface{}
  38965. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38966. // fmt.Println(dat)
  38967. //} else {
  38968. // fmt.Println(err)
  38969. //}
  38970. //userJSONBytes2, _ := json.Marshal(dat2)
  38971. //var res2 models.Result3260
  38972. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38973. // utils.ErrorLog("解析失败:%v", err)
  38974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38975. // return
  38976. //}
  38977. //if res2.Infcode == 0 {
  38978. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38979. // var dat2 map[string]interface{}
  38980. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38981. // fmt.Println(dat)
  38982. // } else {
  38983. // fmt.Println(err)
  38984. // }
  38985. // c.ServeSuccessJSON(map[string]interface{}{
  38986. // "list": res2.Output.Data,
  38987. // })
  38988. //}
  38989. }
  38990. func (c *HisApiController) ComfirmAllopatry() {
  38991. year := c.GetString("year")
  38992. month := c.GetString("month")
  38993. admin_user_id, _ := c.GetInt64("admin_user_id")
  38994. adminUser := c.GetAdminUserInfo()
  38995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38996. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38997. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38998. var dat map[string]interface{}
  38999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39000. fmt.Println(dat)
  39001. } else {
  39002. fmt.Println(err)
  39003. }
  39004. userJSONBytes, _ := json.Marshal(dat)
  39005. var res models.Result9001
  39006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39007. utils.ErrorLog("解析失败:%v", err)
  39008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39009. return
  39010. }
  39011. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39012. var dat2 map[string]interface{}
  39013. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39014. fmt.Println(dat)
  39015. } else {
  39016. fmt.Println(err)
  39017. }
  39018. userJSONBytes2, _ := json.Marshal(dat2)
  39019. var res2 models.Result3260
  39020. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39021. utils.ErrorLog("解析失败:%v", err)
  39022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39023. return
  39024. }
  39025. //if res2.Infcode == 0 {
  39026. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39027. // var dat map[string]interface{}
  39028. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39029. // fmt.Println(dat)
  39030. // } else {
  39031. // fmt.Println(err)
  39032. // }
  39033. // userJSONBytes, _ := json.Marshal(dat)
  39034. // var res3 models.Result3261
  39035. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39036. // utils.ErrorLog("解析失败:%v", err)
  39037. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39038. // return
  39039. // }
  39040. //
  39041. // if res3.Infcode == 0 {
  39042. // record := &models.HisYidiClearRecord{
  39043. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39044. // Ctime: time.Now().Unix(),
  39045. // Mtime: time.Now().Unix(),
  39046. // Status: 1,
  39047. // MsgId: msgId,
  39048. // }
  39049. // service.SaveClearRecord(record)
  39050. // c.ServeSuccessJSON(map[string]interface{}{
  39051. // "msg": "提取成功",
  39052. // })
  39053. // }
  39054. //}
  39055. }
  39056. func (c *HisApiController) RefundAllopatry() {
  39057. year := c.GetString("year")
  39058. month := c.GetString("month")
  39059. //id, _ := c.GetInt64("id")
  39060. admin_user_id, _ := c.GetInt64("admin_user_id")
  39061. adminUser := c.GetAdminUserInfo()
  39062. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39063. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39064. //record, _ := service.GetClearRecordById(id)
  39065. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39066. var dat map[string]interface{}
  39067. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39068. fmt.Println(dat)
  39069. } else {
  39070. fmt.Println(err)
  39071. }
  39072. userJSONBytes, _ := json.Marshal(dat)
  39073. var res models.Result9001
  39074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39075. utils.ErrorLog("解析失败:%v", err)
  39076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39077. return
  39078. }
  39079. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39080. var dat2 map[string]interface{}
  39081. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39082. fmt.Println(dat)
  39083. } else {
  39084. fmt.Println(err)
  39085. }
  39086. userJSONBytes2, _ := json.Marshal(dat2)
  39087. var empty ResultFourteen
  39088. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39089. utils.ErrorLog("解析失败:%v", err)
  39090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39091. return
  39092. }
  39093. if empty.Infcode == 0 {
  39094. c.ServeSuccessJSON(map[string]interface{}{
  39095. "msg": "撤销成功",
  39096. })
  39097. return
  39098. }
  39099. }
  39100. func (c *HisApiController) ReversalOtherData() {
  39101. var customData []*CustomData
  39102. custom := &CustomData{
  39103. MsgId: "H44022900158202103301714472004",
  39104. PsnNo: "44020000001101329945",
  39105. Info: "2208",
  39106. }
  39107. customData = append(customData, custom)
  39108. custom1 := &CustomData{
  39109. MsgId: "H4402290015820210330172057803",
  39110. PsnNo: "44020000001101161813",
  39111. Info: "2208",
  39112. }
  39113. customData = append(customData, custom1)
  39114. custom2 := &CustomData{
  39115. MsgId: "H44022900158202103301705198813",
  39116. PsnNo: "44190000133097375417",
  39117. Info: "2208",
  39118. }
  39119. customData = append(customData, custom2)
  39120. custom3 := &CustomData{
  39121. MsgId: "H44022900158202103301715524756",
  39122. PsnNo: "44020000001100187221",
  39123. Info: "2208",
  39124. }
  39125. customData = append(customData, custom3)
  39126. custom4 := &CustomData{
  39127. MsgId: "H44022900158202103301730376224",
  39128. PsnNo: "44020000001101959155",
  39129. Info: "2208",
  39130. }
  39131. customData = append(customData, custom4)
  39132. custom5 := &CustomData{
  39133. MsgId: "H44022900158202103301748008725",
  39134. PsnNo: "44020000001104246641",
  39135. Info: "2208",
  39136. }
  39137. customData = append(customData, custom5)
  39138. custom6 := &CustomData{
  39139. MsgId: "H44022900158202103301718096755",
  39140. PsnNo: "44020000001102211860",
  39141. Info: "2208",
  39142. }
  39143. customData = append(customData, custom6)
  39144. custom7 := &CustomData{
  39145. MsgId: "H44022900158202103301736551640",
  39146. PsnNo: "44020000001102687718",
  39147. Info: "2208",
  39148. }
  39149. customData = append(customData, custom7)
  39150. custom8 := &CustomData{
  39151. MsgId: "H44022900158202103301743097676",
  39152. PsnNo: "44020000001102127785",
  39153. Info: "2208",
  39154. }
  39155. customData = append(customData, custom8)
  39156. custom9 := &CustomData{
  39157. MsgId: "H44022900158202103301712304203",
  39158. PsnNo: "44020000001101518097",
  39159. Info: "2208",
  39160. }
  39161. customData = append(customData, custom9)
  39162. custom10 := &CustomData{
  39163. MsgId: "H44022900158202103301738448785",
  39164. PsnNo: "44020000001100500813",
  39165. Info: "2208",
  39166. }
  39167. customData = append(customData, custom10)
  39168. custom11 := &CustomData{
  39169. MsgId: "H44022900158202103301732455843",
  39170. PsnNo: "44020000001102690557",
  39171. Info: "2208",
  39172. }
  39173. customData = append(customData, custom11)
  39174. custom12 := &CustomData{
  39175. MsgId: "H44022900158202103301745421708",
  39176. PsnNo: "44020000001102211928",
  39177. Info: "2208",
  39178. }
  39179. customData = append(customData, custom12)
  39180. custom1212 := &CustomData{
  39181. MsgId: "H440229001582021033017351627",
  39182. PsnNo: "44020000001102481733",
  39183. Info: "2208",
  39184. }
  39185. customData = append(customData, custom1212)
  39186. custom13 := &CustomData{
  39187. MsgId: "H44022900158202103301740327951",
  39188. PsnNo: "44020000001103174866",
  39189. Info: "2208",
  39190. }
  39191. customData = append(customData, custom13)
  39192. custom14 := &CustomData{
  39193. MsgId: "H4402290015820210330174922668",
  39194. PsnNo: "44020000001102927272",
  39195. Info: "2208",
  39196. }
  39197. customData = append(customData, custom14)
  39198. custom15 := &CustomData{
  39199. MsgId: "H44022900158202103301752362273",
  39200. PsnNo: "44020000001102942890",
  39201. Info: "2208",
  39202. }
  39203. customData = append(customData, custom15)
  39204. custom16 := &CustomData{
  39205. MsgId: "H44022900158202103301751082917",
  39206. PsnNo: "44020000001101662162",
  39207. Info: "2208",
  39208. }
  39209. customData = append(customData, custom16)
  39210. custom17 := &CustomData{
  39211. MsgId: "H44022900158202103301754147728",
  39212. PsnNo: "44020000000229014511",
  39213. Info: "2208",
  39214. }
  39215. customData = append(customData, custom17)
  39216. adminUser := c.GetAdminUserInfo()
  39217. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39218. for _, item := range customData {
  39219. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39220. fmt.Println(result)
  39221. }
  39222. }
  39223. func PathExists(path string) (bool, error) {
  39224. _, err := os.Stat(path)
  39225. if err == nil {
  39226. return true, nil
  39227. }
  39228. if os.IsNotExist(err) {
  39229. return false, nil
  39230. }
  39231. return false, err
  39232. }
  39233. // 创建文件夹
  39234. func Mkdir(dir string) {
  39235. // 创建文件夹
  39236. exist, err := PathExists(dir)
  39237. if err != nil {
  39238. fmt.Println(err.Error())
  39239. } else {
  39240. if exist {
  39241. fmt.Println(dir + "文件夹已存在!")
  39242. } else {
  39243. // 文件夹名称,权限
  39244. err := os.Mkdir(dir, os.ModePerm)
  39245. if err != nil {
  39246. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39247. } else {
  39248. fmt.Println(dir + "文件夹创建成功!")
  39249. }
  39250. }
  39251. }
  39252. }
  39253. // 压缩文件
  39254. func Zip(srcFile string, destZip string) error {
  39255. zipfile, err := os.Create(destZip)
  39256. if err != nil {
  39257. return err
  39258. }
  39259. defer zipfile.Close()
  39260. archive := zip.NewWriter(zipfile)
  39261. defer archive.Close()
  39262. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39263. if err != nil {
  39264. return err
  39265. }
  39266. header, err := zip.FileInfoHeader(info)
  39267. if err != nil {
  39268. return err
  39269. }
  39270. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39271. // header.Name = path
  39272. if info.IsDir() {
  39273. header.Name += "/"
  39274. } else {
  39275. header.Method = zip.Deflate
  39276. }
  39277. writer, err := archive.CreateHeader(header)
  39278. if err != nil {
  39279. return err
  39280. }
  39281. if !info.IsDir() {
  39282. file, err := os.Open(path)
  39283. if err != nil {
  39284. return err
  39285. }
  39286. defer file.Close()
  39287. _, err = io.Copy(writer, file)
  39288. }
  39289. return err
  39290. })
  39291. return err
  39292. }
  39293. func ReadFile(filePath string) []byte {
  39294. f, err := os.Open(filePath)
  39295. if err != nil {
  39296. fmt.Println("read file fail", err)
  39297. return nil
  39298. }
  39299. defer f.Close()
  39300. fd, err := ioutil.ReadAll(f)
  39301. if err != nil {
  39302. fmt.Println("read to fd fail", err)
  39303. return nil
  39304. }
  39305. return fd
  39306. }
  39307. func saveLogq(result string, request string, infno string, desc string) {
  39308. dir := "日志"
  39309. utils.Mkdir(dir)
  39310. month := time.Unix(1557042972, 0).Format("1")
  39311. year := time.Now().Format("2006")
  39312. month = time.Now().Format("01")
  39313. day := time.Now().Format("02")
  39314. hour := time.Now().Format("15")
  39315. min := time.Now().Format("04")
  39316. sec := time.Now().Format("05")
  39317. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39318. file := year + month + day + "_log"
  39319. file_name := file + ".txt"
  39320. file_path := "日志" + "/" + file_name
  39321. exist, _ := utils.PathExists(file_path)
  39322. if exist { //存在
  39323. fmt.Println("存在")
  39324. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39325. if err != nil {
  39326. fmt.Println("read fail")
  39327. }
  39328. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39329. n, _ := f.Seek(0, 2)
  39330. _, err = f.WriteAt([]byte(content), n)
  39331. } else { //不存在
  39332. fmt.Println("文件不存在,创建文件")
  39333. f, err := os.Create("日志" + "/" + file_name)
  39334. defer f.Close()
  39335. if err != nil {
  39336. } else {
  39337. _, err = f.Write([]byte("记录日志"))
  39338. }
  39339. }
  39340. }
  39341. func saveLog(result string, request string, infno string, desc string) {
  39342. org_id, _ := beego.AppConfig.Int64("org_id")
  39343. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39344. dir := miConfig.OrgName + "日志"
  39345. utils.Mkdir(dir)
  39346. month := time.Unix(1557042972, 0).Format("1")
  39347. year := time.Now().Format("2006")
  39348. month = time.Now().Format("01")
  39349. day := time.Now().Format("02")
  39350. hour := time.Now().Format("15")
  39351. min := time.Now().Format("04")
  39352. sec := time.Now().Format("05")
  39353. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39354. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39355. file_name := file + ".txt"
  39356. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39357. exist, _ := utils.PathExists(file_path)
  39358. if exist { //存在
  39359. fmt.Println("存在")
  39360. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39361. if err != nil {
  39362. fmt.Println("read fail")
  39363. }
  39364. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39365. n, _ := f.Seek(0, 2)
  39366. _, err = f.WriteAt([]byte(content), n)
  39367. } else { //不存在
  39368. fmt.Println("文件不存在,创建文件")
  39369. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39370. defer f.Close()
  39371. if err != nil {
  39372. } else {
  39373. _, err = f.Write([]byte("记录日志"))
  39374. }
  39375. }
  39376. }
  39377. type Charset string
  39378. const (
  39379. UTF8 = Charset("UTF-8")
  39380. GB18030 = Charset("GB18030")
  39381. )
  39382. func ConvertToString(src string, srcCode string, tagCode string) string {
  39383. srcCoder := mahonia.NewDecoder(srcCode)
  39384. srcResult := srcCoder.ConvertString(src)
  39385. tagCoder := mahonia.NewDecoder(tagCode)
  39386. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39387. result := string(cdata)
  39388. return result
  39389. }
  39390. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39391. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39392. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39393. var token string
  39394. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39395. var api string
  39396. if miConfig.MdtrtareaAdmvs == "320830" {
  39397. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39398. "&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
  39399. fmt.Println(api)
  39400. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39401. 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 +
  39402. "&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
  39403. fmt.Println(api)
  39404. } else {
  39405. 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 +
  39406. "&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
  39407. }
  39408. resp, requestErr := http.Get(api)
  39409. if requestErr != nil {
  39410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39411. return ""
  39412. }
  39413. body, ioErr := ioutil.ReadAll(resp.Body)
  39414. if ioErr != nil {
  39415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39417. return ""
  39418. }
  39419. var respJSON map[string]interface{}
  39420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39423. return ""
  39424. }
  39425. var status string
  39426. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39427. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39428. var res ResultTwo //1101结果
  39429. var res10265 ResultTwo10265 //1101结果
  39430. if status == "0" { //读卡成功
  39431. var card_info string //卡信息
  39432. var busi_card_info string
  39433. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39434. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39435. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39436. fmt.Println(card_info)
  39437. fmt.Println(busi_card_info)
  39438. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39439. result, _ := json.Marshal(respJSON)
  39440. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39441. utils.ErrorLog("解析失败:%v", err)
  39442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39443. return ""
  39444. }
  39445. res.ErrMsg = res10265.ErrMsg
  39446. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39447. res.Infcode = infocode
  39448. res.Output = res10265.Output
  39449. res.InfRefmsgid = res10265.InfRefmsgid
  39450. if res.Infcode == 0 {
  39451. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39452. if err == gorm.ErrRecordNotFound {
  39453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39454. return ""
  39455. } else if err != nil {
  39456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39457. return ""
  39458. } else {
  39459. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39460. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39461. infoStr := string(Iinfos)
  39462. idetinfoStr := string(Idetinfos)
  39463. psn := &models.HisPsn{
  39464. PsnNo: res.Output.Baseinfo.PsnNo,
  39465. PatientId: patient.ID,
  39466. Certno: res.Output.Baseinfo.Certno,
  39467. Gend: res.Output.Baseinfo.Gend,
  39468. Naty: res.Output.Baseinfo.Naty,
  39469. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39470. PsnName: res.Output.Baseinfo.PsnName,
  39471. Idetinfo: idetinfoStr,
  39472. Insuinfo: infoStr,
  39473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39474. CardInfo: card_info,
  39475. VerifyNumber: token,
  39476. }
  39477. service.CreateHisPsn(psn)
  39478. return token
  39479. }
  39480. }
  39481. } else {
  39482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39483. return ""
  39484. }
  39485. } else { //读卡失败
  39486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39487. return ""
  39488. }
  39489. return token
  39490. }
  39491. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39492. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39493. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39494. var token string
  39495. var api string
  39496. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39497. "&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
  39498. fmt.Println(api)
  39499. resp, requestErr := http.Get(api)
  39500. if requestErr != nil {
  39501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39502. return ""
  39503. }
  39504. body, ioErr := ioutil.ReadAll(resp.Body)
  39505. if ioErr != nil {
  39506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39508. return ""
  39509. }
  39510. var respJSON map[string]interface{}
  39511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39514. return ""
  39515. }
  39516. var status string
  39517. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39518. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39519. var res ResultTwo //1101结果
  39520. if status == "1" { //读卡成功
  39521. var card_info string //卡信息
  39522. var busi_card_info string
  39523. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39524. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39525. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39526. fmt.Println(card_info)
  39527. fmt.Println(busi_card_info)
  39528. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39529. result, _ := json.Marshal(respJSON)
  39530. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39531. utils.ErrorLog("解析失败:%v", err)
  39532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39533. return ""
  39534. }
  39535. if res.Infcode == 0 {
  39536. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39537. if err == gorm.ErrRecordNotFound {
  39538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39539. return ""
  39540. } else if err != nil {
  39541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39542. return ""
  39543. } else {
  39544. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39545. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39546. infoStr := string(Iinfos)
  39547. idetinfoStr := string(Idetinfos)
  39548. psn := &models.HisPsn{
  39549. PsnNo: res.Output.Baseinfo.PsnNo,
  39550. PatientId: patient.ID,
  39551. Certno: res.Output.Baseinfo.Certno,
  39552. Gend: res.Output.Baseinfo.Gend,
  39553. Naty: res.Output.Baseinfo.Naty,
  39554. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39555. PsnName: res.Output.Baseinfo.PsnName,
  39556. Idetinfo: idetinfoStr,
  39557. Insuinfo: infoStr,
  39558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39559. CardInfo: card_info,
  39560. VerifyNumber: token,
  39561. }
  39562. service.CreateHisPsn(psn)
  39563. return token
  39564. }
  39565. }
  39566. } else {
  39567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39568. return ""
  39569. }
  39570. return token
  39571. }
  39572. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39573. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39574. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39575. var token string
  39576. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39577. var api string
  39578. if miConfig.MdtrtareaAdmvs == "320830" {
  39579. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39580. "&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
  39581. fmt.Println(api)
  39582. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39583. 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 +
  39584. "&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
  39585. fmt.Println(api)
  39586. } else {
  39587. 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 +
  39588. "&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
  39589. }
  39590. resp, requestErr := http.Get(api)
  39591. if requestErr != nil {
  39592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39593. return ""
  39594. }
  39595. body, ioErr := ioutil.ReadAll(resp.Body)
  39596. if ioErr != nil {
  39597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39599. return ""
  39600. }
  39601. var respJSON map[string]interface{}
  39602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39605. return ""
  39606. }
  39607. var status string
  39608. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39609. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39610. var res ResultTwo //1101结果
  39611. var res10265 ResultTwo10265 //1101结果
  39612. if status == "0" { //读卡成功
  39613. var card_info string //卡信息
  39614. var busi_card_info string
  39615. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39616. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39617. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39618. fmt.Println(card_info)
  39619. fmt.Println(busi_card_info)
  39620. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39621. result, _ := json.Marshal(respJSON)
  39622. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39623. utils.ErrorLog("解析失败:%v", err)
  39624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39625. return ""
  39626. }
  39627. res.ErrMsg = res10265.ErrMsg
  39628. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39629. res.Infcode = infocode
  39630. res.Output = res10265.Output
  39631. res.InfRefmsgid = res10265.InfRefmsgid
  39632. if res.Infcode == 0 {
  39633. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39634. if err == gorm.ErrRecordNotFound {
  39635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39636. return ""
  39637. } else if err != nil {
  39638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39639. return ""
  39640. } else {
  39641. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39642. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39643. infoStr := string(Iinfos)
  39644. idetinfoStr := string(Idetinfos)
  39645. psn := &models.HisPsn{
  39646. PsnNo: res.Output.Baseinfo.PsnNo,
  39647. PatientId: patient.ID,
  39648. Certno: res.Output.Baseinfo.Certno,
  39649. Gend: res.Output.Baseinfo.Gend,
  39650. Naty: res.Output.Baseinfo.Naty,
  39651. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39652. PsnName: res.Output.Baseinfo.PsnName,
  39653. Idetinfo: idetinfoStr,
  39654. Insuinfo: infoStr,
  39655. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39656. CardInfo: card_info,
  39657. VerifyNumber: token,
  39658. }
  39659. service.CreateHisPsn(psn)
  39660. return token
  39661. }
  39662. }
  39663. } else {
  39664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39665. return ""
  39666. }
  39667. } else { //读卡失败
  39668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39669. return ""
  39670. }
  39671. return token
  39672. }
  39673. func DeleteExtraSpaceTwo(s string) string {
  39674. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39675. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39676. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39677. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39678. s2 := make([]byte, len(s1)) //定义字符数组切片
  39679. copy(s2, s1) //将字符串复制到切片
  39680. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39681. for len(spc_index) > 0 { //找到适配项
  39682. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39683. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39684. }
  39685. return string(s2)
  39686. }
  39687. func Remove0000(s string) string {
  39688. str := make([]rune, 0, len(s))
  39689. for _, v := range []rune(s) {
  39690. if v == 0 {
  39691. continue
  39692. }
  39693. str = append(str, v)
  39694. }
  39695. return string(str)
  39696. }
  39697. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39698. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39699. readCard := DllDef.MustFindProc("EcQuery")
  39700. pCardInfo := make([]byte, 8192)
  39701. pBusiCardInfo := make([]byte, 8192)
  39702. data := make(map[string]interface{})
  39703. //pData := make(map[string]interface{})
  39704. inputData := make(map[string]interface{})
  39705. inputData["orgId"] = code
  39706. inputData["businessType"] = "01101"
  39707. inputData["operatorId"] = operator_id
  39708. inputData["operatorName"] = operator_name
  39709. inputData["officeId"] = "001"
  39710. inputData["officeName"] = "血透室"
  39711. //
  39712. data["data"] = inputData
  39713. data["transType"] = "ec.query"
  39714. data["orgId"] = code
  39715. bytesData, _ := json.Marshal(data)
  39716. pCardInfo = bytesData
  39717. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39718. fmt.Println(ret2)
  39719. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39720. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39721. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39722. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39723. if ret2 != 0 {
  39724. return "", ""
  39725. }
  39726. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39727. }
  39728. func DeleteExtraSpace(s string) string {
  39729. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39730. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39731. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39732. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39733. s2 := make([]byte, len(s1)) //定义字符数组切片
  39734. copy(s2, s1) //将字符串复制到切片
  39735. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39736. for len(spc_index) > 0 { //找到适配项
  39737. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39738. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39739. }
  39740. return string(s2)
  39741. }
  39742. // 对账
  39743. func (c *HisApiController) Post3202() {
  39744. start_time := c.GetString("start_time")
  39745. end_time := c.GetString("end_time")
  39746. //insutype := c.GetString("insutype")
  39747. clr_type := c.GetString("clr_type")
  39748. clr_org := c.GetString("clr_optins")
  39749. admin_user_id, _ := c.GetInt64("admin_user_id")
  39750. adminUser := c.GetAdminUserInfo()
  39751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39752. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39753. if len(clr_org) == 0 {
  39754. clr_org = miConfig.MdtrtareaAdmvs
  39755. }
  39756. timeLayout := "2006-01-02"
  39757. loc, _ := time.LoadLocation("Local")
  39758. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39759. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39760. var orders []*models.HisOrder
  39761. if clr_org == "421300" {
  39762. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39763. } else if clr_org == "420902" {
  39764. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39765. } else {
  39766. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39767. }
  39768. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39769. //fixmedins_setl_cnt := int64(len(orders))
  39770. var medfee_sumamt float64
  39771. var acct_pay float64
  39772. var fund_pay_sumamt float64
  39773. for _, item := range orders {
  39774. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39775. acct_pay = acct_pay + item.AcctPay
  39776. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39777. }
  39778. //var medfee_sumamt_two float64
  39779. //var acct_pay_two float64
  39780. //var fund_pay_sumamt_two float64
  39781. //for _, item := range orders_two {
  39782. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39783. // acct_pay_two = acct_pay_two + item.AcctPay
  39784. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39785. //}
  39786. //var user_name string
  39787. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39788. //if role.ID == 0 {
  39789. // user_name = "xxx"
  39790. //} else {
  39791. // user_name = role.UserName
  39792. //}
  39793. var res ResultSix
  39794. if config.IsOpen == 1 {
  39795. var bps []*models.BusinessParamsTwo
  39796. var bp models.BusinessParamsTwo
  39797. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39798. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39799. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39800. bp.MedfeeSumamt = medfee_sumamt_str
  39801. bp.AcctPay = acct_pay_str
  39802. bp.FundPaySumamt = fund_pay_sumamt_str
  39803. bp.Insutype = ""
  39804. bp.StmtBegndate = start_time
  39805. bp.ClrType = clr_type
  39806. bp.SetlOptins = clr_org
  39807. bp.StmtEnddate = end_time
  39808. bps = append(bps, &bp)
  39809. data := make(map[string]interface{})
  39810. data["bps"] = bps
  39811. data["org_name"] = miConfig.OrgName
  39812. data["doctor"] = role.UserName
  39813. data["fixmedins_code"] = miConfig.Code
  39814. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39815. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39816. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39817. if miConfig.MdtrtareaAdmvs == "421300" {
  39818. client := &http.Client{}
  39819. bytesData, _ := json.Marshal(data)
  39820. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39821. resp, _ := client.Do(req)
  39822. defer resp.Body.Close()
  39823. body, ioErr := ioutil.ReadAll(resp.Body)
  39824. if ioErr != nil {
  39825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39827. return
  39828. }
  39829. var respJSON map[string]interface{}
  39830. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39833. return
  39834. }
  39835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39836. userJSONBytes, _ := json.Marshal(respJSON)
  39837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39838. utils.ErrorLog("解析失败:%v", err)
  39839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39840. return
  39841. }
  39842. }
  39843. if miConfig.MdtrtareaAdmvs == "420200" {
  39844. client := &http.Client{}
  39845. bytesData, _ := json.Marshal(data)
  39846. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39847. resp, _ := client.Do(req)
  39848. defer resp.Body.Close()
  39849. body, ioErr := ioutil.ReadAll(resp.Body)
  39850. if ioErr != nil {
  39851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39853. return
  39854. }
  39855. var respJSON map[string]interface{}
  39856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39859. return
  39860. }
  39861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39862. userJSONBytes, _ := json.Marshal(respJSON)
  39863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39864. utils.ErrorLog("解析失败:%v", err)
  39865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39866. return
  39867. }
  39868. }
  39869. if miConfig.MdtrtareaAdmvs == "421182" {
  39870. client := &http.Client{}
  39871. bytesData, _ := json.Marshal(data)
  39872. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39873. resp, _ := client.Do(req)
  39874. defer resp.Body.Close()
  39875. body, ioErr := ioutil.ReadAll(resp.Body)
  39876. if ioErr != nil {
  39877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39879. return
  39880. }
  39881. var respJSON map[string]interface{}
  39882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39885. return
  39886. }
  39887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39888. userJSONBytes, _ := json.Marshal(respJSON)
  39889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39890. utils.ErrorLog("解析失败:%v", err)
  39891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39892. return
  39893. }
  39894. }
  39895. if miConfig.MdtrtareaAdmvs == "420902" {
  39896. client := &http.Client{}
  39897. bytesData, _ := json.Marshal(data)
  39898. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39899. resp, _ := client.Do(req)
  39900. defer resp.Body.Close()
  39901. body, ioErr := ioutil.ReadAll(resp.Body)
  39902. if ioErr != nil {
  39903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39905. return
  39906. }
  39907. var respJSON map[string]interface{}
  39908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39911. return
  39912. }
  39913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39914. userJSONBytes, _ := json.Marshal(respJSON)
  39915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39916. utils.ErrorLog("解析失败:%v", err)
  39917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39918. return
  39919. }
  39920. }
  39921. if res.Infcode == 0 {
  39922. c.ServeSuccessJSON(map[string]interface{}{
  39923. "msg": "发起成功",
  39924. })
  39925. } else {
  39926. c.ServeSuccessJSON(map[string]interface{}{
  39927. "failed_code": -10,
  39928. "msg": res.ErrMsg,
  39929. })
  39930. }
  39931. }
  39932. }
  39933. func (c *HisApiController) Post3204a() {
  39934. start_time := c.GetString("start_time")
  39935. end_time := c.GetString("end_time")
  39936. //insutype := c.GetString("insutype")
  39937. clr_type := c.GetString("clr_type")
  39938. clr_org := c.GetString("clr_optins")
  39939. admin_user_id, _ := c.GetInt64("admin_user_id")
  39940. adminUser := c.GetAdminUserInfo()
  39941. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39942. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39943. if len(clr_org) == 0 {
  39944. clr_org = miConfig.MdtrtareaAdmvs
  39945. }
  39946. timeLayout := "2006-01-02"
  39947. loc, _ := time.LoadLocation("Local")
  39948. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39949. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39950. var orders []*models.HisOrder
  39951. if clr_org == "421300" {
  39952. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39953. } else if clr_org == "420902" {
  39954. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39955. } else {
  39956. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39957. }
  39958. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39959. //fixmedins_setl_cnt := int64(len(orders))
  39960. var medfee_sumamt float64
  39961. var acct_pay float64
  39962. var fund_pay_sumamt float64
  39963. for _, item := range orders {
  39964. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39965. acct_pay = acct_pay + item.AcctPay
  39966. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39967. }
  39968. //var medfee_sumamt_two float64
  39969. //var acct_pay_two float64
  39970. //var fund_pay_sumamt_two float64
  39971. //for _, item := range orders_two {
  39972. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39973. // acct_pay_two = acct_pay_two + item.AcctPay
  39974. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39975. //}
  39976. //var user_name string
  39977. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39978. //if role.ID == 0 {
  39979. // user_name = "xxx"
  39980. //} else {
  39981. // user_name = role.UserName
  39982. //}
  39983. var res ResultSix
  39984. if config.IsOpen == 1 {
  39985. var bps []*models.BusinessParamsTwo
  39986. var bp models.BusinessParamsTwo
  39987. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39988. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39989. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39990. bp.MedfeeSumamt = medfee_sumamt_str
  39991. bp.AcctPay = acct_pay_str
  39992. bp.FundPaySumamt = fund_pay_sumamt_str
  39993. bp.Insutype = ""
  39994. bp.StmtBegndate = start_time
  39995. bp.ClrType = clr_type
  39996. bp.SetlOptins = clr_org
  39997. bp.StmtEnddate = end_time
  39998. bps = append(bps, &bp)
  39999. data := make(map[string]interface{})
  40000. data["bps"] = bps
  40001. data["org_name"] = miConfig.OrgName
  40002. data["doctor"] = role.UserName
  40003. data["fixmedins_code"] = miConfig.Code
  40004. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40005. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40006. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40007. if miConfig.MdtrtareaAdmvs == "421300" {
  40008. client := &http.Client{}
  40009. bytesData, _ := json.Marshal(data)
  40010. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40011. resp, _ := client.Do(req)
  40012. defer resp.Body.Close()
  40013. body, ioErr := ioutil.ReadAll(resp.Body)
  40014. if ioErr != nil {
  40015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40017. return
  40018. }
  40019. var respJSON map[string]interface{}
  40020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40023. return
  40024. }
  40025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40026. userJSONBytes, _ := json.Marshal(respJSON)
  40027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40028. utils.ErrorLog("解析失败:%v", err)
  40029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40030. return
  40031. }
  40032. }
  40033. if miConfig.MdtrtareaAdmvs == "420200" {
  40034. client := &http.Client{}
  40035. bytesData, _ := json.Marshal(data)
  40036. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40037. resp, _ := client.Do(req)
  40038. defer resp.Body.Close()
  40039. body, ioErr := ioutil.ReadAll(resp.Body)
  40040. if ioErr != nil {
  40041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40043. return
  40044. }
  40045. var respJSON map[string]interface{}
  40046. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40049. return
  40050. }
  40051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40052. userJSONBytes, _ := json.Marshal(respJSON)
  40053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40054. utils.ErrorLog("解析失败:%v", err)
  40055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40056. return
  40057. }
  40058. }
  40059. if miConfig.MdtrtareaAdmvs == "421182" {
  40060. client := &http.Client{}
  40061. bytesData, _ := json.Marshal(data)
  40062. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40063. resp, _ := client.Do(req)
  40064. defer resp.Body.Close()
  40065. body, ioErr := ioutil.ReadAll(resp.Body)
  40066. if ioErr != nil {
  40067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40069. return
  40070. }
  40071. var respJSON map[string]interface{}
  40072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40075. return
  40076. }
  40077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40078. userJSONBytes, _ := json.Marshal(respJSON)
  40079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40080. utils.ErrorLog("解析失败:%v", err)
  40081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40082. return
  40083. }
  40084. }
  40085. if miConfig.MdtrtareaAdmvs == "420902" {
  40086. client := &http.Client{}
  40087. bytesData, _ := json.Marshal(data)
  40088. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40089. resp, _ := client.Do(req)
  40090. defer resp.Body.Close()
  40091. body, ioErr := ioutil.ReadAll(resp.Body)
  40092. if ioErr != nil {
  40093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40095. return
  40096. }
  40097. var respJSON map[string]interface{}
  40098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40101. return
  40102. }
  40103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40104. userJSONBytes, _ := json.Marshal(respJSON)
  40105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40106. utils.ErrorLog("解析失败:%v", err)
  40107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40108. return
  40109. }
  40110. }
  40111. if res.Infcode == 0 {
  40112. c.ServeSuccessJSON(map[string]interface{}{
  40113. "msg": "撤销成功",
  40114. })
  40115. } else {
  40116. c.ServeSuccessJSON(map[string]interface{}{
  40117. "failed_code": -10,
  40118. "msg": res.ErrMsg,
  40119. })
  40120. }
  40121. }
  40122. }
  40123. func (c *HisApiController) Post3204() {
  40124. admin_user_id, _ := c.GetInt64("admin_user_id")
  40125. id := c.GetString("id")
  40126. adminUser := c.GetAdminUserInfo()
  40127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40129. //clr_org := miConfig.MdtrtareaAdmvs
  40130. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40131. var res ResultSix
  40132. if config.IsOpen == 1 {
  40133. data := make(map[string]interface{})
  40134. data["id"] = id
  40135. data["org_name"] = miConfig.OrgName
  40136. data["doctor"] = role.UserName
  40137. data["fixmedins_code"] = miConfig.Code
  40138. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40139. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40140. client := &http.Client{}
  40141. bytesData, _ := json.Marshal(data)
  40142. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40143. resp, _ := client.Do(req)
  40144. defer resp.Body.Close()
  40145. body, ioErr := ioutil.ReadAll(resp.Body)
  40146. if ioErr != nil {
  40147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40149. return
  40150. }
  40151. var respJSON map[string]interface{}
  40152. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40155. return
  40156. }
  40157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40158. userJSONBytes, _ := json.Marshal(respJSON)
  40159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40160. utils.ErrorLog("解析失败:%v", err)
  40161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40162. return
  40163. }
  40164. if res.Infcode == 0 {
  40165. c.ServeSuccessJSON(map[string]interface{}{
  40166. "msg": "发起成功",
  40167. })
  40168. } else {
  40169. c.ServeSuccessJSON(map[string]interface{}{
  40170. "failed_code": -10,
  40171. "msg": res.ErrMsg,
  40172. })
  40173. }
  40174. }
  40175. }
  40176. func (c *HisApiController) Post8404() {
  40177. admin_user_id, _ := c.GetInt64("admin_user_id")
  40178. month := c.GetString("month")
  40179. adminUser := c.GetAdminUserInfo()
  40180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40181. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40182. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40183. var res ResultSix
  40184. if config.IsOpen == 1 {
  40185. data := make(map[string]interface{})
  40186. data["month"] = month
  40187. data["org_name"] = miConfig.OrgName
  40188. data["doctor"] = role.UserName
  40189. data["fixmedins_code"] = miConfig.Code
  40190. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40191. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40192. client := &http.Client{}
  40193. bytesData, _ := json.Marshal(data)
  40194. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40195. resp, _ := client.Do(req)
  40196. defer resp.Body.Close()
  40197. body, ioErr := ioutil.ReadAll(resp.Body)
  40198. if ioErr != nil {
  40199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40201. return
  40202. }
  40203. var respJSON map[string]interface{}
  40204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40207. return
  40208. }
  40209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40210. userJSONBytes, _ := json.Marshal(respJSON)
  40211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40212. utils.ErrorLog("解析失败:%v", err)
  40213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40214. return
  40215. }
  40216. if res.Infcode == 0 {
  40217. c.ServeSuccessJSON(map[string]interface{}{
  40218. "msg": "查询成功",
  40219. })
  40220. } else {
  40221. c.ServeSuccessJSON(map[string]interface{}{
  40222. "failed_code": -10,
  40223. "msg": res.ErrMsg,
  40224. })
  40225. }
  40226. }
  40227. }
  40228. func (c *HisApiController) Post3202b() {
  40229. start_time := c.GetString("start_time")
  40230. end_time := c.GetString("end_time")
  40231. //insutype := c.GetString("insutype")
  40232. clr_type := c.GetString("clr_type")
  40233. clr_org := c.GetString("clr_optins")
  40234. admin_user_id, _ := c.GetInt64("admin_user_id")
  40235. adminUser := c.GetAdminUserInfo()
  40236. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40237. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40238. if len(clr_org) == 0 {
  40239. clr_org = miConfig.MdtrtareaAdmvs
  40240. }
  40241. timeLayout := "2006-01-02"
  40242. loc, _ := time.LoadLocation("Local")
  40243. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40244. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40245. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40246. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40247. //fixmedins_setl_cnt := int64(len(orders))
  40248. var medfee_sumamt float64
  40249. var acct_pay float64
  40250. var fund_pay_sumamt float64
  40251. for _, item := range orders {
  40252. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40253. acct_pay = acct_pay + item.AcctPay
  40254. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40255. }
  40256. //var medfee_sumamt_two float64
  40257. //var acct_pay_two float64
  40258. //var fund_pay_sumamt_two float64
  40259. //for _, item := range orders_two {
  40260. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40261. // acct_pay_two = acct_pay_two + item.AcctPay
  40262. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40263. //}
  40264. //var user_name string
  40265. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40266. //if role.ID == 0 {
  40267. // user_name = "xxx"
  40268. //} else {
  40269. // user_name = role.UserName
  40270. //}
  40271. var res ResultSix
  40272. if config.IsOpen == 1 {
  40273. var bps []*models.BusinessParamsTwo
  40274. var bp models.BusinessParamsTwo
  40275. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40276. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40277. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40278. bp.MedfeeSumamt = medfee_sumamt_str
  40279. bp.AcctPay = acct_pay_str
  40280. bp.FundPaySumamt = fund_pay_sumamt_str
  40281. bp.Insutype = "390"
  40282. bp.StmtBegndate = start_time
  40283. bp.ClrType = clr_type
  40284. bp.SetlOptins = clr_org
  40285. bp.StmtEnddate = end_time
  40286. bps = append(bps, &bp)
  40287. data := make(map[string]interface{})
  40288. data["bps"] = bps
  40289. data["org_name"] = miConfig.OrgName
  40290. data["doctor"] = role.UserName
  40291. data["fixmedins_code"] = miConfig.Code
  40292. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40293. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40294. if miConfig.MdtrtareaAdmvs == "421300" {
  40295. client := &http.Client{}
  40296. bytesData, _ := json.Marshal(data)
  40297. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40298. resp, _ := client.Do(req)
  40299. defer resp.Body.Close()
  40300. body, ioErr := ioutil.ReadAll(resp.Body)
  40301. if ioErr != nil {
  40302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40304. return
  40305. }
  40306. var respJSON map[string]interface{}
  40307. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40310. return
  40311. }
  40312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40313. userJSONBytes, _ := json.Marshal(respJSON)
  40314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40315. utils.ErrorLog("解析失败:%v", err)
  40316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40317. return
  40318. }
  40319. }
  40320. if miConfig.MdtrtareaAdmvs == "420200" {
  40321. client := &http.Client{}
  40322. bytesData, _ := json.Marshal(data)
  40323. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40324. resp, _ := client.Do(req)
  40325. defer resp.Body.Close()
  40326. body, ioErr := ioutil.ReadAll(resp.Body)
  40327. if ioErr != nil {
  40328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40330. return
  40331. }
  40332. var respJSON map[string]interface{}
  40333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40336. return
  40337. }
  40338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40339. userJSONBytes, _ := json.Marshal(respJSON)
  40340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40341. utils.ErrorLog("解析失败:%v", err)
  40342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40343. return
  40344. }
  40345. }
  40346. if miConfig.MdtrtareaAdmvs == "421182" {
  40347. client := &http.Client{}
  40348. bytesData, _ := json.Marshal(data)
  40349. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40350. resp, _ := client.Do(req)
  40351. defer resp.Body.Close()
  40352. body, ioErr := ioutil.ReadAll(resp.Body)
  40353. if ioErr != nil {
  40354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40356. return
  40357. }
  40358. var respJSON map[string]interface{}
  40359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40362. return
  40363. }
  40364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40365. userJSONBytes, _ := json.Marshal(respJSON)
  40366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40367. utils.ErrorLog("解析失败:%v", err)
  40368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40369. return
  40370. }
  40371. }
  40372. if res.Infcode == 0 {
  40373. c.ServeSuccessJSON(map[string]interface{}{
  40374. "msg": "发起成功",
  40375. })
  40376. } else {
  40377. c.ServeSuccessJSON(map[string]interface{}{
  40378. "failed_code": -10,
  40379. "msg": res.ErrMsg,
  40380. })
  40381. }
  40382. }
  40383. }
  40384. func (c *HisApiController) Post1608() {
  40385. start_time := c.GetString("start_time")
  40386. end_time := c.GetString("end_time")
  40387. admin_user_id, _ := c.GetInt64("admin_user_id")
  40388. adminUser := c.GetAdminUserInfo()
  40389. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40390. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40391. timeLayout := "2006-01-02"
  40392. loc, _ := time.LoadLocation("Local")
  40393. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40394. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40395. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40396. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40397. fixmedins_setl_cnt := int64(len(orders))
  40398. var medfee_sumamt float64
  40399. var func_smamt float64
  40400. for _, item := range orders {
  40401. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40402. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40403. }
  40404. times := strings.Split(start_time, "-")
  40405. time_tows := strings.Split(end_time, "-")
  40406. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40407. var res ResultSix
  40408. if config.IsOpen == 1 {
  40409. //var bps []*models.BusinessParamsTwo
  40410. //var bp models.BusinessParamsTwo
  40411. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40412. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40413. data := make(map[string]interface{})
  40414. data["org_name"] = miConfig.OrgName
  40415. data["doctor"] = role.UserName
  40416. data["func_smamt"] = func_smamt_str
  40417. data["fixmedins_code"] = miConfig.Code
  40418. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40419. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40420. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40421. data["medfee_sumamt"] = medfee_sumamt_str
  40422. data["start_time"] = times[0] + times[1] + times[2]
  40423. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40424. if miConfig.MdtrtareaAdmvs == "421300" {
  40425. client := &http.Client{}
  40426. bytesData, _ := json.Marshal(data)
  40427. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40428. resp, _ := client.Do(req)
  40429. defer resp.Body.Close()
  40430. body, ioErr := ioutil.ReadAll(resp.Body)
  40431. if ioErr != nil {
  40432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40434. return
  40435. }
  40436. var respJSON map[string]interface{}
  40437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40440. return
  40441. }
  40442. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40443. userJSONBytes, _ := json.Marshal(respJSON)
  40444. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40445. utils.ErrorLog("解析失败:%v", err)
  40446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40447. return
  40448. }
  40449. }
  40450. if miConfig.MdtrtareaAdmvs == "420200" {
  40451. client := &http.Client{}
  40452. bytesData, _ := json.Marshal(data)
  40453. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40454. resp, _ := client.Do(req)
  40455. defer resp.Body.Close()
  40456. body, ioErr := ioutil.ReadAll(resp.Body)
  40457. if ioErr != nil {
  40458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40460. return
  40461. }
  40462. var respJSON map[string]interface{}
  40463. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40466. return
  40467. }
  40468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40469. userJSONBytes, _ := json.Marshal(respJSON)
  40470. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40471. utils.ErrorLog("解析失败:%v", err)
  40472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40473. return
  40474. }
  40475. }
  40476. if miConfig.MdtrtareaAdmvs == "421182" {
  40477. client := &http.Client{}
  40478. bytesData, _ := json.Marshal(data)
  40479. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40480. resp, _ := client.Do(req)
  40481. defer resp.Body.Close()
  40482. body, ioErr := ioutil.ReadAll(resp.Body)
  40483. if ioErr != nil {
  40484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40486. return
  40487. }
  40488. var respJSON map[string]interface{}
  40489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40492. return
  40493. }
  40494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40495. userJSONBytes, _ := json.Marshal(respJSON)
  40496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40497. utils.ErrorLog("解析失败:%v", err)
  40498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40499. return
  40500. }
  40501. }
  40502. if res.Infcode == 0 {
  40503. c.ServeSuccessJSON(map[string]interface{}{
  40504. "msg": "发起成功",
  40505. })
  40506. } else {
  40507. c.ServeSuccessJSON(map[string]interface{}{
  40508. "failed_code": -10,
  40509. "msg": res.ErrMsg,
  40510. })
  40511. }
  40512. }
  40513. }
  40514. // 5.11.1.1【5262】结算信息按时间段查询
  40515. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40516. admin_user_id, _ := c.GetInt64("admin_user_id")
  40517. adminUser := c.GetAdminUserInfo()
  40518. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40519. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40520. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40521. var res Result5262
  40522. if config.IsOpen == 1 {
  40523. if miConfig.MdtrtareaAdmvs == "421300" {
  40524. data := make(map[string]interface{})
  40525. data["bps"] = bp
  40526. data["org_name"] = miConfig.OrgName
  40527. data["doctor"] = role.UserName
  40528. data["fixmedins_code"] = miConfig.Code
  40529. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40530. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40531. data["page"] = strconv.FormatInt(page, 10)
  40532. data["limit"] = strconv.FormatInt(limit, 10)
  40533. fmt.Println(data)
  40534. client := &http.Client{}
  40535. bytesData, _ := json.Marshal(data)
  40536. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40537. resp, _ := client.Do(req)
  40538. defer resp.Body.Close()
  40539. body, ioErr := ioutil.ReadAll(resp.Body)
  40540. if ioErr != nil {
  40541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40543. return
  40544. }
  40545. var respJSON map[string]interface{}
  40546. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40549. return
  40550. }
  40551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40552. userJSONBytes, _ := json.Marshal(respJSON)
  40553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40554. utils.ErrorLog("解析失败:%v", err)
  40555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40556. return
  40557. }
  40558. }
  40559. if miConfig.MdtrtareaAdmvs == "420200" {
  40560. data := make(map[string]interface{})
  40561. data["bps"] = bp
  40562. data["org_name"] = miConfig.OrgName
  40563. data["doctor"] = role.UserName
  40564. data["fixmedins_code"] = miConfig.Code
  40565. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40566. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40567. data["page"] = strconv.FormatInt(page, 10)
  40568. data["limit"] = strconv.FormatInt(limit, 10)
  40569. fmt.Println(data)
  40570. client := &http.Client{}
  40571. bytesData, _ := json.Marshal(data)
  40572. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40573. resp, _ := client.Do(req)
  40574. defer resp.Body.Close()
  40575. body, ioErr := ioutil.ReadAll(resp.Body)
  40576. if ioErr != nil {
  40577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40579. return
  40580. }
  40581. var respJSON map[string]interface{}
  40582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40585. return
  40586. }
  40587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40588. userJSONBytes, _ := json.Marshal(respJSON)
  40589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40590. utils.ErrorLog("解析失败:%v", err)
  40591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40592. return
  40593. }
  40594. }
  40595. if miConfig.MdtrtareaAdmvs == "421182" {
  40596. data := make(map[string]interface{})
  40597. data["bps"] = bp
  40598. data["org_name"] = miConfig.OrgName
  40599. data["doctor"] = role.UserName
  40600. data["fixmedins_code"] = miConfig.Code
  40601. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40602. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40603. data["page"] = strconv.FormatInt(page, 10)
  40604. data["limit"] = strconv.FormatInt(limit, 10)
  40605. fmt.Println(data)
  40606. client := &http.Client{}
  40607. bytesData, _ := json.Marshal(data)
  40608. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40609. resp, _ := client.Do(req)
  40610. defer resp.Body.Close()
  40611. body, ioErr := ioutil.ReadAll(resp.Body)
  40612. if ioErr != nil {
  40613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40615. return
  40616. }
  40617. var respJSON map[string]interface{}
  40618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40621. return
  40622. }
  40623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40624. userJSONBytes, _ := json.Marshal(respJSON)
  40625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40626. utils.ErrorLog("解析失败:%v", err)
  40627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40628. return
  40629. }
  40630. }
  40631. if miConfig.MdtrtareaAdmvs == "420902" {
  40632. data := make(map[string]interface{})
  40633. data["bps"] = bp
  40634. data["org_name"] = miConfig.OrgName
  40635. data["doctor"] = role.UserName
  40636. data["fixmedins_code"] = miConfig.Code
  40637. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40639. data["page"] = strconv.FormatInt(page, 10)
  40640. data["limit"] = strconv.FormatInt(limit, 10)
  40641. fmt.Println(data)
  40642. client := &http.Client{}
  40643. bytesData, _ := json.Marshal(data)
  40644. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40645. resp, _ := client.Do(req)
  40646. defer resp.Body.Close()
  40647. body, ioErr := ioutil.ReadAll(resp.Body)
  40648. if ioErr != nil {
  40649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40651. return
  40652. }
  40653. var respJSON map[string]interface{}
  40654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40657. return
  40658. }
  40659. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40660. userJSONBytes, _ := json.Marshal(respJSON)
  40661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40662. utils.ErrorLog("解析失败:%v", err)
  40663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40664. return
  40665. }
  40666. }
  40667. if res.Infcode == 0 {
  40668. c.ServeSuccessJSON(map[string]interface{}{
  40669. "order": res.Output.Result,
  40670. "total": res.Output.PageInfo.RecordCounts,
  40671. })
  40672. } else {
  40673. c.ServeSuccessJSON(map[string]interface{}{
  40674. "failed_code": -10,
  40675. "msg": res.ErrMsg,
  40676. })
  40677. }
  40678. }
  40679. }
  40680. // 5.11.1.2【5267】异地结算信息时间段查询
  40681. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40682. admin_user_id, _ := c.GetInt64("admin_user_id")
  40683. adminUser := c.GetAdminUserInfo()
  40684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40686. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40687. var res Result5267
  40688. if config.IsOpen == 1 {
  40689. if miConfig.MdtrtareaAdmvs == "421300" {
  40690. data := make(map[string]interface{})
  40691. data["bps"] = bp
  40692. data["org_name"] = miConfig.OrgName
  40693. data["doctor"] = role.UserName
  40694. data["fixmedins_code"] = miConfig.Code
  40695. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40697. data["page"] = page
  40698. data["limit"] = limit
  40699. fmt.Println(data)
  40700. client := &http.Client{}
  40701. bytesData, _ := json.Marshal(data)
  40702. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40703. resp, _ := client.Do(req)
  40704. defer resp.Body.Close()
  40705. body, ioErr := ioutil.ReadAll(resp.Body)
  40706. if ioErr != nil {
  40707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40709. return
  40710. }
  40711. var respJSON map[string]interface{}
  40712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40715. return
  40716. }
  40717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40718. userJSONBytes, _ := json.Marshal(respJSON)
  40719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40720. utils.ErrorLog("解析失败:%v", err)
  40721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40722. return
  40723. }
  40724. }
  40725. if miConfig.MdtrtareaAdmvs == "420200" {
  40726. data := make(map[string]interface{})
  40727. data["bps"] = bp
  40728. data["org_name"] = miConfig.OrgName
  40729. data["doctor"] = role.UserName
  40730. data["fixmedins_code"] = miConfig.Code
  40731. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40732. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40733. data["page"] = page
  40734. data["limit"] = limit
  40735. fmt.Println(data)
  40736. client := &http.Client{}
  40737. bytesData, _ := json.Marshal(data)
  40738. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40739. resp, _ := client.Do(req)
  40740. defer resp.Body.Close()
  40741. body, ioErr := ioutil.ReadAll(resp.Body)
  40742. if ioErr != nil {
  40743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40745. return
  40746. }
  40747. var respJSON map[string]interface{}
  40748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40751. return
  40752. }
  40753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40754. userJSONBytes, _ := json.Marshal(respJSON)
  40755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40756. utils.ErrorLog("解析失败:%v", err)
  40757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40758. return
  40759. }
  40760. }
  40761. if miConfig.MdtrtareaAdmvs == "421182" {
  40762. data := make(map[string]interface{})
  40763. data["bps"] = bp
  40764. data["org_name"] = miConfig.OrgName
  40765. data["doctor"] = role.UserName
  40766. data["fixmedins_code"] = miConfig.Code
  40767. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40768. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40769. data["page"] = page
  40770. data["limit"] = limit
  40771. fmt.Println(data)
  40772. client := &http.Client{}
  40773. bytesData, _ := json.Marshal(data)
  40774. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40775. resp, _ := client.Do(req)
  40776. defer resp.Body.Close()
  40777. body, ioErr := ioutil.ReadAll(resp.Body)
  40778. if ioErr != nil {
  40779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40781. return
  40782. }
  40783. var respJSON map[string]interface{}
  40784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40787. return
  40788. }
  40789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40790. userJSONBytes, _ := json.Marshal(respJSON)
  40791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40792. utils.ErrorLog("解析失败:%v", err)
  40793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40794. return
  40795. }
  40796. }
  40797. if res.Infcode == 0 {
  40798. c.ServeSuccessJSON(map[string]interface{}{
  40799. "order": res.Output.Result,
  40800. "total": res.Output.PageInfo.RecordCounts,
  40801. })
  40802. } else {
  40803. c.ServeSuccessJSON(map[string]interface{}{
  40804. "failed_code": -10,
  40805. "msg": res.ErrMsg,
  40806. })
  40807. }
  40808. }
  40809. }
  40810. func (c *HisApiController) Post3501() {
  40811. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40812. data := make(map[string]interface{})
  40813. var struct3501s []models.Struct3501
  40814. var struct3501 models.Struct3501
  40815. struct3501.OrgName = miConfig.OrgName
  40816. struct3501.AccessKey = miConfig.AccessKey
  40817. struct3501.RequestUrl = miConfig.Url
  40818. struct3501.SecretKey = miConfig.SecretKey
  40819. struct3501.ManuDate = "2022-08-17"
  40820. struct3501.FixmedinsBchno = ""
  40821. struct3501.ManuLotnum = ""
  40822. struct3501.RxFlag = "0"
  40823. struct3501.ExpyEnd = "2022-08-17"
  40824. struct3501.Invdate = "2022-08-17"
  40825. struct3501.InvCnt = "20.25"
  40826. struct3501.Memo = ""
  40827. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40828. struct3501.FixmedinsHilistId = miConfig.Code
  40829. struct3501.FixmedinsHilistName = miConfig.OrgName
  40830. struct3501s = append(struct3501s, struct3501)
  40831. data["struct_3501s"] = struct3501s
  40832. client := &http.Client{}
  40833. bytesData, _ := json.Marshal(data)
  40834. var req *http.Request
  40835. if miConfig.MdtrtareaAdmvs == "320830" {
  40836. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40837. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40838. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40839. } else {
  40840. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40841. }
  40842. resp, _ := client.Do(req)
  40843. defer resp.Body.Close()
  40844. body, ioErr := ioutil.ReadAll(resp.Body)
  40845. if ioErr != nil {
  40846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40848. return
  40849. }
  40850. var respJSON map[string]interface{}
  40851. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40854. return
  40855. }
  40856. var res ResultSix
  40857. var resSix10265 ResultSix10265 //1101结果
  40858. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40859. result, _ := json.Marshal(respJSON)
  40860. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40861. utils.ErrorLog("解析失败:%v", err)
  40862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40863. return
  40864. }
  40865. res.InfRefmsgid = resSix10265.InfRefmsgid
  40866. res.Output = resSix10265.Output
  40867. res.ErrMsg = resSix10265.ErrMsg
  40868. res.Cainfo = resSix10265.Cainfo
  40869. res.WarnMsg = resSix10265.WarnMsg
  40870. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40871. res.Infcode = infocode
  40872. if infocode == 0 {
  40873. c.ServeSuccessJSON(map[string]interface{}{
  40874. "msg": "上传成功",
  40875. })
  40876. return
  40877. } else {
  40878. c.ServeSuccessJSON(map[string]interface{}{
  40879. "failed_code": -10,
  40880. "msg": res.ErrMsg,
  40881. })
  40882. return
  40883. }
  40884. }
  40885. func (c *HisApiController) Post3502() {
  40886. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40887. data := make(map[string]interface{})
  40888. var struct3502s []models.Struct3502
  40889. var struct3502 models.Struct3502
  40890. struct3502.OrgName = miConfig.OrgName
  40891. struct3502.AccessKey = miConfig.AccessKey
  40892. struct3502.RequestUrl = miConfig.Url
  40893. struct3502.SecretKey = miConfig.SecretKey
  40894. struct3502.ManuDate = "2022-08-15"
  40895. struct3502.FixmedinsBchno = ""
  40896. struct3502.ManuLotnum = ""
  40897. struct3502.RxFlag = "0"
  40898. struct3502.ExpyEnd = "2022-08-15"
  40899. struct3502.Invdate = "2022-08-15"
  40900. struct3502.InvCnt = "20.25"
  40901. struct3502.Memo = ""
  40902. struct3502.MedListCodg = "XB01ABD056B002020200517"
  40903. struct3502.FixmedinsHilistId = miConfig.Code
  40904. struct3502.FixmedinsHilistName = miConfig.OrgName
  40905. struct3502s = append(struct3502s, struct3502)
  40906. data["struct_3502s"] = struct3502s
  40907. client := &http.Client{}
  40908. bytesData, _ := json.Marshal(data)
  40909. var req *http.Request
  40910. if miConfig.MdtrtareaAdmvs == "320830" {
  40911. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40912. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40913. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40914. } else {
  40915. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40916. }
  40917. resp, _ := client.Do(req)
  40918. defer resp.Body.Close()
  40919. body, ioErr := ioutil.ReadAll(resp.Body)
  40920. if ioErr != nil {
  40921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40923. return
  40924. }
  40925. var respJSON map[string]interface{}
  40926. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40929. return
  40930. }
  40931. var res ResultSix
  40932. var resSix10265 ResultSix10265 //1101结果
  40933. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40934. result, _ := json.Marshal(respJSON)
  40935. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40936. utils.ErrorLog("解析失败:%v", err)
  40937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40938. return
  40939. }
  40940. res.InfRefmsgid = resSix10265.InfRefmsgid
  40941. res.Output = resSix10265.Output
  40942. res.ErrMsg = resSix10265.ErrMsg
  40943. res.Cainfo = resSix10265.Cainfo
  40944. res.WarnMsg = resSix10265.WarnMsg
  40945. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40946. res.Infcode = infocode
  40947. if infocode == 0 {
  40948. c.ServeSuccessJSON(map[string]interface{}{
  40949. "msg": "上传成功",
  40950. })
  40951. return
  40952. } else {
  40953. c.ServeSuccessJSON(map[string]interface{}{
  40954. "failed_code": -10,
  40955. "msg": res.ErrMsg,
  40956. })
  40957. return
  40958. }
  40959. }
  40960. func (c *HisApiController) Post3503() {
  40961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40962. data := make(map[string]interface{})
  40963. var struct3501s []models.Struct3501
  40964. var struct3501 models.Struct3501
  40965. struct3501.OrgName = miConfig.OrgName
  40966. struct3501.AccessKey = miConfig.AccessKey
  40967. struct3501.RequestUrl = miConfig.Url
  40968. struct3501.SecretKey = miConfig.SecretKey
  40969. struct3501.ManuDate = "2022-08-15"
  40970. struct3501.FixmedinsBchno = ""
  40971. struct3501.ManuLotnum = ""
  40972. struct3501.RxFlag = "0"
  40973. struct3501.ExpyEnd = "2022-08-15"
  40974. struct3501.Invdate = "2022-08-15"
  40975. struct3501.InvCnt = "20.25"
  40976. struct3501.Memo = ""
  40977. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40978. struct3501.FixmedinsHilistId = miConfig.Code
  40979. struct3501.FixmedinsHilistName = miConfig.OrgName
  40980. struct3501s = append(struct3501s, struct3501)
  40981. data["struct_3501s"] = struct3501s
  40982. client := &http.Client{}
  40983. bytesData, _ := json.Marshal(data)
  40984. var req *http.Request
  40985. if miConfig.MdtrtareaAdmvs == "320921" {
  40986. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40987. } else {
  40988. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40989. }
  40990. resp, _ := client.Do(req)
  40991. defer resp.Body.Close()
  40992. body, ioErr := ioutil.ReadAll(resp.Body)
  40993. if ioErr != nil {
  40994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40996. return
  40997. }
  40998. var respJSON map[string]interface{}
  40999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41002. return
  41003. }
  41004. var res ResultSix
  41005. var resSix10265 ResultSix10265 //1101结果
  41006. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41007. result, _ := json.Marshal(respJSON)
  41008. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41009. utils.ErrorLog("解析失败:%v", err)
  41010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41011. return
  41012. }
  41013. res.InfRefmsgid = resSix10265.InfRefmsgid
  41014. res.Output = resSix10265.Output
  41015. res.ErrMsg = resSix10265.ErrMsg
  41016. res.Cainfo = resSix10265.Cainfo
  41017. res.WarnMsg = resSix10265.WarnMsg
  41018. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41019. res.Infcode = infocode
  41020. if infocode == 0 {
  41021. c.ServeSuccessJSON(map[string]interface{}{
  41022. "msg": "上传成功",
  41023. })
  41024. return
  41025. } else {
  41026. c.ServeSuccessJSON(map[string]interface{}{
  41027. "failed_code": -10,
  41028. "msg": res.ErrMsg,
  41029. })
  41030. return
  41031. }
  41032. }
  41033. func (c *HisApiController) Post3504() {
  41034. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41035. data := make(map[string]interface{})
  41036. var struct3501s []models.Struct3501
  41037. var struct3501 models.Struct3501
  41038. struct3501.OrgName = miConfig.OrgName
  41039. struct3501.AccessKey = miConfig.AccessKey
  41040. struct3501.RequestUrl = miConfig.Url
  41041. struct3501.SecretKey = miConfig.SecretKey
  41042. struct3501.ManuDate = "2022-08-15"
  41043. struct3501.FixmedinsBchno = ""
  41044. struct3501.ManuLotnum = ""
  41045. struct3501.RxFlag = "0"
  41046. struct3501.ExpyEnd = "2022-08-15"
  41047. struct3501.Invdate = "2022-08-15"
  41048. struct3501.InvCnt = "20.25"
  41049. struct3501.Memo = ""
  41050. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41051. struct3501.FixmedinsHilistId = miConfig.Code
  41052. struct3501.FixmedinsHilistName = miConfig.OrgName
  41053. struct3501s = append(struct3501s, struct3501)
  41054. data["struct_3501s"] = struct3501s
  41055. client := &http.Client{}
  41056. bytesData, _ := json.Marshal(data)
  41057. var req *http.Request
  41058. if miConfig.MdtrtareaAdmvs == "320921" {
  41059. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41060. } else {
  41061. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41062. }
  41063. resp, _ := client.Do(req)
  41064. defer resp.Body.Close()
  41065. body, ioErr := ioutil.ReadAll(resp.Body)
  41066. if ioErr != nil {
  41067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41069. return
  41070. }
  41071. var respJSON map[string]interface{}
  41072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41075. return
  41076. }
  41077. var res ResultSix
  41078. var resSix10265 ResultSix10265 //1101结果
  41079. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41080. result, _ := json.Marshal(respJSON)
  41081. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41082. utils.ErrorLog("解析失败:%v", err)
  41083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41084. return
  41085. }
  41086. res.InfRefmsgid = resSix10265.InfRefmsgid
  41087. res.Output = resSix10265.Output
  41088. res.ErrMsg = resSix10265.ErrMsg
  41089. res.Cainfo = resSix10265.Cainfo
  41090. res.WarnMsg = resSix10265.WarnMsg
  41091. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41092. res.Infcode = infocode
  41093. if infocode == 0 {
  41094. c.ServeSuccessJSON(map[string]interface{}{
  41095. "msg": "上传成功",
  41096. })
  41097. return
  41098. } else {
  41099. c.ServeSuccessJSON(map[string]interface{}{
  41100. "failed_code": -10,
  41101. "msg": res.ErrMsg,
  41102. })
  41103. return
  41104. }
  41105. }
  41106. func (c *HisApiController) Post3505() {
  41107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41108. data := make(map[string]interface{})
  41109. var struct3501s []models.Struct3501
  41110. var struct3501 models.Struct3501
  41111. struct3501.OrgName = miConfig.OrgName
  41112. struct3501.AccessKey = miConfig.AccessKey
  41113. struct3501.RequestUrl = miConfig.Url
  41114. struct3501.SecretKey = miConfig.SecretKey
  41115. struct3501.ManuDate = "2022-08-15"
  41116. struct3501.FixmedinsBchno = ""
  41117. struct3501.ManuLotnum = ""
  41118. struct3501.RxFlag = "0"
  41119. struct3501.ExpyEnd = "2022-08-15"
  41120. struct3501.Invdate = "2022-08-15"
  41121. struct3501.InvCnt = "20.25"
  41122. struct3501.Memo = ""
  41123. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41124. struct3501.FixmedinsHilistId = miConfig.Code
  41125. struct3501.FixmedinsHilistName = miConfig.OrgName
  41126. struct3501s = append(struct3501s, struct3501)
  41127. data["struct_3501s"] = struct3501s
  41128. client := &http.Client{}
  41129. bytesData, _ := json.Marshal(data)
  41130. var req *http.Request
  41131. if miConfig.MdtrtareaAdmvs == "320921" {
  41132. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41133. } else {
  41134. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41135. }
  41136. resp, _ := client.Do(req)
  41137. defer resp.Body.Close()
  41138. body, ioErr := ioutil.ReadAll(resp.Body)
  41139. if ioErr != nil {
  41140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41142. return
  41143. }
  41144. var respJSON map[string]interface{}
  41145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41148. return
  41149. }
  41150. var res ResultSix
  41151. var resSix10265 ResultSix10265 //1101结果
  41152. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41153. result, _ := json.Marshal(respJSON)
  41154. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41155. utils.ErrorLog("解析失败:%v", err)
  41156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41157. return
  41158. }
  41159. res.InfRefmsgid = resSix10265.InfRefmsgid
  41160. res.Output = resSix10265.Output
  41161. res.ErrMsg = resSix10265.ErrMsg
  41162. res.Cainfo = resSix10265.Cainfo
  41163. res.WarnMsg = resSix10265.WarnMsg
  41164. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41165. res.Infcode = infocode
  41166. if infocode == 0 {
  41167. c.ServeSuccessJSON(map[string]interface{}{
  41168. "msg": "上传成功",
  41169. })
  41170. return
  41171. } else {
  41172. c.ServeSuccessJSON(map[string]interface{}{
  41173. "failed_code": -10,
  41174. "msg": res.ErrMsg,
  41175. })
  41176. return
  41177. }
  41178. }
  41179. func (c *HisApiController) Post3506() {
  41180. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41181. data := make(map[string]interface{})
  41182. var struct3501s []models.Struct3501
  41183. var struct3501 models.Struct3501
  41184. struct3501.OrgName = miConfig.OrgName
  41185. struct3501.AccessKey = miConfig.AccessKey
  41186. struct3501.RequestUrl = miConfig.Url
  41187. struct3501.SecretKey = miConfig.SecretKey
  41188. struct3501.ManuDate = "2022-08-15"
  41189. struct3501.FixmedinsBchno = ""
  41190. struct3501.ManuLotnum = ""
  41191. struct3501.RxFlag = "0"
  41192. struct3501.ExpyEnd = "2022-08-15"
  41193. struct3501.Invdate = "2022-08-15"
  41194. struct3501.InvCnt = "20.25"
  41195. struct3501.Memo = ""
  41196. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41197. struct3501.FixmedinsHilistId = miConfig.Code
  41198. struct3501.FixmedinsHilistName = miConfig.OrgName
  41199. struct3501s = append(struct3501s, struct3501)
  41200. data["struct_3501s"] = struct3501s
  41201. client := &http.Client{}
  41202. bytesData, _ := json.Marshal(data)
  41203. var req *http.Request
  41204. if miConfig.MdtrtareaAdmvs == "320921" {
  41205. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41206. } else {
  41207. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41208. }
  41209. resp, _ := client.Do(req)
  41210. defer resp.Body.Close()
  41211. body, ioErr := ioutil.ReadAll(resp.Body)
  41212. if ioErr != nil {
  41213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41215. return
  41216. }
  41217. var respJSON map[string]interface{}
  41218. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41221. return
  41222. }
  41223. var res ResultSix
  41224. var resSix10265 ResultSix10265 //1101结果
  41225. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41226. result, _ := json.Marshal(respJSON)
  41227. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41228. utils.ErrorLog("解析失败:%v", err)
  41229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41230. return
  41231. }
  41232. res.InfRefmsgid = resSix10265.InfRefmsgid
  41233. res.Output = resSix10265.Output
  41234. res.ErrMsg = resSix10265.ErrMsg
  41235. res.Cainfo = resSix10265.Cainfo
  41236. res.WarnMsg = resSix10265.WarnMsg
  41237. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41238. res.Infcode = infocode
  41239. if infocode == 0 {
  41240. c.ServeSuccessJSON(map[string]interface{}{
  41241. "msg": "上传成功",
  41242. })
  41243. return
  41244. } else {
  41245. c.ServeSuccessJSON(map[string]interface{}{
  41246. "failed_code": -10,
  41247. "msg": res.ErrMsg,
  41248. })
  41249. return
  41250. }
  41251. }
  41252. func (c *HisApiController) Post3507() {
  41253. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41254. data := make(map[string]interface{})
  41255. var struct3501s []models.Struct3501
  41256. var struct3501 models.Struct3501
  41257. struct3501.OrgName = miConfig.OrgName
  41258. struct3501.AccessKey = miConfig.AccessKey
  41259. struct3501.RequestUrl = miConfig.Url
  41260. struct3501.SecretKey = miConfig.SecretKey
  41261. struct3501.ManuDate = "2022-08-15"
  41262. struct3501.FixmedinsBchno = ""
  41263. struct3501.ManuLotnum = ""
  41264. struct3501.RxFlag = "0"
  41265. struct3501.ExpyEnd = "2022-08-15"
  41266. struct3501.Invdate = "2022-08-15"
  41267. struct3501.InvCnt = "20.25"
  41268. struct3501.Memo = ""
  41269. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41270. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41271. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41272. struct3501s = append(struct3501s, struct3501)
  41273. data["struct_3501s"] = struct3501s
  41274. client := &http.Client{}
  41275. bytesData, _ := json.Marshal(data)
  41276. var req *http.Request
  41277. if miConfig.MdtrtareaAdmvs == "320921" {
  41278. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41279. } else {
  41280. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41281. }
  41282. resp, _ := client.Do(req)
  41283. defer resp.Body.Close()
  41284. body, ioErr := ioutil.ReadAll(resp.Body)
  41285. if ioErr != nil {
  41286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41288. return
  41289. }
  41290. var respJSON map[string]interface{}
  41291. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41294. return
  41295. }
  41296. var res ResultSix
  41297. var resSix10265 ResultSix10265 //1101结果
  41298. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41299. result, _ := json.Marshal(respJSON)
  41300. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41301. utils.ErrorLog("解析失败:%v", err)
  41302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41303. return
  41304. }
  41305. res.InfRefmsgid = resSix10265.InfRefmsgid
  41306. res.Output = resSix10265.Output
  41307. res.ErrMsg = resSix10265.ErrMsg
  41308. res.Cainfo = resSix10265.Cainfo
  41309. res.WarnMsg = resSix10265.WarnMsg
  41310. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41311. res.Infcode = infocode
  41312. if infocode == 0 {
  41313. c.ServeSuccessJSON(map[string]interface{}{
  41314. "msg": "上传成功",
  41315. })
  41316. return
  41317. } else {
  41318. c.ServeSuccessJSON(map[string]interface{}{
  41319. "failed_code": -10,
  41320. "msg": res.ErrMsg,
  41321. })
  41322. return
  41323. }
  41324. }
  41325. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41326. // WebSocket服务器地址
  41327. serverURL := "ws://127.0.0.1:8899"
  41328. // 解析WebSocket服务器地址
  41329. u, err := url.Parse(serverURL)
  41330. if err != nil {
  41331. }
  41332. // 建立WebSocket连接
  41333. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41334. if err != nil {
  41335. }
  41336. defer conn.Close()
  41337. input2 := make(map[string]interface{})
  41338. input := make(map[string]interface{})
  41339. inputData := make(map[string]interface{})
  41340. inputData["orgId"] = code
  41341. inputData["businessType"] = "01101"
  41342. inputData["operatorId"] = operator_id
  41343. inputData["operatorName"] = operator_name
  41344. inputData["officeId"] = "001"
  41345. inputData["officeName"] = "血透室"
  41346. inputData["deviceType"] = ""
  41347. input["data"] = inputData
  41348. input["orgId"] = code
  41349. input["transType"] = "ec.query"
  41350. //if md == ""
  41351. if md[:4] == "4403" {
  41352. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41353. } else if md[:4] == "4401" {
  41354. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41355. } else {
  41356. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41357. }
  41358. input2["indata"] = input
  41359. fmt.Println(input2)
  41360. bytesData, _ := json.Marshal(input2)
  41361. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41362. if err != nil {
  41363. fmt.Println(err)
  41364. }
  41365. // 接收消息
  41366. _, receivedMessage, err := conn.ReadMessage()
  41367. if err != nil {
  41368. fmt.Println(err)
  41369. }
  41370. return "", string(receivedMessage)
  41371. }
  41372. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41373. // WebSocket服务器地址
  41374. serverURL := "ws://127.0.0.1:8899"
  41375. // 解析WebSocket服务器地址
  41376. u, err := url.Parse(serverURL)
  41377. if err != nil {
  41378. }
  41379. // 建立WebSocket连接
  41380. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41381. if err != nil {
  41382. }
  41383. defer conn.Close()
  41384. input2 := make(map[string]interface{})
  41385. input := make(map[string]interface{})
  41386. inputData := make(map[string]interface{})
  41387. inputData["orgId"] = code
  41388. inputData["businessType"] = "01101"
  41389. inputData["operatorId"] = operator_id
  41390. inputData["operatorName"] = operator_name
  41391. inputData["officeId"] = "001"
  41392. inputData["officeName"] = "血透室"
  41393. inputData["deviceType"] = ""
  41394. input["data"] = inputData
  41395. input["orgId"] = code
  41396. input["transType"] = "ec.query"
  41397. //if md == ""
  41398. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41399. input2["indata"] = input
  41400. fmt.Println(input2)
  41401. bytesData, _ := json.Marshal(input2)
  41402. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41403. if err != nil {
  41404. fmt.Println(err)
  41405. }
  41406. // 接收消息
  41407. _, receivedMessage, err := conn.ReadMessage()
  41408. if err != nil {
  41409. fmt.Println(err)
  41410. }
  41411. return "", string(receivedMessage)
  41412. }
  41413. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41414. // WebSocket服务器地址
  41415. serverURL := "ws://127.0.0.1:8899"
  41416. // 解析WebSocket服务器地址
  41417. u, err := url.Parse(serverURL)
  41418. if err != nil {
  41419. }
  41420. // 建立WebSocket连接
  41421. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41422. if err != nil {
  41423. }
  41424. defer conn.Close()
  41425. input2 := make(map[string]interface{})
  41426. input := make(map[string]interface{})
  41427. inputData := make(map[string]interface{})
  41428. inputData["orgId"] = code
  41429. inputData["businessType"] = "01301"
  41430. inputData["operatorId"] = operator_id
  41431. inputData["operatorName"] = operator_name
  41432. inputData["officeId"] = "001"
  41433. inputData["officeName"] = "血透室"
  41434. inputData["deviceType"] = ""
  41435. input["data"] = inputData
  41436. input["orgId"] = code
  41437. input["transType"] = "ec.query"
  41438. //if md == ""
  41439. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41440. input2["indata"] = input
  41441. fmt.Println(input2)
  41442. bytesData, _ := json.Marshal(input2)
  41443. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41444. if err != nil {
  41445. fmt.Println(err)
  41446. }
  41447. // 接收消息
  41448. _, receivedMessage, err := conn.ReadMessage()
  41449. if err != nil {
  41450. fmt.Println(err)
  41451. }
  41452. return "", string(receivedMessage)
  41453. }
  41454. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41455. // WebSocket服务器地址
  41456. serverURL := "ws://127.0.0.1:8899"
  41457. // 解析WebSocket服务器地址
  41458. u, err := url.Parse(serverURL)
  41459. if err != nil {
  41460. }
  41461. // 建立WebSocket连接
  41462. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41463. if err != nil {
  41464. }
  41465. defer conn.Close()
  41466. input2 := make(map[string]interface{})
  41467. input := make(map[string]interface{})
  41468. inputData := make(map[string]interface{})
  41469. inputData["orgId"] = code
  41470. inputData["businessType"] = "01103"
  41471. inputData["operatorId"] = operator_id
  41472. inputData["operatorName"] = operator_name
  41473. inputData["officeId"] = "001"
  41474. inputData["officeName"] = "血透室"
  41475. inputData["deviceType"] = ""
  41476. input["data"] = inputData
  41477. input["orgId"] = code
  41478. input["transType"] = "ec.query"
  41479. //if md ==
  41480. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41481. input2["indata"] = input
  41482. fmt.Println(input2)
  41483. bytesData, _ := json.Marshal(input2)
  41484. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41485. if err != nil {
  41486. fmt.Println(err)
  41487. }
  41488. // 接收消息
  41489. _, receivedMessage, err := conn.ReadMessage()
  41490. if err != nil {
  41491. fmt.Println(err)
  41492. }
  41493. return "", string(receivedMessage)
  41494. }
  41495. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41496. // WebSocket服务器地址
  41497. serverURL := "ws://127.0.0.1:8899"
  41498. // 解析WebSocket服务器地址
  41499. u, err := url.Parse(serverURL)
  41500. if err != nil {
  41501. }
  41502. // 建立WebSocket连接
  41503. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41504. if err != nil {
  41505. }
  41506. defer conn.Close()
  41507. input2 := make(map[string]interface{})
  41508. input := make(map[string]interface{})
  41509. inputData := make(map[string]interface{})
  41510. inputData["orgId"] = code
  41511. inputData["businessType"] = "01101"
  41512. inputData["operatorId"] = operator_id
  41513. inputData["operatorName"] = operator_name
  41514. inputData["officeId"] = "001"
  41515. inputData["officeName"] = "血透室"
  41516. inputData["deviceType"] = ""
  41517. input["data"] = inputData
  41518. input["orgId"] = code
  41519. input["transType"] = "ec.query"
  41520. //if md == ""
  41521. if md[:4] == "4403" {
  41522. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41523. } else if md[:4] == "4401" {
  41524. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41525. } else {
  41526. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41527. }
  41528. input2["indata"] = input
  41529. fmt.Println(input2)
  41530. bytesData, _ := json.Marshal(input2)
  41531. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41532. if err != nil {
  41533. fmt.Println(err)
  41534. }
  41535. // 接收消息
  41536. _, receivedMessage, err := conn.ReadMessage()
  41537. if err != nil {
  41538. fmt.Println(err)
  41539. }
  41540. return "", string(receivedMessage)
  41541. }
  41542. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41543. // WebSocket服务器地址
  41544. serverURL := "ws://127.0.0.1:8899"
  41545. // 解析WebSocket服务器地址
  41546. u, err := url.Parse(serverURL)
  41547. if err != nil {
  41548. }
  41549. // 建立WebSocket连接
  41550. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41551. if err != nil {
  41552. }
  41553. defer conn.Close()
  41554. input2 := make(map[string]interface{})
  41555. input := make(map[string]interface{})
  41556. inputData := make(map[string]interface{})
  41557. inputData["orgId"] = code
  41558. inputData["businessType"] = "01301"
  41559. inputData["operatorId"] = operator_id
  41560. inputData["operatorName"] = operator_name
  41561. inputData["officeId"] = "001"
  41562. inputData["officeName"] = "血透室"
  41563. inputData["deviceType"] = ""
  41564. input["data"] = inputData
  41565. input["orgId"] = code
  41566. input["transType"] = "ec.query"
  41567. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41568. input2["indata"] = input
  41569. bytesData, _ := json.Marshal(input2)
  41570. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41571. if err != nil {
  41572. fmt.Println(err)
  41573. }
  41574. // 接收消息
  41575. _, receivedMessage, err := conn.ReadMessage()
  41576. if err != nil {
  41577. fmt.Println(err)
  41578. }
  41579. return "", string(receivedMessage)
  41580. }
  41581. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41582. newArr = make([]string, 0)
  41583. for i := 0; i < len(arr); i++ {
  41584. repeat := false
  41585. for j := i + 1; j < len(arr); j++ {
  41586. if arr[i] == arr[j] {
  41587. repeat = true
  41588. break
  41589. }
  41590. }
  41591. if !repeat {
  41592. newArr = append(newArr, arr[i])
  41593. }
  41594. }
  41595. return
  41596. }
  41597. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41598. if len(idNumber) != 18 {
  41599. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41600. }
  41601. // 提取出生日期
  41602. year, err := strconv.Atoi(idNumber[6:10])
  41603. if err != nil {
  41604. return "", 0, err
  41605. }
  41606. month, err := strconv.Atoi(idNumber[10:12])
  41607. if err != nil {
  41608. return "", 0, err
  41609. }
  41610. day, err := strconv.Atoi(idNumber[12:14])
  41611. if err != nil {
  41612. return "", 0, err
  41613. }
  41614. // 格式化生日字符串
  41615. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41616. birthdateFormatted := birthdate.Format("2006-01-02")
  41617. // 计算年龄
  41618. today := time.Now()
  41619. age := today.Year() - birthdate.Year()
  41620. if today.YearDay() < birthdate.YearDay() {
  41621. age--
  41622. }
  41623. return birthdateFormatted, age, nil
  41624. }
  41625. // 从身份证号码中提取出生年月日
  41626. func getBirthDateFromIDCard(idCard string) (string, error) {
  41627. // 身份证号码长度应为18位
  41628. if len(idCard) != 18 {
  41629. return "", fmt.Errorf("身份证号码长度应为18位")
  41630. }
  41631. // 提取出生日期部分 (YYYYMMDD)
  41632. birthDateStr := idCard[6:14]
  41633. // 解析出生日期
  41634. birthDate, err := time.Parse("20060102", birthDateStr)
  41635. if err != nil {
  41636. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41637. }
  41638. // 格式化出生日期为 YYYY-MM-DD
  41639. formattedDate := birthDate.Format("2006-01-02")
  41640. return formattedDate, nil
  41641. }