his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. "strings"
  10. //"crypto/x509/pkix"
  11. "encoding/json"
  12. "fmt"
  13. "gdyb/controllers"
  14. "gdyb/enums"
  15. "gdyb/models"
  16. "gdyb/service"
  17. "gdyb/utils"
  18. "github.com/astaxie/beego"
  19. "github.com/axgle/mahonia"
  20. "github.com/go-ole/go-ole/oleutil"
  21. "github.com/gorilla/websocket"
  22. "github.com/jinzhu/gorm"
  23. "github.com/shopspring/decimal"
  24. "io"
  25. "io/ioutil"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. "github.com/go-ole/go-ole"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  83. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  84. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  86. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  87. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  88. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  89. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  159. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  160. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. //beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "msg": "成功",
  186. })
  187. }
  188. func (c *HisApiController) Get3508() {
  189. admin_user_id, _ := c.GetInt64("admin_user_id")
  190. drug_id, _ := c.GetInt64("id")
  191. start_time := c.GetString("start_time")
  192. end_time := c.GetString("end_time")
  193. adminUser := c.GetAdminUserInfo()
  194. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  196. drug, _ := service.GetDrugByID(drug_id)
  197. var struct3508 models.Struct3508
  198. struct3508.OrgName = miConfig.OrgName
  199. struct3508.FixmedinsCode = miConfig.Code
  200. struct3508.AccessKey = miConfig.AccessKey
  201. struct3508.Opter = curRoles.UserName
  202. struct3508.RequestUrl = miConfig.Url
  203. struct3508.Url = miConfig.Url
  204. struct3508.AppId = miConfig.Cainfo
  205. struct3508.AppSecret = miConfig.AppSecret
  206. struct3508.Enckey = miConfig.EncKey
  207. struct3508.SignKey = miConfig.SignKey
  208. struct3508.SecretKey = miConfig.SecretKey
  209. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  210. struct3508.Begndate = start_time
  211. struct3508.Enddate = end_time
  212. result1, result2, _ := service.FJyb3508(struct3508)
  213. saveLog(result1, result2, "3508", "3508")
  214. var res models.Result3508
  215. var respJSON2 map[string]interface{}
  216. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  219. return
  220. }
  221. userJSONBytes2, _ := json.Marshal(respJSON2)
  222. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  223. utils.ErrorLog("解析失败:%v", err)
  224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  225. return
  226. }
  227. if res.Infcode == -1 {
  228. c.ServeSuccessJSON(map[string]interface{}{
  229. "failed_code": -10,
  230. "msg": res.ErrMsg,
  231. })
  232. } else {
  233. c.ServeSuccessJSON(map[string]interface{}{
  234. "info": res.Output,
  235. })
  236. }
  237. }
  238. func (c *HisApiController) Get3509() {
  239. admin_user_id, _ := c.GetInt64("admin_user_id")
  240. drug_id, _ := c.GetInt64("id")
  241. start_time := c.GetString("start_time")
  242. end_time := c.GetString("end_time")
  243. adminUser := c.GetAdminUserInfo()
  244. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  245. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  246. drug, _ := service.GetDrugByID(drug_id)
  247. var struct3508 models.Struct3509
  248. struct3508.OrgName = miConfig.OrgName
  249. struct3508.FixmedinsCode = miConfig.Code
  250. struct3508.AccessKey = miConfig.AccessKey
  251. struct3508.Opter = curRoles.UserName
  252. struct3508.RequestUrl = miConfig.Url
  253. struct3508.Url = miConfig.Url
  254. struct3508.AppId = miConfig.Cainfo
  255. struct3508.AppSecret = miConfig.AppSecret
  256. struct3508.Enckey = miConfig.EncKey
  257. struct3508.SignKey = miConfig.SignKey
  258. struct3508.SecretKey = miConfig.SecretKey
  259. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  260. struct3508.Begndate = start_time
  261. struct3508.Enddate = end_time
  262. result1, result2, _ := service.FJyb3509(struct3508)
  263. saveLog(result1, result2, "3509", "3509")
  264. var res models.Result3509
  265. var respJSON2 map[string]interface{}
  266. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. return
  270. }
  271. userJSONBytes2, _ := json.Marshal(respJSON2)
  272. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  273. utils.ErrorLog("解析失败:%v", err)
  274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  275. return
  276. }
  277. if res.Infcode == -1 {
  278. c.ServeSuccessJSON(map[string]interface{}{
  279. "failed_code": -10,
  280. "msg": res.ErrMsg,
  281. })
  282. } else {
  283. c.ServeSuccessJSON(map[string]interface{}{
  284. "info": res.Output,
  285. })
  286. }
  287. }
  288. func (c *HisApiController) Get3510() {
  289. admin_user_id, _ := c.GetInt64("admin_user_id")
  290. drug_id, _ := c.GetInt64("id")
  291. start_time := c.GetString("start_time")
  292. end_time := c.GetString("end_time")
  293. adminUser := c.GetAdminUserInfo()
  294. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  296. drug, _ := service.GetDrugByID(drug_id)
  297. var struct3508 models.Struct3510
  298. struct3508.FixmedinsCode = miConfig.Code
  299. struct3508.OrgName = miConfig.OrgName
  300. struct3508.AccessKey = miConfig.AccessKey
  301. struct3508.Opter = curRoles.UserName
  302. struct3508.RequestUrl = miConfig.Url
  303. struct3508.Url = miConfig.Url
  304. struct3508.AppId = miConfig.Cainfo
  305. struct3508.AppSecret = miConfig.AppSecret
  306. struct3508.Enckey = miConfig.EncKey
  307. struct3508.SignKey = miConfig.SignKey
  308. struct3508.SecretKey = miConfig.SecretKey
  309. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  310. struct3508.Begndate = start_time
  311. struct3508.Enddate = end_time
  312. result1, result2, _ := service.FJyb3510(struct3508)
  313. saveLog(result1, result2, "3510", "3510")
  314. var res models.Result3510
  315. var respJSON2 map[string]interface{}
  316. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  319. return
  320. }
  321. userJSONBytes2, _ := json.Marshal(respJSON2)
  322. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  323. utils.ErrorLog("解析失败:%v", err)
  324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  325. return
  326. }
  327. if res.Infcode == -1 {
  328. c.ServeSuccessJSON(map[string]interface{}{
  329. "failed_code": -10,
  330. "msg": res.ErrMsg,
  331. })
  332. } else {
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "info": res.Output,
  335. })
  336. }
  337. }
  338. func (c *HisApiController) Get3511() {
  339. admin_user_id, _ := c.GetInt64("admin_user_id")
  340. drug_id, _ := c.GetInt64("id")
  341. start_time := c.GetString("start_time")
  342. end_time := c.GetString("end_time")
  343. adminUser := c.GetAdminUserInfo()
  344. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  346. drug, _ := service.GetDrugByID(drug_id)
  347. var struct3508 models.Struct3511
  348. struct3508.FixmedinsCode = miConfig.Code
  349. struct3508.OrgName = miConfig.OrgName
  350. struct3508.AccessKey = miConfig.AccessKey
  351. struct3508.Opter = curRoles.UserName
  352. struct3508.RequestUrl = miConfig.Url
  353. struct3508.Url = miConfig.Url
  354. struct3508.AppId = miConfig.Cainfo
  355. struct3508.AppSecret = miConfig.AppSecret
  356. struct3508.Enckey = miConfig.EncKey
  357. struct3508.SignKey = miConfig.SignKey
  358. struct3508.SecretKey = miConfig.SecretKey
  359. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  360. struct3508.Begndate = start_time
  361. struct3508.Enddate = end_time
  362. result1, result2, _ := service.FJyb3511(struct3508)
  363. saveLog(result1, result2, "3511", "3511")
  364. var res models.Result3511
  365. var respJSON2 map[string]interface{}
  366. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  369. return
  370. }
  371. userJSONBytes2, _ := json.Marshal(respJSON2)
  372. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  373. utils.ErrorLog("解析失败:%v", err)
  374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  375. return
  376. }
  377. if res.Infcode == -1 {
  378. c.ServeSuccessJSON(map[string]interface{}{
  379. "failed_code": -10,
  380. "msg": res.ErrMsg,
  381. })
  382. } else {
  383. c.ServeSuccessJSON(map[string]interface{}{
  384. "info": res.Output,
  385. })
  386. }
  387. }
  388. func (c *HisApiController) Get3512() {
  389. admin_user_id, _ := c.GetInt64("admin_user_id")
  390. drug_id, _ := c.GetInt64("id")
  391. start_time := c.GetString("start_time")
  392. end_time := c.GetString("end_time")
  393. adminUser := c.GetAdminUserInfo()
  394. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  395. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  396. drug, _ := service.GetDrugByID(drug_id)
  397. var struct3508 models.Struct3512
  398. struct3508.FixmedinsCode = miConfig.Code
  399. struct3508.OrgName = miConfig.OrgName
  400. struct3508.AccessKey = miConfig.AccessKey
  401. struct3508.Opter = curRoles.UserName
  402. struct3508.RequestUrl = miConfig.Url
  403. struct3508.Url = miConfig.Url
  404. struct3508.AppId = miConfig.Cainfo
  405. struct3508.AppSecret = miConfig.AppSecret
  406. struct3508.Enckey = miConfig.EncKey
  407. struct3508.SignKey = miConfig.SignKey
  408. struct3508.SecretKey = miConfig.SecretKey
  409. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  410. struct3508.Begndate = start_time
  411. struct3508.Enddate = end_time
  412. result1, result2, _ := service.FJyb3512(struct3508)
  413. saveLog(result1, result2, "3512", "3512")
  414. var res models.Result3512
  415. var respJSON2 map[string]interface{}
  416. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  419. return
  420. }
  421. userJSONBytes2, _ := json.Marshal(respJSON2)
  422. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  423. utils.ErrorLog("解析失败:%v", err)
  424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  425. return
  426. }
  427. if res.Infcode == -1 {
  428. c.ServeSuccessJSON(map[string]interface{}{
  429. "failed_code": -10,
  430. "msg": res.ErrMsg,
  431. })
  432. } else {
  433. c.ServeSuccessJSON(map[string]interface{}{
  434. "info": res.Output,
  435. })
  436. }
  437. }
  438. func (c *HisApiController) Get3513() {
  439. admin_user_id, _ := c.GetInt64("admin_user_id")
  440. drug_id, _ := c.GetInt64("id")
  441. start_time := c.GetString("start_time")
  442. end_time := c.GetString("end_time")
  443. adminUser := c.GetAdminUserInfo()
  444. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  445. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  446. drug, _ := service.GetDrugByID(drug_id)
  447. var struct3508 models.Struct3513
  448. struct3508.FixmedinsCode = miConfig.Code
  449. struct3508.OrgName = miConfig.OrgName
  450. struct3508.AccessKey = miConfig.AccessKey
  451. struct3508.Opter = curRoles.UserName
  452. struct3508.RequestUrl = miConfig.Url
  453. struct3508.Url = miConfig.Url
  454. struct3508.AppId = miConfig.Cainfo
  455. struct3508.AppSecret = miConfig.AppSecret
  456. struct3508.Enckey = miConfig.EncKey
  457. struct3508.SignKey = miConfig.SignKey
  458. struct3508.SecretKey = miConfig.SecretKey
  459. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  460. struct3508.Begndate = start_time
  461. struct3508.Enddate = end_time
  462. result1, result2, _ := service.FJyb3513(struct3508)
  463. saveLog(result1, result2, "3513", "3513")
  464. var res models.Result3513
  465. var respJSON2 map[string]interface{}
  466. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. userJSONBytes2, _ := json.Marshal(respJSON2)
  472. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  473. utils.ErrorLog("解析失败:%v", err)
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  475. return
  476. }
  477. if res.Infcode == -1 {
  478. c.ServeSuccessJSON(map[string]interface{}{
  479. "failed_code": -10,
  480. "msg": res.ErrMsg,
  481. })
  482. } else {
  483. c.ServeSuccessJSON(map[string]interface{}{
  484. "info": res.Output,
  485. })
  486. }
  487. }
  488. func (c *HisApiController) Get35081() {
  489. admin_user_id, _ := c.GetInt64("admin_user_id")
  490. drug_id, _ := c.GetInt64("id")
  491. //start_time := c.GetString("start_time")
  492. //end_time := c.GetString("end_time")
  493. page, _ := c.GetInt("page")
  494. adminUser := c.GetAdminUserInfo()
  495. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  497. drug, _ := service.GetDrugByID(drug_id)
  498. var struct3508 models.Struct35081
  499. struct3508.FixmedinsCode = miConfig.Code
  500. struct3508.OrgName = miConfig.OrgName
  501. struct3508.AccessKey = miConfig.AccessKey
  502. struct3508.Opter = curRoles.UserName
  503. struct3508.RequestUrl = miConfig.Url
  504. struct3508.Url = miConfig.Url
  505. struct3508.AppId = miConfig.Cainfo
  506. struct3508.AppSecret = miConfig.AppSecret
  507. struct3508.Enckey = miConfig.EncKey
  508. struct3508.SignKey = miConfig.SignKey
  509. struct3508.SecretKey = miConfig.SecretKey
  510. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  511. struct3508.PageNum = page
  512. struct3508.PageSize = 10
  513. result1, result2, _ := service.FJyb35081(struct3508)
  514. saveLog(result1, result2, "35081", "35081")
  515. var res models.Result35081
  516. var respJSON2 map[string]interface{}
  517. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  520. return
  521. }
  522. userJSONBytes2, _ := json.Marshal(respJSON2)
  523. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  524. utils.ErrorLog("解析失败:%v", err)
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  526. return
  527. }
  528. if res.Infcode == -1 {
  529. c.ServeSuccessJSON(map[string]interface{}{
  530. "failed_code": -10,
  531. "msg": res.ErrMsg,
  532. })
  533. } else {
  534. c.ServeSuccessJSON(map[string]interface{}{
  535. "info": res.Output,
  536. })
  537. }
  538. }
  539. func (c *HisApiController) Get35082() {
  540. admin_user_id, _ := c.GetInt64("admin_user_id")
  541. drug_id, _ := c.GetInt64("id")
  542. //start_time := c.GetString("start_time")
  543. //end_time := c.GetString("end_time")
  544. page, _ := c.GetInt("page")
  545. adminUser := c.GetAdminUserInfo()
  546. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  548. drug, _ := service.GetDrugByID(drug_id)
  549. var struct3508 models.Struct35082
  550. struct3508.FixmedinsCode = miConfig.Code
  551. struct3508.OrgName = miConfig.OrgName
  552. struct3508.AccessKey = miConfig.AccessKey
  553. struct3508.Opter = curRoles.UserName
  554. struct3508.RequestUrl = miConfig.Url
  555. struct3508.Url = miConfig.Url
  556. struct3508.AppId = miConfig.Cainfo
  557. struct3508.AppSecret = miConfig.AppSecret
  558. struct3508.Enckey = miConfig.EncKey
  559. struct3508.SignKey = miConfig.SignKey
  560. struct3508.SecretKey = miConfig.SecretKey
  561. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  562. struct3508.PageNum = page
  563. struct3508.PageSize = 10
  564. result1, result2, _ := service.FJyb35082(struct3508)
  565. saveLog(result1, result2, "35082", "35082")
  566. var res models.Result35082
  567. var respJSON2 map[string]interface{}
  568. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  571. return
  572. }
  573. userJSONBytes2, _ := json.Marshal(respJSON2)
  574. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  575. utils.ErrorLog("解析失败:%v", err)
  576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  577. return
  578. }
  579. if res.Infcode == -1 {
  580. c.ServeSuccessJSON(map[string]interface{}{
  581. "failed_code": -10,
  582. "msg": res.ErrMsg,
  583. })
  584. } else {
  585. c.ServeSuccessJSON(map[string]interface{}{
  586. "info": res.Output,
  587. })
  588. }
  589. }
  590. func (c *HisApiController) FJ3501AND3502() {
  591. ids := c.GetString("ids")
  592. admin_user_id, _ := c.GetInt64("admin_user_id")
  593. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. id_arr := strings.Split(ids, ",")
  595. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  596. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  597. //库盘
  598. var errs []string
  599. for _, drug := range drugs {
  600. if drug.IsPc == 0 && drug.IsBg == 0 {
  601. var res2 ResultSix
  602. var res3 ResultSix
  603. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  604. var struct3501 models.Struct3501
  605. struct3501.Code = miConfig.Code
  606. struct3501.OrgName = miConfig.OrgName
  607. struct3501.AccessKey = miConfig.AccessKey
  608. struct3501.Opter = roles.UserName
  609. struct3501.RequestUrl = miConfig.Url
  610. struct3501.Url = miConfig.Url
  611. struct3501.AppId = miConfig.Cainfo
  612. struct3501.AppSecret = miConfig.AppSecret
  613. struct3501.Enckey = miConfig.EncKey
  614. struct3501.SignKey = miConfig.SignKey
  615. struct3501.SecretKey = miConfig.SecretKey
  616. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  617. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  618. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  619. struct3501.RxFlag = "1"
  620. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  621. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  622. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  623. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  624. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  625. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  626. struct3501.FixmedinsBchno = number
  627. struct3501.DrugTracCodg = drug.DrugCode
  628. memo := make(map[string]interface{})
  629. memo["pric"] = drug.Price
  630. bytesData, _ := json.Marshal(memo)
  631. struct3501.Memo = string(bytesData)
  632. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  633. result1, result2, _ := service.FJyb3501(struct3501)
  634. saveLog(result1, result2, "3501", "3501")
  635. //saveLog(result, requestLog, "2201", "挂号")
  636. var respJSON2 map[string]interface{}
  637. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  640. return
  641. }
  642. userJSONBytes2, _ := json.Marshal(respJSON2)
  643. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  644. utils.ErrorLog("解析失败:%v", err)
  645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  646. return
  647. }
  648. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  649. data := make(map[string]interface{})
  650. data["struct_3501s"] = struct3501
  651. client := &http.Client{}
  652. bytesData, _ := json.Marshal(data)
  653. var req *http.Request
  654. if miConfig.MdtrtareaAdmvs == "320921" {
  655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  656. } else {
  657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. }
  659. resp, _ := client.Do(req)
  660. defer resp.Body.Close()
  661. body, ioErr := ioutil.ReadAll(resp.Body)
  662. if ioErr != nil {
  663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  664. }
  665. var respJSON map[string]interface{}
  666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return
  670. }
  671. var resSix10265 ResultSix10265 //1101结果
  672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  673. result, _ := json.Marshal(respJSON)
  674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  675. utils.ErrorLog("解析失败:%v", err)
  676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  677. return
  678. }
  679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  680. res2.Output = resSix10265.Output
  681. res2.ErrMsg = resSix10265.ErrMsg
  682. res2.Cainfo = resSix10265.Cainfo
  683. res2.WarnMsg = resSix10265.WarnMsg
  684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  685. res2.Infcode = infocode
  686. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  687. data := make(map[string]interface{})
  688. data["struct_3501s"] = struct3501
  689. client := &http.Client{}
  690. bytesData, _ := json.Marshal(data)
  691. var req *http.Request
  692. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  693. resp, _ := client.Do(req)
  694. defer resp.Body.Close()
  695. body, ioErr := ioutil.ReadAll(resp.Body)
  696. if ioErr != nil {
  697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  698. }
  699. var respJSON map[string]interface{}
  700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  703. return
  704. }
  705. var resSix10265 ResultSix10265 //1101结果
  706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  707. result, _ := json.Marshal(respJSON)
  708. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  709. utils.ErrorLog("解析失败:%v", err)
  710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  711. return
  712. }
  713. res2.InfRefmsgid = resSix10265.InfRefmsgid
  714. res2.Output = resSix10265.Output
  715. res2.ErrMsg = resSix10265.ErrMsg
  716. res2.Cainfo = resSix10265.Cainfo
  717. res2.WarnMsg = resSix10265.WarnMsg
  718. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  719. res2.Infcode = infocode
  720. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  721. data := make(map[string]interface{})
  722. data["struct_3501s"] = struct3501
  723. client := &http.Client{}
  724. bytesData, _ := json.Marshal(data)
  725. var req *http.Request
  726. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  727. resp, _ := client.Do(req)
  728. defer resp.Body.Close()
  729. body, ioErr := ioutil.ReadAll(resp.Body)
  730. if ioErr != nil {
  731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  732. }
  733. var respJSON map[string]interface{}
  734. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  737. return
  738. }
  739. var resSix10265 ResultSix10265 //1101结果
  740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  741. result, _ := json.Marshal(respJSON)
  742. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  743. utils.ErrorLog("解析失败:%v", err)
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  745. return
  746. }
  747. res2.InfRefmsgid = resSix10265.InfRefmsgid
  748. res2.Output = resSix10265.Output
  749. res2.ErrMsg = resSix10265.ErrMsg
  750. res2.Cainfo = resSix10265.Cainfo
  751. res2.WarnMsg = resSix10265.WarnMsg
  752. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  753. res2.Infcode = infocode
  754. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  755. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  756. saveLog(result1, result2, "3501", "3501")
  757. //saveLog(result, requestLog, "2201", "挂号")
  758. var respJSON2 map[string]interface{}
  759. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  762. return
  763. }
  764. userJSONBytes2, _ := json.Marshal(respJSON2)
  765. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  766. utils.ErrorLog("解析失败:%v", err)
  767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  768. return
  769. }
  770. }
  771. if res2.Infcode != -1 {
  772. drug.IsPc = 1
  773. drug.Bchno = number
  774. drug.PcDate = time.Now().Unix()
  775. err := service.SaveW(drug)
  776. if err == nil {
  777. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  778. var struct3502 models.Struct3502
  779. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  780. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  781. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  782. struct3502.FixmedinsCode = miConfig.Code
  783. struct3502.Code = miConfig.Code
  784. struct3502.RxFlag = "0"
  785. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  786. struct3502.OrgName = miConfig.OrgName
  787. struct3502.Opter = roles.UserName
  788. struct3502.AccessKey = miConfig.AccessKey
  789. struct3502.RequestUrl = miConfig.Url
  790. struct3502.SecretKey = miConfig.SecretKey
  791. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  792. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  793. struct3502.Url = miConfig.Url
  794. struct3502.AppId = miConfig.Cainfo
  795. struct3502.AppSecret = miConfig.AppSecret
  796. struct3502.Enckey = miConfig.EncKey
  797. struct3502.SignKey = miConfig.SignKey
  798. struct3502.SecretKey = miConfig.SecretKey
  799. struct3502.DrugTracCodg = drug.DrugCode
  800. struct3502.Memo = ""
  801. struct3502.InvChgType = "108"
  802. struct3502.FixmedinsBchno = bg_number
  803. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  804. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  805. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  806. result11, result22, _ := service.FJyb3502(struct3502)
  807. saveLog(result11, result22, "3502", "3502")
  808. var respJSON3 map[string]interface{}
  809. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  812. return
  813. }
  814. userJSONBytes3, _ := json.Marshal(respJSON3)
  815. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  816. utils.ErrorLog("解析失败:%v", err)
  817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  818. return
  819. }
  820. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  821. data := make(map[string]interface{})
  822. data["struct_3502s"] = struct3502
  823. client := &http.Client{}
  824. bytesData, _ := json.Marshal(data)
  825. var req *http.Request
  826. if miConfig.MdtrtareaAdmvs == "320921" {
  827. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  828. } else {
  829. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. }
  831. resp, _ := client.Do(req)
  832. defer resp.Body.Close()
  833. body, ioErr := ioutil.ReadAll(resp.Body)
  834. if ioErr != nil {
  835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  836. }
  837. var respJSON map[string]interface{}
  838. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  841. return
  842. }
  843. var resSix10265 ResultSix10265 //1101结果
  844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  845. result, _ := json.Marshal(respJSON)
  846. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  847. utils.ErrorLog("解析失败:%v", err)
  848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  849. return
  850. }
  851. res3.InfRefmsgid = resSix10265.InfRefmsgid
  852. res3.Output = resSix10265.Output
  853. res3.ErrMsg = resSix10265.ErrMsg
  854. res3.Cainfo = resSix10265.Cainfo
  855. res3.WarnMsg = resSix10265.WarnMsg
  856. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  857. res3.Infcode = infocode
  858. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  859. data := make(map[string]interface{})
  860. data["struct_3502s"] = struct3502
  861. client := &http.Client{}
  862. bytesData, _ := json.Marshal(data)
  863. var req *http.Request
  864. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  865. resp, _ := client.Do(req)
  866. defer resp.Body.Close()
  867. body, ioErr := ioutil.ReadAll(resp.Body)
  868. if ioErr != nil {
  869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  870. }
  871. var respJSON map[string]interface{}
  872. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  875. return
  876. }
  877. var resSix10265 ResultSix10265 //1101结果
  878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  879. result, _ := json.Marshal(respJSON)
  880. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  881. utils.ErrorLog("解析失败:%v", err)
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  883. return
  884. }
  885. res3.InfRefmsgid = resSix10265.InfRefmsgid
  886. res3.Output = resSix10265.Output
  887. res3.ErrMsg = resSix10265.ErrMsg
  888. res3.Cainfo = resSix10265.Cainfo
  889. res3.WarnMsg = resSix10265.WarnMsg
  890. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  891. res3.Infcode = infocode
  892. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  893. data := make(map[string]interface{})
  894. data["struct_3501s"] = struct3501
  895. client := &http.Client{}
  896. bytesData, _ := json.Marshal(data)
  897. var req *http.Request
  898. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  899. resp, _ := client.Do(req)
  900. defer resp.Body.Close()
  901. body, ioErr := ioutil.ReadAll(resp.Body)
  902. if ioErr != nil {
  903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  904. }
  905. var respJSON map[string]interface{}
  906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  909. return
  910. }
  911. var resSix10265 ResultSix10265 //1101结果
  912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  913. result, _ := json.Marshal(respJSON)
  914. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  915. utils.ErrorLog("解析失败:%v", err)
  916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  917. return
  918. }
  919. res2.InfRefmsgid = resSix10265.InfRefmsgid
  920. res2.Output = resSix10265.Output
  921. res2.ErrMsg = resSix10265.ErrMsg
  922. res2.Cainfo = resSix10265.Cainfo
  923. res2.WarnMsg = resSix10265.WarnMsg
  924. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  925. res2.Infcode = infocode
  926. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  927. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  928. saveLog(result11, result22, "3502", "3502")
  929. var respJSON3 map[string]interface{}
  930. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. userJSONBytes3, _ := json.Marshal(respJSON3)
  936. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  937. utils.ErrorLog("解析失败:%v", err)
  938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  939. return
  940. }
  941. }
  942. if res3.Infcode == -1 {
  943. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  944. c.ServeSuccessJSON(map[string]interface{}{
  945. "failed_code": -10,
  946. "msg": res3.ErrMsg,
  947. })
  948. } else {
  949. drug.IsBg = 1
  950. drug.BgBchno = bg_number
  951. service.SaveW(drug)
  952. }
  953. }
  954. } else {
  955. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  956. }
  957. }
  958. //变更
  959. if drug.IsPc == 1 && drug.IsBg == 0 {
  960. var res3 ResultSix
  961. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  962. var struct3502 models.Struct3502
  963. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  964. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  965. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  966. struct3502.FixmedinsCode = miConfig.Code
  967. struct3502.Code = miConfig.Code
  968. struct3502.Opter = roles.UserName
  969. struct3502.RxFlag = "0"
  970. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  971. struct3502.OrgName = miConfig.OrgName
  972. struct3502.AccessKey = miConfig.AccessKey
  973. struct3502.RequestUrl = miConfig.Url
  974. struct3502.SecretKey = miConfig.SecretKey
  975. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  976. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  977. struct3502.InvChgType = "108"
  978. struct3502.DrugTracCodg = drug.DrugCode
  979. struct3502.Url = miConfig.Url
  980. struct3502.AppId = miConfig.Cainfo
  981. struct3502.AppSecret = miConfig.AppSecret
  982. struct3502.Enckey = miConfig.EncKey
  983. struct3502.SignKey = miConfig.SignKey
  984. struct3502.SecretKey = miConfig.SecretKey
  985. struct3502.FixmedinsBchno = bg_number
  986. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  987. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  988. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  989. result1, result2, _ := service.FJyb3502(struct3502)
  990. saveLog(result1, result2, "3502", "3502")
  991. var respJSON3 map[string]interface{}
  992. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. return
  996. }
  997. userJSONBytes3, _ := json.Marshal(respJSON3)
  998. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  999. utils.ErrorLog("解析失败:%v", err)
  1000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1001. return
  1002. }
  1003. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1004. data := make(map[string]interface{})
  1005. data["struct_3502s"] = struct3502
  1006. client := &http.Client{}
  1007. bytesData, _ := json.Marshal(data)
  1008. var req *http.Request
  1009. if miConfig.MdtrtareaAdmvs == "320921" {
  1010. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1011. } else {
  1012. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1013. }
  1014. resp, _ := client.Do(req)
  1015. defer resp.Body.Close()
  1016. body, ioErr := ioutil.ReadAll(resp.Body)
  1017. if ioErr != nil {
  1018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1019. }
  1020. var respJSON map[string]interface{}
  1021. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var resSix10265 ResultSix10265 //1101结果
  1027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1028. result, _ := json.Marshal(respJSON)
  1029. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1030. utils.ErrorLog("解析失败:%v", err)
  1031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1032. return
  1033. }
  1034. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1035. res3.Output = resSix10265.Output
  1036. res3.ErrMsg = resSix10265.ErrMsg
  1037. res3.Cainfo = resSix10265.Cainfo
  1038. res3.WarnMsg = resSix10265.WarnMsg
  1039. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1040. res3.Infcode = infocode
  1041. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1042. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1043. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1044. }
  1045. if res3.Infcode == -1 {
  1046. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1047. } else {
  1048. drug.IsBg = 1
  1049. drug.BgBchno = bg_number
  1050. service.SaveW(drug)
  1051. }
  1052. }
  1053. }
  1054. if len(errs) == 0 {
  1055. c.ServeSuccessJSON(map[string]interface{}{
  1056. "msg": "盘存变更成功",
  1057. })
  1058. } else {
  1059. c.ServeSuccessJSON(map[string]interface{}{
  1060. "failed_code": -10,
  1061. "msg": errs,
  1062. })
  1063. }
  1064. }
  1065. func (c *HisApiController) DeletePCandBG() {
  1066. ids := c.GetString("ids")
  1067. id_arr := strings.Split(ids, ",")
  1068. admin_user_id, _ := c.GetInt64("admin_user_id")
  1069. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1070. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1072. var err []string
  1073. for _, item := range drugs {
  1074. if item.IsPc == 1 && item.IsBg == 1 {
  1075. var res FJ3507Result
  1076. var res2 FJ3507Result
  1077. var struct3507 models.Struct3507
  1078. struct3507.FixmedinsBchno = item.Bchno
  1079. struct3507.InvDataType = "1"
  1080. struct3507.Opter = roles.UserName
  1081. struct3507.OrgName = miConfig.OrgName
  1082. struct3507.AccessKey = miConfig.AccessKey
  1083. struct3507.RequestUrl = miConfig.Url
  1084. struct3507.FixmedinsCode = miConfig.Code
  1085. struct3507.Code = miConfig.Code
  1086. struct3507.SecretKey = miConfig.SecretKey
  1087. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1088. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1089. struct3507.Url = miConfig.Url
  1090. struct3507.AppId = miConfig.Cainfo
  1091. struct3507.AppSecret = miConfig.AppSecret
  1092. struct3507.Enckey = miConfig.EncKey
  1093. struct3507.SignKey = miConfig.SignKey
  1094. struct3507.SecretKey = miConfig.SecretKey
  1095. if miConfig.MdtrtareaAdmvs == "350500" {
  1096. result, result1, _ := service.FJyb3507(struct3507)
  1097. saveLog(result, result1, "3507", "3507")
  1098. var respJSON2 map[string]interface{}
  1099. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1102. return
  1103. }
  1104. userJSONBytes2, _ := json.Marshal(respJSON2)
  1105. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1106. utils.ErrorLog("解析失败:%v", err)
  1107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1108. return
  1109. }
  1110. } else {
  1111. data := make(map[string]interface{})
  1112. data["struct_3507s"] = struct3507
  1113. client := &http.Client{}
  1114. bytesData, _ := json.Marshal(data)
  1115. var req *http.Request
  1116. if miConfig.MdtrtareaAdmvs == "320921" {
  1117. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1118. } else {
  1119. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1120. }
  1121. resp, _ := client.Do(req)
  1122. defer resp.Body.Close()
  1123. body, ioErr := ioutil.ReadAll(resp.Body)
  1124. if ioErr != nil {
  1125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1126. }
  1127. var respJSON map[string]interface{}
  1128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1131. return
  1132. }
  1133. var resSix10265 ResultSix10265 //1101结果
  1134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1135. result, _ := json.Marshal(respJSON)
  1136. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. res.InfRefmsgid = resSix10265.InfRefmsgid
  1142. //res.Output = resSix10265.Output
  1143. res.ErrMsg = resSix10265.ErrMsg
  1144. res.Cainfo = resSix10265.Cainfo
  1145. res.WarnMsg = resSix10265.WarnMsg
  1146. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1147. res.Infcode = infocode
  1148. }
  1149. if res.Infcode == 0 {
  1150. item.IsPc = 0
  1151. err2 := service.SaveW(item)
  1152. if err2 == nil {
  1153. var struct3507_2 models.Struct3507
  1154. struct3507_2.OrgName = miConfig.OrgName
  1155. struct3507_2.AccessKey = miConfig.AccessKey
  1156. struct3507_2.RequestUrl = miConfig.Url
  1157. struct3507_2.Opter = roles.UserName
  1158. struct3507_2.FixmedinsCode = miConfig.Code
  1159. struct3507_2.Code = miConfig.Code
  1160. struct3507_2.SecretKey = miConfig.SecretKey
  1161. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1162. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1163. struct3507_2.Url = miConfig.Url
  1164. struct3507_2.AppId = miConfig.Cainfo
  1165. struct3507_2.AppSecret = miConfig.AppSecret
  1166. struct3507_2.Enckey = miConfig.EncKey
  1167. struct3507_2.SignKey = miConfig.SignKey
  1168. struct3507_2.SecretKey = miConfig.SecretKey
  1169. struct3507_2.FixmedinsBchno = item.BgBchno
  1170. struct3507_2.InvDataType = "2"
  1171. if miConfig.MdtrtareaAdmvs == "350500" {
  1172. result11, result22, _ := service.FJyb3507(struct3507_2)
  1173. saveLog(result11, result22, "3507", "3507")
  1174. var respJSON3 map[string]interface{}
  1175. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1178. return
  1179. }
  1180. userJSONBytes3, _ := json.Marshal(respJSON3)
  1181. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1182. utils.ErrorLog("解析失败:%v", err)
  1183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1184. return
  1185. }
  1186. } else {
  1187. data := make(map[string]interface{})
  1188. data["struct_3507s"] = struct3507_2
  1189. client := &http.Client{}
  1190. bytesData, _ := json.Marshal(data)
  1191. var req *http.Request
  1192. if miConfig.MdtrtareaAdmvs == "320921" {
  1193. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. } else {
  1195. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1196. }
  1197. resp, _ := client.Do(req)
  1198. defer resp.Body.Close()
  1199. body, ioErr := ioutil.ReadAll(resp.Body)
  1200. if ioErr != nil {
  1201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1202. }
  1203. var respJSON map[string]interface{}
  1204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1207. return
  1208. }
  1209. var resSix10265 ResultSix10265 //1101结果
  1210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1211. result, _ := json.Marshal(respJSON)
  1212. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1213. utils.ErrorLog("解析失败:%v", err)
  1214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1215. return
  1216. }
  1217. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1218. //res2.Output = resSix10265.Output
  1219. res2.ErrMsg = resSix10265.ErrMsg
  1220. res2.Cainfo = resSix10265.Cainfo
  1221. res2.WarnMsg = resSix10265.WarnMsg
  1222. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1223. res2.Infcode = infocode
  1224. }
  1225. if res2.Infcode != -1 {
  1226. item.IsBg = 0
  1227. item.Bchno = ""
  1228. item.BgBchno = ""
  1229. item.PcDate = 0
  1230. service.SaveW(item)
  1231. } else {
  1232. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1233. }
  1234. }
  1235. } else {
  1236. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1237. }
  1238. }
  1239. if item.IsPc == 1 && item.IsBg == 0 {
  1240. var res FJ3507Result
  1241. var struct3507 models.Struct3507
  1242. struct3507.FixmedinsBchno = item.Bchno
  1243. struct3507.InvDataType = "1"
  1244. struct3507.Opter = roles.UserName
  1245. struct3507.FixmedinsCode = miConfig.Code
  1246. struct3507.Code = miConfig.Code
  1247. struct3507.OrgName = miConfig.OrgName
  1248. struct3507.AccessKey = miConfig.AccessKey
  1249. struct3507.RequestUrl = miConfig.Url
  1250. struct3507.SecretKey = miConfig.SecretKey
  1251. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1252. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1253. struct3507.Url = miConfig.Url
  1254. struct3507.AppId = miConfig.Cainfo
  1255. struct3507.AppSecret = miConfig.AppSecret
  1256. struct3507.Enckey = miConfig.EncKey
  1257. struct3507.SignKey = miConfig.SignKey
  1258. struct3507.SecretKey = miConfig.SecretKey
  1259. //result, result1, _ := service.FJyb3507(struct3507)
  1260. //saveLog(result, result1, "3507", "3507")
  1261. if miConfig.MdtrtareaAdmvs == "350500" {
  1262. result, result1, _ := service.FJyb3507(struct3507)
  1263. saveLog(result, result1, "3507", "3507")
  1264. var respJSON2 map[string]interface{}
  1265. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1268. return
  1269. }
  1270. userJSONBytes2, _ := json.Marshal(respJSON2)
  1271. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1272. utils.ErrorLog("解析失败:%v", err)
  1273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1274. return
  1275. }
  1276. } else {
  1277. data := make(map[string]interface{})
  1278. data["struct_3507s"] = struct3507
  1279. client := &http.Client{}
  1280. bytesData, _ := json.Marshal(data)
  1281. var req *http.Request
  1282. if miConfig.MdtrtareaAdmvs == "320921" {
  1283. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1284. } else {
  1285. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1286. }
  1287. resp, _ := client.Do(req)
  1288. defer resp.Body.Close()
  1289. body, ioErr := ioutil.ReadAll(resp.Body)
  1290. if ioErr != nil {
  1291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1292. }
  1293. var respJSON map[string]interface{}
  1294. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. var resSix10265 ResultSix10265 //1101结果
  1300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1301. result, _ := json.Marshal(respJSON)
  1302. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1303. utils.ErrorLog("解析失败:%v", err)
  1304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1305. return
  1306. }
  1307. res.InfRefmsgid = resSix10265.InfRefmsgid
  1308. //res.Output = resSix10265.Output
  1309. res.ErrMsg = resSix10265.ErrMsg
  1310. res.Cainfo = resSix10265.Cainfo
  1311. res.WarnMsg = resSix10265.WarnMsg
  1312. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1313. res.Infcode = infocode
  1314. }
  1315. if res.Infcode == 0 {
  1316. item.IsPc = 0
  1317. item.Bchno = ""
  1318. item.BgBchno = ""
  1319. item.PcDate = 0
  1320. service.SaveW(item)
  1321. } else {
  1322. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1323. }
  1324. }
  1325. if item.IsPc == 0 && item.IsBg == 1 {
  1326. var res FJ3507Result
  1327. var struct3507 models.Struct3507
  1328. struct3507.FixmedinsBchno = item.BgBchno
  1329. struct3507.InvDataType = "2"
  1330. struct3507.Opter = roles.UserName
  1331. struct3507.FixmedinsCode = miConfig.Code
  1332. struct3507.OrgName = miConfig.OrgName
  1333. struct3507.AccessKey = miConfig.AccessKey
  1334. struct3507.RequestUrl = miConfig.Url
  1335. struct3507.SecretKey = miConfig.SecretKey
  1336. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1337. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1338. struct3507.Url = miConfig.Url
  1339. struct3507.AppId = miConfig.Cainfo
  1340. struct3507.AppSecret = miConfig.AppSecret
  1341. struct3507.Enckey = miConfig.EncKey
  1342. struct3507.SignKey = miConfig.SignKey
  1343. struct3507.SecretKey = miConfig.SecretKey
  1344. //result, result1, _ := service.FJyb3507(struct3507)
  1345. //saveLog(result, result1, "3507", "3507")
  1346. if miConfig.MdtrtareaAdmvs == "350500" {
  1347. result, result1, _ := service.FJyb3507(struct3507)
  1348. saveLog(result, result1, "3507", "3507")
  1349. var respJSON2 map[string]interface{}
  1350. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. return
  1354. }
  1355. userJSONBytes2, _ := json.Marshal(respJSON2)
  1356. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1357. utils.ErrorLog("解析失败:%v", err)
  1358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1359. return
  1360. }
  1361. } else {
  1362. data := make(map[string]interface{})
  1363. data["struct_3507s"] = struct3507
  1364. client := &http.Client{}
  1365. bytesData, _ := json.Marshal(data)
  1366. var req *http.Request
  1367. if miConfig.MdtrtareaAdmvs == "320921" {
  1368. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1369. } else {
  1370. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1371. }
  1372. resp, _ := client.Do(req)
  1373. defer resp.Body.Close()
  1374. body, ioErr := ioutil.ReadAll(resp.Body)
  1375. if ioErr != nil {
  1376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1377. }
  1378. var respJSON map[string]interface{}
  1379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. var resSix10265 ResultSix10265 //1101结果
  1385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1386. result, _ := json.Marshal(respJSON)
  1387. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1388. utils.ErrorLog("解析失败:%v", err)
  1389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1390. return
  1391. }
  1392. res.InfRefmsgid = resSix10265.InfRefmsgid
  1393. //res.Output = resSix10265.Output
  1394. res.ErrMsg = resSix10265.ErrMsg
  1395. res.Cainfo = resSix10265.Cainfo
  1396. res.WarnMsg = resSix10265.WarnMsg
  1397. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1398. res.Infcode = infocode
  1399. }
  1400. if res.Infcode == 0 {
  1401. item.IsBg = 0
  1402. item.Bchno = ""
  1403. item.BgBchno = ""
  1404. item.PcDate = 0
  1405. service.SaveW(item)
  1406. } else {
  1407. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1408. }
  1409. }
  1410. }
  1411. if len(err) == 0 {
  1412. c.ServeSuccessJSON(map[string]interface{}{
  1413. "msg": "删除盘存变更成功",
  1414. })
  1415. } else {
  1416. c.ServeSuccessJSON(map[string]interface{}{
  1417. "failed_code": -10,
  1418. "msg": err,
  1419. })
  1420. }
  1421. }
  1422. func (c *HisApiController) DeleteXSandBG() {
  1423. ids := c.GetString("ids")
  1424. id_arr := strings.Split(ids, ",")
  1425. admin_user_id, _ := c.GetInt64("admin_user_id")
  1426. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1427. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1429. var err []string
  1430. for _, item := range flows {
  1431. if item.IsSale == 1 && item.IsChange == 1 {
  1432. var res FJ3507Result
  1433. var res2 FJ3507Result
  1434. var struct3507 models.Struct3507
  1435. struct3507.FixmedinsBchno = item.Bchno
  1436. struct3507.InvDataType = "4"
  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.SecretKey = miConfig.SecretKey
  1443. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1444. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1445. struct3507.Url = miConfig.Url
  1446. struct3507.AppId = miConfig.Cainfo
  1447. struct3507.AppSecret = miConfig.AppSecret
  1448. struct3507.Enckey = miConfig.EncKey
  1449. struct3507.SignKey = miConfig.SignKey
  1450. struct3507.SecretKey = miConfig.SecretKey
  1451. //result, result1, _ := service.FJyb3507(struct3507)
  1452. //saveLog(result, result1, "3507", "3507")
  1453. if miConfig.MdtrtareaAdmvs == "350500" {
  1454. result, result1, _ := service.FJyb3507(struct3507)
  1455. saveLog(result, result1, "3507", "3507")
  1456. var respJSON2 map[string]interface{}
  1457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. return
  1461. }
  1462. userJSONBytes2, _ := json.Marshal(respJSON2)
  1463. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1464. utils.ErrorLog("解析失败:%v", err)
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1466. return
  1467. }
  1468. } else {
  1469. data := make(map[string]interface{})
  1470. data["struct_3507s"] = struct3507
  1471. client := &http.Client{}
  1472. bytesData, _ := json.Marshal(data)
  1473. var req *http.Request
  1474. if miConfig.MdtrtareaAdmvs == "320921" {
  1475. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1476. } else {
  1477. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1478. }
  1479. resp, _ := client.Do(req)
  1480. defer resp.Body.Close()
  1481. body, ioErr := ioutil.ReadAll(resp.Body)
  1482. if ioErr != nil {
  1483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1484. }
  1485. var respJSON map[string]interface{}
  1486. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1489. return
  1490. }
  1491. var resSix10265 ResultSix10265 //1101结果
  1492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1493. result, _ := json.Marshal(respJSON)
  1494. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1495. utils.ErrorLog("解析失败:%v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. res.InfRefmsgid = resSix10265.InfRefmsgid
  1500. //res.Output = resSix10265.Output
  1501. res.ErrMsg = resSix10265.ErrMsg
  1502. res.Cainfo = resSix10265.Cainfo
  1503. res.WarnMsg = resSix10265.WarnMsg
  1504. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1505. res.Infcode = infocode
  1506. }
  1507. if res.Infcode == 0 {
  1508. item.IsSale = 0
  1509. item.SaleDate = ""
  1510. item.Bchno = ""
  1511. err2 := service.SaveDF(item)
  1512. if err2 == nil {
  1513. var struct3507_2 models.Struct3507
  1514. struct3507_2.OrgName = miConfig.OrgName
  1515. struct3507_2.AccessKey = miConfig.AccessKey
  1516. struct3507_2.RequestUrl = miConfig.Url
  1517. struct3507_2.Opter = roles.UserName
  1518. struct3507_2.FixmedinsCode = miConfig.Code
  1519. struct3507_2.Code = miConfig.Code
  1520. struct3507_2.SecretKey = miConfig.SecretKey
  1521. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1522. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1523. struct3507_2.Url = miConfig.Url
  1524. struct3507_2.AppId = miConfig.Cainfo
  1525. struct3507_2.AppSecret = miConfig.AppSecret
  1526. struct3507_2.Enckey = miConfig.EncKey
  1527. struct3507_2.SignKey = miConfig.SignKey
  1528. struct3507_2.SecretKey = miConfig.SecretKey
  1529. struct3507_2.FixmedinsBchno = item.BgBchno
  1530. struct3507_2.InvDataType = "2"
  1531. if miConfig.MdtrtareaAdmvs == "350500" {
  1532. result11, result22, _ := service.FJyb3507(struct3507_2)
  1533. saveLog(result11, result22, "3507", "3507")
  1534. var respJSON3 map[string]interface{}
  1535. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. return
  1539. }
  1540. userJSONBytes3, _ := json.Marshal(respJSON3)
  1541. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1542. utils.ErrorLog("解析失败:%v", err)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. return
  1545. }
  1546. } else {
  1547. data := make(map[string]interface{})
  1548. data["struct_3507s"] = struct3507_2
  1549. client := &http.Client{}
  1550. bytesData, _ := json.Marshal(data)
  1551. var req *http.Request
  1552. if miConfig.MdtrtareaAdmvs == "320921" {
  1553. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1554. } else {
  1555. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1556. }
  1557. resp, _ := client.Do(req)
  1558. defer resp.Body.Close()
  1559. body, ioErr := ioutil.ReadAll(resp.Body)
  1560. if ioErr != nil {
  1561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1562. }
  1563. var respJSON map[string]interface{}
  1564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1567. return
  1568. }
  1569. var resSix10265 ResultSix10265 //1101结果
  1570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1571. result, _ := json.Marshal(respJSON)
  1572. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1573. utils.ErrorLog("解析失败:%v", err)
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1575. return
  1576. }
  1577. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1578. //res.Output = resSix10265.Output
  1579. res2.ErrMsg = resSix10265.ErrMsg
  1580. res2.Cainfo = resSix10265.Cainfo
  1581. res2.WarnMsg = resSix10265.WarnMsg
  1582. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1583. res2.Infcode = infocode
  1584. }
  1585. if res2.Infcode == 0 {
  1586. item.IsChange = 0
  1587. item.BgBchno = ""
  1588. service.SaveDF2(item)
  1589. } else {
  1590. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1591. }
  1592. }
  1593. } else {
  1594. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1595. }
  1596. }
  1597. if item.IsSale == 2 && item.IsChange == 1 {
  1598. var res FJ3507Result
  1599. var res2 FJ3507Result
  1600. var struct3507 models.Struct3507
  1601. struct3507.FixmedinsBchno = item.Bchno
  1602. struct3507.InvDataType = "4"
  1603. struct3507.Opter = roles.UserName
  1604. struct3507.OrgName = miConfig.OrgName
  1605. struct3507.AccessKey = miConfig.AccessKey
  1606. struct3507.RequestUrl = miConfig.Url
  1607. struct3507.FixmedinsCode = miConfig.Code
  1608. struct3507.Code = miConfig.Code
  1609. struct3507.SecretKey = miConfig.SecretKey
  1610. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1611. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1612. struct3507.Url = miConfig.Url
  1613. struct3507.AppId = miConfig.Cainfo
  1614. struct3507.AppSecret = miConfig.AppSecret
  1615. struct3507.Enckey = miConfig.EncKey
  1616. struct3507.SignKey = miConfig.SignKey
  1617. struct3507.SecretKey = miConfig.SecretKey
  1618. //result, result1, _ := service.FJyb3507(struct3507)
  1619. //saveLog(result, result1, "3507", "3507")
  1620. //
  1621. //var respJSON2 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1628. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result, result1, _ := service.FJyb3507(struct3507)
  1635. saveLog(result, result1, "3507", "3507")
  1636. var respJSON2 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes2, _ := json.Marshal(respJSON2)
  1643. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res.ErrMsg = resSix10265.ErrMsg
  1682. res.Cainfo = resSix10265.Cainfo
  1683. res.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res.Infcode = infocode
  1686. }
  1687. if res.Infcode == 0 {
  1688. item.IsSale = 0
  1689. item.SaleDate = ""
  1690. item.Bchno = ""
  1691. err2 := service.SaveDF(item)
  1692. if err2 == nil {
  1693. var struct3507_2 models.Struct3507
  1694. struct3507_2.OrgName = miConfig.OrgName
  1695. struct3507_2.AccessKey = miConfig.AccessKey
  1696. struct3507_2.RequestUrl = miConfig.Url
  1697. struct3507_2.Opter = roles.UserName
  1698. struct3507_2.FixmedinsCode = miConfig.Code
  1699. struct3507_2.Code = miConfig.Code
  1700. struct3507_2.SecretKey = miConfig.SecretKey
  1701. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1702. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1703. struct3507_2.Url = miConfig.Url
  1704. struct3507_2.AppId = miConfig.Cainfo
  1705. struct3507_2.AppSecret = miConfig.AppSecret
  1706. struct3507_2.Enckey = miConfig.EncKey
  1707. struct3507_2.SignKey = miConfig.SignKey
  1708. struct3507_2.SecretKey = miConfig.SecretKey
  1709. struct3507_2.FixmedinsBchno = item.BgBchno
  1710. struct3507_2.InvDataType = "2"
  1711. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1712. //saveLog(result11, result22, "3507", "3507")
  1713. //var respJSON3 map[string]interface{}
  1714. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1715. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1717. // return
  1718. //}
  1719. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1720. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1721. // utils.ErrorLog("解析失败:%v", err)
  1722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1723. // return
  1724. //}
  1725. if miConfig.MdtrtareaAdmvs == "350500" {
  1726. result11, result22, _ := service.FJyb3507(struct3507_2)
  1727. saveLog(result11, result22, "3507", "3507")
  1728. var respJSON3 map[string]interface{}
  1729. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. return
  1733. }
  1734. userJSONBytes3, _ := json.Marshal(respJSON3)
  1735. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1736. utils.ErrorLog("解析失败:%v", err)
  1737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1738. return
  1739. }
  1740. } else {
  1741. data := make(map[string]interface{})
  1742. data["struct_3507s"] = struct3507_2
  1743. client := &http.Client{}
  1744. bytesData, _ := json.Marshal(data)
  1745. var req *http.Request
  1746. if miConfig.MdtrtareaAdmvs == "320921" {
  1747. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1748. } else {
  1749. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1750. }
  1751. resp, _ := client.Do(req)
  1752. defer resp.Body.Close()
  1753. body, ioErr := ioutil.ReadAll(resp.Body)
  1754. if ioErr != nil {
  1755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1756. }
  1757. var respJSON map[string]interface{}
  1758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1761. return
  1762. }
  1763. var resSix10265 ResultSix10265 //1101结果
  1764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1765. result, _ := json.Marshal(respJSON)
  1766. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1767. utils.ErrorLog("解析失败:%v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1772. //res.Output = resSix10265.Output
  1773. res2.ErrMsg = resSix10265.ErrMsg
  1774. res2.Cainfo = resSix10265.Cainfo
  1775. res2.WarnMsg = resSix10265.WarnMsg
  1776. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1777. res2.Infcode = infocode
  1778. }
  1779. if res2.Infcode == 0 {
  1780. item.IsChange = 0
  1781. item.BgBchno = ""
  1782. service.SaveDF2(item)
  1783. } else {
  1784. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1785. }
  1786. }
  1787. } else {
  1788. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1789. }
  1790. }
  1791. if item.IsSale == 1 && item.IsChange == 0 {
  1792. var res FJ3507Result
  1793. var struct3507 models.Struct3507
  1794. struct3507.FixmedinsBchno = item.Bchno
  1795. struct3507.InvDataType = "4"
  1796. struct3507.Opter = roles.UserName
  1797. struct3507.FixmedinsCode = miConfig.Code
  1798. struct3507.Code = miConfig.Code
  1799. struct3507.OrgName = miConfig.OrgName
  1800. struct3507.AccessKey = miConfig.AccessKey
  1801. struct3507.RequestUrl = miConfig.Url
  1802. struct3507.SecretKey = miConfig.SecretKey
  1803. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1804. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1805. struct3507.Url = miConfig.Url
  1806. struct3507.AppId = miConfig.Cainfo
  1807. struct3507.AppSecret = miConfig.AppSecret
  1808. struct3507.Enckey = miConfig.EncKey
  1809. struct3507.SignKey = miConfig.SignKey
  1810. struct3507.SecretKey = miConfig.SecretKey
  1811. //result, result1, _ := service.FJyb3507(struct3507)
  1812. //saveLog(result, result1, "3507", "3507")
  1813. //
  1814. //var respJSON3 map[string]interface{}
  1815. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1816. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1818. // return
  1819. //}
  1820. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1821. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1822. // utils.ErrorLog("解析失败:%v", err)
  1823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. // return
  1825. //}
  1826. if miConfig.MdtrtareaAdmvs == "350500" {
  1827. result, result1, _ := service.FJyb3507(struct3507)
  1828. saveLog(result, result1, "3507", "3507")
  1829. var respJSON2 map[string]interface{}
  1830. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1833. return
  1834. }
  1835. userJSONBytes2, _ := json.Marshal(respJSON2)
  1836. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1837. utils.ErrorLog("解析失败:%v", err)
  1838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1839. return
  1840. }
  1841. } else {
  1842. data := make(map[string]interface{})
  1843. data["struct_3507s"] = struct3507
  1844. client := &http.Client{}
  1845. bytesData, _ := json.Marshal(data)
  1846. var req *http.Request
  1847. if miConfig.MdtrtareaAdmvs == "320921" {
  1848. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1849. } else {
  1850. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1851. }
  1852. resp, _ := client.Do(req)
  1853. defer resp.Body.Close()
  1854. body, ioErr := ioutil.ReadAll(resp.Body)
  1855. if ioErr != nil {
  1856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1857. }
  1858. var respJSON map[string]interface{}
  1859. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1862. return
  1863. }
  1864. var resSix10265 ResultSix10265 //1101结果
  1865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1866. result, _ := json.Marshal(respJSON)
  1867. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1868. utils.ErrorLog("解析失败:%v", err)
  1869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1870. return
  1871. }
  1872. res.InfRefmsgid = resSix10265.InfRefmsgid
  1873. //res.Output = resSix10265.Output
  1874. res.ErrMsg = resSix10265.ErrMsg
  1875. res.Cainfo = resSix10265.Cainfo
  1876. res.WarnMsg = resSix10265.WarnMsg
  1877. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1878. res.Infcode = infocode
  1879. }
  1880. if res.Infcode == 0 {
  1881. item.IsSale = 0
  1882. item.SaleDate = ""
  1883. service.SaveDF(item)
  1884. } else {
  1885. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1886. }
  1887. }
  1888. if item.IsSale == 2 && item.IsChange == 0 {
  1889. var res FJ3507Result
  1890. var struct3507 models.Struct3507
  1891. struct3507.FixmedinsBchno = item.Bchno
  1892. struct3507.InvDataType = "4"
  1893. struct3507.Opter = roles.UserName
  1894. struct3507.FixmedinsCode = miConfig.Code
  1895. struct3507.Code = miConfig.Code
  1896. struct3507.OrgName = miConfig.OrgName
  1897. struct3507.AccessKey = miConfig.AccessKey
  1898. struct3507.RequestUrl = miConfig.Url
  1899. struct3507.SecretKey = miConfig.SecretKey
  1900. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1901. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1902. struct3507.Url = miConfig.Url
  1903. struct3507.AppId = miConfig.Cainfo
  1904. struct3507.AppSecret = miConfig.AppSecret
  1905. struct3507.Enckey = miConfig.EncKey
  1906. struct3507.SignKey = miConfig.SignKey
  1907. struct3507.SecretKey = miConfig.SecretKey
  1908. //result, result1, _ := service.FJyb3507(struct3507)
  1909. //saveLog(result, result1, "3507", "3507")
  1910. //
  1911. //var respJSON3 map[string]interface{}
  1912. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1913. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1915. // return
  1916. //}
  1917. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1918. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1919. // utils.ErrorLog("解析失败:%v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. if miConfig.MdtrtareaAdmvs == "350500" {
  1924. result, result1, _ := service.FJyb3507(struct3507)
  1925. saveLog(result, result1, "3507", "3507")
  1926. var respJSON2 map[string]interface{}
  1927. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1930. return
  1931. }
  1932. userJSONBytes2, _ := json.Marshal(respJSON2)
  1933. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1934. utils.ErrorLog("解析失败:%v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. } else {
  1939. data := make(map[string]interface{})
  1940. data["struct_3507s"] = struct3507
  1941. client := &http.Client{}
  1942. bytesData, _ := json.Marshal(data)
  1943. var req *http.Request
  1944. if miConfig.MdtrtareaAdmvs == "320921" {
  1945. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1946. } else {
  1947. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1948. }
  1949. resp, _ := client.Do(req)
  1950. defer resp.Body.Close()
  1951. body, ioErr := ioutil.ReadAll(resp.Body)
  1952. if ioErr != nil {
  1953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1954. }
  1955. var respJSON map[string]interface{}
  1956. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1959. return
  1960. }
  1961. var resSix10265 ResultSix10265 //1101结果
  1962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1963. result, _ := json.Marshal(respJSON)
  1964. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1965. utils.ErrorLog("解析失败:%v", err)
  1966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1967. return
  1968. }
  1969. res.InfRefmsgid = resSix10265.InfRefmsgid
  1970. //res.Output = resSix10265.Output
  1971. res.ErrMsg = resSix10265.ErrMsg
  1972. res.Cainfo = resSix10265.Cainfo
  1973. res.WarnMsg = resSix10265.WarnMsg
  1974. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1975. res.Infcode = infocode
  1976. }
  1977. if res.Infcode == 0 {
  1978. item.IsSale = 0
  1979. item.SaleDate = ""
  1980. item.Bchno = ""
  1981. service.SaveDF(item)
  1982. } else {
  1983. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1984. }
  1985. }
  1986. if item.IsSale == 0 && item.IsChange == 1 {
  1987. var res FJ3507Result
  1988. var struct3507 models.Struct3507
  1989. struct3507.FixmedinsBchno = item.BgBchno
  1990. struct3507.InvDataType = "2"
  1991. struct3507.Opter = roles.UserName
  1992. struct3507.FixmedinsCode = miConfig.Code
  1993. struct3507.Code = miConfig.Code
  1994. struct3507.OrgName = miConfig.OrgName
  1995. struct3507.AccessKey = miConfig.AccessKey
  1996. struct3507.RequestUrl = miConfig.Url
  1997. struct3507.SecretKey = miConfig.SecretKey
  1998. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1999. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2000. struct3507.Url = miConfig.Url
  2001. struct3507.AppId = miConfig.Cainfo
  2002. struct3507.AppSecret = miConfig.AppSecret
  2003. struct3507.Enckey = miConfig.EncKey
  2004. struct3507.SignKey = miConfig.SignKey
  2005. struct3507.SecretKey = miConfig.SecretKey
  2006. //result, result1, _ := service.FJyb3507(struct3507)
  2007. //saveLog(result, result1, "3507", "3507")
  2008. //
  2009. //var respJSON3 map[string]interface{}
  2010. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2011. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2013. // return
  2014. //}
  2015. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2016. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2017. // utils.ErrorLog("解析失败:%v", err)
  2018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2019. // return
  2020. //}
  2021. if miConfig.MdtrtareaAdmvs == "350500" {
  2022. result, result1, _ := service.FJyb3507(struct3507)
  2023. saveLog(result, result1, "3507", "3507")
  2024. var respJSON2 map[string]interface{}
  2025. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2028. return
  2029. }
  2030. userJSONBytes2, _ := json.Marshal(respJSON2)
  2031. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2032. utils.ErrorLog("解析失败:%v", err)
  2033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2034. return
  2035. }
  2036. } else {
  2037. data := make(map[string]interface{})
  2038. data["struct_3507s"] = struct3507
  2039. client := &http.Client{}
  2040. bytesData, _ := json.Marshal(data)
  2041. var req *http.Request
  2042. if miConfig.MdtrtareaAdmvs == "320921" {
  2043. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2044. } else {
  2045. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2046. }
  2047. resp, _ := client.Do(req)
  2048. defer resp.Body.Close()
  2049. body, ioErr := ioutil.ReadAll(resp.Body)
  2050. if ioErr != nil {
  2051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2052. }
  2053. var respJSON map[string]interface{}
  2054. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2057. return
  2058. }
  2059. var resSix10265 ResultSix10265 //1101结果
  2060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2061. result, _ := json.Marshal(respJSON)
  2062. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2063. utils.ErrorLog("解析失败:%v", err)
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. return
  2066. }
  2067. res.InfRefmsgid = resSix10265.InfRefmsgid
  2068. //res.Output = resSix10265.Output
  2069. res.ErrMsg = resSix10265.ErrMsg
  2070. res.Cainfo = resSix10265.Cainfo
  2071. res.WarnMsg = resSix10265.WarnMsg
  2072. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2073. res.Infcode = infocode
  2074. }
  2075. if res.Infcode == 0 {
  2076. item.IsChange = 0
  2077. item.BgBchno = ""
  2078. service.SaveDF2(item)
  2079. } else {
  2080. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2081. }
  2082. }
  2083. }
  2084. if len(err) == 0 {
  2085. c.ServeSuccessJSON(map[string]interface{}{
  2086. "msg": "删除销售变更成功",
  2087. })
  2088. } else {
  2089. c.ServeSuccessJSON(map[string]interface{}{
  2090. "failed_code": -10,
  2091. "msg": err,
  2092. })
  2093. }
  2094. }
  2095. //func (c *HisApiController) BatchFJ3501AND3502() {
  2096. // //ids := c.GetString("ids")
  2097. // start_time := c.GetString("start_time")
  2098. // end_time := c.GetString("end_time")
  2099. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2100. //
  2101. //
  2102. // timeLayout := "2006-01-02"
  2103. // loc, _ := time.LoadLocation("Local")
  2104. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2105. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2106. //
  2107. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2108. // //id_arr := strings.Split(ids, ",")
  2109. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2110. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2111. // //库盘
  2112. // var errs []string
  2113. // for _, drug := range drugs {
  2114. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2115. // var res2 ResultSix
  2116. // var res3 ResultSix
  2117. //
  2118. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2119. // var struct3501 models.Struct3501
  2120. // struct3501.Code = miConfig.Code
  2121. // struct3501.OrgName = miConfig.OrgName
  2122. // struct3501.AccessKey = miConfig.AccessKey
  2123. // struct3501.Opter = roles.UserName
  2124. // struct3501.RequestUrl = miConfig.Url
  2125. // struct3501.Url = miConfig.Url
  2126. // struct3501.AppId = miConfig.Cainfo
  2127. // struct3501.AppSecret = miConfig.AppSecret
  2128. // struct3501.Enckey = miConfig.EncKey
  2129. // struct3501.SignKey = miConfig.SignKey
  2130. // struct3501.SecretKey = miConfig.SecretKey
  2131. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2132. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2133. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2134. // struct3501.RxFlag = "1"
  2135. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2136. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2137. //
  2138. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2139. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2140. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2141. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2142. // struct3501.FixmedinsBchno = number
  2143. // struct3501.DrugTracCodg = drug.DrugCode
  2144. // memo := make(map[string]interface{})
  2145. // memo["pric"] = drug.Price
  2146. // bytesData, _ := json.Marshal(memo)
  2147. // struct3501.Memo = string(bytesData)
  2148. //
  2149. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2150. //
  2151. // result1, result2, _ := service.FJyb3501(struct3501)
  2152. // saveLog(result1, result2, "3501", "3501")
  2153. // //saveLog(result, requestLog, "2201", "挂号")
  2154. //
  2155. // var respJSON2 map[string]interface{}
  2156. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2157. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. // return
  2160. // }
  2161. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2162. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2163. // utils.ErrorLog("解析失败:%v", err)
  2164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2165. // return
  2166. // }
  2167. //
  2168. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2169. // data := make(map[string]interface{})
  2170. // data["struct_3501s"] = struct3501
  2171. // client := &http.Client{}
  2172. // bytesData, _ := json.Marshal(data)
  2173. // var req *http.Request
  2174. // if miConfig.MdtrtareaAdmvs == "320921" {
  2175. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2176. // } else {
  2177. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2178. // }
  2179. //
  2180. // resp, _ := client.Do(req)
  2181. // defer resp.Body.Close()
  2182. // body, ioErr := ioutil.ReadAll(resp.Body)
  2183. // if ioErr != nil {
  2184. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2185. // }
  2186. // var respJSON map[string]interface{}
  2187. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2188. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2190. // return
  2191. // }
  2192. // var resSix10265 ResultSix10265 //1101结果
  2193. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2194. // result, _ := json.Marshal(respJSON)
  2195. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2196. // utils.ErrorLog("解析失败:%v", err)
  2197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2198. // return
  2199. // }
  2200. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2201. // res2.Output = resSix10265.Output
  2202. // res2.ErrMsg = resSix10265.ErrMsg
  2203. // res2.Cainfo = resSix10265.Cainfo
  2204. // res2.WarnMsg = resSix10265.WarnMsg
  2205. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2206. // res2.Infcode = infocode
  2207. //
  2208. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2209. // data := make(map[string]interface{})
  2210. // data["struct_3501s"] = struct3501
  2211. // client := &http.Client{}
  2212. // bytesData, _ := json.Marshal(data)
  2213. // var req *http.Request
  2214. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2215. // resp, _ := client.Do(req)
  2216. // defer resp.Body.Close()
  2217. // body, ioErr := ioutil.ReadAll(resp.Body)
  2218. // if ioErr != nil {
  2219. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2220. // }
  2221. // var respJSON map[string]interface{}
  2222. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2223. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2225. // return
  2226. // }
  2227. // var resSix10265 ResultSix10265 //1101结果
  2228. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2229. // result, _ := json.Marshal(respJSON)
  2230. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2231. // utils.ErrorLog("解析失败:%v", err)
  2232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2233. // return
  2234. // }
  2235. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2236. // res2.Output = resSix10265.Output
  2237. // res2.ErrMsg = resSix10265.ErrMsg
  2238. // res2.Cainfo = resSix10265.Cainfo
  2239. // res2.WarnMsg = resSix10265.WarnMsg
  2240. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2241. // res2.Infcode = infocode
  2242. //
  2243. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2244. // data := make(map[string]interface{})
  2245. // data["struct_3501s"] = struct3501
  2246. // client := &http.Client{}
  2247. // bytesData, _ := json.Marshal(data)
  2248. // var req *http.Request
  2249. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2250. // resp, _ := client.Do(req)
  2251. // defer resp.Body.Close()
  2252. // body, ioErr := ioutil.ReadAll(resp.Body)
  2253. // if ioErr != nil {
  2254. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2255. // }
  2256. // var respJSON map[string]interface{}
  2257. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2258. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2260. // return
  2261. // }
  2262. // var resSix10265 ResultSix10265 //1101结果
  2263. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2264. // result, _ := json.Marshal(respJSON)
  2265. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2266. // utils.ErrorLog("解析失败:%v", err)
  2267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2268. // return
  2269. // }
  2270. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2271. // res2.Output = resSix10265.Output
  2272. // res2.ErrMsg = resSix10265.ErrMsg
  2273. // res2.Cainfo = resSix10265.Cainfo
  2274. // res2.WarnMsg = resSix10265.WarnMsg
  2275. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2276. // res2.Infcode = infocode
  2277. //
  2278. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2279. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2280. // saveLog(result1, result2, "3501", "3501")
  2281. // //saveLog(result, requestLog, "2201", "挂号")
  2282. //
  2283. // var respJSON2 map[string]interface{}
  2284. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2285. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2287. // return
  2288. // }
  2289. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2290. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2291. // utils.ErrorLog("解析失败:%v", err)
  2292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2293. // return
  2294. // }
  2295. //
  2296. // }
  2297. //
  2298. // if res2.Infcode != -1 {
  2299. // drug.IsPc = 1
  2300. // drug.Bchno = number
  2301. // drug.PcDate = time.Now().Unix()
  2302. // err := service.SaveW(drug)
  2303. // if err == nil {
  2304. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2305. // var struct3502 models.Struct3502
  2306. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2307. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2308. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2309. // struct3502.FixmedinsCode = miConfig.Code
  2310. // struct3502.Code = miConfig.Code
  2311. //
  2312. // struct3502.RxFlag = "0"
  2313. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2314. // struct3502.OrgName = miConfig.OrgName
  2315. // struct3502.Opter = roles.UserName
  2316. // struct3502.AccessKey = miConfig.AccessKey
  2317. // struct3502.RequestUrl = miConfig.Url
  2318. // struct3502.SecretKey = miConfig.SecretKey
  2319. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2320. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2321. // struct3502.Url = miConfig.Url
  2322. // struct3502.AppId = miConfig.Cainfo
  2323. // struct3502.AppSecret = miConfig.AppSecret
  2324. // struct3502.Enckey = miConfig.EncKey
  2325. // struct3502.SignKey = miConfig.SignKey
  2326. // struct3502.SecretKey = miConfig.SecretKey
  2327. // struct3502.DrugTracCodg = drug.DrugCode
  2328. //
  2329. // struct3502.Memo = ""
  2330. // struct3502.InvChgType = "108"
  2331. // struct3502.FixmedinsBchno = bg_number
  2332. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2333. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2334. //
  2335. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2336. // result11, result22, _ := service.FJyb3502(struct3502)
  2337. // saveLog(result11, result22, "3502", "3502")
  2338. //
  2339. // var respJSON3 map[string]interface{}
  2340. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2341. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2343. // return
  2344. // }
  2345. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2346. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2347. // utils.ErrorLog("解析失败:%v", err)
  2348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2349. // return
  2350. // }
  2351. //
  2352. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2353. // data := make(map[string]interface{})
  2354. // data["struct_3502s"] = struct3502
  2355. // client := &http.Client{}
  2356. // bytesData, _ := json.Marshal(data)
  2357. // var req *http.Request
  2358. // if miConfig.MdtrtareaAdmvs == "320921" {
  2359. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2360. // } else {
  2361. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2362. // }
  2363. //
  2364. // resp, _ := client.Do(req)
  2365. // defer resp.Body.Close()
  2366. // body, ioErr := ioutil.ReadAll(resp.Body)
  2367. // if ioErr != nil {
  2368. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2369. // }
  2370. // var respJSON map[string]interface{}
  2371. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2372. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2374. // return
  2375. // }
  2376. // var resSix10265 ResultSix10265 //1101结果
  2377. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2378. // result, _ := json.Marshal(respJSON)
  2379. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2380. // utils.ErrorLog("解析失败:%v", err)
  2381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2382. // return
  2383. // }
  2384. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2385. // res3.Output = resSix10265.Output
  2386. // res3.ErrMsg = resSix10265.ErrMsg
  2387. // res3.Cainfo = resSix10265.Cainfo
  2388. // res3.WarnMsg = resSix10265.WarnMsg
  2389. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2390. // res3.Infcode = infocode
  2391. //
  2392. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2393. //
  2394. // data := make(map[string]interface{})
  2395. // data["struct_3502s"] = struct3502
  2396. // client := &http.Client{}
  2397. // bytesData, _ := json.Marshal(data)
  2398. // var req *http.Request
  2399. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2400. // resp, _ := client.Do(req)
  2401. // defer resp.Body.Close()
  2402. // body, ioErr := ioutil.ReadAll(resp.Body)
  2403. // if ioErr != nil {
  2404. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2405. // }
  2406. // var respJSON map[string]interface{}
  2407. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2408. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2410. // return
  2411. // }
  2412. // var resSix10265 ResultSix10265 //1101结果
  2413. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2414. // result, _ := json.Marshal(respJSON)
  2415. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2416. // utils.ErrorLog("解析失败:%v", err)
  2417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2418. // return
  2419. // }
  2420. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2421. // res3.Output = resSix10265.Output
  2422. // res3.ErrMsg = resSix10265.ErrMsg
  2423. // res3.Cainfo = resSix10265.Cainfo
  2424. // res3.WarnMsg = resSix10265.WarnMsg
  2425. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2426. // res3.Infcode = infocode
  2427. //
  2428. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2429. //
  2430. // data := make(map[string]interface{})
  2431. // data["struct_3501s"] = struct3501
  2432. // client := &http.Client{}
  2433. // bytesData, _ := json.Marshal(data)
  2434. // var req *http.Request
  2435. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2436. // resp, _ := client.Do(req)
  2437. // defer resp.Body.Close()
  2438. // body, ioErr := ioutil.ReadAll(resp.Body)
  2439. // if ioErr != nil {
  2440. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2441. // }
  2442. // var respJSON map[string]interface{}
  2443. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2444. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2446. // return
  2447. // }
  2448. // var resSix10265 ResultSix10265 //1101结果
  2449. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2450. // result, _ := json.Marshal(respJSON)
  2451. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2452. // utils.ErrorLog("解析失败:%v", err)
  2453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2454. // return
  2455. // }
  2456. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2457. // res2.Output = resSix10265.Output
  2458. // res2.ErrMsg = resSix10265.ErrMsg
  2459. // res2.Cainfo = resSix10265.Cainfo
  2460. // res2.WarnMsg = resSix10265.WarnMsg
  2461. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2462. // res2.Infcode = infocode
  2463. //
  2464. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2465. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2466. // saveLog(result11, result22, "3502", "3502")
  2467. //
  2468. // var respJSON3 map[string]interface{}
  2469. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2470. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2472. // return
  2473. // }
  2474. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2475. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2476. // utils.ErrorLog("解析失败:%v", err)
  2477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. // return
  2479. // }
  2480. // }
  2481. // if res3.Infcode == -1 {
  2482. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2483. // c.ServeSuccessJSON(map[string]interface{}{
  2484. // "failed_code": -10,
  2485. // "msg": res3.ErrMsg,
  2486. // })
  2487. // } else {
  2488. // drug.IsBg = 1
  2489. // drug.BgBchno = bg_number
  2490. // service.SaveW(drug)
  2491. // }
  2492. // }
  2493. // } else {
  2494. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2495. // }
  2496. // }
  2497. // //变更
  2498. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2499. // var res3 ResultSix
  2500. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2501. //
  2502. // var struct3502 models.Struct3502
  2503. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2504. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2505. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2506. // struct3502.FixmedinsCode = miConfig.Code
  2507. // struct3502.Code = miConfig.Code
  2508. //
  2509. // struct3502.Opter = roles.UserName
  2510. // struct3502.RxFlag = "0"
  2511. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2512. // struct3502.OrgName = miConfig.OrgName
  2513. // struct3502.AccessKey = miConfig.AccessKey
  2514. // struct3502.RequestUrl = miConfig.Url
  2515. // struct3502.SecretKey = miConfig.SecretKey
  2516. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2517. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2518. // struct3502.InvChgType = "108"
  2519. // struct3502.DrugTracCodg = drug.DrugCode
  2520. //
  2521. // struct3502.Url = miConfig.Url
  2522. // struct3502.AppId = miConfig.Cainfo
  2523. // struct3502.AppSecret = miConfig.AppSecret
  2524. // struct3502.Enckey = miConfig.EncKey
  2525. // struct3502.SignKey = miConfig.SignKey
  2526. // struct3502.SecretKey = miConfig.SecretKey
  2527. //
  2528. // struct3502.FixmedinsBchno = bg_number
  2529. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2530. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2531. //
  2532. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2533. // result1, result2, _ := service.FJyb3502(struct3502)
  2534. // saveLog(result1, result2, "3502", "3502")
  2535. // var respJSON3 map[string]interface{}
  2536. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2537. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2539. // return
  2540. // }
  2541. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2542. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2543. // utils.ErrorLog("解析失败:%v", err)
  2544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2545. // return
  2546. // }
  2547. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2548. // data := make(map[string]interface{})
  2549. // data["struct_3502s"] = struct3502
  2550. // client := &http.Client{}
  2551. // bytesData, _ := json.Marshal(data)
  2552. // var req *http.Request
  2553. // if miConfig.MdtrtareaAdmvs == "320921" {
  2554. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2555. // } else {
  2556. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2557. // }
  2558. // resp, _ := client.Do(req)
  2559. // defer resp.Body.Close()
  2560. // body, ioErr := ioutil.ReadAll(resp.Body)
  2561. // if ioErr != nil {
  2562. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2563. // }
  2564. // var respJSON map[string]interface{}
  2565. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2566. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2568. // return
  2569. // }
  2570. // var resSix10265 ResultSix10265 //1101结果
  2571. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2572. // result, _ := json.Marshal(respJSON)
  2573. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2574. // utils.ErrorLog("解析失败:%v", err)
  2575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2576. // return
  2577. // }
  2578. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2579. // res3.Output = resSix10265.Output
  2580. // res3.ErrMsg = resSix10265.ErrMsg
  2581. // res3.Cainfo = resSix10265.Cainfo
  2582. // res3.WarnMsg = resSix10265.WarnMsg
  2583. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2584. // res3.Infcode = infocode
  2585. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2586. //
  2587. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2588. //
  2589. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2590. //
  2591. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2592. //
  2593. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2594. // saveLog(result1, result2, "3501", "3501")
  2595. // //saveLog(result, requestLog, "2201", "挂号")
  2596. //
  2597. // var respJSON2 map[string]interface{}
  2598. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2599. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2601. // return
  2602. // }
  2603. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2604. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2605. // utils.ErrorLog("解析失败:%v", err)
  2606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2607. // return
  2608. // }
  2609. //
  2610. // }
  2611. // if res3.Infcode == -1 {
  2612. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2613. // } else {
  2614. // drug.IsBg = 1
  2615. // drug.BgBchno = bg_number
  2616. // service.SaveW(drug)
  2617. // }
  2618. // }
  2619. // }
  2620. //
  2621. // if len(errs) == 0 {
  2622. // c.ServeSuccessJSON(map[string]interface{}{
  2623. // "msg": "盘存变更成功",
  2624. // })
  2625. // } else {
  2626. // c.ServeSuccessJSON(map[string]interface{}{
  2627. // "failed_code": -10,
  2628. // "msg": errs,
  2629. // })
  2630. // }
  2631. //}
  2632. //func (c *HisApiController) DeleteXSandBGTwo() {
  2633. // patient_id, _ := c.GetInt64("patient_id")
  2634. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2635. // //id_arr := strings.Split(ids, ",")
  2636. // times := c.GetString("time", "")
  2637. // timeLayout := "2006-01-02"
  2638. // loc, _ := time.LoadLocation("Local")
  2639. // var stime, etime int64
  2640. // if times == "" {
  2641. // stime, etime = GetNowTime()
  2642. // } else {
  2643. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2644. // stime = stmp.Unix()
  2645. // etime = stime + 86399
  2646. // }
  2647. // advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2648. // var flows []*models.DrugFlow
  2649. // for _, item := range advicelist {
  2650. // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2651. // flows = append(flows, flow...)
  2652. // }
  2653. //
  2654. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2655. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2656. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2657. //
  2658. // var err []string
  2659. // for _, item := range flows {
  2660. // if item.IsSale == 1 && item.IsChange == 1 {
  2661. // var res FJ3507Result
  2662. // var res2 FJ3507Result
  2663. //
  2664. // var struct3507 models.Struct3507
  2665. // struct3507.FixmedinsBchno = item.Bchno
  2666. // struct3507.InvDataType = "4"
  2667. // struct3507.Opter = roles.UserName
  2668. // struct3507.OrgName = miConfig.OrgName
  2669. // struct3507.AccessKey = miConfig.AccessKey
  2670. // struct3507.RequestUrl = miConfig.Url
  2671. // struct3507.FixmedinsCode = miConfig.Code
  2672. // struct3507.SecretKey = miConfig.SecretKey
  2673. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2674. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2675. // struct3507.Url = miConfig.Url
  2676. // struct3507.AppId = miConfig.Cainfo
  2677. // struct3507.AppSecret = miConfig.AppSecret
  2678. // struct3507.Enckey = miConfig.EncKey
  2679. // struct3507.SignKey = miConfig.SignKey
  2680. // struct3507.SecretKey = miConfig.SecretKey
  2681. //
  2682. // //result, result1, _ := service.FJyb3507(struct3507)
  2683. // //saveLog(result, result1, "3507", "3507")
  2684. //
  2685. // if miConfig.MdtrtareaAdmvs == "350500" {
  2686. // result, result1, _ := service.FJyb3507(struct3507)
  2687. // saveLog(result, result1, "3507", "3507")
  2688. // var respJSON2 map[string]interface{}
  2689. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2690. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2692. // return
  2693. // }
  2694. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2695. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2696. // utils.ErrorLog("解析失败:%v", err)
  2697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2698. // return
  2699. // }
  2700. // } else {
  2701. // data := make(map[string]interface{})
  2702. // data["struct_3507s"] = struct3507
  2703. // client := &http.Client{}
  2704. // bytesData, _ := json.Marshal(data)
  2705. // var req *http.Request
  2706. // if miConfig.MdtrtareaAdmvs == "320921" {
  2707. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2708. // } else {
  2709. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2710. // }
  2711. //
  2712. // resp, _ := client.Do(req)
  2713. // defer resp.Body.Close()
  2714. // body, ioErr := ioutil.ReadAll(resp.Body)
  2715. // if ioErr != nil {
  2716. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2717. // }
  2718. // var respJSON map[string]interface{}
  2719. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2720. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2722. // return
  2723. // }
  2724. // var resSix10265 ResultSix10265 //1101结果
  2725. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2726. // result, _ := json.Marshal(respJSON)
  2727. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2728. // utils.ErrorLog("解析失败:%v", err)
  2729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2730. // return
  2731. // }
  2732. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2733. // //res.Output = resSix10265.Output
  2734. // res.ErrMsg = resSix10265.ErrMsg
  2735. // res.Cainfo = resSix10265.Cainfo
  2736. // res.WarnMsg = resSix10265.WarnMsg
  2737. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2738. // res.Infcode = infocode
  2739. // }
  2740. //
  2741. // if res.Infcode == 0 {
  2742. // item.IsSale = 0
  2743. // item.SaleDate = ""
  2744. // item.Bchno = ""
  2745. //
  2746. // err2 := service.SaveDF(item)
  2747. // if err2 == nil {
  2748. // var struct3507_2 models.Struct3507
  2749. // struct3507_2.OrgName = miConfig.OrgName
  2750. // struct3507_2.AccessKey = miConfig.AccessKey
  2751. // struct3507_2.RequestUrl = miConfig.Url
  2752. // struct3507_2.Opter = roles.UserName
  2753. // struct3507_2.FixmedinsCode = miConfig.Code
  2754. // struct3507_2.Code = miConfig.Code
  2755. //
  2756. // struct3507_2.SecretKey = miConfig.SecretKey
  2757. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2758. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2759. // struct3507_2.Url = miConfig.Url
  2760. // struct3507_2.AppId = miConfig.Cainfo
  2761. // struct3507_2.AppSecret = miConfig.AppSecret
  2762. // struct3507_2.Enckey = miConfig.EncKey
  2763. // struct3507_2.SignKey = miConfig.SignKey
  2764. // struct3507_2.SecretKey = miConfig.SecretKey
  2765. // struct3507_2.FixmedinsBchno = item.BgBchno
  2766. // struct3507_2.InvDataType = "2"
  2767. //
  2768. // if miConfig.MdtrtareaAdmvs == "350500" {
  2769. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2770. // saveLog(result11, result22, "3507", "3507")
  2771. //
  2772. // var respJSON3 map[string]interface{}
  2773. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2774. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2776. // return
  2777. // }
  2778. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2779. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2780. // utils.ErrorLog("解析失败:%v", err)
  2781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2782. // return
  2783. // }
  2784. // } else {
  2785. //
  2786. // data := make(map[string]interface{})
  2787. // data["struct_3507s"] = struct3507_2
  2788. // client := &http.Client{}
  2789. // bytesData, _ := json.Marshal(data)
  2790. // var req *http.Request
  2791. // if miConfig.MdtrtareaAdmvs == "320921" {
  2792. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2793. // } else {
  2794. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2795. // }
  2796. //
  2797. // resp, _ := client.Do(req)
  2798. // defer resp.Body.Close()
  2799. // body, ioErr := ioutil.ReadAll(resp.Body)
  2800. // if ioErr != nil {
  2801. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2802. // }
  2803. // var respJSON map[string]interface{}
  2804. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2805. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2807. // return
  2808. // }
  2809. // var resSix10265 ResultSix10265 //1101结果
  2810. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2811. // result, _ := json.Marshal(respJSON)
  2812. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2813. // utils.ErrorLog("解析失败:%v", err)
  2814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2815. // return
  2816. // }
  2817. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2818. // //res.Output = resSix10265.Output
  2819. // res2.ErrMsg = resSix10265.ErrMsg
  2820. // res2.Cainfo = resSix10265.Cainfo
  2821. // res2.WarnMsg = resSix10265.WarnMsg
  2822. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2823. // res2.Infcode = infocode
  2824. // }
  2825. //
  2826. // if res2.Infcode == 0 {
  2827. // item.IsChange = 0
  2828. // item.BgBchno = ""
  2829. // service.SaveDF2(item)
  2830. // } else {
  2831. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2832. // }
  2833. // }
  2834. // } else {
  2835. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2836. // }
  2837. //
  2838. // }
  2839. // if item.IsSale == 2 && item.IsChange == 1 {
  2840. // var res FJ3507Result
  2841. // var res2 FJ3507Result
  2842. //
  2843. // var struct3507 models.Struct3507
  2844. // struct3507.FixmedinsBchno = item.Bchno
  2845. // struct3507.InvDataType = "4"
  2846. // struct3507.Opter = roles.UserName
  2847. // struct3507.OrgName = miConfig.OrgName
  2848. // struct3507.AccessKey = miConfig.AccessKey
  2849. // struct3507.RequestUrl = miConfig.Url
  2850. // struct3507.FixmedinsCode = miConfig.Code
  2851. // struct3507.Code = miConfig.Code
  2852. //
  2853. // struct3507.SecretKey = miConfig.SecretKey
  2854. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2855. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2856. // struct3507.Url = miConfig.Url
  2857. // struct3507.AppId = miConfig.Cainfo
  2858. // struct3507.AppSecret = miConfig.AppSecret
  2859. // struct3507.Enckey = miConfig.EncKey
  2860. // struct3507.SignKey = miConfig.SignKey
  2861. // struct3507.SecretKey = miConfig.SecretKey
  2862. // //result, result1, _ := service.FJyb3507(struct3507)
  2863. // //saveLog(result, result1, "3507", "3507")
  2864. // //
  2865. // //var respJSON2 map[string]interface{}
  2866. // //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2867. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2868. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2869. // // return
  2870. // //}
  2871. // //userJSONBytes2, _ := json.Marshal(respJSON2)
  2872. // //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2873. // // utils.ErrorLog("解析失败:%v", err)
  2874. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. // // return
  2876. // //}
  2877. //
  2878. // if miConfig.MdtrtareaAdmvs == "350500" {
  2879. // result, result1, _ := service.FJyb3507(struct3507)
  2880. // saveLog(result, result1, "3507", "3507")
  2881. // var respJSON2 map[string]interface{}
  2882. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2883. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2885. // return
  2886. // }
  2887. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2888. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2889. // utils.ErrorLog("解析失败:%v", err)
  2890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2891. // return
  2892. // }
  2893. // } else {
  2894. // data := make(map[string]interface{})
  2895. // data["struct_3507s"] = struct3507
  2896. // client := &http.Client{}
  2897. // bytesData, _ := json.Marshal(data)
  2898. // var req *http.Request
  2899. // if miConfig.MdtrtareaAdmvs == "320921" {
  2900. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2901. // } else {
  2902. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2903. // }
  2904. //
  2905. // resp, _ := client.Do(req)
  2906. // defer resp.Body.Close()
  2907. // body, ioErr := ioutil.ReadAll(resp.Body)
  2908. // if ioErr != nil {
  2909. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2910. // }
  2911. // var respJSON map[string]interface{}
  2912. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2913. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2915. // return
  2916. // }
  2917. // var resSix10265 ResultSix10265 //1101结果
  2918. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2919. // result, _ := json.Marshal(respJSON)
  2920. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2921. // utils.ErrorLog("解析失败:%v", err)
  2922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2923. // return
  2924. // }
  2925. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2926. // //res.Output = resSix10265.Output
  2927. // res.ErrMsg = resSix10265.ErrMsg
  2928. // res.Cainfo = resSix10265.Cainfo
  2929. // res.WarnMsg = resSix10265.WarnMsg
  2930. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2931. // res.Infcode = infocode
  2932. // }
  2933. //
  2934. // if res.Infcode == 0 {
  2935. // item.IsSale = 0
  2936. // item.SaleDate = ""
  2937. // item.Bchno = ""
  2938. // err2 := service.SaveDF(item)
  2939. // if err2 == nil {
  2940. // var struct3507_2 models.Struct3507
  2941. // struct3507_2.OrgName = miConfig.OrgName
  2942. // struct3507_2.AccessKey = miConfig.AccessKey
  2943. // struct3507_2.RequestUrl = miConfig.Url
  2944. // struct3507_2.Opter = roles.UserName
  2945. // struct3507_2.FixmedinsCode = miConfig.Code
  2946. // struct3507_2.Code = miConfig.Code
  2947. //
  2948. // struct3507_2.SecretKey = miConfig.SecretKey
  2949. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2950. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2951. // struct3507_2.Url = miConfig.Url
  2952. // struct3507_2.AppId = miConfig.Cainfo
  2953. // struct3507_2.AppSecret = miConfig.AppSecret
  2954. // struct3507_2.Enckey = miConfig.EncKey
  2955. // struct3507_2.SignKey = miConfig.SignKey
  2956. // struct3507_2.SecretKey = miConfig.SecretKey
  2957. // struct3507_2.FixmedinsBchno = item.BgBchno
  2958. // struct3507_2.InvDataType = "2"
  2959. //
  2960. // //result11, result22, _ := service.FJyb3507(struct3507_2)
  2961. // //saveLog(result11, result22, "3507", "3507")
  2962. // //var respJSON3 map[string]interface{}
  2963. // //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2964. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2965. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2966. // // return
  2967. // //}
  2968. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2969. // //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2970. // // utils.ErrorLog("解析失败:%v", err)
  2971. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2972. // // return
  2973. // //}
  2974. //
  2975. // if miConfig.MdtrtareaAdmvs == "350500" {
  2976. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2977. // saveLog(result11, result22, "3507", "3507")
  2978. //
  2979. // var respJSON3 map[string]interface{}
  2980. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2981. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2982. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. // return
  2984. // }
  2985. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2986. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2987. // utils.ErrorLog("解析失败:%v", err)
  2988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2989. // return
  2990. // }
  2991. // } else {
  2992. //
  2993. // data := make(map[string]interface{})
  2994. // data["struct_3507s"] = struct3507_2
  2995. // client := &http.Client{}
  2996. // bytesData, _ := json.Marshal(data)
  2997. // var req *http.Request
  2998. // if miConfig.MdtrtareaAdmvs == "320921" {
  2999. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3000. // } else {
  3001. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3002. // }
  3003. //
  3004. // resp, _ := client.Do(req)
  3005. // defer resp.Body.Close()
  3006. // body, ioErr := ioutil.ReadAll(resp.Body)
  3007. // if ioErr != nil {
  3008. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3009. // }
  3010. // var respJSON map[string]interface{}
  3011. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3012. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3014. // return
  3015. // }
  3016. // var resSix10265 ResultSix10265 //1101结果
  3017. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3018. // result, _ := json.Marshal(respJSON)
  3019. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3020. // utils.ErrorLog("解析失败:%v", err)
  3021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3022. // return
  3023. // }
  3024. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  3025. // //res.Output = resSix10265.Output
  3026. // res2.ErrMsg = resSix10265.ErrMsg
  3027. // res2.Cainfo = resSix10265.Cainfo
  3028. // res2.WarnMsg = resSix10265.WarnMsg
  3029. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3030. // res2.Infcode = infocode
  3031. // }
  3032. // if res2.Infcode == 0 {
  3033. // item.IsChange = 0
  3034. // item.BgBchno = ""
  3035. // service.SaveDF2(item)
  3036. // } else {
  3037. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3038. // }
  3039. // }
  3040. // } else {
  3041. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3042. // }
  3043. //
  3044. // }
  3045. // if item.IsSale == 1 && item.IsChange == 0 {
  3046. //
  3047. // var res FJ3507Result
  3048. // var struct3507 models.Struct3507
  3049. // struct3507.FixmedinsBchno = item.Bchno
  3050. // struct3507.InvDataType = "4"
  3051. // struct3507.Opter = roles.UserName
  3052. // struct3507.FixmedinsCode = miConfig.Code
  3053. // struct3507.Code = miConfig.Code
  3054. //
  3055. // struct3507.OrgName = miConfig.OrgName
  3056. // struct3507.AccessKey = miConfig.AccessKey
  3057. // struct3507.RequestUrl = miConfig.Url
  3058. // struct3507.SecretKey = miConfig.SecretKey
  3059. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3060. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3061. // struct3507.Url = miConfig.Url
  3062. // struct3507.AppId = miConfig.Cainfo
  3063. // struct3507.AppSecret = miConfig.AppSecret
  3064. // struct3507.Enckey = miConfig.EncKey
  3065. // struct3507.SignKey = miConfig.SignKey
  3066. // struct3507.SecretKey = miConfig.SecretKey
  3067. // //result, result1, _ := service.FJyb3507(struct3507)
  3068. // //saveLog(result, result1, "3507", "3507")
  3069. // //
  3070. // //var respJSON3 map[string]interface{}
  3071. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3072. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3073. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3074. // // return
  3075. // //}
  3076. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  3077. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3078. // // utils.ErrorLog("解析失败:%v", err)
  3079. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3080. // // return
  3081. // //}
  3082. // if miConfig.MdtrtareaAdmvs == "350500" {
  3083. // result, result1, _ := service.FJyb3507(struct3507)
  3084. // saveLog(result, result1, "3507", "3507")
  3085. // var respJSON2 map[string]interface{}
  3086. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3087. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3089. // return
  3090. // }
  3091. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3092. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3093. // utils.ErrorLog("解析失败:%v", err)
  3094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3095. // return
  3096. // }
  3097. // } else {
  3098. // data := make(map[string]interface{})
  3099. // data["struct_3507s"] = struct3507
  3100. // client := &http.Client{}
  3101. // bytesData, _ := json.Marshal(data)
  3102. // var req *http.Request
  3103. // if miConfig.MdtrtareaAdmvs == "320921" {
  3104. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3105. // } else {
  3106. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3107. // }
  3108. //
  3109. // resp, _ := client.Do(req)
  3110. // defer resp.Body.Close()
  3111. // body, ioErr := ioutil.ReadAll(resp.Body)
  3112. // if ioErr != nil {
  3113. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3114. // }
  3115. // var respJSON map[string]interface{}
  3116. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3117. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3119. // return
  3120. // }
  3121. // var resSix10265 ResultSix10265 //1101结果
  3122. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3123. // result, _ := json.Marshal(respJSON)
  3124. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3125. // utils.ErrorLog("解析失败:%v", err)
  3126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3127. // return
  3128. // }
  3129. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3130. // //res.Output = resSix10265.Output
  3131. // res.ErrMsg = resSix10265.ErrMsg
  3132. // res.Cainfo = resSix10265.Cainfo
  3133. // res.WarnMsg = resSix10265.WarnMsg
  3134. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3135. // res.Infcode = infocode
  3136. // }
  3137. //
  3138. // if res.Infcode == 0 {
  3139. // item.IsSale = 0
  3140. // item.SaleDate = ""
  3141. // service.SaveDF(item)
  3142. // } else {
  3143. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3144. // }
  3145. // }
  3146. // if item.IsSale == 2 && item.IsChange == 0 {
  3147. //
  3148. // var res FJ3507Result
  3149. // var struct3507 models.Struct3507
  3150. // struct3507.FixmedinsBchno = item.Bchno
  3151. // struct3507.InvDataType = "4"
  3152. // struct3507.Opter = roles.UserName
  3153. // struct3507.FixmedinsCode = miConfig.Code
  3154. // struct3507.Code = miConfig.Code
  3155. //
  3156. // struct3507.OrgName = miConfig.OrgName
  3157. // struct3507.AccessKey = miConfig.AccessKey
  3158. // struct3507.RequestUrl = miConfig.Url
  3159. // struct3507.SecretKey = miConfig.SecretKey
  3160. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3161. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3162. // struct3507.Url = miConfig.Url
  3163. // struct3507.AppId = miConfig.Cainfo
  3164. // struct3507.AppSecret = miConfig.AppSecret
  3165. // struct3507.Enckey = miConfig.EncKey
  3166. // struct3507.SignKey = miConfig.SignKey
  3167. // struct3507.SecretKey = miConfig.SecretKey
  3168. // //result, result1, _ := service.FJyb3507(struct3507)
  3169. // //saveLog(result, result1, "3507", "3507")
  3170. // //
  3171. // //var respJSON3 map[string]interface{}
  3172. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3173. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3174. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3175. // // return
  3176. // //}
  3177. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  3178. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3179. // // utils.ErrorLog("解析失败:%v", err)
  3180. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. // // return
  3182. // //}
  3183. // if miConfig.MdtrtareaAdmvs == "350500" {
  3184. // result, result1, _ := service.FJyb3507(struct3507)
  3185. // saveLog(result, result1, "3507", "3507")
  3186. // var respJSON2 map[string]interface{}
  3187. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3188. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3190. // return
  3191. // }
  3192. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3193. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3194. // utils.ErrorLog("解析失败:%v", err)
  3195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3196. // return
  3197. // }
  3198. // } else {
  3199. // data := make(map[string]interface{})
  3200. // data["struct_3507s"] = struct3507
  3201. // client := &http.Client{}
  3202. // bytesData, _ := json.Marshal(data)
  3203. // var req *http.Request
  3204. // if miConfig.MdtrtareaAdmvs == "320921" {
  3205. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3206. // } else {
  3207. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3208. // }
  3209. //
  3210. // resp, _ := client.Do(req)
  3211. // defer resp.Body.Close()
  3212. // body, ioErr := ioutil.ReadAll(resp.Body)
  3213. // if ioErr != nil {
  3214. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3215. // }
  3216. // var respJSON map[string]interface{}
  3217. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3218. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3220. // return
  3221. // }
  3222. // var resSix10265 ResultSix10265 //1101结果
  3223. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3224. // result, _ := json.Marshal(respJSON)
  3225. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3226. // utils.ErrorLog("解析失败:%v", err)
  3227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3228. // return
  3229. // }
  3230. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3231. // //res.Output = resSix10265.Output
  3232. // res.ErrMsg = resSix10265.ErrMsg
  3233. // res.Cainfo = resSix10265.Cainfo
  3234. // res.WarnMsg = resSix10265.WarnMsg
  3235. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3236. // res.Infcode = infocode
  3237. // }
  3238. //
  3239. // if res.Infcode == 0 {
  3240. // item.IsSale = 0
  3241. // item.SaleDate = ""
  3242. // item.Bchno = ""
  3243. //
  3244. // service.SaveDF(item)
  3245. // } else {
  3246. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3247. // }
  3248. // }
  3249. // if item.IsSale == 0 && item.IsChange == 1 {
  3250. //
  3251. // var res FJ3507Result
  3252. // var struct3507 models.Struct3507
  3253. // struct3507.FixmedinsBchno = item.BgBchno
  3254. // struct3507.InvDataType = "2"
  3255. // struct3507.Opter = roles.UserName
  3256. // struct3507.FixmedinsCode = miConfig.Code
  3257. // struct3507.Code = miConfig.Code
  3258. //
  3259. // struct3507.OrgName = miConfig.OrgName
  3260. // struct3507.AccessKey = miConfig.AccessKey
  3261. // struct3507.RequestUrl = miConfig.Url
  3262. // struct3507.SecretKey = miConfig.SecretKey
  3263. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3264. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3265. // struct3507.Url = miConfig.Url
  3266. // struct3507.AppId = miConfig.Cainfo
  3267. // struct3507.AppSecret = miConfig.AppSecret
  3268. // struct3507.Enckey = miConfig.EncKey
  3269. // struct3507.SignKey = miConfig.SignKey
  3270. // struct3507.SecretKey = miConfig.SecretKey
  3271. // //result, result1, _ := service.FJyb3507(struct3507)
  3272. // //saveLog(result, result1, "3507", "3507")
  3273. // //
  3274. // //var respJSON3 map[string]interface{}
  3275. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3276. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3277. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3278. // // return
  3279. // //}
  3280. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  3281. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3282. // // utils.ErrorLog("解析失败:%v", err)
  3283. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3284. // // return
  3285. // //}
  3286. // if miConfig.MdtrtareaAdmvs == "350500" {
  3287. // result, result1, _ := service.FJyb3507(struct3507)
  3288. // saveLog(result, result1, "3507", "3507")
  3289. // var respJSON2 map[string]interface{}
  3290. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3291. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3293. // return
  3294. // }
  3295. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3296. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3297. // utils.ErrorLog("解析失败:%v", err)
  3298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3299. // return
  3300. // }
  3301. // } else {
  3302. // data := make(map[string]interface{})
  3303. // data["struct_3507s"] = struct3507
  3304. // client := &http.Client{}
  3305. // bytesData, _ := json.Marshal(data)
  3306. // var req *http.Request
  3307. // if miConfig.MdtrtareaAdmvs == "320921" {
  3308. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3309. // } else {
  3310. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3311. // }
  3312. //
  3313. // resp, _ := client.Do(req)
  3314. // defer resp.Body.Close()
  3315. // body, ioErr := ioutil.ReadAll(resp.Body)
  3316. // if ioErr != nil {
  3317. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3318. // }
  3319. // var respJSON map[string]interface{}
  3320. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3321. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. // return
  3324. // }
  3325. // var resSix10265 ResultSix10265 //1101结果
  3326. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3327. // result, _ := json.Marshal(respJSON)
  3328. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3329. // utils.ErrorLog("解析失败:%v", err)
  3330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3331. // return
  3332. // }
  3333. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3334. // //res.Output = resSix10265.Output
  3335. // res.ErrMsg = resSix10265.ErrMsg
  3336. // res.Cainfo = resSix10265.Cainfo
  3337. // res.WarnMsg = resSix10265.WarnMsg
  3338. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3339. // res.Infcode = infocode
  3340. // }
  3341. //
  3342. // if res.Infcode == 0 {
  3343. // item.IsChange = 0
  3344. // item.BgBchno = ""
  3345. // service.SaveDF2(item)
  3346. // } else {
  3347. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3348. // }
  3349. // }
  3350. // }
  3351. // if len(err) == 0 {
  3352. // c.ServeSuccessJSON(map[string]interface{}{
  3353. // "msg": "删除销售变更成功",
  3354. // })
  3355. //
  3356. // } else {
  3357. // c.ServeSuccessJSON(map[string]interface{}{
  3358. // "failed_code": -10,
  3359. // "msg": err,
  3360. // })
  3361. //
  3362. // }
  3363. //
  3364. //}
  3365. // 获取当天起止时间戳
  3366. func GetNowTime() (int64, int64) {
  3367. t := time.Now()
  3368. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3369. timesamp := addTime.Unix()
  3370. return timesamp, timesamp + 86399
  3371. }
  3372. func (c *HisApiController) ChangeDrugfour() {
  3373. patient_id, _ := c.GetInt64("patient_id")
  3374. admin_user_id, _ := c.GetInt64("admin_user_id")
  3375. //id_arr := strings.Split(ids, ",")
  3376. times := c.GetString("time", "")
  3377. timeLayout := "2006-01-02"
  3378. loc, _ := time.LoadLocation("Local")
  3379. var stime, etime int64
  3380. if times == "" {
  3381. stime, etime = GetNowTime()
  3382. } else {
  3383. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3384. stime = stmp.Unix()
  3385. etime = stime + 86399
  3386. }
  3387. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3388. var flows []*models.DrugFlow
  3389. for _, item := range advicelist {
  3390. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, stime, c.GetAdminUserInfo().CurrentOrgId)
  3391. flows = append(flows, flow...)
  3392. }
  3393. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3394. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3395. var err []string
  3396. for _, item := range flows {
  3397. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3398. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3399. if prescription.OrderStatus == 2 {
  3400. //已经结算
  3401. //判断是否已经销售
  3402. if item.IsSale == 1 { //是否已经销售,1是 0否
  3403. //是否已经变更 1是 0否
  3404. //if item.IsChange == 0 { //没变更,进行变更操作
  3405. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3406. //
  3407. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3408. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3409. // var respJSON3 map[string]interface{}
  3410. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3411. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. // return
  3414. // }
  3415. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3416. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3417. // utils.ErrorLog("解析失败:%v", err)
  3418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. // return
  3420. // }
  3421. // if res3.Infcode == 0 {
  3422. // item.IsChange = 1
  3423. // item.BgBchno = bg_number
  3424. // service.SaveDF2(item)
  3425. // } else {
  3426. //
  3427. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3428. // }
  3429. //}
  3430. } else { //没销售,
  3431. var res FJ3507Result
  3432. var res3507for10188 FJ3507ResultFor10188
  3433. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3434. //进行商品销售接口
  3435. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3436. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3437. var respJSON3 map[string]interface{}
  3438. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3441. return
  3442. }
  3443. userJSONBytes3, _ := json.Marshal(respJSON3)
  3444. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3445. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3446. utils.ErrorLog("解析失败:%v", err)
  3447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3448. return
  3449. }
  3450. //if res3507for10188.Infcode
  3451. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3452. //res.Output = resSix10265.Output
  3453. res.ErrMsg = res3507for10188.ErrMsg
  3454. res.Cainfo = res3507for10188.Cainfo
  3455. res.WarnMsg = res3507for10188.WarnMsg
  3456. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3457. res.Infcode = infocode
  3458. } else {
  3459. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3460. utils.ErrorLog("解析失败:%v", err)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. }
  3465. if res.Infcode == 0 {
  3466. item.IsSale = 1
  3467. item.Bchno = number
  3468. item.SaleDate = time.Now().Format("2006-01-02")
  3469. service.SaveDF(item)
  3470. //if err5 == nil {
  3471. // if item.IsChange == 0 { //没变更,进行变更操作
  3472. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3473. //
  3474. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3475. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3476. //
  3477. // var respJSON3 map[string]interface{}
  3478. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3481. // return
  3482. // }
  3483. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3484. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3485. // utils.ErrorLog("解析失败:%v", err)
  3486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3487. // return
  3488. // }
  3489. // //if res3507for10188.Infcode
  3490. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3491. // //res.Output = resSix10265.Output
  3492. // res3.ErrMsg = res3507for10188.ErrMsg
  3493. // res3.Cainfo = res3507for10188.Cainfo
  3494. // res3.WarnMsg = res3507for10188.WarnMsg
  3495. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3496. // res3.Infcode = infocode
  3497. // } else {
  3498. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3499. // utils.ErrorLog("解析失败:%v", err)
  3500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. // return
  3502. // }
  3503. // }
  3504. // if res3.Infcode == 0 {
  3505. // item.IsChange = 1
  3506. // item.BgBchno = bg_number
  3507. // service.SaveDF2(item)
  3508. // } else {
  3509. //
  3510. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3511. // }
  3512. // }
  3513. //}
  3514. } else {
  3515. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3516. }
  3517. }
  3518. } else { //还没结,提示用户去结算,并药品追溯上传
  3519. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3520. }
  3521. }
  3522. }
  3523. if len(err) == 0 {
  3524. c.ServeSuccessJSON(map[string]interface{}{
  3525. "msg": "销售成功",
  3526. })
  3527. } else {
  3528. c.ServeSuccessJSON(map[string]interface{}{
  3529. "failed_code": -10,
  3530. "msg": err,
  3531. })
  3532. }
  3533. }
  3534. //func (c *HisApiController) ChangeDrugfour() {
  3535. // patient_id, _ := c.GetInt64("patient_id")
  3536. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3537. // //id_arr := strings.Split(ids, ",")
  3538. // times := c.GetString("time", "")
  3539. // timeLayout := "2006-01-02"
  3540. // loc, _ := time.LoadLocation("Local")
  3541. // var stime, etime int64
  3542. // if times == "" {
  3543. // stime, etime = GetNowTime()
  3544. // } else {
  3545. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3546. // stime = stmp.Unix()
  3547. // etime = stime + 86399
  3548. // }
  3549. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3550. // var flows []*models.DrugFlow
  3551. // for _, item := range advicelist {
  3552. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3553. // flows = append(flows, flow...)
  3554. // }
  3555. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3556. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3557. // var err []string
  3558. //
  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. //
  3571. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3572. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3573. // var respJSON3 map[string]interface{}
  3574. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3575. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3577. // return
  3578. // }
  3579. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3580. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3581. // utils.ErrorLog("解析失败:%v", err)
  3582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3583. // return
  3584. // }
  3585. // if res3.Infcode == 0 {
  3586. // item.IsChange = 1
  3587. // item.BgBchno = bg_number
  3588. // service.SaveDF2(item)
  3589. // } else {
  3590. //
  3591. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3592. // }
  3593. // }
  3594. // } else { //没销售,
  3595. // var res FJ3507Result
  3596. // var res3507for10188 FJ3507ResultFor10188
  3597. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3598. //
  3599. // //进行商品销售接口
  3600. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3601. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3602. // var respJSON3 map[string]interface{}
  3603. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3604. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. // return
  3607. // }
  3608. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3609. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3610. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3611. // utils.ErrorLog("解析失败:%v", err)
  3612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3613. // return
  3614. // }
  3615. // //if res3507for10188.Infcode
  3616. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3617. // //res.Output = resSix10265.Output
  3618. // res.ErrMsg = res3507for10188.ErrMsg
  3619. // res.Cainfo = res3507for10188.Cainfo
  3620. // res.WarnMsg = res3507for10188.WarnMsg
  3621. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3622. // res.Infcode = infocode
  3623. // } else {
  3624. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3625. // utils.ErrorLog("解析失败:%v", err)
  3626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3627. // return
  3628. // }
  3629. //
  3630. // }
  3631. // if res.Infcode == 0 {
  3632. // item.IsSale = 1
  3633. // item.Bchno = number
  3634. // item.SaleDate = time.Now().Format("2006-01-02")
  3635. //
  3636. // err5 := service.SaveDF(item)
  3637. // if err5 == nil {
  3638. // if item.IsChange == 0 { //没变更,进行变更操作
  3639. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3640. //
  3641. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3642. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3643. //
  3644. // var respJSON3 map[string]interface{}
  3645. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3646. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3648. // return
  3649. // }
  3650. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3651. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3652. // utils.ErrorLog("解析失败:%v", err)
  3653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3654. // return
  3655. // }
  3656. // //if res3507for10188.Infcode
  3657. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3658. // //res.Output = resSix10265.Output
  3659. // res3.ErrMsg = res3507for10188.ErrMsg
  3660. // res3.Cainfo = res3507for10188.Cainfo
  3661. // res3.WarnMsg = res3507for10188.WarnMsg
  3662. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3663. // res3.Infcode = infocode
  3664. // } else {
  3665. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3666. // utils.ErrorLog("解析失败:%v", err)
  3667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. // return
  3669. // }
  3670. // }
  3671. // if res3.Infcode == 0 {
  3672. // item.IsChange = 1
  3673. // item.BgBchno = bg_number
  3674. // service.SaveDF2(item)
  3675. // } else {
  3676. //
  3677. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3678. // }
  3679. // }
  3680. // }
  3681. // } else {
  3682. //
  3683. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3684. // }
  3685. // }
  3686. //
  3687. // } else { //还没结,提示用户去结算,并药品追溯上传
  3688. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3689. // }
  3690. // }
  3691. // }
  3692. // if len(err) == 0 {
  3693. // c.ServeSuccessJSON(map[string]interface{}{
  3694. // "msg": "销售变更成功",
  3695. // })
  3696. // } else {
  3697. // c.ServeSuccessJSON(map[string]interface{}{
  3698. // "failed_code": -10,
  3699. // "msg": err,
  3700. // })
  3701. // }
  3702. //}
  3703. func (c *HisApiController) ChangeDrug() {
  3704. ids := c.GetString("ids")
  3705. id_arr := strings.Split(ids, ",")
  3706. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3707. admin_user_id, _ := c.GetInt64("admin_user_id")
  3708. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3710. var err []string
  3711. for _, item := range flows {
  3712. var res3 ResultSix
  3713. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3714. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3715. if prescription.OrderStatus == 2 {
  3716. //已经结算
  3717. //判断是否已经销售
  3718. if item.IsSale == 1 { //是否已经销售,1是 0否
  3719. //是否已经变更 1是 0否
  3720. if item.IsChange == 0 { //没变更,进行变更操作
  3721. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3722. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3723. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3724. var respJSON3 map[string]interface{}
  3725. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3728. return
  3729. }
  3730. userJSONBytes3, _ := json.Marshal(respJSON3)
  3731. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3732. utils.ErrorLog("解析失败:%v", err)
  3733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3734. return
  3735. }
  3736. if res3.Infcode == 0 {
  3737. item.IsChange = 1
  3738. item.BgBchno = bg_number
  3739. service.SaveDF2(item)
  3740. } else {
  3741. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3742. }
  3743. }
  3744. } else { //没销售,
  3745. var res FJ3507Result
  3746. var res3507for10188 FJ3507ResultFor10188
  3747. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3748. //进行商品销售接口
  3749. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3750. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3751. var respJSON3 map[string]interface{}
  3752. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3755. return
  3756. }
  3757. userJSONBytes3, _ := json.Marshal(respJSON3)
  3758. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3759. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3760. utils.ErrorLog("解析失败:%v", err)
  3761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. return
  3763. }
  3764. //if res3507for10188.Infcode
  3765. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3766. //res.Output = resSix10265.Output
  3767. res.ErrMsg = res3507for10188.ErrMsg
  3768. res.Cainfo = res3507for10188.Cainfo
  3769. res.WarnMsg = res3507for10188.WarnMsg
  3770. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3771. res.Infcode = infocode
  3772. } else {
  3773. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3774. utils.ErrorLog("解析失败:%v", err)
  3775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3776. return
  3777. }
  3778. }
  3779. if res.Infcode == 0 {
  3780. item.IsSale = 1
  3781. item.Bchno = number
  3782. item.SaleDate = time.Now().Format("2006-01-02")
  3783. err5 := service.SaveDF(item)
  3784. if err5 == nil {
  3785. if item.IsChange == 0 { //没变更,进行变更操作
  3786. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3787. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3788. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3789. var respJSON3 map[string]interface{}
  3790. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3793. return
  3794. }
  3795. userJSONBytes3, _ := json.Marshal(respJSON3)
  3796. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3797. utils.ErrorLog("解析失败:%v", err)
  3798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3799. return
  3800. }
  3801. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3802. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3803. utils.ErrorLog("解析失败:%v", err)
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3805. return
  3806. }
  3807. //if res3507for10188.Infcode
  3808. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3809. //res.Output = resSix10265.Output
  3810. res3.ErrMsg = res3507for10188.ErrMsg
  3811. res3.Cainfo = res3507for10188.Cainfo
  3812. res3.WarnMsg = res3507for10188.WarnMsg
  3813. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3814. res3.Infcode = infocode
  3815. } else {
  3816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3817. utils.ErrorLog("解析失败:%v", err)
  3818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3819. return
  3820. }
  3821. }
  3822. if res3.Infcode == 0 {
  3823. item.IsChange = 1
  3824. item.BgBchno = bg_number
  3825. service.SaveDF2(item)
  3826. } else {
  3827. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3828. }
  3829. }
  3830. }
  3831. } else {
  3832. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3833. }
  3834. }
  3835. } else { //还没结算
  3836. var res3507for10188 FJ3507ResultFor10188
  3837. if item.IsChange == 0 { //没变更,进行变更操作
  3838. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3839. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3840. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3841. var respJSON3 map[string]interface{}
  3842. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3845. return
  3846. }
  3847. userJSONBytes3, _ := json.Marshal(respJSON3)
  3848. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3849. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3850. utils.ErrorLog("解析失败:%v", err)
  3851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3852. return
  3853. }
  3854. //if res3507for10188.Infcode
  3855. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3856. //res.Output = resSix10265.Output
  3857. res3.ErrMsg = res3507for10188.ErrMsg
  3858. res3.Cainfo = res3507for10188.Cainfo
  3859. res3.WarnMsg = res3507for10188.WarnMsg
  3860. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3861. res3.Infcode = infocode
  3862. } else {
  3863. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3864. utils.ErrorLog("解析失败:%v", err)
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. return
  3867. }
  3868. }
  3869. if res3.Infcode == 0 {
  3870. item.IsChange = 1
  3871. item.BgBchno = bg_number
  3872. service.SaveDF2(item)
  3873. } else {
  3874. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3875. }
  3876. }
  3877. }
  3878. } else if item.ConsumableType == 7 {
  3879. var res3507for10188 FJ3507ResultFor10188
  3880. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3881. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3882. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3883. //判断是否已经销售
  3884. if item.IsSale == 2 { //是否已经销售,1是 0否
  3885. //是否已经变更 1是 0否
  3886. if item.IsChange == 0 { //没变更,进行变更操作
  3887. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3888. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3889. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3890. var respJSON3 map[string]interface{}
  3891. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3894. return
  3895. }
  3896. userJSONBytes3, _ := json.Marshal(respJSON3)
  3897. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3898. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3899. utils.ErrorLog("解析失败:%v", err)
  3900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3901. return
  3902. }
  3903. //if res3507for10188.Infcode
  3904. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3905. //res.Output = resSix10265.Output
  3906. res3.ErrMsg = res3507for10188.ErrMsg
  3907. res3.Cainfo = res3507for10188.Cainfo
  3908. res3.WarnMsg = res3507for10188.WarnMsg
  3909. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3910. res3.Infcode = infocode
  3911. } else {
  3912. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3913. utils.ErrorLog("解析失败:%v", err)
  3914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. return
  3916. }
  3917. }
  3918. if res3.Infcode == 0 {
  3919. item.IsChange = 1
  3920. item.BgBchno = bg_number
  3921. service.SaveDF2(item)
  3922. } else {
  3923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3924. }
  3925. }
  3926. } else { //没销售,
  3927. //进行商品销售退货接口
  3928. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3929. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3930. saveLog(result111, result222, "3506", "销售退货")
  3931. var res7 FJ3507Result
  3932. //进行商品销售接口
  3933. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3934. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3935. var respJSON3 map[string]interface{}
  3936. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. userJSONBytes3, _ := json.Marshal(respJSON3)
  3942. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3943. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3944. utils.ErrorLog("解析失败:%v", err)
  3945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. return
  3947. }
  3948. //if res3507for10188.Infcode
  3949. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3950. //res.Output = resSix10265.Output
  3951. res7.ErrMsg = res3507for10188.ErrMsg
  3952. res7.Cainfo = res3507for10188.Cainfo
  3953. res7.WarnMsg = res3507for10188.WarnMsg
  3954. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3955. res7.Infcode = infocode
  3956. } else {
  3957. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3958. utils.ErrorLog("解析失败:%v", err)
  3959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3960. return
  3961. }
  3962. }
  3963. if res7.Infcode == 0 {
  3964. item.IsSale = 2
  3965. item.SaleDate = item.SaleDate
  3966. item.Bchno = number
  3967. service.SaveDF(item)
  3968. if item.IsChange == 0 { //没变更,进行变更操作
  3969. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3970. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3971. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3972. var respJSON3 map[string]interface{}
  3973. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3976. return
  3977. }
  3978. userJSONBytes3, _ := json.Marshal(respJSON3)
  3979. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3980. // utils.ErrorLog("解析失败:%v", err)
  3981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3982. // return
  3983. //}
  3984. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3985. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3986. utils.ErrorLog("解析失败:%v", err)
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. //if res3507for10188.Infcode
  3991. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3992. //res.Output = resSix10265.Output
  3993. res3.ErrMsg = res3507for10188.ErrMsg
  3994. res3.Cainfo = res3507for10188.Cainfo
  3995. res3.WarnMsg = res3507for10188.WarnMsg
  3996. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3997. res3.Infcode = infocode
  3998. } else {
  3999. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4000. utils.ErrorLog("解析失败:%v", err)
  4001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. return
  4003. }
  4004. }
  4005. if res3.Infcode == 0 {
  4006. item.IsChange = 1
  4007. item.BgBchno = bg_number
  4008. service.SaveDF2(item)
  4009. } else {
  4010. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4011. }
  4012. }
  4013. } else {
  4014. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4015. }
  4016. }
  4017. } else { //还没结算
  4018. if item.IsChange == 0 { //没变更,进行变更操作
  4019. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4020. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4021. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4022. var respJSON3 map[string]interface{}
  4023. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4026. return
  4027. }
  4028. userJSONBytes3, _ := json.Marshal(respJSON3)
  4029. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4030. // utils.ErrorLog("解析失败:%v", err)
  4031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4032. // return
  4033. //}
  4034. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4035. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4036. utils.ErrorLog("解析失败:%v", err)
  4037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4038. return
  4039. }
  4040. //if res3507for10188.Infcode
  4041. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4042. //res.Output = resSix10265.Output
  4043. res3.ErrMsg = res3507for10188.ErrMsg
  4044. res3.Cainfo = res3507for10188.Cainfo
  4045. res3.WarnMsg = res3507for10188.WarnMsg
  4046. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4047. res3.Infcode = infocode
  4048. } else {
  4049. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4050. utils.ErrorLog("解析失败:%v", err)
  4051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4052. return
  4053. }
  4054. }
  4055. if res3.Infcode == 0 {
  4056. item.IsChange = 1
  4057. item.BgBchno = bg_number
  4058. service.SaveDF2(item)
  4059. } else {
  4060. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4061. }
  4062. }
  4063. }
  4064. }
  4065. }
  4066. if len(err) == 0 {
  4067. c.ServeSuccessJSON(map[string]interface{}{
  4068. "msg": "销售变更成功",
  4069. })
  4070. } else {
  4071. c.ServeSuccessJSON(map[string]interface{}{
  4072. "failed_code": -10,
  4073. "msg": err,
  4074. })
  4075. }
  4076. }
  4077. func (c *HisApiController) ChangeDrugtwo() {
  4078. //ids := c.GetString("ids")
  4079. //id_arr := strings.Split(ids, ",")
  4080. flows, _ := service.GetNewDrugFlowInfothree123()
  4081. admin_user_id, _ := c.GetInt64("admin_user_id")
  4082. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4083. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4084. var err []string
  4085. for _, item := range flows {
  4086. var res3 ResultSix
  4087. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4088. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4089. if prescription.OrderStatus == 2 {
  4090. //已经结算
  4091. //判断是否已经销售
  4092. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4093. // //是否已经变更 1是 0否
  4094. // if item.IsChange == 0 { //没变更,进行变更操作
  4095. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4096. //
  4097. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4098. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4099. // var respJSON3 map[string]interface{}
  4100. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4101. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4102. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. // return
  4104. // }
  4105. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4106. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4107. // utils.ErrorLog("解析失败:%v", err)
  4108. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4109. // return
  4110. // }
  4111. // if res3.Infcode == 0 {
  4112. // item.IsChange = 1
  4113. // item.BgBchno = bg_number
  4114. // service.SaveDF2(item)
  4115. // } else {
  4116. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4117. // }
  4118. // }
  4119. //}
  4120. //else
  4121. { //没销售,
  4122. var res FJ3507Result
  4123. var res3507for10188 FJ3507ResultFor10188
  4124. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4125. //进行商品销售接口
  4126. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4127. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4128. var respJSON3 map[string]interface{}
  4129. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4132. return
  4133. }
  4134. userJSONBytes3, _ := json.Marshal(respJSON3)
  4135. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4136. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. //if res3507for10188.Infcode
  4142. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4143. //res.Output = resSix10265.Output
  4144. res.ErrMsg = res3507for10188.ErrMsg
  4145. res.Cainfo = res3507for10188.Cainfo
  4146. res.WarnMsg = res3507for10188.WarnMsg
  4147. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4148. res.Infcode = infocode
  4149. } else {
  4150. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4151. utils.ErrorLog("解析失败:%v", err)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. }
  4156. if res.Infcode == 0 {
  4157. item.IsSale = 1
  4158. item.Bchno = number
  4159. item.SaleDate = time.Now().Format("2006-01-02")
  4160. service.SaveDF(item)
  4161. //if err5 == nil {
  4162. // if item.IsChange == 0 { //没变更,进行变更操作
  4163. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4164. //
  4165. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4166. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4167. //
  4168. // var respJSON3 map[string]interface{}
  4169. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4170. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4172. // return
  4173. // }
  4174. //
  4175. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4176. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4177. // utils.ErrorLog("解析失败:%v", err)
  4178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. // return
  4180. // }
  4181. // //if res3507for10188.Infcode
  4182. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4183. // //res.Output = resSix10265.Output
  4184. // res3.ErrMsg = res3507for10188.ErrMsg
  4185. // res3.Cainfo = res3507for10188.Cainfo
  4186. // res3.WarnMsg = res3507for10188.WarnMsg
  4187. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4188. // res3.Infcode = infocode
  4189. // } else {
  4190. //
  4191. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4192. // utils.ErrorLog("解析失败:%v", err)
  4193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4194. // return
  4195. // }
  4196. //
  4197. // }
  4198. //
  4199. // if res3.Infcode == 0 {
  4200. // item.IsChange = 1
  4201. // item.BgBchno = bg_number
  4202. // service.SaveDF2(item)
  4203. // } else {
  4204. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4205. // }
  4206. // }
  4207. //}
  4208. } else {
  4209. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4210. }
  4211. }
  4212. } else
  4213. { //还没结算
  4214. var res3507for10188 FJ3507ResultFor10188
  4215. if item.IsChange == 0 { //没变更,进行变更操作
  4216. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4217. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4218. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4219. var respJSON3 map[string]interface{}
  4220. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4223. return
  4224. }
  4225. userJSONBytes3, _ := json.Marshal(respJSON3)
  4226. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4227. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4228. utils.ErrorLog("解析失败:%v", err)
  4229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4230. return
  4231. }
  4232. //if res3507for10188.Infcode
  4233. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4234. //res.Output = resSix10265.Output
  4235. res3.ErrMsg = res3507for10188.ErrMsg
  4236. res3.Cainfo = res3507for10188.Cainfo
  4237. res3.WarnMsg = res3507for10188.WarnMsg
  4238. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4239. res3.Infcode = infocode
  4240. } else {
  4241. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4242. utils.ErrorLog("解析失败:%v", err)
  4243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4244. return
  4245. }
  4246. }
  4247. if res3.Infcode == 0 {
  4248. item.IsChange = 1
  4249. item.BgBchno = bg_number
  4250. service.SaveDF2(item)
  4251. } else {
  4252. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4253. }
  4254. }
  4255. }
  4256. }
  4257. //if item.ConsumableType == 7 {
  4258. // var res3507for10188 FJ3507ResultFor10188
  4259. //
  4260. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4261. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4262. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4263. // //判断是否已经销售
  4264. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4265. // //是否已经变更 1是 0否
  4266. // if item.IsChange == 0 { //没变更,进行变更操作
  4267. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4268. //
  4269. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4270. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4271. //
  4272. // var respJSON3 map[string]interface{}
  4273. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4274. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. // return
  4277. // }
  4278. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4279. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4280. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4281. // utils.ErrorLog("解析失败:%v", err)
  4282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4283. // return
  4284. // }
  4285. // //if res3507for10188.Infcode
  4286. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4287. // //res.Output = resSix10265.Output
  4288. // res3.ErrMsg = res3507for10188.ErrMsg
  4289. // res3.Cainfo = res3507for10188.Cainfo
  4290. // res3.WarnMsg = res3507for10188.WarnMsg
  4291. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4292. // res3.Infcode = infocode
  4293. // } else {
  4294. //
  4295. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4296. // utils.ErrorLog("解析失败:%v", err)
  4297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4298. // return
  4299. // }
  4300. //
  4301. // }
  4302. // if res3.Infcode == 0 {
  4303. // item.IsChange = 1
  4304. // item.BgBchno = bg_number
  4305. // service.SaveDF2(item)
  4306. // } else {
  4307. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4308. // }
  4309. // }
  4310. // } else { //没销售,
  4311. // //进行商品销售退货接口
  4312. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4313. //
  4314. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4315. // saveLog(result111, result222, "3506", "销售退货")
  4316. // var res7 FJ3507Result
  4317. //
  4318. // //进行商品销售接口
  4319. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4320. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4321. // var respJSON3 map[string]interface{}
  4322. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4323. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4325. // return
  4326. // }
  4327. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4328. //
  4329. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4330. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4331. // utils.ErrorLog("解析失败:%v", err)
  4332. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4333. // return
  4334. // }
  4335. // //if res3507for10188.Infcode
  4336. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4337. // //res.Output = resSix10265.Output
  4338. // res7.ErrMsg = res3507for10188.ErrMsg
  4339. // res7.Cainfo = res3507for10188.Cainfo
  4340. // res7.WarnMsg = res3507for10188.WarnMsg
  4341. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4342. // res7.Infcode = infocode
  4343. // } else {
  4344. //
  4345. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4346. // utils.ErrorLog("解析失败:%v", err)
  4347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4348. // return
  4349. // }
  4350. //
  4351. // }
  4352. // if res7.Infcode == 0 {
  4353. // item.IsSale = 2
  4354. // item.SaleDate = item.SaleDate
  4355. // item.Bchno = number
  4356. // service.SaveDF(item)
  4357. // if item.IsChange == 0 { //没变更,进行变更操作
  4358. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4359. //
  4360. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4361. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4362. //
  4363. // var respJSON3 map[string]interface{}
  4364. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4365. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. // return
  4368. // }
  4369. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4370. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4371. // // utils.ErrorLog("解析失败:%v", err)
  4372. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4373. // // return
  4374. // //}
  4375. //
  4376. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4377. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4378. // utils.ErrorLog("解析失败:%v", err)
  4379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4380. // return
  4381. // }
  4382. // //if res3507for10188.Infcode
  4383. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4384. // //res.Output = resSix10265.Output
  4385. // res3.ErrMsg = res3507for10188.ErrMsg
  4386. // res3.Cainfo = res3507for10188.Cainfo
  4387. // res3.WarnMsg = res3507for10188.WarnMsg
  4388. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4389. // res3.Infcode = infocode
  4390. // } else {
  4391. //
  4392. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4393. // utils.ErrorLog("解析失败:%v", err)
  4394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4395. // return
  4396. // }
  4397. //
  4398. // }
  4399. // if res3.Infcode == 0 {
  4400. // item.IsChange = 1
  4401. // item.BgBchno = bg_number
  4402. // service.SaveDF2(item)
  4403. // } else {
  4404. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4405. // }
  4406. // }
  4407. // } else {
  4408. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4409. // }
  4410. // }
  4411. // } else { //还没结算
  4412. // if item.IsChange == 0 { //没变更,进行变更操作
  4413. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4414. //
  4415. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4416. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4417. //
  4418. // var respJSON3 map[string]interface{}
  4419. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4420. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4422. // return
  4423. // }
  4424. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4425. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4426. // // utils.ErrorLog("解析失败:%v", err)
  4427. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4428. // // return
  4429. // //}
  4430. //
  4431. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4432. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4433. // utils.ErrorLog("解析失败:%v", err)
  4434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4435. // return
  4436. // }
  4437. // //if res3507for10188.Infcode
  4438. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4439. // //res.Output = resSix10265.Output
  4440. // res3.ErrMsg = res3507for10188.ErrMsg
  4441. // res3.Cainfo = res3507for10188.Cainfo
  4442. // res3.WarnMsg = res3507for10188.WarnMsg
  4443. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4444. // res3.Infcode = infocode
  4445. // } else {
  4446. //
  4447. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4448. // utils.ErrorLog("解析失败:%v", err)
  4449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4450. // return
  4451. // }
  4452. //
  4453. // }
  4454. // if res3.Infcode == 0 {
  4455. // item.IsChange = 1
  4456. // item.BgBchno = bg_number
  4457. // service.SaveDF2(item)
  4458. // } else {
  4459. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4460. // }
  4461. // }
  4462. // }
  4463. //}
  4464. }
  4465. if len(err) == 0 {
  4466. c.ServeSuccessJSON(map[string]interface{}{
  4467. "msg": "销售变更成功",
  4468. })
  4469. } else {
  4470. c.ServeSuccessJSON(map[string]interface{}{
  4471. "failed_code": -10,
  4472. "msg": err,
  4473. })
  4474. }
  4475. }
  4476. func (c *HisApiController) ChangeDrugthree() {
  4477. //ids := c.GetString("ids")
  4478. //id_arr := strings.Split(ids, ",")
  4479. flows, _ := service.GetNewDrugFlowInfothree()
  4480. admin_user_id, _ := c.GetInt64("admin_user_id")
  4481. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4482. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4483. var err []string
  4484. for _, item := range flows {
  4485. var res3 ResultSix
  4486. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4487. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4488. if prescription.OrderStatus == 2 {
  4489. //已经结算
  4490. //判断是否已经销售
  4491. if item.IsSale == 1 { //是否已经销售,1是 0否
  4492. //是否已经变更 1是 0否
  4493. if item.IsChange == 0 { //没变更,进行变更操作
  4494. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4495. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4496. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4497. var respJSON3 map[string]interface{}
  4498. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4501. return
  4502. }
  4503. userJSONBytes3, _ := json.Marshal(respJSON3)
  4504. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4505. utils.ErrorLog("解析失败:%v", err)
  4506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4507. return
  4508. }
  4509. if res3.Infcode == 0 {
  4510. item.IsChange = 1
  4511. item.BgBchno = bg_number
  4512. service.SaveDF2(item)
  4513. } else {
  4514. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4515. }
  4516. }
  4517. } else { //没销售,
  4518. var res FJ3507Result
  4519. var res3507for10188 FJ3507ResultFor10188
  4520. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4521. //进行商品销售接口
  4522. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4523. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4524. var respJSON3 map[string]interface{}
  4525. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4528. return
  4529. }
  4530. userJSONBytes3, _ := json.Marshal(respJSON3)
  4531. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4532. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4533. utils.ErrorLog("解析失败:%v", err)
  4534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4535. return
  4536. }
  4537. //if res3507for10188.Infcode
  4538. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4539. //res.Output = resSix10265.Output
  4540. res.ErrMsg = res3507for10188.ErrMsg
  4541. res.Cainfo = res3507for10188.Cainfo
  4542. res.WarnMsg = res3507for10188.WarnMsg
  4543. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4544. res.Infcode = infocode
  4545. } else {
  4546. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4547. utils.ErrorLog("解析失败:%v", err)
  4548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4549. return
  4550. }
  4551. }
  4552. if res.Infcode == 0 {
  4553. item.IsSale = 1
  4554. item.Bchno = number
  4555. item.SaleDate = time.Now().Format("2006-01-02")
  4556. err5 := service.SaveDF(item)
  4557. if err5 == nil {
  4558. if item.IsChange == 0 { //没变更,进行变更操作
  4559. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4560. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4561. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4562. var respJSON3 map[string]interface{}
  4563. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4566. return
  4567. }
  4568. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4569. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4570. utils.ErrorLog("解析失败:%v", err)
  4571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4572. return
  4573. }
  4574. //if res3507for10188.Infcode
  4575. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4576. //res.Output = resSix10265.Output
  4577. res3.ErrMsg = res3507for10188.ErrMsg
  4578. res3.Cainfo = res3507for10188.Cainfo
  4579. res3.WarnMsg = res3507for10188.WarnMsg
  4580. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4581. res3.Infcode = infocode
  4582. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4583. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4584. utils.ErrorLog("解析失败:%v", err)
  4585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4586. return
  4587. }
  4588. //if res3507for10188.Infcode
  4589. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4590. //res.Output = resSix10265.Output
  4591. res3.ErrMsg = res3507for10188.ErrMsg
  4592. res3.Cainfo = res3507for10188.Cainfo
  4593. res3.WarnMsg = res3507for10188.WarnMsg
  4594. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4595. res3.Infcode = infocode
  4596. } else {
  4597. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4598. utils.ErrorLog("解析失败:%v", err)
  4599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4600. return
  4601. }
  4602. }
  4603. if res3.Infcode == 0 {
  4604. item.IsChange = 1
  4605. item.BgBchno = bg_number
  4606. service.SaveDF2(item)
  4607. } else {
  4608. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4609. }
  4610. }
  4611. }
  4612. } else {
  4613. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4614. }
  4615. }
  4616. } else { //还没结算
  4617. var res3507for10188 FJ3507ResultFor10188
  4618. if item.IsChange == 0 { //没变更,进行变更操作
  4619. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4620. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4621. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4622. var respJSON3 map[string]interface{}
  4623. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4626. return
  4627. }
  4628. userJSONBytes3, _ := json.Marshal(respJSON3)
  4629. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4630. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4631. utils.ErrorLog("解析失败:%v", err)
  4632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4633. return
  4634. }
  4635. //if res3507for10188.Infcode
  4636. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4637. //res.Output = resSix10265.Output
  4638. res3.ErrMsg = res3507for10188.ErrMsg
  4639. res3.Cainfo = res3507for10188.Cainfo
  4640. res3.WarnMsg = res3507for10188.WarnMsg
  4641. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4642. res3.Infcode = infocode
  4643. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4644. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4645. utils.ErrorLog("解析失败:%v", err)
  4646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4647. return
  4648. }
  4649. //if res3507for10188.Infcode
  4650. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4651. //res.Output = resSix10265.Output
  4652. res3.ErrMsg = res3507for10188.ErrMsg
  4653. res3.Cainfo = res3507for10188.Cainfo
  4654. res3.WarnMsg = res3507for10188.WarnMsg
  4655. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4656. res3.Infcode = infocode
  4657. } else {
  4658. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4659. utils.ErrorLog("解析失败:%v", err)
  4660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4661. return
  4662. }
  4663. }
  4664. if res3.Infcode == 0 {
  4665. item.IsChange = 1
  4666. item.BgBchno = bg_number
  4667. service.SaveDF2(item)
  4668. } else {
  4669. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4670. }
  4671. }
  4672. }
  4673. } else if item.ConsumableType == 7 {
  4674. var res3507for10188 FJ3507ResultFor10188
  4675. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4676. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4677. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4678. //判断是否已经销售
  4679. if item.IsSale == 2 { //是否已经销售,1是 0否
  4680. //是否已经变更 1是 0否
  4681. if item.IsChange == 0 { //没变更,进行变更操作
  4682. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4683. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4684. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4685. var respJSON3 map[string]interface{}
  4686. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4689. return
  4690. }
  4691. userJSONBytes3, _ := json.Marshal(respJSON3)
  4692. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4693. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4694. utils.ErrorLog("解析失败:%v", err)
  4695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4696. return
  4697. }
  4698. //if res3507for10188.Infcode
  4699. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4700. //res.Output = resSix10265.Output
  4701. res3.ErrMsg = res3507for10188.ErrMsg
  4702. res3.Cainfo = res3507for10188.Cainfo
  4703. res3.WarnMsg = res3507for10188.WarnMsg
  4704. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4705. res3.Infcode = infocode
  4706. } else {
  4707. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4708. utils.ErrorLog("解析失败:%v", err)
  4709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. return
  4711. }
  4712. }
  4713. if res3.Infcode == 0 {
  4714. item.IsChange = 1
  4715. item.BgBchno = bg_number
  4716. service.SaveDF2(item)
  4717. } else {
  4718. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4719. }
  4720. }
  4721. } else { //没销售,
  4722. //进行商品销售退货接口
  4723. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4724. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4725. saveLog(result111, result222, "3506", "销售退货")
  4726. var res7 FJ3507Result
  4727. //进行商品销售接口
  4728. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4729. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4730. var respJSON3 map[string]interface{}
  4731. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4734. return
  4735. }
  4736. userJSONBytes3, _ := json.Marshal(respJSON3)
  4737. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4738. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4739. utils.ErrorLog("解析失败:%v", err)
  4740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4741. return
  4742. }
  4743. //if res3507for10188.Infcode
  4744. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4745. //res.Output = resSix10265.Output
  4746. res7.ErrMsg = res3507for10188.ErrMsg
  4747. res7.Cainfo = res3507for10188.Cainfo
  4748. res7.WarnMsg = res3507for10188.WarnMsg
  4749. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4750. res7.Infcode = infocode
  4751. } else {
  4752. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4753. utils.ErrorLog("解析失败:%v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. }
  4758. if res7.Infcode == 0 {
  4759. item.IsSale = 2
  4760. item.SaleDate = item.SaleDate
  4761. item.Bchno = number
  4762. service.SaveDF(item)
  4763. if item.IsChange == 0 { //没变更,进行变更操作
  4764. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4765. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4766. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4767. var respJSON3 map[string]interface{}
  4768. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4771. return
  4772. }
  4773. userJSONBytes3, _ := json.Marshal(respJSON3)
  4774. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4775. // utils.ErrorLog("解析失败:%v", err)
  4776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4777. // return
  4778. //}
  4779. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4780. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. //if res3507for10188.Infcode
  4786. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4787. //res.Output = resSix10265.Output
  4788. res3.ErrMsg = res3507for10188.ErrMsg
  4789. res3.Cainfo = res3507for10188.Cainfo
  4790. res3.WarnMsg = res3507for10188.WarnMsg
  4791. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4792. res3.Infcode = infocode
  4793. } else {
  4794. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4795. utils.ErrorLog("解析失败:%v", err)
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. }
  4800. if res3.Infcode == 0 {
  4801. item.IsChange = 1
  4802. item.BgBchno = bg_number
  4803. service.SaveDF2(item)
  4804. } else {
  4805. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4806. }
  4807. }
  4808. } else {
  4809. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4810. }
  4811. }
  4812. } else { //还没结算
  4813. if item.IsChange == 0 { //没变更,进行变更操作
  4814. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4815. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4816. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4817. var respJSON3 map[string]interface{}
  4818. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4821. return
  4822. }
  4823. userJSONBytes3, _ := json.Marshal(respJSON3)
  4824. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4825. // utils.ErrorLog("解析失败:%v", err)
  4826. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4827. // return
  4828. //}
  4829. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4830. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4831. utils.ErrorLog("解析失败:%v", err)
  4832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4833. return
  4834. }
  4835. //if res3507for10188.Infcode
  4836. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4837. //res.Output = resSix10265.Output
  4838. res3.ErrMsg = res3507for10188.ErrMsg
  4839. res3.Cainfo = res3507for10188.Cainfo
  4840. res3.WarnMsg = res3507for10188.WarnMsg
  4841. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4842. res3.Infcode = infocode
  4843. } else {
  4844. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4845. utils.ErrorLog("解析失败:%v", err)
  4846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. return
  4848. }
  4849. }
  4850. if res3.Infcode == 0 {
  4851. item.IsChange = 1
  4852. item.BgBchno = bg_number
  4853. service.SaveDF2(item)
  4854. } else {
  4855. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4856. }
  4857. }
  4858. }
  4859. }
  4860. }
  4861. if len(err) == 0 {
  4862. c.ServeSuccessJSON(map[string]interface{}{
  4863. "msg": "销售变更成功",
  4864. })
  4865. } else {
  4866. c.ServeSuccessJSON(map[string]interface{}{
  4867. "failed_code": -10,
  4868. "msg": err,
  4869. })
  4870. }
  4871. }
  4872. func (c *HisApiController) ChangeDrugTen() {
  4873. start_time_str := c.GetString("start_time")
  4874. end_time_str := c.GetString("end_time")
  4875. //ids := c.GetString("ids")
  4876. //id_arr := strings.Split(ids, ",")
  4877. timeLayout := "2006-01-02"
  4878. loc, _ := time.LoadLocation("Local")
  4879. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4880. recordStartTime := theStartTime.Unix()
  4881. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4882. recordEndTime := theEndTime.Unix()
  4883. //timestamp := int64(1729612800)
  4884. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4885. admin_user_id, _ := c.GetInt64("admin_user_id")
  4886. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4887. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4888. var err []string
  4889. for _, item := range flows {
  4890. var res3 ResultSix
  4891. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4892. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4893. continue
  4894. }
  4895. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4896. continue
  4897. }
  4898. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4899. if prescription.OrderStatus == 2 {
  4900. //已经结算
  4901. //判断 是否已经销售
  4902. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4903. ////是否已经变更 1是 0否
  4904. //if item.IsChange == 0 { //没变更,进行变更操作
  4905. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4906. //
  4907. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4908. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4909. // var respJSON3 map[string]interface{}
  4910. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4911. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4913. // return
  4914. // }
  4915. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4916. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4917. // utils.ErrorLog("解析失败:%v", err)
  4918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4919. // return
  4920. // }
  4921. // if res3.Infcode == 0 {
  4922. // item.IsChange = 1
  4923. // item.BgBchno = bg_number
  4924. // service.SaveDF2(item)
  4925. // } else {
  4926. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4927. // }
  4928. //}
  4929. //} else
  4930. if item.IsSale == 0 { //没销售,
  4931. var res FJ3507Result
  4932. var res3507for10188 FJ3507ResultFor10188
  4933. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4934. //进行商品销售接口
  4935. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4936. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4937. var respJSON3 map[string]interface{}
  4938. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4941. return
  4942. }
  4943. userJSONBytes3, _ := json.Marshal(respJSON3)
  4944. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4945. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4946. utils.ErrorLog("解析失败:%v", err)
  4947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4948. return
  4949. }
  4950. //if res3507for10188.Infcode
  4951. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4952. //res.Output = resSix10265.Output
  4953. res.ErrMsg = res3507for10188.ErrMsg
  4954. res.Cainfo = res3507for10188.Cainfo
  4955. res.WarnMsg = res3507for10188.WarnMsg
  4956. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4957. res.Infcode = infocode
  4958. } else {
  4959. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4960. utils.ErrorLog("解析失败:%v", err)
  4961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4962. return
  4963. }
  4964. }
  4965. if res.Infcode == 0 {
  4966. item.IsSale = 1
  4967. item.Bchno = number
  4968. item.SaleDate = time.Now().Format("2006-01-02")
  4969. err5 := service.SaveDF(item)
  4970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4971. //if err5 == nil {
  4972. //
  4973. // if item.IsChange == 1 { //没变更,进行变更操作
  4974. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4975. //
  4976. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4977. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4978. //
  4979. // var respJSON3 map[string]interface{}
  4980. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4981. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4982. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4983. // return
  4984. // }
  4985. //
  4986. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4987. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4988. // utils.ErrorLog("解析失败:%v", err)
  4989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4990. // return
  4991. // }
  4992. // //if res3507for10188.Infcode
  4993. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4994. // //res.Output = resSix10265.Output
  4995. // res3.ErrMsg = res3507for10188.ErrMsg
  4996. // res3.Cainfo = res3507for10188.Cainfo
  4997. // res3.WarnMsg = res3507for10188.WarnMsg
  4998. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4999. // res3.Infcode = infocode
  5000. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5001. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5002. // utils.ErrorLog("解析失败:%v", err)
  5003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5004. // return
  5005. // }
  5006. // //if res3507for10188.Infcode
  5007. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5008. // //res.Output = resSix10265.Output
  5009. // res3.ErrMsg = res3507for10188.ErrMsg
  5010. // res3.Cainfo = res3507for10188.Cainfo
  5011. // res3.WarnMsg = res3507for10188.WarnMsg
  5012. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5013. // res3.Infcode = infocode
  5014. //
  5015. // } else {
  5016. //
  5017. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5018. // utils.ErrorLog("解析失败:%v", err)
  5019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. // return
  5021. // }
  5022. //
  5023. // }
  5024. //
  5025. // if res3.Infcode == 0 {
  5026. // item.IsChange = 1
  5027. // item.BgBchno = bg_number
  5028. // service.SaveDF2(item)
  5029. // return
  5030. // } else {
  5031. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5032. // }
  5033. // }
  5034. //}
  5035. } else {
  5036. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5037. }
  5038. }
  5039. }
  5040. } else if item.ConsumableType == 7 {
  5041. var res3507for10188 FJ3507ResultFor10188
  5042. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5043. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  5044. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  5045. //判断是否已经销售
  5046. if item.IsSale == 2 { //是否已经销售,1是 0否
  5047. //是否已经变更 1是 0否
  5048. if item.IsChange == 0 { //没变更,进行变更操作
  5049. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5050. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5051. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5052. var respJSON3 map[string]interface{}
  5053. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5056. return
  5057. }
  5058. userJSONBytes3, _ := json.Marshal(respJSON3)
  5059. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5060. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5061. utils.ErrorLog("解析失败:%v", err)
  5062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5063. return
  5064. }
  5065. //if res3507for10188.Infcode
  5066. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5067. //res.Output = resSix10265.Output
  5068. res3.ErrMsg = res3507for10188.ErrMsg
  5069. res3.Cainfo = res3507for10188.Cainfo
  5070. res3.WarnMsg = res3507for10188.WarnMsg
  5071. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5072. res3.Infcode = infocode
  5073. } else {
  5074. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5075. utils.ErrorLog("解析失败:%v", err)
  5076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5077. return
  5078. }
  5079. }
  5080. if res3.Infcode == 0 {
  5081. item.IsChange = 1
  5082. item.BgBchno = bg_number
  5083. service.SaveDF2(item)
  5084. } else {
  5085. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5086. }
  5087. }
  5088. } else { //没销售,
  5089. //进行商品销售退货接口
  5090. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  5091. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  5092. saveLog(result111, result222, "3506", "销售退货")
  5093. var res7 FJ3507Result
  5094. //进行商品销售接口
  5095. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5096. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5097. var respJSON3 map[string]interface{}
  5098. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5101. return
  5102. }
  5103. userJSONBytes3, _ := json.Marshal(respJSON3)
  5104. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5105. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5106. utils.ErrorLog("解析失败:%v", err)
  5107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5108. return
  5109. }
  5110. //if res3507for10188.Infcode
  5111. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5112. //res.Output = resSix10265.Output
  5113. res7.ErrMsg = res3507for10188.ErrMsg
  5114. res7.Cainfo = res3507for10188.Cainfo
  5115. res7.WarnMsg = res3507for10188.WarnMsg
  5116. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5117. res7.Infcode = infocode
  5118. } else {
  5119. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5120. utils.ErrorLog("解析失败:%v", err)
  5121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5122. return
  5123. }
  5124. }
  5125. if res7.Infcode == 0 {
  5126. item.IsSale = 2
  5127. item.SaleDate = item.SaleDate
  5128. item.Bchno = number
  5129. service.SaveDF(item)
  5130. if item.IsChange == 0 { //没变更,进行变更操作
  5131. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5132. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5133. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5134. var respJSON3 map[string]interface{}
  5135. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5138. return
  5139. }
  5140. userJSONBytes3, _ := json.Marshal(respJSON3)
  5141. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5142. // utils.ErrorLog("解析失败:%v", err)
  5143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5144. // return
  5145. //}
  5146. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5147. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5148. utils.ErrorLog("解析失败:%v", err)
  5149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5150. return
  5151. }
  5152. //if res3507for10188.Infcode
  5153. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5154. //res.Output = resSix10265.Output
  5155. res3.ErrMsg = res3507for10188.ErrMsg
  5156. res3.Cainfo = res3507for10188.Cainfo
  5157. res3.WarnMsg = res3507for10188.WarnMsg
  5158. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5159. res3.Infcode = infocode
  5160. } else {
  5161. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5162. utils.ErrorLog("解析失败:%v", err)
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5164. return
  5165. }
  5166. }
  5167. if res3.Infcode == 0 {
  5168. item.IsChange = 1
  5169. item.BgBchno = bg_number
  5170. service.SaveDF2(item)
  5171. } else {
  5172. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5173. }
  5174. }
  5175. } else {
  5176. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5177. }
  5178. }
  5179. } else { //还没结算
  5180. if item.IsChange == 0 { //没变更,进行变更操作
  5181. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5182. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5183. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5184. var respJSON3 map[string]interface{}
  5185. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5188. return
  5189. }
  5190. userJSONBytes3, _ := json.Marshal(respJSON3)
  5191. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5192. // utils.ErrorLog("解析失败:%v", err)
  5193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5194. // return
  5195. //}
  5196. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5197. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5198. utils.ErrorLog("解析失败:%v", err)
  5199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5200. return
  5201. }
  5202. //if res3507for10188.Infcode
  5203. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5204. //res.Output = resSix10265.Output
  5205. res3.ErrMsg = res3507for10188.ErrMsg
  5206. res3.Cainfo = res3507for10188.Cainfo
  5207. res3.WarnMsg = res3507for10188.WarnMsg
  5208. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5209. res3.Infcode = infocode
  5210. } else {
  5211. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5212. utils.ErrorLog("解析失败:%v", err)
  5213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5214. return
  5215. }
  5216. }
  5217. if res3.Infcode == 0 {
  5218. item.IsChange = 1
  5219. item.BgBchno = bg_number
  5220. service.SaveDF2(item)
  5221. } else {
  5222. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5223. }
  5224. }
  5225. }
  5226. }
  5227. }
  5228. if len(err) == 0 {
  5229. c.ServeSuccessJSON(map[string]interface{}{
  5230. "msg": "销售变更成功",
  5231. })
  5232. } else {
  5233. c.ServeSuccessJSON(map[string]interface{}{
  5234. "failed_code": -10,
  5235. "msg": err,
  5236. })
  5237. }
  5238. }
  5239. func ChangeDrugTenone() {
  5240. //ids := c.GetString("ids")
  5241. //id_arr := strings.Split(ids, ",")
  5242. now := time.Now()
  5243. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5244. //timestamp := int64(1729612800)
  5245. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5246. admin_user_id := int64(2463)
  5247. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5248. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5249. var err []string
  5250. for _, item := range flows {
  5251. var res3 ResultSix
  5252. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5253. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5254. continue
  5255. }
  5256. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5257. continue
  5258. }
  5259. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5260. if prescription.OrderStatus == 2 {
  5261. //已经结算
  5262. //判断是否已经销售
  5263. if item.IsSale == 1 { //是否已经销售,1是 0否
  5264. //是否已经变更 1是 0否
  5265. if item.IsChange == 0 { //没变更,进行变更操作
  5266. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5267. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5268. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5269. var respJSON3 map[string]interface{}
  5270. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5272. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5273. return
  5274. }
  5275. userJSONBytes3, _ := json.Marshal(respJSON3)
  5276. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5277. utils.ErrorLog("解析失败:%v", err)
  5278. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5279. return
  5280. }
  5281. if res3.Infcode == 0 {
  5282. item.IsChange = 1
  5283. item.BgBchno = bg_number
  5284. service.SaveDF2(item)
  5285. } else {
  5286. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5287. }
  5288. }
  5289. } else { //没销售,
  5290. var res FJ3507Result
  5291. var res3507for10188 FJ3507ResultFor10188
  5292. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5293. //进行商品销售接口
  5294. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5295. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5296. var respJSON3 map[string]interface{}
  5297. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5299. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5300. return
  5301. }
  5302. userJSONBytes3, _ := json.Marshal(respJSON3)
  5303. {
  5304. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5305. utils.ErrorLog("解析失败:%v", err)
  5306. return
  5307. }
  5308. //if res3507for10188.Infcode
  5309. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5310. //res.Output = resSix10265.Output
  5311. res.ErrMsg = res3507for10188.ErrMsg
  5312. res.Cainfo = res3507for10188.Cainfo
  5313. res.WarnMsg = res3507for10188.WarnMsg
  5314. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5315. res.Infcode = infocode
  5316. }
  5317. if res.Infcode == 0 {
  5318. item.IsSale = 1
  5319. item.Bchno = number
  5320. item.SaleDate = time.Now().Format("2006-01-02")
  5321. err5 := service.SaveDF(item)
  5322. if err5 == nil {
  5323. if item.IsChange == 1 { //没变更,进行变更操作
  5324. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5325. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5326. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5327. var respJSON3 map[string]interface{}
  5328. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5330. return
  5331. }
  5332. {
  5333. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5334. utils.ErrorLog("解析失败:%v", err)
  5335. return
  5336. }
  5337. //if res3507for10188.Infcode
  5338. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5339. //res.Output = resSix10265.Output
  5340. res3.ErrMsg = res3507for10188.ErrMsg
  5341. res3.Cainfo = res3507for10188.Cainfo
  5342. res3.WarnMsg = res3507for10188.WarnMsg
  5343. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5344. res3.Infcode = infocode
  5345. }
  5346. if res3.Infcode == 0 {
  5347. item.IsChange = 1
  5348. item.BgBchno = bg_number
  5349. service.SaveDF2(item)
  5350. } else {
  5351. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5352. }
  5353. }
  5354. }
  5355. } else {
  5356. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5357. }
  5358. }
  5359. }
  5360. }
  5361. }
  5362. }
  5363. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5364. var struct3502 models.Struct3502
  5365. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5366. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5367. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5368. struct3502.FixmedinsCode = miConfig.Code
  5369. struct3502.Code = miConfig.Code
  5370. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5371. struct3502.Opter = role.UserName
  5372. struct3502.RxFlag = "1"
  5373. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5374. struct3502.OrgName = miConfig.OrgName
  5375. struct3502.AccessKey = miConfig.AccessKey
  5376. struct3502.RequestUrl = miConfig.Url
  5377. struct3502.SecretKey = miConfig.SecretKey
  5378. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5379. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5380. struct3502.Url = miConfig.Url
  5381. struct3502.AppId = miConfig.Cainfo
  5382. struct3502.AppSecret = miConfig.AppSecret
  5383. struct3502.Enckey = miConfig.EncKey
  5384. struct3502.SignKey = miConfig.SignKey
  5385. struct3502.SecretKey = miConfig.SecretKey
  5386. struct3502.InvChgType = chgType
  5387. struct3502.FixmedinsBchno = number
  5388. struct3502.Cnt = strconv.FormatInt(count, 10)
  5389. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5390. //result1, result2, _ := service.FJyb3502(struct3502)
  5391. if miConfig.MdtrtareaAdmvs == "350500" {
  5392. result1, result2, _ := service.FJyb3502(struct3502)
  5393. //saveLog(result1, result2, "3502", "3502")
  5394. return result1, result2
  5395. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5396. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5397. return result1, result2
  5398. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5399. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5400. return result1, result2
  5401. } else {
  5402. data := make(map[string]interface{})
  5403. data["struct_3502s"] = struct3502
  5404. client := &http.Client{}
  5405. bytesData, _ := json.Marshal(data)
  5406. var req *http.Request
  5407. if miConfig.MdtrtareaAdmvs == "320921" {
  5408. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5409. } else {
  5410. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5411. }
  5412. resp, _ := client.Do(req)
  5413. defer resp.Body.Close()
  5414. body, ioErr := ioutil.ReadAll(resp.Body)
  5415. if ioErr != nil {
  5416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5417. }
  5418. var respJSON map[string]interface{}
  5419. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5421. }
  5422. //var resSix10265 ResultSix10265 //1101结果
  5423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5424. result, _ := json.Marshal(respJSON)
  5425. return string(result), ""
  5426. }
  5427. }
  5428. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5429. var struct3505 models.Struct3505
  5430. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5431. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5432. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5433. struct3505.FixmedinsBchno = number
  5434. struct3505.Opter = role.UserName
  5435. struct3505.Bchno = "---"
  5436. struct3505.FixmedinsCode = miConfig.Code
  5437. struct3505.Code = miConfig.Code
  5438. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5439. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5440. struct3505.PrscDrName = roles.UserName
  5441. if org_id == 10191 {
  5442. struct3505.PharName = "刘水山"
  5443. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5444. }
  5445. if org_id == 10188 {
  5446. struct3505.PharName = "李汉清"
  5447. struct3505.PharPracCertNo = "30220200932022010034"
  5448. }
  5449. if org_id == 10217 {
  5450. struct3505.PharName = "张敏"
  5451. struct3505.PharPracCertNo = "30220230432090100108"
  5452. }
  5453. if org_id == 10318 {
  5454. struct3505.PharName = "邹刘阳"
  5455. struct3505.PharPracCertNo = "210441200001378"
  5456. }
  5457. if org_id == 10402 {
  5458. struct3505.PharName = "刘韶健"
  5459. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5460. }
  5461. if org_id == 9919 {
  5462. struct3505.PharName = "周君权"
  5463. struct3505.PharPracCertNo = "089644396094401375"
  5464. }
  5465. if org_id == 10644 {
  5466. struct3505.PharName = "陈金娣"
  5467. struct3505.PharPracCertNo = "20181441500320100066"
  5468. }
  5469. if org_id == 10567 {
  5470. struct3505.PharName = "范小兰"
  5471. struct3505.PharPracCertNo = "0200102079485"
  5472. }
  5473. if org_id == 10721 {
  5474. struct3505.PharName = "孙莉侠"
  5475. struct3505.PharPracCertNo = "060399"
  5476. }
  5477. if org_id == 10726 {
  5478. struct3505.PharName = "彭建福"
  5479. struct3505.PharPracCertNo = "D445281006261"
  5480. }
  5481. if org_id == 10265 {
  5482. struct3505.PharName = "李彩星"
  5483. struct3505.PharPracCertNo = "20171110600110100019"
  5484. }
  5485. if org_id == 10028 {
  5486. struct3505.PharName = "曾细平"
  5487. struct3505.PharPracCertNo = "D440307022134"
  5488. }
  5489. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5490. struct3505.SetlId = order.SetlId
  5491. struct3505.MdtrtSn = order.MdtrtId
  5492. struct3505.ManuLotnum = drug.BatchNumber
  5493. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5494. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5495. struct3505.RxFlag = "1"
  5496. struct3505.TrdnFlag = "0"
  5497. struct3505.RtalDocno = order.Number
  5498. struct3505.PsnCertType = "01"
  5499. struct3505.CertNo = order.Certno
  5500. struct3505.PsnNo = order.PsnNo
  5501. struct3505.PsnName = order.PsnName
  5502. struct3505.Url = miConfig.Url
  5503. struct3505.AppId = miConfig.Cainfo
  5504. struct3505.AppSecret = miConfig.AppSecret
  5505. struct3505.Enckey = miConfig.EncKey
  5506. struct3505.SignKey = miConfig.SignKey
  5507. struct3505.SecretKey = miConfig.SecretKey
  5508. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5509. struct3505.SelRetnCnt = strValue
  5510. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5511. struct3505.SelRetnOpterName = role.UserName
  5512. if order.IsMedicineInsurance == 1 {
  5513. struct3505.MdtrtSetlType = "1"
  5514. } else {
  5515. struct3505.MdtrtSetlType = "2"
  5516. }
  5517. struct3505.OrgName = miConfig.OrgName
  5518. struct3505.AccessKey = miConfig.AccessKey
  5519. struct3505.RequestUrl = miConfig.Url
  5520. struct3505.SecretKey = miConfig.SecretKey
  5521. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5522. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5523. struct3505.Cainfo = miConfig.Cainfo
  5524. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5525. if miConfig.MdtrtareaAdmvs == "350500" {
  5526. result1, result2, _ := service.FJyb3505(struct3505)
  5527. return result1, result2
  5528. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5529. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5530. return result1, result2
  5531. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5532. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5533. return result1, result2
  5534. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5535. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey,struct3505.AccessKey,struct3505.RequestUrl)
  5536. return result1, result2
  5537. }else if miConfig.MdtrtareaAdmvs == "340699" {
  5538. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey,struct3505.RequestUrl)
  5539. return result1, result2
  5540. }else if miConfig.MdtrtareaAdmvs == "150499" {
  5541. data := make(map[string]interface{})
  5542. data["struct_3505s"] = struct3505
  5543. client := &http.Client{}
  5544. bytesData, _ := json.Marshal(data)
  5545. var req *http.Request
  5546. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5547. resp, _ := client.Do(req)
  5548. defer resp.Body.Close()
  5549. body, ioErr := ioutil.ReadAll(resp.Body)
  5550. if ioErr != nil {
  5551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5552. }
  5553. var respJSON map[string]interface{}
  5554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5556. }
  5557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5558. result, _ := json.Marshal(respJSON)
  5559. return string(result), ""
  5560. } else {
  5561. data := make(map[string]interface{})
  5562. data["struct_3505s"] = struct3505
  5563. client := &http.Client{}
  5564. bytesData, _ := json.Marshal(data)
  5565. var req *http.Request
  5566. if miConfig.MdtrtareaAdmvs == "320921" {
  5567. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5568. } else {
  5569. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5570. }
  5571. resp, _ := client.Do(req)
  5572. defer resp.Body.Close()
  5573. body, ioErr := ioutil.ReadAll(resp.Body)
  5574. if ioErr != nil {
  5575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5576. }
  5577. var respJSON map[string]interface{}
  5578. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5580. }
  5581. //var resSix10265 ResultSix10265 //1101结果
  5582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5583. result, _ := json.Marshal(respJSON)
  5584. return string(result), ""
  5585. }
  5586. }
  5587. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5588. var struct3505 models.Struct3505
  5589. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5590. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5591. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5592. struct3505.FixmedinsBchno = number
  5593. struct3505.Opter = role.UserName
  5594. struct3505.FixmedinsCode = miConfig.Code
  5595. struct3505.Code = miConfig.Code
  5596. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5597. struct3505.PrscDrName = roles.UserName
  5598. if org_id == 10191 {
  5599. struct3505.PharName = "刘水山"
  5600. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5601. }
  5602. if org_id == 10188 {
  5603. struct3505.PharName = "李汉清"
  5604. struct3505.PharPracCertNo = "30220200932022010034"
  5605. }
  5606. if org_id == 10217 {
  5607. struct3505.PharName = "张敏"
  5608. struct3505.PharPracCertNo = "30220230432090100108"
  5609. }
  5610. if org_id == 10318 {
  5611. struct3505.PharName = "邹刘阳"
  5612. struct3505.PharPracCertNo = "210441200001378"
  5613. }
  5614. if org_id == 10402 {
  5615. struct3505.PharName = "刘韶健"
  5616. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5617. }
  5618. if org_id == 9919 {
  5619. struct3505.PharName = "周君权"
  5620. struct3505.PharPracCertNo = "089644396094401375"
  5621. }
  5622. if org_id == 10644 {
  5623. struct3505.PharName = "陈金娣"
  5624. struct3505.PharPracCertNo = "20181441500320100066"
  5625. }
  5626. if org_id == 10567 {
  5627. struct3505.PharName = "范小兰"
  5628. struct3505.PharPracCertNo = "0200102079485"
  5629. }
  5630. if org_id == 10721 {
  5631. struct3505.PharName = "孙莉侠"
  5632. struct3505.PharPracCertNo = "060399"
  5633. }
  5634. if org_id == 10726 {
  5635. struct3505.PharName = "彭建福"
  5636. struct3505.PharPracCertNo = "D445281006261"
  5637. }
  5638. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5639. struct3505.SetlId = order.SetlId
  5640. struct3505.MdtrtSn = order.MdtrtId
  5641. struct3505.ManuLotnum = drug.Number
  5642. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5643. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5644. struct3505.RxFlag = "1"
  5645. struct3505.TrdnFlag = "0"
  5646. struct3505.RtalDocno = order.Number
  5647. struct3505.PsnCertType = "01"
  5648. struct3505.CertNo = order.Certno
  5649. struct3505.PsnNo = order.PsnNo
  5650. struct3505.PsnName = order.PsnName
  5651. struct3505.Url = miConfig.Url
  5652. struct3505.AppId = miConfig.Cainfo
  5653. struct3505.AppSecret = miConfig.AppSecret
  5654. struct3505.Enckey = miConfig.EncKey
  5655. struct3505.SignKey = miConfig.SignKey
  5656. struct3505.SecretKey = miConfig.SecretKey
  5657. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5658. struct3505.SelRetnCnt = strValue
  5659. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5660. struct3505.SelRetnOpterName = role.UserName
  5661. if order.IsMedicineInsurance == 1 {
  5662. struct3505.MdtrtSetlType = "1"
  5663. } else {
  5664. struct3505.MdtrtSetlType = "2"
  5665. }
  5666. struct3505.OrgName = miConfig.OrgName
  5667. struct3505.AccessKey = miConfig.AccessKey
  5668. struct3505.RequestUrl = miConfig.Url
  5669. struct3505.SecretKey = miConfig.SecretKey
  5670. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5671. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5672. struct3505.Cainfo = miConfig.Cainfo
  5673. struct3505.DrugTracCodg = drug.DrugCode
  5674. if miConfig.MdtrtareaAdmvs == "350500" {
  5675. result1, result2, _ := service.FJyb3505(struct3505)
  5676. return result1, result2
  5677. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5678. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5679. return result1, result2
  5680. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5681. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5682. return result1, result2
  5683. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5684. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5685. return result1, result2
  5686. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5687. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5688. return result1, result2
  5689. } else {
  5690. data := make(map[string]interface{})
  5691. data["struct_3505s"] = struct3505
  5692. client := &http.Client{}
  5693. bytesData, _ := json.Marshal(data)
  5694. var req *http.Request
  5695. if miConfig.MdtrtareaAdmvs == "320921" {
  5696. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5697. } else {
  5698. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5699. }
  5700. resp, _ := client.Do(req)
  5701. defer resp.Body.Close()
  5702. body, ioErr := ioutil.ReadAll(resp.Body)
  5703. if ioErr != nil {
  5704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5705. }
  5706. var respJSON map[string]interface{}
  5707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5709. }
  5710. //var resSix10265 ResultSix10265 //1101结果
  5711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5712. result, _ := json.Marshal(respJSON)
  5713. return string(result), ""
  5714. }
  5715. }
  5716. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5717. var struct3506 models.Struct3506
  5718. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5719. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5720. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5721. struct3506.FixmedinsCode = miConfig.Code
  5722. struct3506.Code = miConfig.Code
  5723. struct3506.FixmedinsBchno = number
  5724. struct3506.Opter = role.UserName
  5725. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5726. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5727. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5728. struct3506.MdtrtSn = order.MdtrtId
  5729. struct3506.ExpyEnd = ""
  5730. struct3506.RxFlag = "0"
  5731. struct3506.TrdnFlag = "1"
  5732. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5733. struct3506.SelRetnCnt = strValue
  5734. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5735. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5736. struct3506.SelRetnOpterName = role.UserName
  5737. struct3506.OrgName = miConfig.OrgName
  5738. struct3506.AccessKey = miConfig.AccessKey
  5739. struct3506.RequestUrl = miConfig.Url
  5740. struct3506.SecretKey = miConfig.SecretKey
  5741. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5742. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5743. struct3506.Url = miConfig.Url
  5744. struct3506.AppId = miConfig.Cainfo
  5745. struct3506.AppSecret = miConfig.AppSecret
  5746. struct3506.Enckey = miConfig.EncKey
  5747. struct3506.SignKey = miConfig.SignKey
  5748. struct3506.SecretKey = miConfig.SecretKey
  5749. struct3506.DrugTracCodg = drug.DrugCode
  5750. if miConfig.MdtrtareaAdmvs == "350500" {
  5751. result1, result2, _ := service.FJyb3506(struct3506)
  5752. return result1, result2
  5753. } else {
  5754. data := make(map[string]interface{})
  5755. data["struct_3506s"] = struct3506
  5756. client := &http.Client{}
  5757. bytesData, _ := json.Marshal(data)
  5758. var req *http.Request
  5759. if miConfig.MdtrtareaAdmvs == "320921" {
  5760. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5761. } else {
  5762. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5763. }
  5764. resp, _ := client.Do(req)
  5765. defer resp.Body.Close()
  5766. body, ioErr := ioutil.ReadAll(resp.Body)
  5767. if ioErr != nil {
  5768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5769. }
  5770. var respJSON map[string]interface{}
  5771. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5773. }
  5774. //var resSix10265 ResultSix10265 //1101结果
  5775. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5776. result, _ := json.Marshal(respJSON)
  5777. return string(result), ""
  5778. }
  5779. }
  5780. func (c *HisApiController) Get1318() {
  5781. adminUser := c.GetAdminUserInfo()
  5782. admin_user_id, _ := c.GetInt64("admin_user_id")
  5783. code := c.GetString("code")
  5784. code = ""
  5785. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5786. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5787. api := ""
  5788. if miConfig.MdtrtareaAdmvs == "320921" {
  5789. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5790. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5791. } else {
  5792. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5793. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5794. }
  5795. resp, requestErr := http.Get(api)
  5796. if requestErr != nil {
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5798. return
  5799. }
  5800. body, ioErr := ioutil.ReadAll(resp.Body)
  5801. if ioErr != nil {
  5802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5804. return
  5805. }
  5806. var respJSON map[string]interface{}
  5807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5810. return
  5811. }
  5812. //var res Result2406
  5813. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5814. result, _ := json.Marshal(respJSON)
  5815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5816. utils.ErrorLog("解析失败:%v", err)
  5817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5818. return
  5819. }
  5820. if res.Infcode == "0" {
  5821. c.ServeSuccessJSON(map[string]interface{}{
  5822. "result": "",
  5823. })
  5824. } else {
  5825. c.ServeSuccessJSON(map[string]interface{}{
  5826. "failed_code": -10,
  5827. "msg": res.ErrMsg,
  5828. })
  5829. */return
  5830. //}
  5831. }
  5832. func (c *HisApiController) Get2503() {
  5833. adminUser := c.GetAdminUserInfo()
  5834. admin_user_id, _ := c.GetInt64("admin_user_id")
  5835. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5836. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5837. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5838. }
  5839. func (c *HisApiController) Get2406() {
  5840. id, _ := c.GetInt64("id")
  5841. record_time := c.GetString("record_time")
  5842. his_patient_id, _ := c.GetInt64("his_patient_id")
  5843. admin_user_id, _ := c.GetInt64("admin_user_id")
  5844. diagnosis_id := c.GetString("diagnosis")
  5845. timeLayout := "2006-01-02"
  5846. loc, _ := time.LoadLocation("Local")
  5847. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5848. if err != nil {
  5849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5850. return
  5851. }
  5852. recordDateTime := theTime.Unix()
  5853. adminUser := c.GetAdminUserInfo()
  5854. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5855. var config []*models.HisXtDiagnoseConfig
  5856. for _, item := range diagnosis_ids {
  5857. id, _ := strconv.ParseInt(item, 10, 64)
  5858. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5859. config = append(config, &diagnosisConfig)
  5860. }
  5861. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5862. fmt.Println(his_patient_id)
  5863. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5864. //timestamp := time.Now().Unix()
  5865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5866. var patientPrescription models.HisPrescriptionInfo
  5867. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5868. if patientPrescription.ID == 0 {
  5869. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5870. }
  5871. var res2 Result2406
  5872. if miConfig.MdtrtareaAdmvs == "341203" {
  5873. data := make(map[string]interface{})
  5874. client := &http.Client{}
  5875. data["psn_no"] = his.PsnNo
  5876. data["mdtrt_id"] = his.Number
  5877. data["operator"] = roles.UserName
  5878. data["cert_no"] = his.IdCardNo
  5879. data["org_name"] = miConfig.OrgName
  5880. data["psn_name"] = his.Name
  5881. data["ipt_otp_no"] = his.IptOtpNo
  5882. data["ipt_psn_sp_flag_type"] = "0901"
  5883. data["ipt_psn_sp_flag"] = "1"
  5884. data["fixmedins_code"] = miConfig.Code
  5885. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5886. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5887. data["url"] = miConfig.Url
  5888. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5889. bytesData, _ := json.Marshal(data)
  5890. var req *http.Request
  5891. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5892. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5893. resp, _ := client.Do(req)
  5894. defer resp.Body.Close()
  5895. body, ioErr := ioutil.ReadAll(resp.Body)
  5896. if ioErr != nil {
  5897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5899. return
  5900. }
  5901. var respJSON map[string]interface{}
  5902. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5908. if status == "0" {
  5909. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5910. c.ServeSuccessJSON(map[string]interface{}{
  5911. "failed_code": -10,
  5912. "msg": err_msg,
  5913. })
  5914. return
  5915. }
  5916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5917. userJSONBytes, _ := json.Marshal(respJSON)
  5918. fmt.Println("log")
  5919. fmt.Println(string(userJSONBytes))
  5920. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5921. utils.ErrorLog("解析失败:%v", err)
  5922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. return
  5924. }
  5925. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5926. data := make(map[string]interface{})
  5927. client := &http.Client{}
  5928. data["psn_no"] = his.PsnNo
  5929. data["mdtrt_id"] = his.Number
  5930. data["operator"] = roles.UserName
  5931. data["cert_no"] = his.IdCardNo
  5932. data["org_name"] = miConfig.OrgName
  5933. data["psn_name"] = his.Name
  5934. data["ipt_otp_no"] = his.IptOtpNo
  5935. data["ipt_psn_sp_flag_type"] = "0901"
  5936. data["ipt_psn_sp_flag"] = "1"
  5937. data["fixmedins_code"] = miConfig.Code
  5938. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5939. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5940. data["url"] = miConfig.Url
  5941. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5942. bytesData, _ := json.Marshal(data)
  5943. var req *http.Request
  5944. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5945. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5946. resp, _ := client.Do(req)
  5947. defer resp.Body.Close()
  5948. body, ioErr := ioutil.ReadAll(resp.Body)
  5949. if ioErr != nil {
  5950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5952. return
  5953. }
  5954. var respJSON map[string]interface{}
  5955. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5958. return
  5959. }
  5960. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5961. if status == "0" {
  5962. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5963. c.ServeSuccessJSON(map[string]interface{}{
  5964. "failed_code": -10,
  5965. "msg": err_msg,
  5966. })
  5967. return
  5968. }
  5969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5970. userJSONBytes, _ := json.Marshal(respJSON)
  5971. fmt.Println("log")
  5972. fmt.Println(string(userJSONBytes))
  5973. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5974. utils.ErrorLog("解析失败:%v", err)
  5975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5976. return
  5977. }
  5978. }
  5979. if res2.Infcode != 0 {
  5980. adminUser := c.GetAdminUserInfo()
  5981. errlog := &models.HisOrderError{
  5982. UserOrgId: adminUser.CurrentOrgId,
  5983. Ctime: time.Now().Unix(),
  5984. Mtime: time.Now().Unix(),
  5985. ErrMsg: res2.ErrMsg,
  5986. Status: 1,
  5987. PatientId: id,
  5988. RecordTime: recordDateTime,
  5989. Stage: 3,
  5990. }
  5991. service.CreateErrMsgLog(errlog)
  5992. c.ServeSuccessJSON(map[string]interface{}{
  5993. "failed_code": -10,
  5994. "msg": res2.ErrMsg,
  5995. })
  5996. return
  5997. } else {
  5998. c.ServeSuccessJSON(map[string]interface{}{
  5999. "msg": "上传成功",
  6000. })
  6001. return
  6002. }
  6003. }
  6004. func (c *HisApiController) Get4105() {
  6005. }
  6006. func (c *HisApiController) Post5302() {
  6007. patient_id, _ := c.GetInt64("id")
  6008. admin_user_id, _ := c.GetInt64("admin_user_id")
  6009. p, _ := service.GetHisPatientById(patient_id)
  6010. adminUser := c.GetAdminUserInfo()
  6011. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6012. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6013. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6014. }
  6015. func (c *HisApiController) Get4104() {
  6016. }
  6017. type Output struct {
  6018. CertNo string `json:"certno"`
  6019. PsnName string `json:"psn_name"`
  6020. CardNo string `json:"card_no"`
  6021. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6022. CardSN string `json:"card_sn"`
  6023. PsnCertType string `json:"psn_cert_type"`
  6024. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6025. MdtrtCertType string `json:"mdtrt_cert_type"`
  6026. QRCode string `json:"qrCode"`
  6027. EcToken string `json:"ecToken"`
  6028. }
  6029. type AHResponse struct {
  6030. Body AHBody `json:"body"`
  6031. Code int `json:"code"`
  6032. CSBCode int `json:"csbCode"`
  6033. Message string `json:"message"`
  6034. RequestID string `json:"requestId"`
  6035. State struct{} `json:"state"`
  6036. }
  6037. type AHBody struct {
  6038. ErrMsg string `json:"err_msg"`
  6039. InfRefMsgID string `json:"inf_refmsgid"`
  6040. InfCode int `json:"infcode"`
  6041. Output struct {
  6042. Result []struct {
  6043. BasMednFlag string `json:"bas_medn_flag"`
  6044. ChldMedcFlag string `json:"chld_medc_flag"`
  6045. ChrgitmLv string `json:"chrgitm_lv"`
  6046. Cnt float64 `json:"cnt"`
  6047. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6048. DrtReimFlag string `json:"drt_reim_flag"`
  6049. FeedetlSn string `json:"feedetl_sn"`
  6050. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6051. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6052. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6053. ListSpItemFlag string `json:"list_sp_item_flag"`
  6054. LmtUsedFlag string `json:"lmt_used_flag"`
  6055. MedChrgitmType string `json:"med_chrgitm_type"`
  6056. Memo string `json:"memo"`
  6057. OverlmtAmt float64 `json:"overlmt_amt"`
  6058. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6059. Pric float64 `json:"pric"`
  6060. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6061. SelfpayProp float64 `json:"selfpay_prop"`
  6062. } `json:"result"`
  6063. } `json:"output"`
  6064. }
  6065. type Response struct {
  6066. Output Output `json:"output"`
  6067. Infcode int `json:"infcode"`
  6068. InfRefMsgID string `json:"inf_refmsgid"`
  6069. RefMsgTime string `json:"refmsg_time"`
  6070. RespondTime string `json:"respond_time"`
  6071. ErrMsg string `json:"err_msg"`
  6072. WarnMsg string `json:"warn_msg"`
  6073. SignType string `json:"signtype"`
  6074. CAInfo string `json:"cainfo"`
  6075. }
  6076. func (c *HisApiController) Getquerydata() {
  6077. query_type, _ := c.GetInt64("type")
  6078. refd_setl_flag := c.GetString("refd_setl_flag")
  6079. med_type := c.GetString("med_type")
  6080. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6081. cert_no := c.GetString("cert_no")
  6082. psn_no := c.GetString("psn_no")
  6083. start_time := c.GetString("start_time")
  6084. end_time := c.GetString("end_time")
  6085. page, _ := c.GetInt64("page")
  6086. limit, _ := c.GetInt64("limit")
  6087. var bp models.BusinessParams5262
  6088. bp.RefdSetlFlag = refd_setl_flag
  6089. bp.MedType = med_type
  6090. bp.Certno = cert_no
  6091. bp.Psnno = psn_no
  6092. bp.QBegntime = start_time
  6093. bp.QEndtime = end_time
  6094. if query_type == 1 { //本地
  6095. Post5262(c, bp, page, limit)
  6096. } else { //异地
  6097. Post5267(c, bp, page, limit)
  6098. }
  6099. }
  6100. func (c *HisApiController) Drugscheck() {
  6101. admin_user_id, _ := c.GetInt64("admin_user_id")
  6102. adminUser := c.GetAdminUserInfo()
  6103. var queryResult []QueryResult
  6104. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6105. for _, item := range drugs {
  6106. result := QueryResult{
  6107. ID: item.ID,
  6108. Name: item.DrugName,
  6109. Code: item.MedicalInsuranceNumber,
  6110. List_type_code: "101",
  6111. }
  6112. queryResult = append(queryResult, result)
  6113. }
  6114. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6115. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6116. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6117. for _, item := range queryResult {
  6118. 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)
  6119. }
  6120. }
  6121. func (c *HisApiController) Goodcheck() {
  6122. admin_user_id, _ := c.GetInt64("admin_user_id")
  6123. adminUser := c.GetAdminUserInfo()
  6124. var queryResult []QueryResult
  6125. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6126. for _, item := range goods {
  6127. result := QueryResult{
  6128. ID: item.ID,
  6129. Name: item.GoodName,
  6130. Code: item.SocialSecurityDirectoryCode,
  6131. List_type_code: "301",
  6132. }
  6133. queryResult = append(queryResult, result)
  6134. }
  6135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6136. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6137. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6138. for _, item := range queryResult {
  6139. 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)
  6140. //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)
  6141. }
  6142. }
  6143. func (c *HisApiController) Projectcheck() {
  6144. admin_user_id, _ := c.GetInt64("admin_user_id")
  6145. adminUser := c.GetAdminUserInfo()
  6146. var queryResult []QueryResult
  6147. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6148. for _, item := range projects {
  6149. result := QueryResult{
  6150. ID: item.ID,
  6151. Name: item.ProjectName,
  6152. Code: item.MedicalCode,
  6153. List_type_code: "201",
  6154. }
  6155. queryResult = append(queryResult, result)
  6156. }
  6157. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6158. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6159. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6160. for _, item := range queryResult {
  6161. 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)
  6162. }
  6163. }
  6164. //func (c *HisApiController)CancleDia(){
  6165. //
  6166. // id, _ := c.GetInt64("id")
  6167. // record_time := c.GetString("record_time")
  6168. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6169. //
  6170. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6171. //
  6172. // diagnosis_id := c.GetString("diagnosis")
  6173. // sick_type, _ := c.GetInt64("sick_type")
  6174. // reg_type, _ := c.GetInt64("p_type")
  6175. // begin_time := c.GetString("begin_time")
  6176. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6177. //
  6178. //
  6179. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6180. //
  6181. // fmt.Println(acct_used_flag)
  6182. //
  6183. //
  6184. // timeLayout := "2006-01-02"
  6185. // loc, _ := time.LoadLocation("Local")
  6186. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6187. // if err != nil {
  6188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6189. // return
  6190. // }
  6191. // recordDateTime := theTime.Unix()
  6192. // adminUser := c.GetAdminUserInfo()
  6193. //
  6194. //
  6195. //
  6196. //
  6197. //
  6198. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6199. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6200. // var patientPrescription models.HisPrescriptionInfo
  6201. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6202. // if patientPrescription.ID == 0 {
  6203. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6204. // }
  6205. // //if patientPrescription.Do
  6206. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6207. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6208. //
  6209. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6210. //
  6211. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6212. //
  6213. // var config []*models.HisXtDiagnoseConfig
  6214. // for _, item := range diagnosis_ids {
  6215. // id, _ := strconv.ParseInt(item, 10, 64)
  6216. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6217. // config = append(config, &diagnosisConfig)
  6218. // }
  6219. //
  6220. // sickConfig, _ := service.FindSickById(sick_type)
  6221. //
  6222. //
  6223. // data := make(map[string]interface{})
  6224. // client := &http.Client{}
  6225. // data["psn_no"] = his.PsnNo
  6226. // data["mdtrt_id"] = his.Number
  6227. // data["doctor"] = roles.UserName
  6228. // data["department"] = department.Name
  6229. // data["org_name"] = miConfig.OrgName
  6230. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6231. // data["doctor_id"] = doctor_info.DoctorNumber
  6232. // data["new_doctor_name"] = doctor_info.UserName
  6233. // data["fixmedins_code"] = miConfig.Code
  6234. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6235. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6236. // data["secret_key"] = miConfig.SecretKey
  6237. // data["sick_code"] = sickConfig.CountryCode
  6238. // data["sick_name"] = sickConfig.ClassName
  6239. // data["url"] = miConfig.Url
  6240. // data["ak"] = miConfig.AccessKey
  6241. // data["begin_time"] = begin_time
  6242. // data["cainfo"] = miConfig.Cainfo
  6243. // data["is_vaild"] = "0"
  6244. //
  6245. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6246. // data["config"] = config
  6247. // bytesData, _ := json.Marshal(data)
  6248. //
  6249. // var req *http.Request
  6250. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6251. // resp, _ := client.Do(req)
  6252. // defer resp.Body.Close()
  6253. // body, ioErr := ioutil.ReadAll(resp.Body)
  6254. // if ioErr != nil {
  6255. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6257. // return
  6258. // }
  6259. // var respJSON map[string]interface{}
  6260. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6261. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. // return
  6264. // }
  6265. //
  6266. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6267. // userJSONBytes, _ := json.Marshal(respJSON)
  6268. // fmt.Println("log")
  6269. // fmt.Println(string(userJSONBytes))
  6270. //
  6271. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6272. // utils.ErrorLog("解析失败:%v", err)
  6273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6274. // return
  6275. // }
  6276. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6277. // res2.Output = ressix10265.Output
  6278. // res2.ErrMsg = ressix10265.ErrMsg
  6279. // res2.Cainfo = ressix10265.Cainfo
  6280. // res2.WarnMsg = ressix10265.WarnMsg
  6281. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6282. // res2.Infcode = infocode
  6283. //
  6284. //}
  6285. func (c *HisApiController) Get4102() {
  6286. order_id, _ := c.GetInt64("order_id")
  6287. admin_user_id, _ := c.GetInt64("admin_user_id")
  6288. stas_type := c.GetString("stas_type")
  6289. order, _ := service.GetHisOrderByIDTwo(order_id)
  6290. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6291. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6292. var pp models.PublicParams
  6293. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6294. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6295. pp.FixmedinsName = miConfig.OrgName
  6296. pp.FixmedinsCode = miConfig.Code
  6297. pp.RequestUrl = miConfig.Url
  6298. pp.Cainfo = miConfig.Cainfo
  6299. pp.SecretKey = miConfig.SecretKey
  6300. pp.AccessKey = miConfig.AccessKey
  6301. pp.OpterName = curRoles.UserName
  6302. if miConfig.MdtrtareaAdmvs == "350500" {
  6303. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6304. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6305. saveLog(result, request, "4102", "清单确认")
  6306. var dat map[string]interface{}
  6307. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6308. fmt.Println(dat)
  6309. } else {
  6310. fmt.Println(err)
  6311. }
  6312. var empty ResultFourteen
  6313. userJSONBytes, _ := json.Marshal(dat)
  6314. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6315. utils.ErrorLog("解析失败:%v", err)
  6316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6317. return
  6318. }
  6319. if empty.Infcode == 0 {
  6320. c.ServeSuccessJSON(map[string]interface{}{
  6321. "msg": "确认成功",
  6322. })
  6323. return
  6324. }
  6325. } else {
  6326. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6327. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6328. result3, request3 := service.Jxyb4105(pp)
  6329. saveLog(result, request, "4102", "清单确认")
  6330. saveLog(result2, request2, "4103", "清单确认")
  6331. saveLog(result3, request3, "4105", "清单统计")
  6332. var dat map[string]interface{}
  6333. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6334. fmt.Println(dat)
  6335. } else {
  6336. fmt.Println(err)
  6337. }
  6338. var empty ResultFourteen
  6339. userJSONBytes, _ := json.Marshal(dat)
  6340. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6341. utils.ErrorLog("解析失败:%v", err)
  6342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6343. return
  6344. }
  6345. if empty.Infcode == 0 {
  6346. c.ServeSuccessJSON(map[string]interface{}{
  6347. "msg": "确认成功",
  6348. })
  6349. return
  6350. }
  6351. }
  6352. }
  6353. // 对账权限查询
  6354. func (c *HisApiController) Get3260() {
  6355. admin_user_id, _ := c.GetInt64("admin_user_id")
  6356. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6358. var api string
  6359. var res models.JSResult3260
  6360. if miConfig.MdtrtareaAdmvs == "320921" {
  6361. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "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
  6363. } else {
  6364. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "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
  6366. }
  6367. resp, requestErr := http.Get(api)
  6368. if requestErr != nil {
  6369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6370. return
  6371. }
  6372. body, ioErr := ioutil.ReadAll(resp.Body)
  6373. if ioErr != nil {
  6374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6376. return
  6377. }
  6378. var respJSON map[string]interface{}
  6379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6382. return
  6383. }
  6384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6385. result, _ := json.Marshal(respJSON)
  6386. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6387. utils.ErrorLog("解析失败:%v", err)
  6388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6389. return
  6390. }
  6391. if res.Infcode == "0" {
  6392. c.ServeSuccessJSON(map[string]interface{}{
  6393. "result": res.Output.Data,
  6394. })
  6395. } else {
  6396. c.ServeSuccessJSON(map[string]interface{}{
  6397. "failed_code": -10,
  6398. "msg": res.ErrMsg,
  6399. })
  6400. return
  6401. }
  6402. }
  6403. func (c *HisApiController) Get3261() {
  6404. admin_user_id, _ := c.GetInt64("admin_user_id")
  6405. //month := c.GetString("month")
  6406. startTime := c.GetString("start_time")
  6407. //endTime, _ := c.GetString("end_time")
  6408. times := strings.Split(startTime, "-")
  6409. stmt_mon := times[0] + times[1]
  6410. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6411. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6412. var api string
  6413. var res models.JSResult3261
  6414. //var res10265 Result5301For10265
  6415. if miConfig.MdtrtareaAdmvs == "320921" {
  6416. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6417. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6418. } else {
  6419. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6420. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6421. }
  6422. resp, requestErr := http.Get(api)
  6423. if requestErr != nil {
  6424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6425. return
  6426. }
  6427. body, ioErr := ioutil.ReadAll(resp.Body)
  6428. if ioErr != nil {
  6429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6431. return
  6432. }
  6433. var respJSON map[string]interface{}
  6434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6437. return
  6438. }
  6439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6440. result, _ := json.Marshal(respJSON)
  6441. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6442. utils.ErrorLog("解析失败:%v", err)
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. return
  6445. }
  6446. if res.Infcode == "0" {
  6447. c.ServeSuccessJSON(map[string]interface{}{
  6448. "result": res.Output,
  6449. })
  6450. } else {
  6451. c.ServeSuccessJSON(map[string]interface{}{
  6452. "failed_code": -10,
  6453. "msg": res.ErrMsg,
  6454. })
  6455. return
  6456. }
  6457. }
  6458. type TempFun struct {
  6459. FundKey string
  6460. FundCode string
  6461. }
  6462. func (c *HisApiController) Get3262() {
  6463. admin_user_id, _ := c.GetInt64("admin_user_id")
  6464. startTime := c.GetString("start_time")
  6465. endTime := c.GetString("end_time")
  6466. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6467. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6468. //timeLayout := "2006-01-02"
  6469. //loc, _ := time.LoadLocation("Local")
  6470. //var theStartTIme int64
  6471. //if len(startTime) > 0 {
  6472. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6473. // if err != nil {
  6474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6475. // return
  6476. // }
  6477. // theStartTIme = theTime.Unix()
  6478. //}
  6479. //var theEndtTIme int64
  6480. //if len(endTime) > 0 {
  6481. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6482. // if err != nil {
  6483. // utils.ErrorLog(err.Error())
  6484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6485. // return
  6486. // }
  6487. // theEndtTIme = theTime.Unix()
  6488. //}
  6489. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6490. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6491. for _, team := range datas {
  6492. fmt.Println(team.PsnTime)
  6493. for _, team_two := range datas_two {
  6494. fmt.Println(team_two.PsnTime)
  6495. if team.FundKey == team_two.FundKey {
  6496. fmt.Println(team_two.PsnTime)
  6497. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6498. fmt.Println(team.PsnTime)
  6499. }
  6500. }
  6501. }
  6502. fmt.Println("1111")
  6503. fmt.Println(datas)
  6504. fmt.Println("1111")
  6505. var twos []models.FixMonRecDetailFileInTwo
  6506. for _, team := range datas {
  6507. var two models.FixMonRecDetailFileInTwo
  6508. two.MedType = team.MedType
  6509. two.Insutype = team.Insutype
  6510. two.PsnType = team.PsnType
  6511. two.MedType = team.MedType
  6512. two.FixBlngAdmdvs = "999999"
  6513. two.InsuAdmdvs = "555555"
  6514. two.PsnTime = team.PsnTime
  6515. two.PsnCnt = team.PsnCnt
  6516. two.FundKey = team.FundKey
  6517. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6518. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6519. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6520. two.MedfeeSumAmt = ms
  6521. two.InscpAmt = ia
  6522. two.FundPaySumAmt = fps
  6523. twos = append(twos, two)
  6524. }
  6525. //startTime := c.GetString("start_time")
  6526. //endTime, _ := c.GetString("end_time")
  6527. times := strings.Split(startTime, "-")
  6528. stmt_mon := times[0] + times[1]
  6529. var funs []models.FundDetail
  6530. for _, item := range datas {
  6531. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6532. funs = append(funs, fun...)
  6533. }
  6534. var funInfos []models.Fund
  6535. //for _, item := range funs {
  6536. // var rf []models.FundInfo
  6537. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6538. // for _, subitem := range rf {
  6539. // var fund models.Fund
  6540. // fund.FundCode = subitem.FundPayType
  6541. // fund.FundName = subitem.FundPayTypeName
  6542. // fund.FundAmt = subitem.FundPayAmt
  6543. // fund.FundKey = item.FundKey
  6544. // fund.InsuAdmdvs = "555555"
  6545. // fund.FixBlngAdmdvs = "999999"
  6546. // funInfos = append(funInfos, fund)
  6547. // }
  6548. //}
  6549. var tempFuns []TempFun
  6550. for _, funInfo := range funInfos {
  6551. var tempFun TempFun
  6552. tempFun.FundKey = funInfo.FundKey
  6553. tempFun.FundCode = funInfo.FundCode
  6554. tempFuns = append(tempFuns, tempFun)
  6555. }
  6556. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6557. fmt.Println(tempFuns)
  6558. var funInfosTwo []models.Fund
  6559. decimal.DivisionPrecision = 2
  6560. for _, item := range tempFuns {
  6561. var fund models.Fund
  6562. for _, subItem := range funInfos {
  6563. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6564. fund.FundKey = subItem.FundKey
  6565. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6566. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6567. fund.FundName = subItem.FundName
  6568. fund.FundCode = subItem.FundCode
  6569. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6570. }
  6571. }
  6572. funInfosTwo = append(funInfosTwo, fund)
  6573. }
  6574. fmt.Println("funInfosTwo")
  6575. fmt.Println(funInfosTwo)
  6576. var upld_btch string
  6577. var empty models.JSResultEmpty
  6578. data := make(map[string]interface{})
  6579. data["org_name"] = miConfig.OrgName
  6580. data["doctor"] = curRoles.UserName
  6581. data["doctor_name"] = curRoles.UserName
  6582. data["fixmedins_code"] = miConfig.Code
  6583. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6584. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6585. data["secret_key"] = miConfig.SecretKey
  6586. data["url"] = miConfig.Url
  6587. data["ak"] = miConfig.AccessKey
  6588. data["cainfo"] = miConfig.Cainfo
  6589. data["datas"] = twos
  6590. data["fund"] = funInfosTwo
  6591. fmt.Println(twos)
  6592. month := time.Unix(1557042972, 0).Format("1")
  6593. year := time.Now().Format("2006")
  6594. month = time.Now().Format("01")
  6595. day := time.Now().Format("02")
  6596. hour := time.Now().Format("15")
  6597. min := time.Now().Format("04")
  6598. sec := time.Now().Format("05")
  6599. fix_fill_date := year + month + day + hour + min + sec
  6600. data["fix_fill_dept"] = miConfig.OrgName
  6601. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6602. data["fix_fill_psn"] = curRoles.UserName
  6603. data["fix_fill_date"] = fix_fill_date
  6604. data["stmt_loc"] = "2"
  6605. data["setl_mon"] = stmt_mon
  6606. upld_btch = "0"
  6607. data["upld_btch"] = upld_btch
  6608. //fmt.Println(data)
  6609. client := &http.Client{}
  6610. bytesData, _ := json.Marshal(data)
  6611. var req *http.Request
  6612. if miConfig.MdtrtareaAdmvs == "320921" {
  6613. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6614. } else {
  6615. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6616. }
  6617. resp, _ := client.Do(req)
  6618. defer resp.Body.Close()
  6619. body, ioErr := ioutil.ReadAll(resp.Body)
  6620. if ioErr != nil {
  6621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6623. }
  6624. var respJSON map[string]interface{}
  6625. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. }
  6629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6630. //fmt.Println(respJSON)
  6631. result, _ := json.Marshal(respJSON)
  6632. //fmt.Println(result)
  6633. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6634. utils.ErrorLog("解析失败:%v", err)
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. }
  6637. if empty.Infcode != "0" {
  6638. c.ServeSuccessJSON(map[string]interface{}{
  6639. "failed_code": -10,
  6640. "msg": empty.ErrMsg,
  6641. })
  6642. return
  6643. } else {
  6644. c.ServeSuccessJSON(map[string]interface{}{
  6645. "msg": "上传成功",
  6646. })
  6647. return
  6648. }
  6649. }
  6650. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6651. newArr = make([]TempFun, 0)
  6652. for i := 0; i < len(arr); i++ {
  6653. repeat := false
  6654. for j := i + 1; j < len(arr); j++ {
  6655. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6656. repeat = true
  6657. break
  6658. }
  6659. }
  6660. if !repeat {
  6661. newArr = append(newArr, arr[i])
  6662. }
  6663. }
  6664. return
  6665. }
  6666. func (c *HisApiController) Get3263() {
  6667. admin_user_id, _ := c.GetInt64("admin_user_id")
  6668. startTime := c.GetString("start_time")
  6669. //endTime, _ := c.GetString("end_time")
  6670. times := strings.Split(startTime, "-")
  6671. setl_mon := times[0] + times[1]
  6672. upld_btch := "0"
  6673. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6674. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6675. var result3263 models.JSResult3263
  6676. data := make(map[string]interface{})
  6677. data["org_name"] = miConfig.OrgName
  6678. data["doctor"] = curRoles.UserName
  6679. data["doctor_name"] = curRoles.UserName
  6680. data["fixmedins_code"] = miConfig.Code
  6681. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6682. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6683. data["secret_key"] = miConfig.SecretKey
  6684. data["url"] = miConfig.Url
  6685. data["ak"] = miConfig.AccessKey
  6686. data["cainfo"] = miConfig.Cainfo
  6687. data["setl_mon"] = setl_mon
  6688. data["stmt_loc"] = "2"
  6689. data["upld_btch"] = upld_btch
  6690. client := &http.Client{}
  6691. bytesData, _ := json.Marshal(data)
  6692. var req *http.Request
  6693. if miConfig.MdtrtareaAdmvs == "320921" {
  6694. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6695. } else {
  6696. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6697. }
  6698. resp, _ := client.Do(req)
  6699. defer resp.Body.Close()
  6700. body, ioErr := ioutil.ReadAll(resp.Body)
  6701. if ioErr != nil {
  6702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6704. }
  6705. var respJSON map[string]interface{}
  6706. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6709. }
  6710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6711. fmt.Println(respJSON)
  6712. result, _ := json.Marshal(respJSON)
  6713. fmt.Println(result)
  6714. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6715. utils.ErrorLog("解析失败:%v", err)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. }
  6718. if result3263.Infcode != "0" {
  6719. c.ServeSuccessJSON(map[string]interface{}{
  6720. "failed_code": -10,
  6721. "msg": result3263.ErrMsg,
  6722. })
  6723. return
  6724. } else {
  6725. c.ServeSuccessJSON(map[string]interface{}{
  6726. "list": result3263.Output,
  6727. })
  6728. return
  6729. }
  6730. }
  6731. func (c *HisApiController) Get3264() {
  6732. admin_user_id, _ := c.GetInt64("admin_user_id")
  6733. startTime := c.GetString("start_time")
  6734. //endTime, _ := c.GetString("end_time")
  6735. times := strings.Split(startTime, "-")
  6736. setl_mon := times[0] + times[1]
  6737. upld_btch := "0"
  6738. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6740. //solidify_id := []
  6741. var result3263 models.JSResult3263
  6742. data := make(map[string]interface{})
  6743. data["org_name"] = miConfig.OrgName
  6744. data["doctor"] = curRoles.UserName
  6745. data["doctor_name"] = curRoles.UserName
  6746. data["fixmedins_code"] = miConfig.Code
  6747. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6748. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6749. data["secret_key"] = miConfig.SecretKey
  6750. data["url"] = miConfig.Url
  6751. data["ak"] = miConfig.AccessKey
  6752. data["cainfo"] = miConfig.Cainfo
  6753. data["setl_mon"] = setl_mon
  6754. data["stmt_loc"] = "2"
  6755. data["upld_btch"] = upld_btch
  6756. client := &http.Client{}
  6757. bytesData, _ := json.Marshal(data)
  6758. var req3263 *http.Request
  6759. if miConfig.MdtrtareaAdmvs == "320921" {
  6760. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6761. } else {
  6762. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6763. }
  6764. resp, _ := client.Do(req3263)
  6765. defer resp.Body.Close()
  6766. body, ioErr := ioutil.ReadAll(resp.Body)
  6767. if ioErr != nil {
  6768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6770. }
  6771. var respJSON3263 map[string]interface{}
  6772. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6775. }
  6776. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6777. fmt.Println(respJSON3263)
  6778. result, _ := json.Marshal(respJSON3263)
  6779. fmt.Println(result)
  6780. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6781. utils.ErrorLog("解析失败:%v", err)
  6782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6783. }
  6784. var ids []string
  6785. for _, item := range result3263.Output {
  6786. ids = append(ids, item.SolidifyID)
  6787. }
  6788. var empty models.JSResultEmpty
  6789. data2 := make(map[string]interface{})
  6790. data2["org_name"] = miConfig.OrgName
  6791. data2["doctor"] = curRoles.UserName
  6792. data2["doctor_name"] = curRoles.UserName
  6793. data2["fixmedins_code"] = miConfig.Code
  6794. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6795. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6796. data2["secret_key"] = miConfig.SecretKey
  6797. data2["url"] = miConfig.Url
  6798. data2["ak"] = miConfig.AccessKey
  6799. data2["cainfo"] = miConfig.Cainfo
  6800. data2["setl_mon"] = setl_mon
  6801. data2["stmt_loc"] = "2"
  6802. data2["upld_btch"] = upld_btch
  6803. data2["solidify_id"] = ids
  6804. client2 := &http.Client{}
  6805. bytesData2, _ := json.Marshal(data2)
  6806. var req *http.Request
  6807. if miConfig.MdtrtareaAdmvs == "320921" {
  6808. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6809. } else {
  6810. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6811. }
  6812. resp2, _ := client2.Do(req)
  6813. defer resp.Body.Close()
  6814. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6815. if ioErr2 != nil {
  6816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6818. }
  6819. var respJSON map[string]interface{}
  6820. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6823. }
  6824. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6825. fmt.Println(respJSON)
  6826. result2, _ := json.Marshal(respJSON)
  6827. fmt.Println(result2)
  6828. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6829. utils.ErrorLog("解析失败:%v", err)
  6830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6831. }
  6832. if empty.Infcode != "0" {
  6833. c.ServeSuccessJSON(map[string]interface{}{
  6834. "failed_code": -10,
  6835. "msg": empty.ErrMsg,
  6836. })
  6837. return
  6838. } else {
  6839. c.ServeSuccessJSON(map[string]interface{}{
  6840. "msg": "",
  6841. })
  6842. return
  6843. }
  6844. }
  6845. func (c *HisApiController) Get3265() {
  6846. admin_user_id, _ := c.GetInt64("admin_user_id")
  6847. startTime := c.GetString("start_time")
  6848. //endTime, _ := c.GetString("end_time")
  6849. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6850. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6851. times := strings.Split(startTime, "-")
  6852. setl_mon := times[0] + times[1]
  6853. var upld_btch string
  6854. upld_btch = "0"
  6855. //var empty models.JSResultEmpty
  6856. var result3265 models.JSResult3264
  6857. var result3263 models.JSResult3263
  6858. data2 := make(map[string]interface{})
  6859. data2["org_name"] = miConfig.OrgName
  6860. data2["doctor"] = curRoles.UserName
  6861. data2["doctor_name"] = curRoles.UserName
  6862. data2["fixmedins_code"] = miConfig.Code
  6863. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6864. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6865. data2["secret_key"] = miConfig.SecretKey
  6866. data2["url"] = miConfig.Url
  6867. data2["ak"] = miConfig.AccessKey
  6868. data2["cainfo"] = miConfig.Cainfo
  6869. data2["setl_mon"] = setl_mon
  6870. data2["stmt_loc"] = "2"
  6871. data2["upld_btch"] = upld_btch
  6872. client2 := &http.Client{}
  6873. bytesData2, _ := json.Marshal(data2)
  6874. var req3263 *http.Request
  6875. if miConfig.MdtrtareaAdmvs == "320921" {
  6876. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6877. } else {
  6878. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6879. }
  6880. resp2, _ := client2.Do(req3263)
  6881. defer resp2.Body.Close()
  6882. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6883. if ioErr2 != nil {
  6884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. }
  6887. var respJSON3263 map[string]interface{}
  6888. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6891. }
  6892. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6893. fmt.Println(respJSON3263)
  6894. result2, _ := json.Marshal(respJSON3263)
  6895. fmt.Println(result2)
  6896. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6897. utils.ErrorLog("解析失败:%v", err)
  6898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6899. }
  6900. var ids []string
  6901. for _, item := range result3263.Output {
  6902. ids = append(ids, item.SolidifyID)
  6903. }
  6904. data := make(map[string]interface{})
  6905. data["org_name"] = miConfig.OrgName
  6906. data["doctor"] = curRoles.UserName
  6907. data["doctor_name"] = curRoles.UserName
  6908. data["fixmedins_code"] = miConfig.Code
  6909. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6910. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6911. data["secret_key"] = miConfig.SecretKey
  6912. data["url"] = miConfig.Url
  6913. data["ak"] = miConfig.AccessKey
  6914. data["cainfo"] = miConfig.Cainfo
  6915. data["setl_mon"] = setl_mon
  6916. data["solidify_id"] = ids
  6917. month := time.Unix(1557042972, 0).Format("1")
  6918. year := time.Now().Format("2006")
  6919. month = time.Now().Format("01")
  6920. day := time.Now().Format("02")
  6921. hour := time.Now().Format("15")
  6922. min := time.Now().Format("04")
  6923. sec := time.Now().Format("05")
  6924. fix_fill_date := year + month + day + hour + min + sec
  6925. data["fix_fill_dept"] = miConfig.OrgName
  6926. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6927. data["fix_fill_psn"] = curRoles.UserName
  6928. data["fix_fill_date"] = fix_fill_date
  6929. data["stmt_loc"] = "2"
  6930. data["upld_btch"] = upld_btch
  6931. client := &http.Client{}
  6932. bytesData, _ := json.Marshal(data)
  6933. var req *http.Request
  6934. if miConfig.MdtrtareaAdmvs == "320921" {
  6935. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6936. } else {
  6937. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6938. }
  6939. resp, _ := client.Do(req)
  6940. defer resp.Body.Close()
  6941. body, ioErr := ioutil.ReadAll(resp.Body)
  6942. if ioErr != nil {
  6943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6945. }
  6946. var respJSON map[string]interface{}
  6947. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6950. }
  6951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6952. fmt.Println(respJSON)
  6953. result, _ := json.Marshal(respJSON)
  6954. fmt.Println(result)
  6955. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6956. utils.ErrorLog("解析失败:%v", err)
  6957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6958. }
  6959. if result3265.Infcode != "0" {
  6960. c.ServeSuccessJSON(map[string]interface{}{
  6961. "failed_code": -10,
  6962. "msg": result3265.ErrMsg,
  6963. })
  6964. return
  6965. } else {
  6966. c.ServeSuccessJSON(map[string]interface{}{
  6967. "info": result3265.Output,
  6968. })
  6969. return
  6970. }
  6971. }
  6972. func (c *HisApiController) Get3266() {
  6973. admin_user_id, _ := c.GetInt64("admin_user_id")
  6974. startTime := c.GetString("start_time")
  6975. //endTime, _ := c.GetString("end_time")
  6976. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6978. times := strings.Split(startTime, "-")
  6979. stmt_mon := times[0] + times[1]
  6980. var upld_btch string
  6981. //var empty models.JSResultEmpty
  6982. var result3265 models.JSResult3264
  6983. data := make(map[string]interface{})
  6984. data["org_name"] = miConfig.OrgName
  6985. data["doctor"] = curRoles.UserName
  6986. data["doctor_name"] = curRoles.UserName
  6987. data["fixmedins_code"] = miConfig.Code
  6988. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6989. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6990. data["secret_key"] = miConfig.SecretKey
  6991. data["url"] = miConfig.Url
  6992. data["ak"] = miConfig.AccessKey
  6993. data["cainfo"] = miConfig.Cainfo
  6994. data["setl_mon"] = stmt_mon
  6995. month := time.Unix(1557042972, 0).Format("1")
  6996. year := time.Now().Format("2006")
  6997. month = time.Now().Format("01")
  6998. day := time.Now().Format("02")
  6999. hour := time.Now().Format("15")
  7000. min := time.Now().Format("04")
  7001. sec := time.Now().Format("05")
  7002. fix_fill_date := year + month + day + hour + min + sec
  7003. data["fix_fill_dept"] = miConfig.OrgName
  7004. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7005. data["fix_fill_psn"] = curRoles.UserName
  7006. data["fix_fill_date"] = fix_fill_date
  7007. data["stmt_loc"] = "2"
  7008. upld_btch = "0"
  7009. data["upld_btch"] = upld_btch
  7010. client := &http.Client{}
  7011. bytesData, _ := json.Marshal(data)
  7012. var req *http.Request
  7013. if miConfig.MdtrtareaAdmvs == "320921" {
  7014. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7015. } else {
  7016. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7017. }
  7018. resp, _ := client.Do(req)
  7019. defer resp.Body.Close()
  7020. body, ioErr := ioutil.ReadAll(resp.Body)
  7021. if ioErr != nil {
  7022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. }
  7025. var respJSON map[string]interface{}
  7026. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. }
  7030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7031. fmt.Println(respJSON)
  7032. result, _ := json.Marshal(respJSON)
  7033. fmt.Println(result)
  7034. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7035. utils.ErrorLog("解析失败:%v", err)
  7036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7037. }
  7038. if result3265.Infcode != "0" {
  7039. c.ServeSuccessJSON(map[string]interface{}{
  7040. "failed_code": -10,
  7041. "msg": result3265.ErrMsg,
  7042. })
  7043. return
  7044. } else {
  7045. c.ServeSuccessJSON(map[string]interface{}{
  7046. "info": result3265.Output,
  7047. })
  7048. return
  7049. }
  7050. }
  7051. func (c *HisApiController) Get3267() {
  7052. admin_user_id, _ := c.GetInt64("admin_user_id")
  7053. startTime := c.GetString("start_time")
  7054. //endTime, _ := c.GetString("end_time")
  7055. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7057. times := strings.Split(startTime, "-")
  7058. setl_mon := times[0] + times[1]
  7059. var upld_btch string
  7060. //var empty models.JSResultEmpty
  7061. var result3265 models.JSResult3264
  7062. upld_btch = "0"
  7063. data := make(map[string]interface{})
  7064. data["org_name"] = miConfig.OrgName
  7065. data["doctor"] = curRoles.UserName
  7066. data["doctor_name"] = curRoles.UserName
  7067. data["fixmedins_code"] = miConfig.Code
  7068. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7069. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7070. data["secret_key"] = miConfig.SecretKey
  7071. data["url"] = miConfig.Url
  7072. data["ak"] = miConfig.AccessKey
  7073. data["cainfo"] = miConfig.Cainfo
  7074. data["setl_mon"] = setl_mon
  7075. data["stmt_loc"] = "2"
  7076. data["upld_btch"] = upld_btch
  7077. client := &http.Client{}
  7078. bytesData, _ := json.Marshal(data)
  7079. var req *http.Request
  7080. if miConfig.MdtrtareaAdmvs == "320921" {
  7081. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7082. } else {
  7083. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7084. }
  7085. resp, _ := client.Do(req)
  7086. defer resp.Body.Close()
  7087. body, ioErr := ioutil.ReadAll(resp.Body)
  7088. if ioErr != nil {
  7089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. }
  7092. var respJSON map[string]interface{}
  7093. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7096. }
  7097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7098. fmt.Println(respJSON)
  7099. result, _ := json.Marshal(respJSON)
  7100. fmt.Println(result)
  7101. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7102. utils.ErrorLog("解析失败:%v", err)
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. }
  7105. if result3265.Infcode != "0" {
  7106. c.ServeSuccessJSON(map[string]interface{}{
  7107. "failed_code": -10,
  7108. "msg": result3265.ErrMsg,
  7109. })
  7110. return
  7111. } else {
  7112. c.ServeSuccessJSON(map[string]interface{}{
  7113. "info": result3265.Output.Data,
  7114. })
  7115. return
  7116. }
  7117. }
  7118. func (c *HisApiController) Get3268() {
  7119. admin_user_id, _ := c.GetInt64("admin_user_id")
  7120. startTime := c.GetString("start_time")
  7121. endTime := c.GetString("end_time")
  7122. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7123. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7124. times := strings.Split(startTime, "-")
  7125. setl_mon := times[0] + times[1]
  7126. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7127. var twos []models.FixMonRecDetailFileInTwo
  7128. var funs []models.FundDetail
  7129. for _, item := range datas {
  7130. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7131. funs = append(funs, fun...)
  7132. }
  7133. var funInfos []models.Fund
  7134. //for _, item := range funs {
  7135. // var rf []models.FundInfo
  7136. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7137. // for _, subitem := range rf {
  7138. // var fund models.Fund
  7139. // fund.FundCode = subitem.FundPayType
  7140. // fund.FundName = subitem.FundPayTypeName
  7141. // fund.FundAmt = subitem.FundPayAmt
  7142. // fund.FundKey = item.FundKey
  7143. // fund.InsuAdmdvs = "555555"
  7144. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7145. // funInfos = append(funInfos, fund)
  7146. // }
  7147. //}
  7148. for _, team := range datas {
  7149. var two models.FixMonRecDetailFileInTwo
  7150. two.SetlDate = time.Now().Format("2006-01-02")
  7151. two.MedType = team.MedType
  7152. two.Insutype = team.Insutype
  7153. two.PsnType = team.PsnType
  7154. two.MedType = team.MedType
  7155. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7156. two.InsuAdmdvs = team.InsuAdmdvs
  7157. two.PsnTime = team.PsnTime
  7158. two.PsnCnt = team.PsnCnt
  7159. two.FundKey = team.FundKey
  7160. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7161. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7162. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7163. two.MedfeeSumAmt = ms
  7164. two.InscpAmt = ia
  7165. two.FundPaySumAmt = fps
  7166. twos = append(twos, two)
  7167. }
  7168. var upld_btch string
  7169. upld_btch = "0"
  7170. var empty models.JSResultEmpty
  7171. data := make(map[string]interface{})
  7172. data["org_name"] = miConfig.OrgName
  7173. data["doctor"] = curRoles.UserName
  7174. data["doctor_name"] = curRoles.UserName
  7175. data["fixmedins_code"] = miConfig.Code
  7176. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7177. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7178. data["secret_key"] = miConfig.SecretKey
  7179. data["url"] = miConfig.Url
  7180. data["ak"] = miConfig.AccessKey
  7181. data["cainfo"] = miConfig.Cainfo
  7182. data["datas"] = twos
  7183. data["fund"] = funInfos
  7184. data["setl_mon"] = setl_mon
  7185. month := time.Unix(1557042972, 0).Format("1")
  7186. year := time.Now().Format("2006")
  7187. month = time.Now().Format("01")
  7188. day := time.Now().Format("02")
  7189. hour := time.Now().Format("15")
  7190. min := time.Now().Format("04")
  7191. sec := time.Now().Format("05")
  7192. fix_fill_date := year + month + day + hour + min + sec
  7193. data["fix_fill_dept"] = miConfig.OrgName
  7194. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7195. data["fix_fill_psn"] = curRoles.UserName
  7196. data["fix_fill_date"] = fix_fill_date
  7197. data["stmt_loc"] = "2"
  7198. data["upld_btch"] = upld_btch
  7199. client := &http.Client{}
  7200. bytesData, _ := json.Marshal(data)
  7201. var req *http.Request
  7202. if miConfig.MdtrtareaAdmvs == "320921" {
  7203. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7204. } else {
  7205. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7206. }
  7207. resp, _ := client.Do(req)
  7208. defer resp.Body.Close()
  7209. body, ioErr := ioutil.ReadAll(resp.Body)
  7210. if ioErr != nil {
  7211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. }
  7214. var respJSON map[string]interface{}
  7215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. }
  7219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7220. fmt.Println(respJSON)
  7221. result, _ := json.Marshal(respJSON)
  7222. fmt.Println(result)
  7223. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7224. utils.ErrorLog("解析失败:%v", err)
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. }
  7227. if empty.Infcode != "0" {
  7228. c.ServeSuccessJSON(map[string]interface{}{
  7229. "failed_code": -10,
  7230. "msg": empty.ErrMsg,
  7231. })
  7232. return
  7233. } else {
  7234. c.ServeSuccessJSON(map[string]interface{}{
  7235. "msg": "上传成功",
  7236. })
  7237. return
  7238. }
  7239. }
  7240. func (c *HisApiController) Get3269() {
  7241. admin_user_id, _ := c.GetInt64("admin_user_id")
  7242. startTime := c.GetString("start_time")
  7243. //endTime, _ := c.GetString("end_time")
  7244. times := strings.Split(startTime, "-")
  7245. setl_mon := times[0] + times[1]
  7246. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7247. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7248. var result3263 models.JSResult3263
  7249. data := make(map[string]interface{})
  7250. data["org_name"] = miConfig.OrgName
  7251. data["doctor"] = curRoles.UserName
  7252. data["doctor_name"] = curRoles.UserName
  7253. data["fixmedins_code"] = miConfig.Code
  7254. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7255. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7256. data["secret_key"] = miConfig.SecretKey
  7257. data["url"] = miConfig.Url
  7258. data["ak"] = miConfig.AccessKey
  7259. data["cainfo"] = miConfig.Cainfo
  7260. data["setl_mon"] = setl_mon
  7261. data["stmt_loc"] = "2"
  7262. client := &http.Client{}
  7263. bytesData, _ := json.Marshal(data)
  7264. var req *http.Request
  7265. if miConfig.MdtrtareaAdmvs == "320921" {
  7266. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7267. } else {
  7268. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7269. }
  7270. resp, _ := client.Do(req)
  7271. defer resp.Body.Close()
  7272. body, ioErr := ioutil.ReadAll(resp.Body)
  7273. if ioErr != nil {
  7274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7276. }
  7277. var respJSON map[string]interface{}
  7278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. }
  7282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7283. fmt.Println(respJSON)
  7284. result, _ := json.Marshal(respJSON)
  7285. fmt.Println(result)
  7286. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7287. utils.ErrorLog("解析失败:%v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. }
  7290. if result3263.Infcode != "0" {
  7291. c.ServeSuccessJSON(map[string]interface{}{
  7292. "failed_code": -10,
  7293. "msg": result3263.ErrMsg,
  7294. })
  7295. return
  7296. } else {
  7297. c.ServeSuccessJSON(map[string]interface{}{
  7298. "msg": "上传成功",
  7299. })
  7300. return
  7301. }
  7302. }
  7303. func (c *HisApiController) Get3270() {
  7304. admin_user_id, _ := c.GetInt64("admin_user_id")
  7305. startTime := c.GetString("start_time")
  7306. //endTime, _ := c.GetString("end_time")
  7307. times := strings.Split(startTime, "-")
  7308. setl_mon := times[0] + times[1]
  7309. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7311. var result3263 models.JSResult3263
  7312. data2 := make(map[string]interface{})
  7313. data2["org_name"] = miConfig.OrgName
  7314. data2["doctor"] = curRoles.UserName
  7315. data2["doctor_name"] = curRoles.UserName
  7316. data2["fixmedins_code"] = miConfig.Code
  7317. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7318. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7319. data2["secret_key"] = miConfig.SecretKey
  7320. data2["url"] = miConfig.Url
  7321. data2["ak"] = miConfig.AccessKey
  7322. data2["cainfo"] = miConfig.Cainfo
  7323. data2["setl_mon"] = setl_mon
  7324. data2["stmt_loc"] = "2"
  7325. client2 := &http.Client{}
  7326. bytesData2, _ := json.Marshal(data2)
  7327. var req3263 *http.Request
  7328. if miConfig.MdtrtareaAdmvs == "320921" {
  7329. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7330. } else {
  7331. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7332. }
  7333. resp2, _ := client2.Do(req3263)
  7334. defer resp2.Body.Close()
  7335. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7336. if ioErr2 != nil {
  7337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7339. }
  7340. var respJSON3263 map[string]interface{}
  7341. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7344. }
  7345. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7346. fmt.Println(respJSON3263)
  7347. result2, _ := json.Marshal(respJSON3263)
  7348. fmt.Println(result2)
  7349. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7350. utils.ErrorLog("解析失败:%v", err)
  7351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7352. }
  7353. var ids []string
  7354. for _, item := range result3263.Output {
  7355. ids = append(ids, item.SolidifyID)
  7356. }
  7357. var result3264 models.JSResult3264
  7358. data := make(map[string]interface{})
  7359. data["org_name"] = miConfig.OrgName
  7360. data["doctor"] = curRoles.UserName
  7361. data["doctor_name"] = curRoles.UserName
  7362. data["fixmedins_code"] = miConfig.Code
  7363. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7364. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7365. data["secret_key"] = miConfig.SecretKey
  7366. data["url"] = miConfig.Url
  7367. data["ak"] = miConfig.AccessKey
  7368. data["cainfo"] = miConfig.Cainfo
  7369. data["setl_mon"] = setl_mon
  7370. data["stmt_loc"] = "2"
  7371. data["solidify_id"] = ids
  7372. client := &http.Client{}
  7373. bytesData, _ := json.Marshal(data)
  7374. var req *http.Request
  7375. if miConfig.MdtrtareaAdmvs == "320921" {
  7376. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7377. } else {
  7378. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7379. }
  7380. resp, _ := client.Do(req)
  7381. defer resp.Body.Close()
  7382. body, ioErr := ioutil.ReadAll(resp.Body)
  7383. if ioErr != nil {
  7384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. }
  7387. var respJSON map[string]interface{}
  7388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7391. }
  7392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7393. fmt.Println(respJSON)
  7394. result, _ := json.Marshal(respJSON)
  7395. fmt.Println(result)
  7396. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7397. utils.ErrorLog("解析失败:%v", err)
  7398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7399. }
  7400. if result3264.Infcode != "0" {
  7401. c.ServeSuccessJSON(map[string]interface{}{
  7402. "failed_code": -10,
  7403. "msg": result3264.ErrMsg,
  7404. })
  7405. return
  7406. } else {
  7407. c.ServeSuccessJSON(map[string]interface{}{
  7408. "info": result3264.Output,
  7409. })
  7410. return
  7411. }
  7412. }
  7413. func (c *HisApiController) Get3271() {
  7414. admin_user_id, _ := c.GetInt64("admin_user_id")
  7415. startTime := c.GetString("start_time")
  7416. //endTime, _ := c.GetString("end_time")
  7417. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7419. times := strings.Split(startTime, "-")
  7420. setl_mon := times[0] + times[1]
  7421. //var empty models.JSResultEmpty
  7422. var result3265 models.JSResult3264
  7423. var result3263 models.JSResult3263
  7424. data2 := make(map[string]interface{})
  7425. data2["org_name"] = miConfig.OrgName
  7426. data2["doctor"] = curRoles.UserName
  7427. data2["doctor_name"] = curRoles.UserName
  7428. data2["fixmedins_code"] = miConfig.Code
  7429. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7430. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7431. data2["secret_key"] = miConfig.SecretKey
  7432. data2["url"] = miConfig.Url
  7433. data2["ak"] = miConfig.AccessKey
  7434. data2["cainfo"] = miConfig.Cainfo
  7435. data2["setl_mon"] = setl_mon
  7436. data2["stmt_loc"] = "2"
  7437. client2 := &http.Client{}
  7438. bytesData2, _ := json.Marshal(data2)
  7439. var req3263 *http.Request
  7440. if miConfig.MdtrtareaAdmvs == "320921" {
  7441. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7442. } else {
  7443. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7444. }
  7445. resp2, _ := client2.Do(req3263)
  7446. defer resp2.Body.Close()
  7447. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7448. if ioErr2 != nil {
  7449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7451. }
  7452. var respJSON3263 map[string]interface{}
  7453. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. }
  7457. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7458. fmt.Println(respJSON3263)
  7459. result2, _ := json.Marshal(respJSON3263)
  7460. fmt.Println(result2)
  7461. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7462. utils.ErrorLog("解析失败:%v", err)
  7463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7464. }
  7465. var ids []string
  7466. for _, item := range result3263.Output {
  7467. ids = append(ids, item.SolidifyID)
  7468. }
  7469. data := make(map[string]interface{})
  7470. data["org_name"] = miConfig.OrgName
  7471. data["doctor"] = curRoles.UserName
  7472. data["doctor_name"] = curRoles.UserName
  7473. data["fixmedins_code"] = miConfig.Code
  7474. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7475. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7476. data["secret_key"] = miConfig.SecretKey
  7477. data["url"] = miConfig.Url
  7478. data["ak"] = miConfig.AccessKey
  7479. data["cainfo"] = miConfig.Cainfo
  7480. data["setl_mon"] = setl_mon
  7481. data["solidify_id"] = ids
  7482. month := time.Unix(1557042972, 0).Format("1")
  7483. year := time.Now().Format("2006")
  7484. month = time.Now().Format("01")
  7485. day := time.Now().Format("02")
  7486. hour := time.Now().Format("15")
  7487. min := time.Now().Format("04")
  7488. sec := time.Now().Format("05")
  7489. fix_fill_date := year + month + day + hour + min + sec
  7490. data["fix_fill_dept"] = miConfig.OrgName
  7491. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7492. data["fix_fill_psn"] = curRoles.UserName
  7493. data["fix_fill_date"] = fix_fill_date
  7494. data["stmt_loc"] = "2"
  7495. client := &http.Client{}
  7496. bytesData, _ := json.Marshal(data)
  7497. var req *http.Request
  7498. if miConfig.MdtrtareaAdmvs == "320921" {
  7499. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7500. } else {
  7501. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7502. }
  7503. resp, _ := client.Do(req)
  7504. defer resp.Body.Close()
  7505. body, ioErr := ioutil.ReadAll(resp.Body)
  7506. if ioErr != nil {
  7507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7509. }
  7510. var respJSON map[string]interface{}
  7511. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7514. }
  7515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7516. fmt.Println(respJSON)
  7517. result, _ := json.Marshal(respJSON)
  7518. fmt.Println(result)
  7519. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7520. utils.ErrorLog("解析失败:%v", err)
  7521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7522. }
  7523. if result3265.Infcode != "0" {
  7524. c.ServeSuccessJSON(map[string]interface{}{
  7525. "failed_code": -10,
  7526. "msg": result3265.ErrMsg,
  7527. })
  7528. return
  7529. } else {
  7530. c.ServeSuccessJSON(map[string]interface{}{
  7531. "info": result3265.Output.Data,
  7532. })
  7533. return
  7534. }
  7535. }
  7536. func (c *HisApiController) Get3272() {
  7537. admin_user_id, _ := c.GetInt64("admin_user_id")
  7538. startTime := c.GetString("start_time")
  7539. //endTime, _ := c.GetString("end_time")
  7540. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7541. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7542. times := strings.Split(startTime, "-")
  7543. setl_mon := times[0] + times[1]
  7544. var upld_btch string
  7545. //var empty models.JSResultEmpty
  7546. var result3265 models.JSResult3264
  7547. data := make(map[string]interface{})
  7548. data["org_name"] = miConfig.OrgName
  7549. data["doctor"] = curRoles.UserName
  7550. data["doctor_name"] = curRoles.UserName
  7551. data["fixmedins_code"] = miConfig.Code
  7552. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7553. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7554. data["secret_key"] = miConfig.SecretKey
  7555. data["url"] = miConfig.Url
  7556. data["ak"] = miConfig.AccessKey
  7557. data["cainfo"] = miConfig.Cainfo
  7558. data["setl_mon"] = setl_mon
  7559. month := time.Unix(1557042972, 0).Format("1")
  7560. year := time.Now().Format("2006")
  7561. month = time.Now().Format("01")
  7562. day := time.Now().Format("02")
  7563. hour := time.Now().Format("15")
  7564. min := time.Now().Format("04")
  7565. sec := time.Now().Format("05")
  7566. fix_fill_date := year + month + day + hour + min + sec
  7567. data["fix_fill_dept"] = miConfig.OrgName
  7568. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7569. data["fix_fill_psn"] = curRoles.UserName
  7570. data["fix_fill_date"] = fix_fill_date
  7571. data["stmt_loc"] = "2"
  7572. data["upld_btch"] = upld_btch
  7573. client := &http.Client{}
  7574. bytesData, _ := json.Marshal(data)
  7575. var req *http.Request
  7576. if miConfig.MdtrtareaAdmvs == "320921" {
  7577. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7578. } else {
  7579. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7580. }
  7581. resp, _ := client.Do(req)
  7582. defer resp.Body.Close()
  7583. body, ioErr := ioutil.ReadAll(resp.Body)
  7584. if ioErr != nil {
  7585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7587. }
  7588. var respJSON map[string]interface{}
  7589. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7592. }
  7593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7594. fmt.Println(respJSON)
  7595. result, _ := json.Marshal(respJSON)
  7596. fmt.Println(result)
  7597. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7598. utils.ErrorLog("解析失败:%v", err)
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. }
  7601. if result3265.Infcode != "0" {
  7602. c.ServeSuccessJSON(map[string]interface{}{
  7603. "failed_code": -10,
  7604. "msg": result3265.ErrMsg,
  7605. })
  7606. return
  7607. } else {
  7608. c.ServeSuccessJSON(map[string]interface{}{
  7609. "info": result3265.Output,
  7610. })
  7611. return
  7612. }
  7613. }
  7614. func (c *HisApiController) Get3273() {
  7615. admin_user_id, _ := c.GetInt64("admin_user_id")
  7616. startTime := c.GetString("start_time")
  7617. //endTime, _ := c.GetString("end_time")
  7618. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7619. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7620. times := strings.Split(startTime, "-")
  7621. setl_mon := times[0] + times[1]
  7622. var result3265 models.JSResult3264
  7623. data := make(map[string]interface{})
  7624. data["org_name"] = miConfig.OrgName
  7625. data["doctor"] = curRoles.UserName
  7626. data["doctor_name"] = curRoles.UserName
  7627. data["fixmedins_code"] = miConfig.Code
  7628. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7629. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7630. data["secret_key"] = miConfig.SecretKey
  7631. data["url"] = miConfig.Url
  7632. data["ak"] = miConfig.AccessKey
  7633. data["cainfo"] = miConfig.Cainfo
  7634. data["setl_mon"] = setl_mon
  7635. data["stmt_loc"] = "2"
  7636. client := &http.Client{}
  7637. bytesData, _ := json.Marshal(data)
  7638. var req *http.Request
  7639. if miConfig.MdtrtareaAdmvs == "320921" {
  7640. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7641. } else {
  7642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7643. }
  7644. resp, _ := client.Do(req)
  7645. defer resp.Body.Close()
  7646. body, ioErr := ioutil.ReadAll(resp.Body)
  7647. if ioErr != nil {
  7648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7650. }
  7651. var respJSON map[string]interface{}
  7652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7655. }
  7656. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7657. fmt.Println(respJSON)
  7658. result, _ := json.Marshal(respJSON)
  7659. fmt.Println(result)
  7660. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7661. utils.ErrorLog("解析失败:%v", err)
  7662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7663. }
  7664. if result3265.Infcode != "0" {
  7665. c.ServeSuccessJSON(map[string]interface{}{
  7666. "failed_code": -10,
  7667. "msg": result3265.ErrMsg,
  7668. })
  7669. return
  7670. } else {
  7671. c.ServeSuccessJSON(map[string]interface{}{
  7672. "info": result3265.Output.Data,
  7673. })
  7674. return
  7675. }
  7676. }
  7677. func (c *HisApiController) Get3274() {
  7678. //if miConfig.MdtrtareaAdmvs == "320921" {
  7679. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7680. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7681. // "&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
  7682. //
  7683. //} else {
  7684. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7685. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7686. // "&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
  7687. //
  7688. //}
  7689. }
  7690. func (c *HisApiController) Get3275() {
  7691. //if miConfig.MdtrtareaAdmvs == "320921" {
  7692. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7693. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7694. // "&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
  7695. //
  7696. //} else {
  7697. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7698. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7699. // "&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
  7700. //
  7701. //}
  7702. }
  7703. func (c *HisApiController) Get3276() {
  7704. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7705. //month := c.GetString("month")
  7706. //
  7707. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7708. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7709. //var api string
  7710. //var res Result5301
  7711. //
  7712. //if miConfig.MdtrtareaAdmvs == "320921" {
  7713. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7714. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7715. //} else {
  7716. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7717. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7718. //}
  7719. //
  7720. //resp, requestErr := http.Get(api)
  7721. //if requestErr != nil {
  7722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7723. // return
  7724. //}
  7725. //
  7726. //body, ioErr := ioutil.ReadAll(resp.Body)
  7727. //if ioErr != nil {
  7728. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7730. // return
  7731. //}
  7732. //var respJSON map[string]interface{}
  7733. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7734. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7736. // return
  7737. //}
  7738. //
  7739. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7740. //result, _ := json.Marshal(respJSON)
  7741. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7742. // utils.ErrorLog("解析失败:%v", err)
  7743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. // return
  7745. //}
  7746. }
  7747. func (c *HisApiController) Get3277() {
  7748. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7749. //month := c.GetString("month")
  7750. //
  7751. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7752. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7753. //var api string
  7754. //var res Result5301
  7755. //
  7756. //if miConfig.MdtrtareaAdmvs == "320921" {
  7757. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7758. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7759. //} else {
  7760. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7761. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7762. //}
  7763. //
  7764. //resp, requestErr := http.Get(api)
  7765. //if requestErr != nil {
  7766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7767. // return
  7768. //}
  7769. //
  7770. //body, ioErr := ioutil.ReadAll(resp.Body)
  7771. //if ioErr != nil {
  7772. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7774. // return
  7775. //}
  7776. //var respJSON map[string]interface{}
  7777. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7778. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7779. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7780. // return
  7781. //}
  7782. //
  7783. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7784. //result, _ := json.Marshal(respJSON)
  7785. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7786. // utils.ErrorLog("解析失败:%v", err)
  7787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7788. // return
  7789. //}
  7790. }
  7791. func (c *HisApiController) GetCFYLJG001() {
  7792. admin_user_id, _ := c.GetInt64("admin_user_id")
  7793. patient_id, _ := c.GetInt64("patient_id")
  7794. his_patient_id, _ := c.GetInt64("his_patient_id")
  7795. record_time := c.GetString("record_time")
  7796. admin_user_id = 3626
  7797. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7798. psn, _ := service.GetPsnByPatientId(patient_id)
  7799. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7800. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7801. var cFYLJG001 models.CFYLJG001
  7802. timeLayout := "2006-01-02"
  7803. loc, _ := time.LoadLocation("Local")
  7804. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7805. if err != nil {
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7807. return
  7808. }
  7809. recordDateTime := theTime.Unix()
  7810. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7811. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7812. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7813. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7814. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7815. for _, item := range prescriptions {
  7816. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7817. if his.IdCardType == 1 {
  7818. bas := strings.Split(psn.CardInfo, "|")
  7819. basNumber := bas[1]
  7820. fmt.Println(basNumber)
  7821. card_sn := bas[3]
  7822. card_no := bas[2]
  7823. cFYLJG001.MdtrtCertType = "03"
  7824. cFYLJG001.CardSn = card_sn
  7825. cFYLJG001.MdtrtCertNo = card_no
  7826. cFYLJG001.EcToken = ""
  7827. cFYLJG001.AuthNo = ""
  7828. } else if his.IdCardType == 2 {
  7829. cFYLJG001.MdtrtCertType = "02"
  7830. cFYLJG001.CardSn = ""
  7831. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7832. cFYLJG001.EcToken = ""
  7833. cFYLJG001.AuthNo = ""
  7834. } else if his.IdCardType == 4 {
  7835. cFYLJG001.MdtrtCertType = "01"
  7836. cFYLJG001.CardSn = ""
  7837. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7838. cFYLJG001.EcToken = psn.VerifyNumber
  7839. cFYLJG001.AuthNo = ""
  7840. }
  7841. cFYLJG001.BizTypeCode = "01"
  7842. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7843. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7844. cFYLJG001.RxTypeCode = "1"
  7845. tempTime := time.Unix(item.PreTime, 0)
  7846. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7847. cFYLJG001.PrscTime = timeFormatOne
  7848. var count float64
  7849. if item.Type == 1 {
  7850. for _, sumItem := range item.HisDoctorAdviceInfo {
  7851. count = count + sumItem.PrescribingNumber
  7852. }
  7853. }
  7854. cFYLJG001.RxDrugCnt = count
  7855. cFYLJG001.ValiDays = "5"
  7856. ts := time.Unix(item.PreTime, 0)
  7857. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7858. tempTime3 := time.Unix(record_time2, 0)
  7859. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7860. cFYLJG001.ValiEndTime = timeFormat3
  7861. cFYLJG001.RxCotnFlag = "0"
  7862. for _, subItem := range item.HisDoctorAdviceInfo {
  7863. var drug models.RxDrug
  7864. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7865. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7866. drug.RxItemTypeCode = "11"
  7867. drug.DrugDosform = "乳膏剂" //TODO
  7868. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7869. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7870. }
  7871. drug.MedcWayDscr = subItem.DeliveryWay
  7872. tempTime2 := time.Unix(subItem.StartTime, 0)
  7873. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7874. drug.MedcBegntime = timeFormatTwo
  7875. if subItem.Day > 0 {
  7876. ts := time.Unix(subItem.StartTime, 0)
  7877. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7878. tempTime4 := time.Unix(record_time, 0)
  7879. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7880. drug.MedcEndtime = timeFormat5
  7881. } else {
  7882. tempTime2 := time.Unix(subItem.StartTime, 0)
  7883. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7884. drug.MedcEndtime = timeFormatTwo
  7885. }
  7886. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7887. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7888. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7889. drug.DrugCnt = subItem.PrescribingNumber
  7890. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7891. drug.DrugGenname = subItem.AdviceName
  7892. drug.MedcWayCodg = subItem.DeliveryWay
  7893. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7894. drug.SinDoscnt = subItem.SingleDose
  7895. drug.SinDosunt = subItem.SingleDoseUnit
  7896. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7897. drug.UsedFrquName = subItem.ExecutionFrequency
  7898. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7899. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7900. drug.HospApprFlag = "1"
  7901. cFYLJG001.List = append(cFYLJG001.List, drug)
  7902. }
  7903. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7904. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7905. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7906. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7907. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7908. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7909. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7910. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7911. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7912. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7913. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7914. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7915. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7916. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7917. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7918. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7919. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7920. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7921. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7922. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7923. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7924. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7925. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7926. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7927. tempTime2 := time.Now().Unix()
  7928. tempTime6 := time.Unix(tempTime2, 0)
  7929. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7930. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7931. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7932. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7933. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7934. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7935. //memo := make(map[string]interface{})
  7936. //inputData := make(map[string]interface{}, 0)
  7937. //type MyData struct {
  7938. // Insutype string `json:"insutype"`
  7939. //}
  7940. //
  7941. // data := MyData{
  7942. // Insutype: his.Insutype,
  7943. //}
  7944. //
  7945. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7946. var config []*models.HisXtDiagnoseConfig
  7947. for _, item := range diagnosis_ids {
  7948. id, _ := strconv.ParseInt(item, 10, 64)
  7949. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7950. config = append(config, &diagnosisConfig)
  7951. }
  7952. for index, subitem := range config {
  7953. if index == 0 {
  7954. var dia models.DiseInfo
  7955. dia.DiagType = "1"
  7956. dia.MaindiagFlag = "1"
  7957. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7958. dia.DiagCode = subitem.CountryCode
  7959. dia.DiagName = subitem.ClassName
  7960. dia.DiagDept = "肾内科"
  7961. dia.DiagDrNo = doctor.DoctorNumber
  7962. dia.DiagDrName = doctor.UserName
  7963. tempTime3 := time.Unix(item.PreTime, 0)
  7964. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7965. dia.DiagTime = timeFormatTwo
  7966. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7967. } else {
  7968. var dia models.DiseInfo
  7969. dia.DiagType = "1"
  7970. dia.MaindiagFlag = "0"
  7971. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7972. dia.DiagCode = subitem.CountryCode
  7973. dia.DiagName = subitem.ClassName
  7974. dia.DiagDept = "肾内科"
  7975. dia.DiagDrNo = doctor.DoctorNumber
  7976. dia.DiagDrName = doctor.UserName
  7977. tempTime3 := time.Unix(item.PreTime, 0)
  7978. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7979. dia.DiagTime = timeFormatTwo
  7980. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7981. }
  7982. }
  7983. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7984. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7985. var res ResultCFYLJG001
  7986. var respJSON2 map[string]interface{}
  7987. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7990. return
  7991. }
  7992. userJSONBytes2, _ := json.Marshal(respJSON2)
  7993. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7994. utils.ErrorLog("解析失败:%v", err)
  7995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7996. return
  7997. }
  7998. if res.Infcode == -1 {
  7999. c.ServeSuccessJSON(map[string]interface{}{
  8000. "failed_code": -10,
  8001. "msg": res.ErrMsg,
  8002. })
  8003. return
  8004. } else {
  8005. var flow models.HisPrescriptionFlow
  8006. flow.Ctime = time.Now().Unix()
  8007. flow.SignDigest = ""
  8008. flow.RxTraceCode = res.Output.RxTraceCode
  8009. flow.HiRxno = res.Output.HiRxno
  8010. flow.MID = his.Number
  8011. flow.Status = 1
  8012. flow.DCode = doctor_info.DoctorNumber
  8013. flow.OriginalRxFile = ""
  8014. flow.OriginalValue = ""
  8015. flow.SignCertDn = ""
  8016. flow.UserOrgId = 10454
  8017. flow.SignCertSn = ""
  8018. flow.Mtime = time.Now().Unix()
  8019. service.Createflow(&flow)
  8020. c.ServeSuccessJSON(map[string]interface{}{
  8021. "msg": "上传成功",
  8022. })
  8023. }
  8024. }
  8025. }
  8026. func (c *HisApiController) GetCFYLJG002() {
  8027. admin_user_id, _ := c.GetInt64("admin_user_id")
  8028. his_patient_id, _ := c.GetInt64("his_patient_id")
  8029. record_time := c.GetString("record_time")
  8030. admin_user_id = 3626
  8031. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8032. //id, _ := c.GetInt64("id")
  8033. admin_user_id = 3626
  8034. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8035. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8036. flow, _ := service.Getflowtwo(his.Number)
  8037. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8038. //record_time := c.GetString("record_time")
  8039. patient_id, _ := c.GetInt64("patient_id")
  8040. //patient_id = 23834
  8041. //record_time = "2023-09-18"
  8042. timeLayout := "2006-01-02"
  8043. loc, _ := time.LoadLocation("Local")
  8044. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8045. if err != nil {
  8046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8047. return
  8048. }
  8049. recordDateTime := theTime.Unix()
  8050. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8051. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8052. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8053. dept, _ := service.GetDepartMentDetail(info.Departments)
  8054. inputData := make(map[string]interface{})
  8055. inputData["rxTraceCode"] = flow.RxTraceCode
  8056. inputData["hiRxno"] = flow.HiRxno
  8057. inputData["mdtrtId"] = flow.MID
  8058. inputData["patnName"] = his.PsnName
  8059. inputData["psnCertType"] = his.PsnCertType
  8060. inputData["certno"] = his.Certno
  8061. inputData["fixmedinsName"] = miConfig.OrgName
  8062. inputData["fixmedinsCode"] = miConfig.Code
  8063. inputData["drCode"] = doctor_info.DoctorNumber
  8064. inputData["prscDrName"] = doctor_info.UserName
  8065. inputData["pharDeptName"] = dept.Name
  8066. inputData["pharDeptCode"] = dept.Number
  8067. inputData["pharProfttlCodg"] = dept.Name
  8068. inputData["pharProfttlName"] = ""
  8069. inputData["pharCode"] = "HY440309002107"
  8070. inputData["pharCertType"] = "01"
  8071. inputData["pharCertno"] = "430482199408260023"
  8072. inputData["pharName"] = "彭斯遥"
  8073. inputData["pharPracCertNo"] = ""
  8074. tempTime2 := time.Unix(info.Ctime, 0)
  8075. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8076. inputData["pharChkTime"] = timeFormatTwo
  8077. bytesData, _ := json.Marshal(inputData)
  8078. fmt.Println(string(bytesData))
  8079. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8080. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8081. if err != nil {
  8082. fmt.Println("Error reading PDF file:", err)
  8083. return
  8084. }
  8085. // 将 PDF 文件内容进行 Base64 编码
  8086. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8087. fmt.Println(err)
  8088. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8089. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8090. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8091. var res2 Result002
  8092. var respJSON2 map[string]interface{}
  8093. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8096. return
  8097. }
  8098. userJSONBytes2, _ := json.Marshal(respJSON2)
  8099. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8100. utils.ErrorLog("解析失败:%v", err)
  8101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8102. return
  8103. }
  8104. if res2.Infcode == 0 {
  8105. flow.Ctime = time.Now().Unix()
  8106. flow.SignDigest = res2.Output.SignDigest
  8107. flow.RxFile = res2.Output.RxFile
  8108. flow.MID = his.Number
  8109. flow.Status = 1
  8110. flow.DCode = doctor_info.DoctorNumber
  8111. flow.OriginalRxFile = rx_encoded
  8112. flow.OriginalValue = encoded
  8113. flow.SignCertDn = res2.Output.SignCertDn
  8114. flow.SignCertSn = res2.Output.SignCertSn
  8115. flow.Mtime = time.Now().Unix()
  8116. service.Saveflow(flow)
  8117. c.ServeSuccessJSON(map[string]interface{}{
  8118. "msg": "预签名成功",
  8119. })
  8120. } else {
  8121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. return
  8123. }
  8124. }
  8125. func (c *HisApiController) GetCFYLJG003() {
  8126. admin_user_id, _ := c.GetInt64("admin_user_id")
  8127. his_patient_id, _ := c.GetInt64("his_patient_id")
  8128. record_time := c.GetString("record_time")
  8129. admin_user_id = 3626
  8130. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8131. //id, _ := c.GetInt64("id")
  8132. admin_user_id = 3626
  8133. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8134. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8135. flow, _ := service.Getflowtwo(his.Number)
  8136. //id = 3
  8137. patient_id, _ := c.GetInt64("patient_id")
  8138. //patient_id = 23834
  8139. //record_time = "2023-09-18"
  8140. timeLayout := "2006-01-02"
  8141. loc, _ := time.LoadLocation("Local")
  8142. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8143. if err != nil {
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8145. return
  8146. }
  8147. recordDateTime := theTime.Unix()
  8148. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8149. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8150. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8151. dept, _ := service.GetDepartMentDetail(info.Departments)
  8152. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8153. var cFYLJG003 models.CFYLJG003
  8154. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8155. cFYLJG003.HiRxno = flow.HiRxno
  8156. cFYLJG003.MdtrtID = flow.MID
  8157. cFYLJG003.PatnName = his.Name
  8158. cFYLJG003.Certno = his.Certno
  8159. cFYLJG003.FixmedinsName = miConfig.OrgName
  8160. cFYLJG003.FixmedinsCode = miConfig.Code
  8161. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8162. cFYLJG003.PrscDrName = doctor_info.UserName
  8163. cFYLJG003.PharDeptName = dept.Name
  8164. cFYLJG003.PharDeptCode = dept.Number
  8165. cFYLJG003.PharCode = "HY440309002107"
  8166. cFYLJG003.PharCertType = "01"
  8167. cFYLJG003.PharCertno = "430482199408260023"
  8168. cFYLJG003.PharName = "彭斯遥"
  8169. cFYLJG003.PsnCertType = "01"
  8170. cFYLJG003.RxFile = flow.RxFile
  8171. cFYLJG003.SignDigest = flow.SignDigest
  8172. cFYLJG003.FixmedinsCode = miConfig.Code
  8173. cFYLJG003.PsnCertType = "01"
  8174. cFYLJG003.PharProfttlCodg = dept.Name
  8175. //inputData["pharProfttlCodg"] =dept.Name
  8176. tempTime2 := time.Unix(info.Ctime, 0)
  8177. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8178. cFYLJG003.PharChkTime = timeFormatTwo
  8179. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8180. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8181. var res ResultCFYLJG003
  8182. var respJSON2 map[string]interface{}
  8183. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8186. return
  8187. }
  8188. userJSONBytes2, _ := json.Marshal(respJSON2)
  8189. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8190. utils.ErrorLog("解析失败:%v", err)
  8191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8192. return
  8193. }
  8194. if res.Infcode == -1 {
  8195. c.ServeSuccessJSON(map[string]interface{}{
  8196. "failed_code": -10,
  8197. "msg": res.ErrMsg,
  8198. })
  8199. return
  8200. } else {
  8201. c.ServeSuccessJSON(map[string]interface{}{
  8202. "info": res.Output,
  8203. })
  8204. }
  8205. }
  8206. func (c *HisApiController) GetCFYLJG004() {
  8207. admin_user_id, _ := c.GetInt64("admin_user_id")
  8208. his_patient_id, _ := c.GetInt64("his_patient_id")
  8209. record_time := c.GetString("record_time")
  8210. admin_user_id = 3626
  8211. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8212. //id, _ := c.GetInt64("id")
  8213. admin_user_id = 3626
  8214. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8215. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8216. flow, _ := service.Getflowtwo(his.Number)
  8217. //id = 3
  8218. patient_id, _ := c.GetInt64("patient_id")
  8219. //patient_id = 23834
  8220. //record_time = "2023-09-18"
  8221. timeLayout := "2006-01-02"
  8222. loc, _ := time.LoadLocation("Local")
  8223. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8224. if err != nil {
  8225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8226. return
  8227. }
  8228. recordDateTime := theTime.Unix()
  8229. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8230. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8231. var cFYLJG004 models.CFYLJG004
  8232. cFYLJG004.HiRxno = flow.HiRxno
  8233. cFYLJG004.FixmedinsCode = miConfig.Code
  8234. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8235. cFYLJG004.UndoDrCertType = "01"
  8236. cFYLJG004.UndoRea = "撤销处方"
  8237. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8238. cFYLJG004.UndoDrName = doctor_info.UserName
  8239. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8240. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8241. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8242. var res ResultCFYLJG004
  8243. var respJSON2 map[string]interface{}
  8244. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8247. return
  8248. }
  8249. userJSONBytes2, _ := json.Marshal(respJSON2)
  8250. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8251. utils.ErrorLog("解析失败:%v", err)
  8252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8253. return
  8254. }
  8255. if res.Infcode == -1 {
  8256. c.ServeSuccessJSON(map[string]interface{}{
  8257. "failed_code": -10,
  8258. "msg": res.ErrMsg,
  8259. })
  8260. return
  8261. } else {
  8262. flow.Status = 0
  8263. service.Saveflow(flow)
  8264. c.ServeSuccessJSON(map[string]interface{}{
  8265. "msg": "撤销成功",
  8266. })
  8267. return
  8268. }
  8269. }
  8270. func (c *HisApiController) GetCFYLJG005() {
  8271. admin_user_id, _ := c.GetInt64("admin_user_id")
  8272. his_patient_id, _ := c.GetInt64("his_patient_id")
  8273. //record_time := c.GetString("record_time")
  8274. admin_user_id = 3626
  8275. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8276. //id, _ := c.GetInt64("id")
  8277. admin_user_id = 3626
  8278. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8279. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8280. flow, _ := service.Getflowtwo(his.Number)
  8281. //id = 3
  8282. var cFYLJG005 models.CFYLJG005
  8283. //patient_id, _ := c.GetInt64("patient_id")
  8284. cFYLJG005.HiRxno = flow.HiRxno
  8285. cFYLJG005.MdtrtID = flow.MID
  8286. cFYLJG005.EcToken = ""
  8287. cFYLJG005.PsnName = his.Name
  8288. cFYLJG005.PsnCertType = "01"
  8289. cFYLJG005.Certno = his.IdCardNo
  8290. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8291. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8292. var res ResultCFYLJG005
  8293. var respJSON2 map[string]interface{}
  8294. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. userJSONBytes2, _ := json.Marshal(respJSON2)
  8300. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8301. utils.ErrorLog("解析失败:%v", err)
  8302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8303. return
  8304. }
  8305. if res.Infcode == -1 {
  8306. c.ServeSuccessJSON(map[string]interface{}{
  8307. "failed_code": -10,
  8308. "msg": res.ErrMsg,
  8309. })
  8310. return
  8311. } else {
  8312. c.ServeSuccessJSON(map[string]interface{}{
  8313. "info": res.Output,
  8314. })
  8315. return
  8316. }
  8317. }
  8318. func (c *HisApiController) GetCFYLJG006() {
  8319. admin_user_id, _ := c.GetInt64("admin_user_id")
  8320. his_patient_id, _ := c.GetInt64("his_patient_id")
  8321. admin_user_id = 3626
  8322. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8323. //id, _ := c.GetInt64("id")
  8324. admin_user_id = 3626
  8325. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8327. flow, _ := service.Getflowtwo(his.Number)
  8328. //id = 3
  8329. patient_id, _ := c.GetInt64("patient_id")
  8330. var cFYLJG006 models.CFYLJG006
  8331. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8332. cFYLJG006.HiRxno = flow.HiRxno
  8333. cFYLJG006.MdtrtID = flow.MID
  8334. cFYLJG006.PsnName = patient.Name
  8335. cFYLJG006.PsnCertType = "01"
  8336. cFYLJG006.Certno = patient.IdCardNo
  8337. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8338. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8339. var res ResultCFYLJG006
  8340. var respJSON2 map[string]interface{}
  8341. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. userJSONBytes2, _ := json.Marshal(respJSON2)
  8347. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8348. utils.ErrorLog("解析失败:%v", err)
  8349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8350. return
  8351. }
  8352. if res.Infcode == -1 {
  8353. c.ServeSuccessJSON(map[string]interface{}{
  8354. "failed_code": -10,
  8355. "msg": res.ErrMsg,
  8356. })
  8357. return
  8358. } else {
  8359. c.ServeSuccessJSON(map[string]interface{}{
  8360. "info": res.Output,
  8361. })
  8362. return
  8363. }
  8364. }
  8365. func (c *HisApiController) GetCFYLJG007() {
  8366. admin_user_id, _ := c.GetInt64("admin_user_id")
  8367. his_patient_id, _ := c.GetInt64("his_patient_id")
  8368. admin_user_id = 3626
  8369. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8370. //id, _ := c.GetInt64("id")
  8371. admin_user_id = 3626
  8372. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8374. flow, _ := service.Getflowtwo(his.Number)
  8375. //id = 3
  8376. patient_id, _ := c.GetInt64("patient_id")
  8377. var cFYLJG007 models.CFYLJG007
  8378. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8379. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8380. cFYLJG007.HiRxno = flow.HiRxno
  8381. cFYLJG007.MdtrtID = flow.MID
  8382. cFYLJG007.PsnNo = his.PsnNo
  8383. cFYLJG007.PsnCertType = "01"
  8384. cFYLJG007.Certno = patient.IdCardNo
  8385. cFYLJG007.PsnName = patient.Name
  8386. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8387. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8388. var res ResultCFYLJG007
  8389. var respJSON2 map[string]interface{}
  8390. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8393. return
  8394. }
  8395. userJSONBytes2, _ := json.Marshal(respJSON2)
  8396. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8397. utils.ErrorLog("解析失败:%v", err)
  8398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8399. return
  8400. }
  8401. if res.Infcode == -1 {
  8402. c.ServeSuccessJSON(map[string]interface{}{
  8403. "failed_code": -10,
  8404. "msg": res.ErrMsg,
  8405. })
  8406. return
  8407. } else {
  8408. c.ServeSuccessJSON(map[string]interface{}{
  8409. "info": res,
  8410. })
  8411. return
  8412. }
  8413. }
  8414. func (c *HisApiController) GetCFYLJG008() {
  8415. admin_user_id, _ := c.GetInt64("admin_user_id")
  8416. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8417. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8418. var cFYLJG008 models.CFYLJG008
  8419. //id, _ := c.GetInt64("id")
  8420. patient_id, _ := c.GetInt64("patient_id")
  8421. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8422. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8423. //id = 3
  8424. //flow, _ := service.Getflow(id)
  8425. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8426. //
  8427. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8428. //patient_id, _ := c.GetInt64("patient_id")
  8429. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8430. record_time := c.GetString("record_time")
  8431. admin_user_id = 3626
  8432. patient_id = 19424
  8433. //his_patient_id = 263947
  8434. record_time = "2023-08-29"
  8435. timeLayout := "2006-01-02"
  8436. loc, _ := time.LoadLocation("Local")
  8437. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8438. if err != nil {
  8439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8440. return
  8441. }
  8442. recordDateTime := theTime.Unix()
  8443. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8444. cFYLJG008.FixmedinsName = ""
  8445. cFYLJG008.Lat = ""
  8446. cFYLJG008.Lng = ""
  8447. cFYLJG008.OrderType = "1"
  8448. cFYLJG008.PoolareaNo = ""
  8449. cFYLJG008.Lng = ""
  8450. cFYLJG008.PageNum = 1
  8451. cFYLJG008.PageSize = 10
  8452. var MPI models.MedinsProdInvChgDDTO
  8453. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8454. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8455. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8456. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8457. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8458. var res ResultCFYLJG008
  8459. var respJSON2 map[string]interface{}
  8460. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8463. return
  8464. }
  8465. userJSONBytes2, _ := json.Marshal(respJSON2)
  8466. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8467. utils.ErrorLog("解析失败:%v", err)
  8468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8469. return
  8470. }
  8471. if res.Infcode == -1 {
  8472. c.ServeSuccessJSON(map[string]interface{}{
  8473. "failed_code": -10,
  8474. "msg": res.ErrMsg,
  8475. })
  8476. return
  8477. } else {
  8478. c.ServeSuccessJSON(map[string]interface{}{
  8479. "info": res.Output,
  8480. })
  8481. return
  8482. }
  8483. }
  8484. func (c *HisApiController) GetBL4201A() {
  8485. order_id, _ := c.GetInt64("order_id")
  8486. admin_user_id, _ := c.GetInt64("admin_user_id")
  8487. order, _ := service.GetHisOrderByIDTwo(order_id)
  8488. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8489. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8490. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8491. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8492. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8493. department, _ := service.GetDepartMentDetail(his.Departments)
  8494. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8495. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8496. if order.ID == 0 {
  8497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8498. return
  8499. }
  8500. var struct4201A models.Struct4201A
  8501. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8502. for _, items := range order_info {
  8503. memo := make(map[string]interface{})
  8504. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8505. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8506. fsiOPFLD.MedType = "14"
  8507. fsiOPFLD.BkkpSn = items.FeedetlSn
  8508. fsiOPFLD.FixmedinsCode = miConfig.Code
  8509. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8510. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8511. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8512. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8513. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8514. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8515. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8516. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8517. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8518. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8519. fsiOPFLD.BilgDeptName = department.Name
  8520. fsiOPFLD.BilgDeptCodg = department.Number
  8521. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8522. fsiOPFLD.BilgDrName = doctor.UserName
  8523. fsiOPFLD.MedChrgitmType = "09"
  8524. memo["hosp_appr_flag"] = "1"
  8525. memo["invoice_no"] = order.MdtrtId
  8526. memo["memo"] = "自费"
  8527. bytesData, _ := json.Marshal(memo)
  8528. fsiOPFLD.Memo = string(bytesData)
  8529. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8530. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8531. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8532. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8533. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8534. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8535. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8536. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8537. fsiOPFLD.BilgDeptName = department.Name
  8538. fsiOPFLD.BilgDeptCodg = department.Number
  8539. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8540. fsiOPFLD.BilgDrName = doctor.UserName
  8541. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8542. case 0:
  8543. break
  8544. case 1:
  8545. fsiOPFLD.MedChrgitmType = "14"
  8546. break
  8547. case 2:
  8548. fsiOPFLD.MedChrgitmType = "05"
  8549. break
  8550. case 3:
  8551. fsiOPFLD.MedChrgitmType = "03"
  8552. break
  8553. case 4:
  8554. fsiOPFLD.MedChrgitmType = "03"
  8555. break
  8556. case 5:
  8557. fsiOPFLD.MedChrgitmType = "08"
  8558. break
  8559. case 6:
  8560. fsiOPFLD.MedChrgitmType = "14"
  8561. break
  8562. case 7:
  8563. fsiOPFLD.MedChrgitmType = "14"
  8564. break
  8565. case 8:
  8566. fsiOPFLD.MedChrgitmType = "03"
  8567. break
  8568. case 9:
  8569. fsiOPFLD.MedChrgitmType = "14"
  8570. break
  8571. case 10:
  8572. fsiOPFLD.MedChrgitmType = "14"
  8573. break
  8574. case 11:
  8575. fsiOPFLD.MedChrgitmType = "06"
  8576. break
  8577. case 12:
  8578. fsiOPFLD.MedChrgitmType = "12"
  8579. break
  8580. case 13:
  8581. fsiOPFLD.MedChrgitmType = "01"
  8582. break
  8583. case 14:
  8584. fsiOPFLD.MedChrgitmType = "04"
  8585. break
  8586. case 15:
  8587. fsiOPFLD.MedChrgitmType = "14"
  8588. break
  8589. }
  8590. memo["hosp_appr_flag"] = "1"
  8591. memo["invoice_no"] = order.MdtrtId
  8592. memo["memo"] = "自费"
  8593. bytesData, _ := json.Marshal(memo)
  8594. fsiOPFLD.Memo = string(bytesData)
  8595. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8596. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8597. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8598. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8599. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8600. fsiOPFLD.BilgDeptName = department.Name
  8601. fsiOPFLD.BilgDeptCodg = department.Number
  8602. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8603. fsiOPFLD.BilgDrName = doctor.UserName
  8604. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8605. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8606. fsiOPFLD.MedChrgitmType = "08"
  8607. memo["hosp_appr_flag"] = "1"
  8608. memo["invoice_no"] = order.MdtrtId
  8609. memo["memo"] = "自费"
  8610. bytesData, _ := json.Marshal(memo)
  8611. fsiOPFLD.Memo = string(bytesData)
  8612. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8613. }
  8614. }
  8615. }
  8616. for _, items := range order_info_two {
  8617. memo := make(map[string]interface{})
  8618. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8619. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8620. fsiOPFLD.MedType = "14"
  8621. fsiOPFLD.BkkpSn = items.FeedetlSn
  8622. fsiOPFLD.FixmedinsCode = miConfig.Code
  8623. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8624. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8625. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8626. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8627. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8628. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8629. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8630. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8631. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8632. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8633. fsiOPFLD.BilgDeptName = department.Name
  8634. fsiOPFLD.BilgDeptCodg = department.Number
  8635. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8636. fsiOPFLD.BilgDrName = doctor.UserName
  8637. fsiOPFLD.MedChrgitmType = "09"
  8638. memo["hosp_appr_flag"] = "1"
  8639. memo["invoice_no"] = order.MdtrtId
  8640. memo["memo"] = "自费"
  8641. bytesData, _ := json.Marshal(memo)
  8642. fsiOPFLD.Memo = string(bytesData)
  8643. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8644. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8645. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8646. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8647. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8648. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8649. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8650. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8651. fsiOPFLD.BilgDeptName = department.Name
  8652. fsiOPFLD.BilgDeptCodg = department.Number
  8653. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8654. fsiOPFLD.BilgDrName = doctor.UserName
  8655. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8656. case 0:
  8657. break
  8658. case 1:
  8659. fsiOPFLD.MedChrgitmType = "14"
  8660. break
  8661. case 2:
  8662. fsiOPFLD.MedChrgitmType = "05"
  8663. break
  8664. case 3:
  8665. fsiOPFLD.MedChrgitmType = "03"
  8666. break
  8667. case 4:
  8668. fsiOPFLD.MedChrgitmType = "03"
  8669. break
  8670. case 5:
  8671. fsiOPFLD.MedChrgitmType = "08"
  8672. break
  8673. case 6:
  8674. fsiOPFLD.MedChrgitmType = "14"
  8675. break
  8676. case 7:
  8677. fsiOPFLD.MedChrgitmType = "14"
  8678. break
  8679. case 8:
  8680. fsiOPFLD.MedChrgitmType = "03"
  8681. break
  8682. case 9:
  8683. fsiOPFLD.MedChrgitmType = "14"
  8684. break
  8685. case 10:
  8686. fsiOPFLD.MedChrgitmType = "14"
  8687. break
  8688. case 11:
  8689. fsiOPFLD.MedChrgitmType = "06"
  8690. break
  8691. case 12:
  8692. fsiOPFLD.MedChrgitmType = "12"
  8693. break
  8694. case 13:
  8695. fsiOPFLD.MedChrgitmType = "01"
  8696. break
  8697. case 14:
  8698. fsiOPFLD.MedChrgitmType = "04"
  8699. break
  8700. case 15:
  8701. fsiOPFLD.MedChrgitmType = "14"
  8702. break
  8703. }
  8704. memo["hosp_appr_flag"] = "1"
  8705. memo["invoice_no"] = order.MdtrtId
  8706. memo["memo"] = "自费"
  8707. bytesData, _ := json.Marshal(memo)
  8708. fsiOPFLD.Memo = string(bytesData)
  8709. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8710. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8711. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8712. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8713. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8714. fsiOPFLD.BilgDeptName = department.Name
  8715. fsiOPFLD.BilgDeptCodg = department.Number
  8716. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8717. fsiOPFLD.BilgDrName = doctor.UserName
  8718. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8719. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8720. fsiOPFLD.MedChrgitmType = "08"
  8721. memo["hosp_appr_flag"] = "1"
  8722. memo["invoice_no"] = order.MdtrtId
  8723. memo["memo"] = "自费"
  8724. bytesData, _ := json.Marshal(memo)
  8725. fsiOPFLD.Memo = string(bytesData)
  8726. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8727. }
  8728. }
  8729. }
  8730. fmt.Println(fsiOPFLDs)
  8731. struct4201A.Fopfd = fsiOPFLDs
  8732. fmt.Println(struct4201A.Fopfd)
  8733. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8734. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8735. var res2 ResultSix
  8736. var respJSON2 map[string]interface{}
  8737. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8740. return
  8741. }
  8742. userJSONBytes2, _ := json.Marshal(respJSON2)
  8743. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8744. utils.ErrorLog("解析失败:%v", err)
  8745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8746. return
  8747. }
  8748. if res2.Infcode != 0 {
  8749. c.ServeSuccessJSON(map[string]interface{}{
  8750. "failed_code": -10,
  8751. "msg": res2.ErrMsg,
  8752. })
  8753. return
  8754. } else {
  8755. order.IsUploadOrderInfo = 1
  8756. service.UpdateOrder(order)
  8757. c.ServeSuccessJSON(map[string]interface{}{
  8758. "msg": "上传成功",
  8759. })
  8760. }
  8761. }
  8762. func (c *HisApiController) Get2505() {
  8763. admin_user_id, _ := c.GetInt64("admin_user_id")
  8764. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8765. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8766. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  8767. }
  8768. func (c *HisApiController) Get4201A() {
  8769. order_id, _ := c.GetInt64("order_id")
  8770. admin_user_id, _ := c.GetInt64("admin_user_id")
  8771. order, _ := service.GetHisOrderByIDTwo(order_id)
  8772. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8773. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8774. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8775. //order_info = append(order_info, order_info_two...)
  8776. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8778. department, _ := service.GetDepartMentDetail(his.Departments)
  8779. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8780. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8781. if order.ID == 0 {
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8783. return
  8784. }
  8785. var struct4201A models.Struct4201A
  8786. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8787. for _, items := range order_info {
  8788. memo := make(map[string]interface{})
  8789. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8790. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8791. fsiOPFLD.MedType = "14"
  8792. fsiOPFLD.BkkpSn = items.FeedetlSn
  8793. fsiOPFLD.FixmedinsCode = miConfig.Code
  8794. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8795. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8796. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8797. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8798. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8799. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8800. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8801. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8802. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8803. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8804. fsiOPFLD.BilgDeptName = department.Name
  8805. fsiOPFLD.BilgDeptCodg = department.Number
  8806. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8807. fsiOPFLD.BilgDrName = doctor.UserName
  8808. fsiOPFLD.MedChrgitmType = "09"
  8809. memo["hosp_appr_flag"] = "1"
  8810. memo["invoice_no"] = order.MdtrtId
  8811. memo["memo"] = "自费"
  8812. bytesData, _ := json.Marshal(memo)
  8813. fsiOPFLD.Memo = string(bytesData)
  8814. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8815. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8816. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8817. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8818. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8819. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8820. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8821. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8822. fsiOPFLD.BilgDeptName = department.Name
  8823. fsiOPFLD.BilgDeptCodg = department.Number
  8824. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8825. fsiOPFLD.BilgDrName = doctor.UserName
  8826. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8827. case 0:
  8828. break
  8829. case 1:
  8830. fsiOPFLD.MedChrgitmType = "14"
  8831. break
  8832. case 2:
  8833. fsiOPFLD.MedChrgitmType = "05"
  8834. break
  8835. case 3:
  8836. fsiOPFLD.MedChrgitmType = "03"
  8837. break
  8838. case 4:
  8839. fsiOPFLD.MedChrgitmType = "03"
  8840. break
  8841. case 5:
  8842. fsiOPFLD.MedChrgitmType = "08"
  8843. break
  8844. case 6:
  8845. fsiOPFLD.MedChrgitmType = "14"
  8846. break
  8847. case 7:
  8848. fsiOPFLD.MedChrgitmType = "14"
  8849. break
  8850. case 8:
  8851. fsiOPFLD.MedChrgitmType = "03"
  8852. break
  8853. case 9:
  8854. fsiOPFLD.MedChrgitmType = "14"
  8855. break
  8856. case 10:
  8857. fsiOPFLD.MedChrgitmType = "14"
  8858. break
  8859. case 11:
  8860. fsiOPFLD.MedChrgitmType = "06"
  8861. break
  8862. case 12:
  8863. fsiOPFLD.MedChrgitmType = "12"
  8864. break
  8865. case 13:
  8866. fsiOPFLD.MedChrgitmType = "01"
  8867. break
  8868. case 14:
  8869. fsiOPFLD.MedChrgitmType = "04"
  8870. break
  8871. case 15:
  8872. fsiOPFLD.MedChrgitmType = "14"
  8873. break
  8874. }
  8875. memo["hosp_appr_flag"] = "1"
  8876. memo["invoice_no"] = order.MdtrtId
  8877. memo["memo"] = "自费"
  8878. bytesData, _ := json.Marshal(memo)
  8879. fsiOPFLD.Memo = string(bytesData)
  8880. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8881. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8882. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8883. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8884. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8885. fsiOPFLD.BilgDeptName = department.Name
  8886. fsiOPFLD.BilgDeptCodg = department.Number
  8887. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8888. fsiOPFLD.BilgDrName = doctor.UserName
  8889. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8890. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8891. fsiOPFLD.MedChrgitmType = "08"
  8892. memo["hosp_appr_flag"] = "1"
  8893. memo["invoice_no"] = order.MdtrtId
  8894. memo["memo"] = "自费"
  8895. bytesData, _ := json.Marshal(memo)
  8896. fsiOPFLD.Memo = string(bytesData)
  8897. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8898. }
  8899. }
  8900. }
  8901. for _, items := range order_info_two {
  8902. memo := make(map[string]interface{})
  8903. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8904. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8905. fsiOPFLD.MedType = "14"
  8906. fsiOPFLD.BkkpSn = items.FeedetlSn
  8907. fsiOPFLD.FixmedinsCode = miConfig.Code
  8908. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8909. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8910. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8911. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8912. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8913. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8914. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8915. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8916. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8917. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8918. fsiOPFLD.BilgDeptName = department.Name
  8919. fsiOPFLD.BilgDeptCodg = department.Number
  8920. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8921. fsiOPFLD.BilgDrName = doctor.UserName
  8922. fsiOPFLD.MedChrgitmType = "09"
  8923. memo["hosp_appr_flag"] = "1"
  8924. memo["invoice_no"] = order.MdtrtId
  8925. memo["memo"] = "自费"
  8926. bytesData, _ := json.Marshal(memo)
  8927. fsiOPFLD.Memo = string(bytesData)
  8928. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8929. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8930. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8931. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8932. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8933. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8934. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8935. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8936. fsiOPFLD.BilgDeptName = department.Name
  8937. fsiOPFLD.BilgDeptCodg = department.Number
  8938. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8939. fsiOPFLD.BilgDrName = doctor.UserName
  8940. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8941. case 0:
  8942. break
  8943. case 1:
  8944. fsiOPFLD.MedChrgitmType = "14"
  8945. break
  8946. case 2:
  8947. fsiOPFLD.MedChrgitmType = "05"
  8948. break
  8949. case 3:
  8950. fsiOPFLD.MedChrgitmType = "03"
  8951. break
  8952. case 4:
  8953. fsiOPFLD.MedChrgitmType = "03"
  8954. break
  8955. case 5:
  8956. fsiOPFLD.MedChrgitmType = "08"
  8957. break
  8958. case 6:
  8959. fsiOPFLD.MedChrgitmType = "14"
  8960. break
  8961. case 7:
  8962. fsiOPFLD.MedChrgitmType = "14"
  8963. break
  8964. case 8:
  8965. fsiOPFLD.MedChrgitmType = "03"
  8966. break
  8967. case 9:
  8968. fsiOPFLD.MedChrgitmType = "14"
  8969. break
  8970. case 10:
  8971. fsiOPFLD.MedChrgitmType = "14"
  8972. break
  8973. case 11:
  8974. fsiOPFLD.MedChrgitmType = "06"
  8975. break
  8976. case 12:
  8977. fsiOPFLD.MedChrgitmType = "12"
  8978. break
  8979. case 13:
  8980. fsiOPFLD.MedChrgitmType = "01"
  8981. break
  8982. case 14:
  8983. fsiOPFLD.MedChrgitmType = "04"
  8984. break
  8985. case 15:
  8986. fsiOPFLD.MedChrgitmType = "14"
  8987. break
  8988. }
  8989. memo["hosp_appr_flag"] = "1"
  8990. memo["invoice_no"] = order.MdtrtId
  8991. memo["memo"] = "自费"
  8992. bytesData, _ := json.Marshal(memo)
  8993. fsiOPFLD.Memo = string(bytesData)
  8994. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8995. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8996. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8997. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8998. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8999. fsiOPFLD.BilgDeptName = department.Name
  9000. fsiOPFLD.BilgDeptCodg = department.Number
  9001. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9002. fsiOPFLD.BilgDrName = doctor.UserName
  9003. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9004. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9005. fsiOPFLD.MedChrgitmType = "08"
  9006. memo["hosp_appr_flag"] = "1"
  9007. memo["invoice_no"] = order.MdtrtId
  9008. memo["memo"] = "自费"
  9009. bytesData, _ := json.Marshal(memo)
  9010. fsiOPFLD.Memo = string(bytesData)
  9011. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9012. }
  9013. }
  9014. }
  9015. fmt.Println(fsiOPFLDs)
  9016. struct4201A.Fopfd = fsiOPFLDs
  9017. fmt.Println(struct4201A.Fopfd)
  9018. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9019. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9020. var res2 ResultSix
  9021. var respJSON2 map[string]interface{}
  9022. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. userJSONBytes2, _ := json.Marshal(respJSON2)
  9028. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9029. utils.ErrorLog("解析失败:%v", err)
  9030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9031. return
  9032. }
  9033. if res2.Infcode != 0 {
  9034. c.ServeSuccessJSON(map[string]interface{}{
  9035. "failed_code": -10,
  9036. "msg": res2.ErrMsg,
  9037. })
  9038. return
  9039. } else {
  9040. order.IsUploadOrderInfo = 1
  9041. service.UpdateOrder(order)
  9042. c.ServeSuccessJSON(map[string]interface{}{
  9043. "msg": "上传成功",
  9044. })
  9045. }
  9046. }
  9047. func (c *HisApiController) Get4202() {
  9048. order_id, _ := c.GetInt64("order_id")
  9049. admin_user_id, _ := c.GetInt64("admin_user_id")
  9050. order, _ := service.GetHisOrderByIDTwo(order_id)
  9051. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9052. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9053. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9054. if order.ID == 0 {
  9055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9056. return
  9057. }
  9058. var struct4202 models.Struct4202
  9059. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9060. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9061. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9062. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9063. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9064. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9065. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9066. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9067. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9068. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9069. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9070. var config []*models.HisXtDiagnoseConfig
  9071. for _, item := range diagnosis_ids {
  9072. id, _ := strconv.ParseInt(item, 10, 64)
  9073. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9074. config = append(config, &diagnosisConfig)
  9075. }
  9076. var tempDiaginfos []models.OwnPayPatnDiagListD
  9077. for index, item := range config {
  9078. if index == 0 {
  9079. var tempDiaginfo models.OwnPayPatnDiagListD
  9080. tempDiaginfo.InoutDiagType = "1"
  9081. tempDiaginfo.DiagCode = item.CountryCode
  9082. tempDiaginfo.DiagName = item.CountryContentName
  9083. tempDiaginfo.DiagType = "1"
  9084. tempDiaginfo.DiagSrtNo = "1"
  9085. tempDiaginfo.MaindiagFlag = "1"
  9086. tempDiaginfo.ValiFlag = "1"
  9087. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9088. } else {
  9089. var tempDiaginfo models.OwnPayPatnDiagListD
  9090. tempDiaginfo.DiagCode = item.CountryCode
  9091. tempDiaginfo.DiagName = item.CountryContentName
  9092. tempDiaginfo.DiagType = "2"
  9093. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9094. tempDiaginfo.MaindiagFlag = "0"
  9095. tempDiaginfo.ValiFlag = "1"
  9096. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9097. }
  9098. }
  9099. struct4202.ODiagListD = tempDiaginfos
  9100. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9101. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9102. var res2 ResultSix
  9103. var respJSON2 map[string]interface{}
  9104. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9107. return
  9108. }
  9109. userJSONBytes2, _ := json.Marshal(respJSON2)
  9110. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9111. utils.ErrorLog("解析失败:%v", err)
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. if res2.Infcode != 0 {
  9116. c.ServeSuccessJSON(map[string]interface{}{
  9117. "failed_code": -10,
  9118. "msg": res2.ErrMsg,
  9119. })
  9120. return
  9121. } else {
  9122. order.IsUploadDiagnose = 1
  9123. service.UpdateOrder(order)
  9124. c.ServeSuccessJSON(map[string]interface{}{
  9125. "msg": "上传成功",
  9126. })
  9127. }
  9128. }
  9129. func (c *HisApiController) Get4203() {
  9130. admin_user_id, _ := c.GetInt64("admin_user_id")
  9131. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9132. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9133. order_id, _ := c.GetInt64("order_id")
  9134. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9135. number := ""
  9136. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9137. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9138. if his.ID == 0 {
  9139. number = hospital.Number
  9140. } else {
  9141. number = his.Number
  9142. }
  9143. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9144. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9145. var res2 ResultSix
  9146. var respJSON2 map[string]interface{}
  9147. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9150. return
  9151. }
  9152. userJSONBytes2, _ := json.Marshal(respJSON2)
  9153. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9154. utils.ErrorLog("解析失败:%v", err)
  9155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9156. return
  9157. }
  9158. if res2.Infcode != 0 {
  9159. c.ServeSuccessJSON(map[string]interface{}{
  9160. "failed_code": -10,
  9161. "msg": res2.ErrMsg,
  9162. })
  9163. return
  9164. } else {
  9165. order.IsUploadSuccess = 1
  9166. service.UpdateOrderTwo(order)
  9167. c.ServeSuccessJSON(map[string]interface{}{
  9168. "msg": "上传成功",
  9169. })
  9170. }
  9171. }
  9172. func (c *HisApiController) Get4205() {
  9173. order_id, _ := c.GetInt64("order_id")
  9174. admin_user_id, _ := c.GetInt64("admin_user_id")
  9175. fapiao_code := c.GetString("fapiao_code")
  9176. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9177. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9178. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9179. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9180. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9181. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9182. //order_info = append(order_info, order_info_two...)
  9183. department, _ := service.GetDepartMentDetail(his.Departments)
  9184. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9185. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9186. if order.ID == 0 {
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9188. return
  9189. }
  9190. var struct4201A models.Struct4201A
  9191. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9192. for _, items := range order_info {
  9193. memo := make(map[string]interface{})
  9194. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9195. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9196. fsiOPFLD.MedType = pre.MedType
  9197. fsiOPFLD.FixmedinsCode = miConfig.Code
  9198. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9199. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9200. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9201. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9202. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9203. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9204. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9205. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9206. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9207. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9208. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9209. fsiOPFLD.BilgDeptName = department.Name
  9210. fsiOPFLD.BilgDeptCodg = department.Number
  9211. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9212. fsiOPFLD.BilgDrName = doctor.UserName
  9213. fsiOPFLD.MedChrgitmType = "09"
  9214. memo["hosp_appr_flag"] = "1"
  9215. memo["invoice_no"] = fapiao_code
  9216. memo["memo"] = "自费"
  9217. bytesData, _ := json.Marshal(memo)
  9218. fsiOPFLD.Memo = string(bytesData)
  9219. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9220. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9221. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9222. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9223. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9224. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9225. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9226. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9227. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9228. fsiOPFLD.BilgDeptName = department.Name
  9229. fsiOPFLD.BilgDeptCodg = department.Number
  9230. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9231. fsiOPFLD.BilgDrName = doctor.UserName
  9232. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9233. case 0:
  9234. break
  9235. case 1:
  9236. fsiOPFLD.MedChrgitmType = "14"
  9237. break
  9238. case 2:
  9239. fsiOPFLD.MedChrgitmType = "05"
  9240. break
  9241. case 3:
  9242. fsiOPFLD.MedChrgitmType = "03"
  9243. break
  9244. case 4:
  9245. fsiOPFLD.MedChrgitmType = "03"
  9246. break
  9247. case 5:
  9248. fsiOPFLD.MedChrgitmType = "08"
  9249. break
  9250. case 6:
  9251. fsiOPFLD.MedChrgitmType = "14"
  9252. break
  9253. case 7:
  9254. fsiOPFLD.MedChrgitmType = "14"
  9255. break
  9256. case 8:
  9257. fsiOPFLD.MedChrgitmType = "03"
  9258. break
  9259. case 9:
  9260. fsiOPFLD.MedChrgitmType = "14"
  9261. break
  9262. case 10:
  9263. fsiOPFLD.MedChrgitmType = "14"
  9264. break
  9265. case 11:
  9266. fsiOPFLD.MedChrgitmType = "06"
  9267. break
  9268. case 12:
  9269. fsiOPFLD.MedChrgitmType = "12"
  9270. break
  9271. case 13:
  9272. fsiOPFLD.MedChrgitmType = "01"
  9273. break
  9274. case 14:
  9275. fsiOPFLD.MedChrgitmType = "04"
  9276. break
  9277. case 15:
  9278. fsiOPFLD.MedChrgitmType = "14"
  9279. break
  9280. }
  9281. memo["hosp_appr_flag"] = "1"
  9282. memo["invoice_no"] = fapiao_code
  9283. memo["memo"] = "自费"
  9284. bytesData, _ := json.Marshal(memo)
  9285. fsiOPFLD.Memo = string(bytesData)
  9286. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9287. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9288. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9289. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9290. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9291. fsiOPFLD.BilgDeptName = department.Name
  9292. fsiOPFLD.BilgDeptCodg = department.Number
  9293. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9294. fsiOPFLD.BilgDrName = doctor.UserName
  9295. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9296. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9297. fsiOPFLD.MedChrgitmType = "08"
  9298. memo["hosp_appr_flag"] = "1"
  9299. memo["invoice_no"] = fapiao_code
  9300. memo["memo"] = "自费"
  9301. bytesData, _ := json.Marshal(memo)
  9302. fsiOPFLD.Memo = string(bytesData)
  9303. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9304. }
  9305. }
  9306. }
  9307. for _, items := range order_info_two {
  9308. memo := make(map[string]interface{})
  9309. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9310. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9311. fsiOPFLD.MedType = pre.MedType
  9312. fsiOPFLD.BkkpSn = items.FeedetlSn
  9313. fsiOPFLD.FixmedinsCode = miConfig.Code
  9314. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9315. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9316. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9317. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9318. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9319. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9320. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9321. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9322. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9323. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9324. fsiOPFLD.BilgDeptName = department.Name
  9325. fsiOPFLD.BilgDeptCodg = department.Number
  9326. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9327. fsiOPFLD.BilgDrName = doctor.UserName
  9328. fsiOPFLD.MedChrgitmType = "09"
  9329. memo["hosp_appr_flag"] = "1"
  9330. memo["invoice_no"] = fapiao_code
  9331. memo["memo"] = "自费"
  9332. bytesData, _ := json.Marshal(memo)
  9333. fsiOPFLD.Memo = string(bytesData)
  9334. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9335. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9336. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9337. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9338. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9339. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9340. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9341. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9342. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9343. fsiOPFLD.BilgDeptName = department.Name
  9344. fsiOPFLD.BilgDeptCodg = department.Number
  9345. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9346. fsiOPFLD.BilgDrName = doctor.UserName
  9347. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9348. case 0:
  9349. break
  9350. case 1:
  9351. fsiOPFLD.MedChrgitmType = "14"
  9352. break
  9353. case 2:
  9354. fsiOPFLD.MedChrgitmType = "05"
  9355. break
  9356. case 3:
  9357. fsiOPFLD.MedChrgitmType = "03"
  9358. break
  9359. case 4:
  9360. fsiOPFLD.MedChrgitmType = "03"
  9361. break
  9362. case 5:
  9363. fsiOPFLD.MedChrgitmType = "08"
  9364. break
  9365. case 6:
  9366. fsiOPFLD.MedChrgitmType = "14"
  9367. break
  9368. case 7:
  9369. fsiOPFLD.MedChrgitmType = "14"
  9370. break
  9371. case 8:
  9372. fsiOPFLD.MedChrgitmType = "03"
  9373. break
  9374. case 9:
  9375. fsiOPFLD.MedChrgitmType = "14"
  9376. break
  9377. case 10:
  9378. fsiOPFLD.MedChrgitmType = "14"
  9379. break
  9380. case 11:
  9381. fsiOPFLD.MedChrgitmType = "06"
  9382. break
  9383. case 12:
  9384. fsiOPFLD.MedChrgitmType = "12"
  9385. break
  9386. case 13:
  9387. fsiOPFLD.MedChrgitmType = "01"
  9388. break
  9389. case 14:
  9390. fsiOPFLD.MedChrgitmType = "04"
  9391. break
  9392. case 15:
  9393. fsiOPFLD.MedChrgitmType = "14"
  9394. break
  9395. }
  9396. memo["hosp_appr_flag"] = "1"
  9397. memo["invoice_no"] = fapiao_code
  9398. memo["memo"] = "自费"
  9399. bytesData, _ := json.Marshal(memo)
  9400. fsiOPFLD.Memo = string(bytesData)
  9401. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9402. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9403. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9404. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9405. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9406. fsiOPFLD.BilgDeptName = department.Name
  9407. fsiOPFLD.BilgDeptCodg = department.Number
  9408. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9409. fsiOPFLD.BilgDrName = doctor.UserName
  9410. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9411. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9412. fsiOPFLD.MedChrgitmType = "08"
  9413. memo["hosp_appr_flag"] = "1"
  9414. memo["invoice_no"] = fapiao_code
  9415. memo["memo"] = "自费"
  9416. bytesData, _ := json.Marshal(memo)
  9417. fsiOPFLD.Memo = string(bytesData)
  9418. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9419. }
  9420. }
  9421. }
  9422. fmt.Println(fsiOPFLDs)
  9423. struct4201A.Fopfd = fsiOPFLDs
  9424. fmt.Println(struct4201A.Fopfd)
  9425. var struct4202 models.Struct4202
  9426. timeLayout := "2006-01-02 15:04:05"
  9427. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9428. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9429. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9430. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9431. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9432. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9433. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9434. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9435. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9436. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9437. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9438. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9439. var config []*models.HisXtDiagnoseConfig
  9440. for _, item := range diagnosis_ids {
  9441. id, _ := strconv.ParseInt(item, 10, 64)
  9442. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9443. config = append(config, &diagnosisConfig)
  9444. }
  9445. var tempDiaginfos []models.OwnPayPatnDiagListD
  9446. for index, item := range config {
  9447. if index == 0 {
  9448. var tempDiaginfo models.OwnPayPatnDiagListD
  9449. tempDiaginfo.InoutDiagType = "1"
  9450. tempDiaginfo.DiagCode = item.CountryCode
  9451. tempDiaginfo.DiagName = item.CountryContentName
  9452. tempDiaginfo.DiagType = "1"
  9453. tempDiaginfo.DiagSrtNo = "1"
  9454. tempDiaginfo.MaindiagFlag = "1"
  9455. tempDiaginfo.ValiFlag = "1"
  9456. tempDiaginfo.DiagDrName = doctor.UserName
  9457. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9458. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9459. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9460. } else {
  9461. var tempDiaginfo models.OwnPayPatnDiagListD
  9462. tempDiaginfo.DiagCode = item.CountryCode
  9463. tempDiaginfo.DiagName = item.CountryContentName
  9464. tempDiaginfo.DiagType = "2"
  9465. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9466. tempDiaginfo.MaindiagFlag = "0"
  9467. tempDiaginfo.ValiFlag = "1"
  9468. tempDiaginfo.DiagDrName = doctor.UserName
  9469. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9470. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9471. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9472. }
  9473. }
  9474. struct4202.ODiagListD = tempDiaginfos
  9475. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9476. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9477. var res2 ResultSix
  9478. var respJSON2 map[string]interface{}
  9479. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9482. return
  9483. }
  9484. userJSONBytes2, _ := json.Marshal(respJSON2)
  9485. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9486. utils.ErrorLog("解析失败:%v", err)
  9487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9488. return
  9489. }
  9490. if res2.Infcode != 0 {
  9491. c.ServeSuccessJSON(map[string]interface{}{
  9492. "failed_code": -10,
  9493. "msg": res2.ErrMsg,
  9494. })
  9495. return
  9496. } else {
  9497. order.IsUploadDiagnose = 1
  9498. order.IsUploadOrderInfo = 1
  9499. service.UpdateOrderTwo(order)
  9500. c.ServeSuccessJSON(map[string]interface{}{
  9501. "msg": "上传成功",
  9502. })
  9503. }
  9504. }
  9505. func (c *HisApiController) Get4207() {
  9506. admin_user_id, _ := c.GetInt64("admin_user_id")
  9507. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9508. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9509. order_id, _ := c.GetInt64("order_id")
  9510. order, _ := service.GetHisOrderByIDTwo(order_id)
  9511. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9512. var struct4207 models.Struct4207
  9513. struct4207.PageNum = "1"
  9514. struct4207.PageSize = "1000"
  9515. struct4207.FixmedinsCode = miConfig.Code
  9516. struct4207.FixmedinsMdtrtID = order.Number
  9517. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9518. saveLog(result, requestLog, "4207", "查询")
  9519. var res2 ResultSix
  9520. var respJSON2 map[string]interface{}
  9521. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9524. return
  9525. }
  9526. userJSONBytes2, _ := json.Marshal(respJSON2)
  9527. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9528. utils.ErrorLog("解析失败:%v", err)
  9529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9530. return
  9531. }
  9532. if res2.Infcode != 0 {
  9533. c.ServeSuccessJSON(map[string]interface{}{
  9534. "failed_code": -10,
  9535. "msg": res2.ErrMsg,
  9536. })
  9537. return
  9538. } else {
  9539. c.ServeSuccessJSON(map[string]interface{}{
  9540. "msg": "查询成功",
  9541. })
  9542. }
  9543. }
  9544. func (c *HisApiController) Get4208() {
  9545. admin_user_id, _ := c.GetInt64("admin_user_id")
  9546. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9547. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9548. order_id, _ := c.GetInt64("order_id")
  9549. order, _ := service.GetHisOrderByIDTwo(order_id)
  9550. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9551. var struct4208 models.Struct4208
  9552. struct4208.PageNum = "1"
  9553. struct4208.PageSize = "1000"
  9554. struct4208.PsnCertType = "01"
  9555. struct4208.Certno = his.Certno
  9556. struct4208.MedType = order.MedType
  9557. struct4208.PsnName = his.Name
  9558. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9559. saveLog(result, requestLog, "4208", "查询")
  9560. var res2 ResultSix
  9561. var respJSON2 map[string]interface{}
  9562. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9565. return
  9566. }
  9567. userJSONBytes2, _ := json.Marshal(respJSON2)
  9568. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9569. utils.ErrorLog("解析失败:%v", err)
  9570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9571. return
  9572. }
  9573. if res2.Infcode != 0 {
  9574. c.ServeSuccessJSON(map[string]interface{}{
  9575. "failed_code": -10,
  9576. "msg": res2.ErrMsg,
  9577. })
  9578. return
  9579. } else {
  9580. c.ServeSuccessJSON(map[string]interface{}{
  9581. "msg": "查询成功",
  9582. })
  9583. }
  9584. }
  9585. func (c *HisApiController) Get4209() {
  9586. admin_user_id, _ := c.GetInt64("admin_user_id")
  9587. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9588. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9589. order_id, _ := c.GetInt64("order_id")
  9590. order, _ := service.GetHisOrderByIDTwo(order_id)
  9591. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9592. var struct4209 models.Struct4209
  9593. struct4209.FixmedinsMdtrtID = order.Number
  9594. struct4209.FixmedinsCode = miConfig.Code
  9595. struct4209.PageSize = "1000"
  9596. struct4209.PageNum = "1"
  9597. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9598. saveLog(result, requestLog, "4209", "查询")
  9599. var res2 ResultSix
  9600. var respJSON2 map[string]interface{}
  9601. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9604. return
  9605. }
  9606. userJSONBytes2, _ := json.Marshal(respJSON2)
  9607. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9608. utils.ErrorLog("解析失败:%v", err)
  9609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9610. return
  9611. }
  9612. if res2.Infcode != 0 {
  9613. c.ServeSuccessJSON(map[string]interface{}{
  9614. "failed_code": -10,
  9615. "msg": res2.ErrMsg,
  9616. })
  9617. return
  9618. } else {
  9619. c.ServeSuccessJSON(map[string]interface{}{
  9620. "msg": "查询成功",
  9621. })
  9622. }
  9623. }
  9624. type Result3101 struct {
  9625. Infcode string `json:"infcode"`
  9626. InfRefmsgid string `json:"inf_refmsgid"`
  9627. RefmsgTime string `json:"refmsg_time"`
  9628. RespondTime string `json:"respond_time"`
  9629. Enctype string `json:"enctype"`
  9630. Signtype string `json:"signtype"`
  9631. ErrMsg string `json:"err_msg"`
  9632. Output struct {
  9633. Result []struct {
  9634. JudgeResultDetailDtos []struct {
  9635. VolaItemType string `json:"vola_item_type"`
  9636. MdtrtID string `json:"mdtrt_id"`
  9637. JrdID string `json:"jrd_id"`
  9638. PatnID string `json:"patn_id"`
  9639. RxID string `json:"rx_id"`
  9640. VolaAmt interface{} `json:"vola_amt"`
  9641. } `json:"judge_result_detail_dtos"`
  9642. RuleID string `json:"rule_id"`
  9643. VolaEvid string `json:"vola_evid"`
  9644. MdtrtID string `json:"mdtrt_id"`
  9645. RuleName string `json:"rule_name"`
  9646. VolaAmtStas string `json:"vola_amt_stas"`
  9647. JrID string `json:"jr_id"`
  9648. PatnID string `json:"patn_id"`
  9649. SevDeg string `json:"sev_deg"`
  9650. VolaAmt float64 `json:"vola_amt"`
  9651. VolaBhvrType string `json:"vola_bhvr_type"`
  9652. VolaCont string `json:"vola_cont"`
  9653. } `json:"result"`
  9654. } `json:"output"`
  9655. }
  9656. type Resultgd3101 struct {
  9657. Infcode int64 `json:"infcode"`
  9658. InfRefmsgid string `json:"inf_refmsgid"`
  9659. RefmsgTime string `json:"refmsg_time"`
  9660. RespondTime string `json:"respond_time"`
  9661. Enctype string `json:"enctype"`
  9662. Signtype string `json:"signtype"`
  9663. ErrMsg string `json:"err_msg"`
  9664. Output struct {
  9665. Result []struct {
  9666. JudgeResultDetailDtos []struct {
  9667. VolaItemType string `json:"vola_item_type"`
  9668. MdtrtID string `json:"mdtrt_id"`
  9669. JrdID string `json:"jrd_id"`
  9670. PatnID string `json:"patn_id"`
  9671. RxID string `json:"rx_id"`
  9672. VolaAmt interface{} `json:"vola_amt"`
  9673. } `json:"judge_result_detail_dtos"`
  9674. RuleID string `json:"rule_id"`
  9675. VolaEvid string `json:"vola_evid"`
  9676. MdtrtID string `json:"mdtrt_id"`
  9677. RuleName string `json:"rule_name"`
  9678. VolaAmtStas string `json:"vola_amt_stas"`
  9679. JrID string `json:"jr_id"`
  9680. PatnID string `json:"patn_id"`
  9681. SevDeg string `json:"sev_deg"`
  9682. VolaAmt float64 `json:"vola_amt"`
  9683. VolaBhvrType string `json:"vola_bhvr_type"`
  9684. VolaCont string `json:"vola_cont"`
  9685. } `json:"result"`
  9686. } `json:"output"`
  9687. }
  9688. func (c *HisApiController) ReadEleToken() {
  9689. admin_user_id, _ := c.GetInt64("admin_user_id")
  9690. his_patient_id, _ := c.GetInt64("his_patient_id")
  9691. adminUser := c.GetAdminUserInfo()
  9692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9693. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9694. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9695. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9696. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9697. if len(tokens) > 0 {
  9698. c.ServeSuccessJSON(map[string]interface{}{
  9699. "msg": "读取成功",
  9700. })
  9701. } else {
  9702. c.ServeSuccessJSON(map[string]interface{}{
  9703. "failed_code": -10,
  9704. "msg": "读取失败",
  9705. })
  9706. }
  9707. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9708. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9709. if len(tokens) > 0 {
  9710. c.ServeSuccessJSON(map[string]interface{}{
  9711. "msg": "读取成功",
  9712. })
  9713. } else {
  9714. c.ServeSuccessJSON(map[string]interface{}{
  9715. "failed_code": -10,
  9716. "msg": "读取失败",
  9717. })
  9718. }
  9719. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9720. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9721. if len(tokens) > 0 {
  9722. c.ServeSuccessJSON(map[string]interface{}{
  9723. "msg": "读取成功",
  9724. })
  9725. } else {
  9726. c.ServeSuccessJSON(map[string]interface{}{
  9727. "failed_code": -10,
  9728. "msg": "读取失败",
  9729. })
  9730. }
  9731. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9732. var api string
  9733. 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 +
  9734. "&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"
  9735. resp, requestErr := http.Get(api)
  9736. if requestErr != nil {
  9737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9738. }
  9739. body, ioErr := ioutil.ReadAll(resp.Body)
  9740. if ioErr != nil {
  9741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9743. }
  9744. var respJSON map[string]interface{}
  9745. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9748. return
  9749. }
  9750. var status string
  9751. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9752. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9753. var token string
  9754. var res ResultTwo //1101结果
  9755. var res10265 ResultTwo10265 //1101结果
  9756. if status == "0" { //读卡成功
  9757. var card_info string //卡信息
  9758. var busi_card_info string
  9759. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9760. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9761. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9762. fmt.Println(card_info)
  9763. fmt.Println(busi_card_info)
  9764. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9765. result, _ := json.Marshal(respJSON)
  9766. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9767. utils.ErrorLog("解析失败:%v", err)
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9769. return
  9770. }
  9771. res.ErrMsg = res10265.ErrMsg
  9772. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9773. res.Infcode = infocode
  9774. res.Output = res10265.Output
  9775. res.InfRefmsgid = res10265.InfRefmsgid
  9776. if res.Infcode == 0 {
  9777. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9778. if err == gorm.ErrRecordNotFound {
  9779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9780. return
  9781. } else if err != nil {
  9782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9783. return
  9784. } else {
  9785. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9786. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9787. infoStr := string(Iinfos)
  9788. idetinfoStr := string(Idetinfos)
  9789. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9790. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9791. psn := &models.HisPsn{
  9792. PsnNo: res.Output.Baseinfo.PsnNo,
  9793. PatientId: patient.ID,
  9794. Certno: res.Output.Baseinfo.Certno,
  9795. Gend: res.Output.Baseinfo.Gend,
  9796. Naty: res.Output.Baseinfo.Naty,
  9797. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9798. PsnName: res.Output.Baseinfo.PsnName,
  9799. Age: float64(age),
  9800. Brdy: b,
  9801. Idetinfo: idetinfoStr,
  9802. Insuinfo: infoStr,
  9803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9804. CardInfo: card_info,
  9805. VerifyNumber: token,
  9806. IdCardType: 4,
  9807. }
  9808. var rf []*ResultFive
  9809. json.Unmarshal([]byte(infoStr), &rf)
  9810. var insutypes []*ResultFive
  9811. var insutype string
  9812. var is390 int = 0
  9813. var is310 int = 0
  9814. for _, item := range rf {
  9815. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9816. insutypes = append(insutypes, item)
  9817. }
  9818. }
  9819. if len(insutypes) == 1 {
  9820. insutype = insutypes[0].Insutype
  9821. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9822. } else {
  9823. for _, i := range insutypes {
  9824. if i.Insutype == "390" {
  9825. is390 = 1
  9826. }
  9827. if i.Insutype == "310" {
  9828. is310 = 1
  9829. }
  9830. }
  9831. }
  9832. if is390 == 1 {
  9833. insutype = "390"
  9834. }
  9835. if is310 == 1 {
  9836. insutype = "310"
  9837. }
  9838. if len(insutypes) == 0 {
  9839. insutype = "310"
  9840. }
  9841. service.CreateHisPsn(psn)
  9842. c.ServeSuccessJSON(map[string]interface{}{
  9843. "patient": patient,
  9844. "number": token,
  9845. "insutype": insutype,
  9846. })
  9847. }
  9848. } else {
  9849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9850. return
  9851. }
  9852. } else { //读卡失败
  9853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9854. return
  9855. }
  9856. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9857. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9858. if len(errMsg) == 0 {
  9859. type ELeData struct {
  9860. Data struct {
  9861. IdNo string `json:"idNo"`
  9862. IdType string `json:"idType"`
  9863. UserName string `json:"userName"`
  9864. EcToken string `json:"ecToken"`
  9865. InsuOrg string `json:"insuOrg"`
  9866. Gender string `json:"gender"`
  9867. Birthday string `json:"birthday"`
  9868. Nationality string `json:"nationality"`
  9869. Email string `json:"email"`
  9870. Extra string `json:"extra"`
  9871. } `json:"data"`
  9872. Code int `json:"code"`
  9873. Message string `json:"message"`
  9874. }
  9875. var ele ELeData
  9876. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9877. if err != nil {
  9878. utils.ErrorLog("解析失败:%v", err)
  9879. }
  9880. token := ele.Data.EcToken
  9881. if len(token) > 0 {
  9882. psn := &models.HisPsn{
  9883. PsnNo: his.PsnNo,
  9884. Age: 0,
  9885. PatientId: his.PatientId,
  9886. Certno: his.Certno,
  9887. Brdy: his.Brdy,
  9888. Gend: his.Gend,
  9889. Naty: his.Naty,
  9890. PsnCertType: his.PsnCertType,
  9891. PsnName: his.PsnName,
  9892. Idetinfo: his.Idetinfo,
  9893. Insuinfo: his.Iinfo,
  9894. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9895. CardInfo: outPutInfo,
  9896. VerifyNumber: token,
  9897. }
  9898. service.CreateHisPsn(psn)
  9899. }
  9900. if len(token) > 0 {
  9901. c.ServeSuccessJSON(map[string]interface{}{
  9902. "msg": "读取成功",
  9903. })
  9904. } else {
  9905. c.ServeSuccessJSON(map[string]interface{}{
  9906. "failed_code": -10,
  9907. "msg": "读取失败",
  9908. })
  9909. }
  9910. }
  9911. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9912. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9913. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9914. type ELeData struct {
  9915. Data struct {
  9916. IdNo string `json:"idNo"`
  9917. IdType string `json:"idType"`
  9918. UserName string `json:"userName"`
  9919. EcToken string `json:"ecToken"`
  9920. InsuOrg string `json:"insuOrg"`
  9921. Gender string `json:"gender"`
  9922. Birthday string `json:"birthday"`
  9923. Nationality string `json:"nationality"`
  9924. Email string `json:"email"`
  9925. Extra string `json:"extra"`
  9926. } `json:"data"`
  9927. Code int `json:"code"`
  9928. Message string `json:"message"`
  9929. }
  9930. var ele ELeData
  9931. err := json.Unmarshal([]byte(result), &ele)
  9932. if err != nil {
  9933. utils.ErrorLog("解析失败:%v", err)
  9934. }
  9935. token := ele.Data.EcToken
  9936. token = Remove0000(token)
  9937. fmt.Println(ele.Data.UserName)
  9938. 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)
  9939. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9940. var res ResultTwo
  9941. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9942. utils.ErrorLog("解析失败:%v", err)
  9943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9944. return
  9945. }
  9946. if res.Infcode == 0 {
  9947. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9948. if err == gorm.ErrRecordNotFound {
  9949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9950. return
  9951. } else if err != nil {
  9952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9953. return
  9954. } else {
  9955. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9956. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9957. infoStr := string(Iinfos)
  9958. idetinfoStr := string(Idetinfos)
  9959. psn := &models.HisPsn{
  9960. PsnNo: res.Output.Baseinfo.PsnNo,
  9961. PatientId: patient.ID,
  9962. Certno: res.Output.Baseinfo.Certno,
  9963. Gend: res.Output.Baseinfo.Gend,
  9964. Naty: res.Output.Baseinfo.Naty,
  9965. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9966. PsnName: res.Output.Baseinfo.PsnName,
  9967. Idetinfo: idetinfoStr,
  9968. Insuinfo: infoStr,
  9969. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9970. CardInfo: "",
  9971. VerifyNumber: token,
  9972. }
  9973. service.CreateHisPsn(psn)
  9974. c.ServeSuccessJSON(map[string]interface{}{
  9975. "patient": patient,
  9976. "number": token,
  9977. })
  9978. }
  9979. } else {
  9980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9981. return
  9982. }
  9983. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9984. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9985. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9986. type ELeData struct {
  9987. Data struct {
  9988. IdNo string `json:"idNo"`
  9989. IdType string `json:"idType"`
  9990. UserName string `json:"userName"`
  9991. EcToken string `json:"ecToken"`
  9992. InsuOrg string `json:"insuOrg"`
  9993. Gender string `json:"gender"`
  9994. Birthday string `json:"birthday"`
  9995. Nationality string `json:"nationality"`
  9996. Email string `json:"email"`
  9997. Extra string `json:"extra"`
  9998. } `json:"data"`
  9999. Code int `json:"code"`
  10000. Message string `json:"message"`
  10001. }
  10002. var ele ELeData
  10003. err := json.Unmarshal([]byte(result), &ele)
  10004. if err != nil {
  10005. utils.ErrorLog("解析失败:%v", err)
  10006. }
  10007. token := ele.Data.EcToken
  10008. token = Remove0000(token)
  10009. fmt.Println(ele.Data.UserName)
  10010. 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)
  10011. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10012. var res ResultTwo
  10013. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10014. utils.ErrorLog("解析失败:%v", err)
  10015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10016. return
  10017. }
  10018. if res.Infcode == 0 {
  10019. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10020. if err == gorm.ErrRecordNotFound {
  10021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10022. return
  10023. } else if err != nil {
  10024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10025. return
  10026. } else {
  10027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10029. infoStr := string(Iinfos)
  10030. idetinfoStr := string(Idetinfos)
  10031. psn := &models.HisPsn{
  10032. PsnNo: res.Output.Baseinfo.PsnNo,
  10033. PatientId: patient.ID,
  10034. Certno: res.Output.Baseinfo.Certno,
  10035. Gend: res.Output.Baseinfo.Gend,
  10036. Naty: res.Output.Baseinfo.Naty,
  10037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10038. PsnName: res.Output.Baseinfo.PsnName,
  10039. Idetinfo: idetinfoStr,
  10040. Insuinfo: infoStr,
  10041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10042. CardInfo: "",
  10043. VerifyNumber: token,
  10044. }
  10045. service.CreateHisPsn(psn)
  10046. c.ServeSuccessJSON(map[string]interface{}{
  10047. "patient": patient,
  10048. "number": token,
  10049. })
  10050. }
  10051. } else {
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10053. return
  10054. }
  10055. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10056. //if initFlag == 0 {
  10057. //c.TestGetJiangXiBasBaseInit()
  10058. //}
  10059. //if initEleFlag == 0 {
  10060. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10061. //}
  10062. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10063. utils.ErrorLog("解析失败:%v", json_result)
  10064. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10065. type ELeData struct {
  10066. Data struct {
  10067. IdNo string `json:"idNo"`
  10068. IdType string `json:"idType"`
  10069. UserName string `json:"userName"`
  10070. EcToken string `json:"ecToken"`
  10071. InsuOrg string `json:"insuOrg"`
  10072. Gender string `json:"gender"`
  10073. Birthday string `json:"birthday"`
  10074. Nationality string `json:"nationality"`
  10075. Email string `json:"email"`
  10076. Extra string `json:"extra"`
  10077. } `json:"data"`
  10078. Code int `json:"code"`
  10079. Message string `json:"message"`
  10080. }
  10081. var ele ELeData
  10082. err := json.Unmarshal([]byte(json_result), &ele)
  10083. if err != nil {
  10084. utils.ErrorLog("解析失败:%v", err)
  10085. }
  10086. token := ele.Data.EcToken
  10087. token = Remove0000(token)
  10088. //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)
  10089. 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)
  10090. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10091. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10092. var res ResultTwo
  10093. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10094. utils.ErrorLog("解析失败:%v", err)
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10096. return
  10097. }
  10098. if res.Infcode == 0 {
  10099. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10100. if err == gorm.ErrRecordNotFound {
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10102. return
  10103. } else if err != nil {
  10104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10105. return
  10106. } else {
  10107. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10108. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10109. infoStr := string(Iinfos)
  10110. idetinfoStr := string(Idetinfos)
  10111. psn := &models.HisPsn{
  10112. PsnNo: res.Output.Baseinfo.PsnNo,
  10113. PatientId: patient.ID,
  10114. Certno: res.Output.Baseinfo.Certno,
  10115. Gend: res.Output.Baseinfo.Gend,
  10116. Naty: res.Output.Baseinfo.Naty,
  10117. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10118. PsnName: res.Output.Baseinfo.PsnName,
  10119. Idetinfo: idetinfoStr,
  10120. Insuinfo: infoStr,
  10121. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10122. CardInfo: "",
  10123. VerifyNumber: token,
  10124. InsuplcAdmdvs: ele.Data.InsuOrg,
  10125. }
  10126. service.CreateHisPsn(psn)
  10127. c.ServeSuccessJSON(map[string]interface{}{
  10128. "patient": patient,
  10129. "number": token,
  10130. })
  10131. }
  10132. } else {
  10133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10134. return
  10135. }
  10136. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10137. res := c.GetoleInfo()
  10138. if res.Infcode == 0 {
  10139. var result string
  10140. if res.Output.MdtrtCertType == "01" {
  10141. 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)
  10142. } else if res.Output.MdtrtCertType == "02" {
  10143. 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)
  10144. } else if res.Output.MdtrtCertType == "03" {
  10145. 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)
  10146. }
  10147. var dat map[string]interface{}
  10148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10149. fmt.Println(dat)
  10150. } else {
  10151. fmt.Println(err)
  10152. }
  10153. userJSONBytes, _ := json.Marshal(dat)
  10154. var res2 ResultTwo
  10155. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10156. utils.ErrorLog("解析失败:%v", err)
  10157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10158. return
  10159. }
  10160. if res2.Infcode == 0 {
  10161. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10162. if err == gorm.ErrRecordNotFound {
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10164. return
  10165. } else if err != nil {
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10167. return
  10168. } else {
  10169. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10170. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10171. infoStr := string(Iinfos)
  10172. idetinfoStr := string(Idetinfos)
  10173. var rf []*ResultFive
  10174. json.Unmarshal([]byte(infoStr), &rf)
  10175. var insutypes []*ResultFive
  10176. var insutype string
  10177. var is390 int = 0
  10178. var is310 int = 0
  10179. //var insuplc_admdvs string
  10180. for _, item := range rf {
  10181. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10182. insutypes = append(insutypes, item)
  10183. }
  10184. }
  10185. if len(insutypes) == 1 {
  10186. insutype = insutypes[0].Insutype
  10187. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10188. } else {
  10189. for _, i := range insutypes {
  10190. if i.Insutype == "390" {
  10191. is390 = 1
  10192. }
  10193. if i.Insutype == "310" {
  10194. is310 = 1
  10195. }
  10196. }
  10197. }
  10198. if is390 == 1 {
  10199. insutype = "390"
  10200. }
  10201. if is310 == 1 {
  10202. insutype = "310"
  10203. }
  10204. if len(insutypes) == 0 {
  10205. insutype = "310"
  10206. }
  10207. psn := &models.HisPsn{
  10208. PsnNo: res2.Output.Baseinfo.PsnNo,
  10209. PatientId: patient.ID,
  10210. Certno: res2.Output.Baseinfo.Certno,
  10211. Gend: res2.Output.Baseinfo.Gend,
  10212. Naty: res2.Output.Baseinfo.Naty,
  10213. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10214. PsnName: res2.Output.Baseinfo.PsnName,
  10215. Idetinfo: idetinfoStr,
  10216. Insuinfo: infoStr,
  10217. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10218. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10219. VerifyNumber: res.Output.EcToken,
  10220. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10221. }
  10222. service.CreateHisPsn(psn)
  10223. c.ServeSuccessJSON(map[string]interface{}{
  10224. "patient": patient,
  10225. "number": res.Output.CardNo,
  10226. "insutype": insutype,
  10227. })
  10228. }
  10229. } else {
  10230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10231. return
  10232. }
  10233. } else {
  10234. c.ServeSuccessJSON(map[string]interface{}{
  10235. "failed_code": -10,
  10236. "msg": res.ErrMsg,
  10237. })
  10238. }
  10239. } else {
  10240. //if initFlag == 0 {
  10241. // c.TestGetBasBaseInit()
  10242. //}
  10243. //token := c.GetEleBaseInfo()
  10244. //token = Remove0000(token)
  10245. type ELeData struct {
  10246. Code string `json:"code"`
  10247. Data struct {
  10248. Aac002 string `json:"aac002"`
  10249. Aaz500 string `json:"aaz500"`
  10250. ActCardNo string `json:"actCardNo"`
  10251. Bab520 string `json:"bab520"`
  10252. Bkz543 string `json:"bkz543"`
  10253. BusinessType string `json:"businessType"`
  10254. CertfCodg string `json:"certfCodg"`
  10255. EcIndexNo string `json:"ecIndexNo"`
  10256. EcToken string `json:"ecToken"`
  10257. ID0000 string `json:"id0000"`
  10258. IDNo string `json:"idNo"`
  10259. IDType string `json:"idType"`
  10260. Idcode string `json:"idcode"`
  10261. IdentityToken string `json:"identity_token"`
  10262. InsuOrg string `json:"insuOrg"`
  10263. OfficeID string `json:"officeId"`
  10264. OfficeName string `json:"officeName"`
  10265. OperatorID string `json:"operatorId"`
  10266. OperatorName string `json:"operatorName"`
  10267. OrgID string `json:"orgId"`
  10268. UserName string `json:"userName"`
  10269. } `json:"data"`
  10270. Infno interface{} `json:"infno"`
  10271. Message string `json:"message"`
  10272. OrgID string `json:"orgId"`
  10273. TransType string `json:"transType"`
  10274. }
  10275. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10276. fmt.Println(result)
  10277. outPutInfo := Remove0000(result)
  10278. fmt.Println(outPutInfo)
  10279. var ele ELeData
  10280. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10281. if err != nil {
  10282. utils.ErrorLog("解析失败:%v", err)
  10283. }
  10284. token := ele.Data.EcToken
  10285. var result2 string
  10286. var requestLog2 string
  10287. if len(token) > 0 {
  10288. if strings.Contains(ele.Data.IDNo, "HKG") {
  10289. 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)
  10290. } else {
  10291. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10292. }
  10293. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10294. var res ResultTwo
  10295. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10296. utils.ErrorLog("解析失败:%v", err)
  10297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10298. return
  10299. }
  10300. if res.Infcode == 0 {
  10301. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10302. if err == gorm.ErrRecordNotFound {
  10303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10304. return
  10305. } else if err != nil {
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10307. return
  10308. } else {
  10309. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10310. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10311. infoStr := string(Iinfos)
  10312. idetinfoStr := string(Idetinfos)
  10313. psn := &models.HisPsn{
  10314. PsnNo: res.Output.Baseinfo.PsnNo,
  10315. PatientId: patient.ID,
  10316. Certno: res.Output.Baseinfo.Certno,
  10317. Gend: res.Output.Baseinfo.Gend,
  10318. Naty: res.Output.Baseinfo.Naty,
  10319. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10320. PsnName: res.Output.Baseinfo.PsnName,
  10321. Idetinfo: idetinfoStr,
  10322. Insuinfo: infoStr,
  10323. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10324. CardInfo: "",
  10325. VerifyNumber: token,
  10326. }
  10327. service.CreateHisPsn(psn)
  10328. c.ServeSuccessJSON(map[string]interface{}{
  10329. "msg": "读取成功",
  10330. })
  10331. }
  10332. } else {
  10333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10334. return
  10335. }
  10336. } else {
  10337. c.ServeSuccessJSON(map[string]interface{}{
  10338. "failed_code": -10,
  10339. "msg": "读取失败",
  10340. })
  10341. }
  10342. }
  10343. }
  10344. func (c *HisApiController) ReadEleFace() {
  10345. admin_user_id, _ := c.GetInt64("admin_user_id")
  10346. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10347. adminUser := c.GetAdminUserInfo()
  10348. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10349. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10350. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10351. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10352. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10353. if len(tokens) > 0 {
  10354. c.ServeSuccessJSON(map[string]interface{}{
  10355. "msg": "读取成功",
  10356. })
  10357. } else {
  10358. c.ServeSuccessJSON(map[string]interface{}{
  10359. "failed_code": -10,
  10360. "msg": "读取失败",
  10361. })
  10362. }
  10363. }
  10364. }
  10365. func (c *HisApiController) Get9001() {
  10366. adminUser := c.GetAdminUserInfo()
  10367. admin_user_id, _ := c.GetInt64("admin_user_id")
  10368. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10369. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10370. if miConfig.MdtrtareaAdmvs == "350500" {
  10371. service.GetFjAuthorizationInfo(miConfig.Code)
  10372. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10373. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10374. var dat map[string]interface{}
  10375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10376. fmt.Println(dat)
  10377. } else {
  10378. fmt.Println(err)
  10379. }
  10380. userJSONBytes, _ := json.Marshal(dat)
  10381. var res models.Result9001
  10382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10383. utils.ErrorLog("解析失败:%v", err)
  10384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10385. return
  10386. }
  10387. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10388. fmt.Println(miConfig.SecretKey)
  10389. var res models.Result9001Two
  10390. 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 +
  10391. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10392. resp, requestErr := http.Get(api)
  10393. if requestErr != nil {
  10394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10395. return
  10396. }
  10397. body, ioErr := ioutil.ReadAll(resp.Body)
  10398. if ioErr != nil {
  10399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10401. return
  10402. }
  10403. var respJSON map[string]interface{}
  10404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10407. return
  10408. }
  10409. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10410. if status == "0" {
  10411. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10412. c.ServeSuccessJSON(map[string]interface{}{
  10413. "failed_code": -10,
  10414. "msg": err_msg,
  10415. })
  10416. return
  10417. }
  10418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10419. result, _ := json.Marshal(respJSON)
  10420. fmt.Println("log")
  10421. fmt.Println(string(result))
  10422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10423. utils.ErrorLog("解析失败:%v", err)
  10424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10425. return
  10426. }
  10427. if res.Infcode == 0 {
  10428. sign := models.HisSignIn{
  10429. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10430. SignNo: res.Output.Signinoutb.SignNo,
  10431. SignTime: "",
  10432. Ctime: time.Now().Unix(),
  10433. Mtime: time.Now().Unix(),
  10434. Status: 1,
  10435. InputLog: "",
  10436. OutputLog: "",
  10437. FixmedinsCode: miConfig.Code,
  10438. }
  10439. err := service.CreateSignIn(&sign)
  10440. if err == nil {
  10441. c.ServeSuccessJSON(map[string]interface{}{
  10442. "msg": "签到成功",
  10443. })
  10444. }
  10445. } else {
  10446. c.ServeSuccessJSON(map[string]interface{}{
  10447. "failed_code": -10,
  10448. "msg": res.ErrMsg,
  10449. })
  10450. return
  10451. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10452. //return
  10453. }
  10454. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10455. fmt.Println(miConfig.SecretKey)
  10456. var res models.Result9001Two
  10457. 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 +
  10458. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10459. resp, requestErr := http.Get(api)
  10460. if requestErr != nil {
  10461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10462. return
  10463. }
  10464. body, ioErr := ioutil.ReadAll(resp.Body)
  10465. if ioErr != nil {
  10466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10468. return
  10469. }
  10470. var respJSON map[string]interface{}
  10471. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10474. return
  10475. }
  10476. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10477. if status == "0" {
  10478. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10479. c.ServeSuccessJSON(map[string]interface{}{
  10480. "failed_code": -10,
  10481. "msg": err_msg,
  10482. })
  10483. return
  10484. }
  10485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10486. result, _ := json.Marshal(respJSON)
  10487. fmt.Println("log")
  10488. fmt.Println(string(result))
  10489. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10490. utils.ErrorLog("解析失败:%v", err)
  10491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10492. return
  10493. }
  10494. if res.Infcode == 0 {
  10495. sign := models.HisSignIn{
  10496. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10497. SignNo: res.Output.Signinoutb.SignNo,
  10498. SignTime: "",
  10499. Ctime: time.Now().Unix(),
  10500. Mtime: time.Now().Unix(),
  10501. Status: 1,
  10502. InputLog: "",
  10503. OutputLog: "",
  10504. FixmedinsCode: miConfig.Code,
  10505. }
  10506. err := service.CreateSignIn(&sign)
  10507. if err == nil {
  10508. c.ServeSuccessJSON(map[string]interface{}{
  10509. "msg": "签到成功",
  10510. })
  10511. }
  10512. } else {
  10513. c.ServeSuccessJSON(map[string]interface{}{
  10514. "failed_code": -10,
  10515. "msg": res.ErrMsg,
  10516. })
  10517. return
  10518. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10519. //return
  10520. }
  10521. } else {
  10522. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10523. var dat map[string]interface{}
  10524. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10525. fmt.Println(dat)
  10526. } else {
  10527. fmt.Println(err)
  10528. }
  10529. userJSONBytes, _ := json.Marshal(dat)
  10530. var res models.Result9001
  10531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10532. utils.ErrorLog("解析失败:%v", err)
  10533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10534. return
  10535. }
  10536. if res.Infcode == 0 {
  10537. sign := models.HisSignIn{
  10538. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10539. SignNo: res.Output.Signinoutb.SignNo,
  10540. SignTime: res.Output.Signinoutb.SignTime,
  10541. Ctime: time.Now().Unix(),
  10542. Mtime: time.Now().Unix(),
  10543. Status: 1,
  10544. InputLog: "",
  10545. OutputLog: "",
  10546. FixmedinsCode: miConfig.Code,
  10547. }
  10548. err := service.CreateSignIn(&sign)
  10549. if err == nil {
  10550. c.ServeSuccessJSON(map[string]interface{}{
  10551. "msg": "签到成功",
  10552. })
  10553. }
  10554. }
  10555. }
  10556. }
  10557. 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) {
  10558. var res Result3101
  10559. adminUser := c.GetAdminUserInfo()
  10560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10561. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10563. //record_time := c.GetString("record_time")
  10564. //trig_scen := c.GetString("trig_scen")
  10565. timeLayout := "2006-01-02"
  10566. loc, _ := time.LoadLocation("Local")
  10567. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10568. if err != nil {
  10569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10570. return res
  10571. }
  10572. recordDateTime := theTime.Unix()
  10573. var patientPrescription models.HisPrescriptionInfo
  10574. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10575. //if patientPrescription.ID == 0 {
  10576. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10577. //}
  10578. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10579. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10580. //
  10581. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10582. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10583. var pp models.PublicParams
  10584. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10585. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10586. pp.FixmedinsName = miConfig.OrgName
  10587. pp.FixmedinsCode = miConfig.Code
  10588. pp.RequestUrl = miConfig.Url
  10589. pp.Cainfo = miConfig.Cainfo
  10590. pp.SecretKey = miConfig.SecretKey
  10591. pp.AccessKey = miConfig.AccessKey
  10592. pp.OpterName = roles.UserName
  10593. var config []*models.HisXtDiagnoseConfig
  10594. for _, item := range diagnosis_ids {
  10595. id, _ := strconv.ParseInt(item, 10, 64)
  10596. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10597. config = append(config, &diagnosisConfig)
  10598. }
  10599. var pd models.PatientDtos
  10600. pd.PatnID = his.PsnNo
  10601. pd.PatnName = his.Name
  10602. pd.Gend = his.Gend
  10603. pd.Brdy = his.Brdy
  10604. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10605. pd.CurrMdtrtID = his.Number
  10606. var fed models.FsiEncounterDtos
  10607. fed.MdtrtID = his.Number
  10608. fed.MedinsID = miConfig.Code
  10609. fed.MedinsName = miConfig.OrgName
  10610. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10611. fed.MedMdtrtType = "1"
  10612. fed.MedinsType = "1"
  10613. fed.MedinsLv = "11"
  10614. tm := time.Unix(his.RecordDate, 0)
  10615. s_tm := tm.Format("2006-01-02 15:04:05")
  10616. fed.AdmDate = s_tm
  10617. fed.DscgDate = s_tm
  10618. fed.DscgMainDiseCodg = config[0].CountryCode
  10619. fed.DscgMainDiseName = config[0].CountryContentName
  10620. //诊断信息
  10621. var fdds []*models.FsiDiagnoseDtos
  10622. for index, item := range config {
  10623. if index == 0 {
  10624. var fdd models.FsiDiagnoseDtos
  10625. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10626. fdd.InoutDiseType = "1"
  10627. fdd.MaindiseFlag = "1"
  10628. fdd.DiseDate = s_tm
  10629. fdd.DiasSrtNo = "1"
  10630. fdd.DiseName = item.CountryContentName
  10631. fdd.DiseCodg = item.CountryCode
  10632. fdds = append(fdds, &fdd)
  10633. } else {
  10634. var fdd models.FsiDiagnoseDtos
  10635. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10636. fdd.InoutDiseType = "1"
  10637. fdd.MaindiseFlag = "1"
  10638. fdd.DiseDate = s_tm
  10639. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10640. fdd.DiseName = item.CountryContentName
  10641. fdd.DiseCodg = item.CountryCode
  10642. fdds = append(fdds, &fdd)
  10643. }
  10644. }
  10645. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10646. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10647. fed.AdmDeptName = de.Name
  10648. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10649. fed.DscgDeptName = de.Name
  10650. fed.MedMdtrtType = "1"
  10651. fed.MedType = "11"
  10652. //if his.Insutype == "390" {
  10653. // fed.MedType = "1402"
  10654. //} else {
  10655. // fed.MedType = "9933"
  10656. //}
  10657. var orders []*models.FsiOrderDtos
  10658. if trig_scen == "2" {
  10659. //处方医嘱信息
  10660. for _, item := range prescriptions {
  10661. for _, subItem := range item.HisDoctorAdviceInfo {
  10662. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10663. var order models.FsiOrderDtos
  10664. order.RxID = strconv.FormatInt(item.ID, 10)
  10665. order.Rxno = strconv.FormatInt(item.ID, 10)
  10666. order.LongDrordFlag = "0"
  10667. order.HilistType = "1"
  10668. order.ChrgType = "1"
  10669. order.DrordBhvr = "-"
  10670. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10671. order.HosplistName = subItem.BaseDrugLib.DrugName
  10672. order.HilistLv = "1"
  10673. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10674. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10675. order.HosplistName = subItem.BaseDrugLib.DrugName
  10676. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10677. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10678. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10679. order.OwnpayAmt = ""
  10680. order.SelfpayAmt = ""
  10681. order.Spec = ""
  10682. order.SpecUnt = ""
  10683. order.DrordBegnDate = s_tm
  10684. order.DrordStopDate = ""
  10685. order.DrordDrCodg = doctor_info.DoctorNumber
  10686. order.DrordDeptName = department.Name
  10687. order.DrordDeptCodg = department.Number
  10688. order.DrordDrName = doctor_info.UserName
  10689. order.DrordDrProfttl = "234"
  10690. order.CurrDrordFlag = "1"
  10691. orders = append(orders, &order)
  10692. }
  10693. }
  10694. for _, subItem := range item.HisPrescriptionProject {
  10695. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10696. var order models.FsiOrderDtos
  10697. order.RxID = strconv.FormatInt(item.ID, 10)
  10698. order.Rxno = strconv.FormatInt(item.ID, 10)
  10699. order.LongDrordFlag = "0"
  10700. order.HilistType = "1"
  10701. order.ChrgType = "1"
  10702. order.DrordBhvr = "-"
  10703. order.HilistCode = subItem.HisProject.MedicalCode
  10704. order.HosplistName = subItem.HisProject.ProjectName
  10705. order.HilistLv = "1"
  10706. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10707. order.HosplistCode = subItem.HisProject.MedicalCode
  10708. order.HosplistName = subItem.HisProject.ProjectName
  10709. order.Cnt = subItem.Count
  10710. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10711. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10712. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10713. order.OwnpayAmt = ""
  10714. order.SelfpayAmt = ""
  10715. order.Spec = ""
  10716. order.SpecUnt = ""
  10717. order.DrordBegnDate = s_tm
  10718. order.DrordStopDate = ""
  10719. order.DrordDrCodg = doctor_info.DoctorNumber
  10720. order.DrordDeptName = department.Name
  10721. order.DrordDeptCodg = department.Number
  10722. order.DrordDrName = doctor_info.UserName
  10723. order.DrordDrProfttl = "234"
  10724. order.CurrDrordFlag = "1"
  10725. orders = append(orders, &order)
  10726. }
  10727. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10728. var order models.FsiOrderDtos
  10729. order.RxID = strconv.FormatInt(item.ID, 10)
  10730. order.Rxno = strconv.FormatInt(item.ID, 10)
  10731. order.LongDrordFlag = "0"
  10732. order.HilistType = "1"
  10733. order.ChrgType = "1"
  10734. order.DrordBhvr = "-"
  10735. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10736. order.HosplistName = subItem.GoodInfo.GoodName
  10737. order.HilistLv = "1"
  10738. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10739. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10740. order.HosplistName = subItem.GoodInfo.GoodName
  10741. order.Cnt = subItem.Count
  10742. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10743. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10744. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10745. order.OwnpayAmt = ""
  10746. order.SelfpayAmt = ""
  10747. order.Spec = ""
  10748. order.SpecUnt = ""
  10749. order.DrordBegnDate = s_tm
  10750. order.DrordStopDate = ""
  10751. order.DrordDrCodg = doctor_info.DoctorNumber
  10752. order.DrordDeptName = department.Name
  10753. order.DrordDeptCodg = department.Number
  10754. order.DrordDrName = doctor_info.UserName
  10755. order.DrordDrProfttl = "234"
  10756. order.CurrDrordFlag = "1"
  10757. orders = append(orders, &order)
  10758. }
  10759. }
  10760. }
  10761. //处方医嘱信息
  10762. }
  10763. fed.MatnStas = "0"
  10764. fed.MedfeeSumamt = "0"
  10765. fed.OwnpayAmt = "0"
  10766. fed.SelfpayAmt = "0"
  10767. fed.AcctPayamt = "0"
  10768. fed.MaAmt = "0"
  10769. fed.HifpPayamt = "0"
  10770. fed.SetlTotlnum = "1"
  10771. fed.Insutype = his.Insutype
  10772. fed.ReimFlag = "0"
  10773. fed.OutSetlFlag = "0"
  10774. var fopd []*models.FsiOperationDtosData
  10775. data := make(map[string]interface{})
  10776. data["fed"] = fed
  10777. data["fdd"] = fdds
  10778. data["fod"] = orders
  10779. data["pd"] = pd
  10780. data["pp"] = pp
  10781. data["fopd"] = fopd
  10782. data["trig_scen"] = trig_scen
  10783. fmt.Println(data)
  10784. fmt.Println(fed)
  10785. fmt.Println(fdds)
  10786. fmt.Println(orders)
  10787. fmt.Println(pd)
  10788. fmt.Println(pp)
  10789. fmt.Println(fopd)
  10790. client := &http.Client{}
  10791. bytesData, _ := json.Marshal(data)
  10792. var req *http.Request
  10793. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10794. if miConfig.MdtrtareaAdmvs == "320921" {
  10795. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10796. } else {
  10797. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10798. }
  10799. resp, _ := client.Do(req)
  10800. defer resp.Body.Close()
  10801. body, ioErr := ioutil.ReadAll(resp.Body)
  10802. if ioErr != nil {
  10803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10805. return res
  10806. }
  10807. var respJSON map[string]interface{}
  10808. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10811. return res
  10812. }
  10813. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10814. fmt.Println(respJSON)
  10815. result, _ := json.Marshal(respJSON)
  10816. fmt.Println(result)
  10817. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10818. utils.ErrorLog("解析失败:%v", err)
  10819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10820. return res
  10821. }
  10822. return res
  10823. } else {
  10824. //if miConfig.MdtrtareaAdmvs == "441202" {
  10825. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10826. saveLog(output, input, "3101", "事前")
  10827. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10828. utils.ErrorLog("解析失败:%v", err)
  10829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10830. return
  10831. }
  10832. return res
  10833. //}
  10834. }
  10835. }
  10836. 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) {
  10837. adminUser := c.GetAdminUserInfo()
  10838. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10839. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10840. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10841. //record_time := c.GetString("record_time")
  10842. //trig_scen := c.GetString("trig_scen")
  10843. timeLayout := "2006-01-02"
  10844. loc, _ := time.LoadLocation("Local")
  10845. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10846. if err != nil {
  10847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10848. return res
  10849. }
  10850. recordDateTime := theTime.Unix()
  10851. var patientPrescription models.HisPrescriptionInfo
  10852. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10853. if patientPrescription.ID == 0 {
  10854. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10855. }
  10856. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10857. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10858. //
  10859. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10860. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10861. var pp models.PublicParams
  10862. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10863. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10864. pp.FixmedinsName = miConfig.OrgName
  10865. pp.FixmedinsCode = miConfig.Code
  10866. pp.RequestUrl = miConfig.Url
  10867. pp.Cainfo = miConfig.Cainfo
  10868. pp.SecretKey = miConfig.SecretKey
  10869. pp.AccessKey = miConfig.AccessKey
  10870. pp.OpterName = roles.UserName
  10871. var config []*models.HisXtDiagnoseConfig
  10872. for _, item := range diagnosis_ids {
  10873. id, _ := strconv.ParseInt(item, 10, 64)
  10874. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10875. config = append(config, &diagnosisConfig)
  10876. }
  10877. var pd models.PatientDtos
  10878. pd.PatnID = his.PsnNo
  10879. pd.PatnName = his.Name
  10880. pd.Gend = his.Gend
  10881. pd.Brdy = his.Brdy
  10882. pd.Poolarea = his.InsuplcAdmdvs
  10883. pd.CurrMdtrtID = his.Number
  10884. var fed models.FsiEncounterDtos
  10885. fed.MdtrtID = his.Number
  10886. fed.MedinsID = miConfig.Code
  10887. fed.MedinsName = miConfig.OrgName
  10888. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10889. fed.MedMdtrtType = "1"
  10890. fed.MedinsType = "1"
  10891. fed.MedinsLv = "11"
  10892. tm := time.Unix(his.RecordDate, 0)
  10893. s_tm := tm.Format("2006-01-02 15:04:05")
  10894. fed.AdmDate = s_tm
  10895. fed.DscgDate = s_tm
  10896. fed.DscgMainDiseCodg = config[0].CountryCode
  10897. fed.DscgMainDiseName = config[0].CountryContentName
  10898. //诊断信息
  10899. var fdds []*models.FsiDiagnoseDtos
  10900. for index, item := range config {
  10901. if index == 0 {
  10902. var fdd models.FsiDiagnoseDtos
  10903. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10904. fdd.InoutDiseType = "1"
  10905. fdd.MaindiseFlag = "1"
  10906. fdd.DiseDate = s_tm
  10907. fdd.DiasSrtNo = "1"
  10908. fdd.DiseName = item.CountryContentName
  10909. fdd.DiseCodg = item.CountryCode
  10910. fdds = append(fdds, &fdd)
  10911. } else {
  10912. var fdd models.FsiDiagnoseDtos
  10913. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10914. fdd.InoutDiseType = "1"
  10915. fdd.MaindiseFlag = "1"
  10916. fdd.DiseDate = s_tm
  10917. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10918. fdd.DiseName = item.CountryContentName
  10919. fdd.DiseCodg = item.CountryCode
  10920. fdds = append(fdds, &fdd)
  10921. }
  10922. }
  10923. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10924. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10925. fed.AdmDeptName = department.Name
  10926. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10927. fed.DscgDeptName = department.Name
  10928. fed.MedMdtrtType = "1"
  10929. fed.MedType = "11"
  10930. //if his.Insutype == "390" {
  10931. // fed.MedType = "1402"
  10932. //} else {
  10933. // fed.MedType = "9933"
  10934. //}
  10935. var orders []*models.FsiOrderDtos
  10936. if trig_scen == "2" {
  10937. //处方医嘱信息
  10938. for _, item := range prescriptions {
  10939. for _, subItem := range item.HisDoctorAdviceInfo {
  10940. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10941. var order models.FsiOrderDtos
  10942. order.RxID = strconv.FormatInt(item.ID, 10)
  10943. order.Rxno = strconv.FormatInt(item.ID, 10)
  10944. order.LongDrordFlag = "0"
  10945. order.HilistType = "1"
  10946. order.ChrgType = "1"
  10947. order.DrordBhvr = "-"
  10948. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10949. order.HosplistName = subItem.BaseDrugLib.DrugName
  10950. order.HilistLv = "1"
  10951. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10952. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10953. order.HosplistName = subItem.BaseDrugLib.DrugName
  10954. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10955. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10956. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10957. order.OwnpayAmt = ""
  10958. order.SelfpayAmt = ""
  10959. order.Spec = ""
  10960. order.SpecUnt = ""
  10961. order.DrordBegnDate = s_tm
  10962. order.DrordStopDate = ""
  10963. order.DrordDrCodg = doctor_info.DoctorNumber
  10964. order.DrordDeptName = department.Name
  10965. order.DrordDeptCodg = department.Number
  10966. order.DrordDrName = doctor_info.UserName
  10967. order.DrordDrProfttl = "234"
  10968. order.CurrDrordFlag = "1"
  10969. orders = append(orders, &order)
  10970. }
  10971. }
  10972. for _, subItem := range item.HisPrescriptionProject {
  10973. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10974. var order models.FsiOrderDtos
  10975. order.RxID = strconv.FormatInt(item.ID, 10)
  10976. order.Rxno = strconv.FormatInt(item.ID, 10)
  10977. order.LongDrordFlag = "0"
  10978. order.HilistType = "1"
  10979. order.ChrgType = "1"
  10980. order.DrordBhvr = "-"
  10981. order.HilistCode = subItem.HisProject.MedicalCode
  10982. order.HosplistName = subItem.HisProject.ProjectName
  10983. order.HilistLv = "1"
  10984. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10985. order.HosplistCode = subItem.HisProject.MedicalCode
  10986. order.HosplistName = subItem.HisProject.ProjectName
  10987. order.Cnt = subItem.Count
  10988. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10989. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10990. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10991. order.OwnpayAmt = ""
  10992. order.SelfpayAmt = ""
  10993. order.Spec = ""
  10994. order.SpecUnt = ""
  10995. order.DrordBegnDate = s_tm
  10996. order.DrordStopDate = ""
  10997. order.DrordDrCodg = doctor_info.DoctorNumber
  10998. order.DrordDeptName = department.Name
  10999. order.DrordDeptCodg = department.Number
  11000. order.DrordDrName = doctor_info.UserName
  11001. order.DrordDrProfttl = "234"
  11002. order.CurrDrordFlag = "1"
  11003. orders = append(orders, &order)
  11004. }
  11005. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11006. var order models.FsiOrderDtos
  11007. order.RxID = strconv.FormatInt(item.ID, 10)
  11008. order.Rxno = strconv.FormatInt(item.ID, 10)
  11009. order.LongDrordFlag = "0"
  11010. order.HilistType = "1"
  11011. order.ChrgType = "1"
  11012. order.DrordBhvr = "-"
  11013. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11014. order.HosplistName = subItem.GoodInfo.GoodName
  11015. order.HilistLv = "1"
  11016. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11017. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11018. order.HosplistName = subItem.GoodInfo.GoodName
  11019. order.Cnt = subItem.Count
  11020. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11021. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11022. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11023. order.OwnpayAmt = ""
  11024. order.SelfpayAmt = ""
  11025. order.Spec = ""
  11026. order.SpecUnt = ""
  11027. order.DrordBegnDate = s_tm
  11028. order.DrordStopDate = ""
  11029. order.DrordDrCodg = doctor_info.DoctorNumber
  11030. order.DrordDeptName = department.Name
  11031. order.DrordDeptCodg = department.Number
  11032. order.DrordDrName = doctor_info.UserName
  11033. order.DrordDrProfttl = "234"
  11034. order.CurrDrordFlag = "1"
  11035. orders = append(orders, &order)
  11036. }
  11037. }
  11038. }
  11039. //处方医嘱信息
  11040. }
  11041. fed.MatnStas = "0"
  11042. fed.MedfeeSumamt = "0"
  11043. fed.OwnpayAmt = "0"
  11044. fed.SelfpayAmt = "0"
  11045. fed.AcctPayamt = "0"
  11046. fed.MaAmt = "0"
  11047. fed.HifpPayamt = "0"
  11048. fed.SetlTotlnum = "1"
  11049. fed.Insutype = his.Insutype
  11050. fed.ReimFlag = "0"
  11051. fed.OutSetlFlag = "0"
  11052. var fopd []*models.FsiOperationDtosData
  11053. data := make(map[string]interface{})
  11054. data["fed"] = fed
  11055. data["fdd"] = fdds
  11056. data["fod"] = orders
  11057. data["pd"] = pd
  11058. data["pp"] = pp
  11059. data["fopd"] = fopd
  11060. data["trig_scen"] = trig_scen
  11061. fmt.Println(data)
  11062. fmt.Println(fed)
  11063. fmt.Println(fdds)
  11064. fmt.Println(orders)
  11065. fmt.Println(pd)
  11066. fmt.Println(pp)
  11067. fmt.Println(fopd)
  11068. client := &http.Client{}
  11069. bytesData, _ := json.Marshal(data)
  11070. var req *http.Request
  11071. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11072. if miConfig.MdtrtareaAdmvs == "320921" {
  11073. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11074. } else {
  11075. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11076. }
  11077. resp, _ := client.Do(req)
  11078. defer resp.Body.Close()
  11079. body, ioErr := ioutil.ReadAll(resp.Body)
  11080. if ioErr != nil {
  11081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11083. return res
  11084. }
  11085. var respJSON map[string]interface{}
  11086. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11089. return res
  11090. }
  11091. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11092. fmt.Println(respJSON)
  11093. result, _ := json.Marshal(respJSON)
  11094. fmt.Println(result)
  11095. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11096. utils.ErrorLog("解析失败:%v", err)
  11097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11098. return res
  11099. }
  11100. return res
  11101. } else {
  11102. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11103. saveLog(output, input, "3101", "事前")
  11104. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11105. utils.ErrorLog("解析失败:%v", err)
  11106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11107. return
  11108. }
  11109. return res
  11110. }
  11111. return res
  11112. }
  11113. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11114. ////patient_id, _ := c.GetInt64("patient_id")
  11115. //order_id, _ := c.GetInt64("order_id")
  11116. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11117. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11118. //trig_scen := c.GetString("trig_scen")
  11119. adminUser := c.GetAdminUserInfo()
  11120. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11121. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11122. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11123. record_time := c.GetString("record_time")
  11124. order, _ := service.GetHisOrderByID(order_id)
  11125. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11126. timeLayout := "2006-01-02"
  11127. loc, _ := time.LoadLocation("Local")
  11128. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11129. if err != nil {
  11130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11131. return
  11132. }
  11133. recordDateTime := theTime.Unix()
  11134. var patientPrescription models.HisPrescriptionInfo
  11135. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11136. if patientPrescription.ID == 0 {
  11137. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11138. }
  11139. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11140. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11141. //
  11142. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11143. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11144. var pp models.PublicParams
  11145. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11146. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11147. pp.FixmedinsName = miConfig.OrgName
  11148. pp.FixmedinsCode = miConfig.Code
  11149. pp.RequestUrl = miConfig.Url
  11150. pp.Cainfo = miConfig.Cainfo
  11151. pp.SecretKey = miConfig.SecretKey
  11152. pp.AccessKey = miConfig.AccessKey
  11153. pp.OpterName = roles.UserName
  11154. var config []*models.HisXtDiagnoseConfig
  11155. for _, item := range diagnosis_ids {
  11156. id, _ := strconv.ParseInt(item, 10, 64)
  11157. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11158. config = append(config, &diagnosisConfig)
  11159. }
  11160. var pd models.PatientDtos
  11161. pd.PatnID = his.PsnNo
  11162. pd.PatnName = his.Name
  11163. pd.Gend = his.Gend
  11164. pd.Brdy = psn_info.Brdy
  11165. pd.Poolarea = his.InsuplcAdmdvs
  11166. pd.CurrMdtrtID = his.Number
  11167. var fed models.FsiEncounterDtos
  11168. fed.MdtrtID = his.Number
  11169. fed.MedinsID = miConfig.Code
  11170. fed.MedinsName = miConfig.OrgName
  11171. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11172. fed.MedMdtrtType = "1"
  11173. fed.MedinsType = "1"
  11174. fed.MedinsLv = "11"
  11175. tm := time.Unix(his.RecordDate, 0)
  11176. s_tm := tm.Format("2006-01-02 15:04:05")
  11177. fed.AdmDate = s_tm
  11178. fed.DscgDate = s_tm
  11179. fed.DscgMainDiseCodg = config[0].CountryCode
  11180. fed.DscgMainDiseName = config[0].CountryContentName
  11181. //诊断信息
  11182. var fdds []*models.FsiDiagnoseDtos
  11183. for index, item := range config {
  11184. if index == 0 {
  11185. var fdd models.FsiDiagnoseDtos
  11186. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11187. fdd.InoutDiseType = "1"
  11188. fdd.MaindiseFlag = "1"
  11189. fdd.DiseDate = s_tm
  11190. fdd.DiasSrtNo = "1"
  11191. fdd.DiseName = item.CountryContentName
  11192. fdd.DiseCodg = item.CountryCode
  11193. fdds = append(fdds, &fdd)
  11194. } else {
  11195. var fdd models.FsiDiagnoseDtos
  11196. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11197. fdd.InoutDiseType = "1"
  11198. fdd.MaindiseFlag = "1"
  11199. fdd.DiseDate = s_tm
  11200. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11201. fdd.DiseName = item.CountryContentName
  11202. fdd.DiseCodg = item.CountryCode
  11203. fdds = append(fdds, &fdd)
  11204. }
  11205. }
  11206. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11207. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11208. fed.AdmDeptName = department.Name
  11209. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11210. fed.DscgDeptName = department.Name
  11211. fed.MedType = order.MedType
  11212. //处方医嘱信息
  11213. var orders []*models.FsiOrderDtos
  11214. //for _, item := range prescriptions {
  11215. // for _, subItem := range item.HisDoctorAdviceInfo {
  11216. // var order models.FsiOrderDtos
  11217. // order.RxID = strconv.FormatInt(item.ID, 10)
  11218. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11219. // order.LongDrordFlag = "0"
  11220. // order.HilistType = "1"
  11221. // order.ChrgType = "1"
  11222. // order.DrordBhvr = "-"
  11223. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11224. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11225. // order.HilistLv = "1"
  11226. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11227. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11228. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11229. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11230. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11231. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11232. // order.OwnpayAmt = ""
  11233. // order.SelfpayAmt = ""
  11234. // order.Spec = ""
  11235. // order.SpecUnt = ""
  11236. // order.DrordBegnDate = s_tm
  11237. // order.DrordStopDate = ""
  11238. // order.DrordDrCodg = "1"
  11239. // order.DrordDeptName = department.Name
  11240. // order.DrordDrCodg = "1"
  11241. // order.DrordDrName = doctor_info.UserName
  11242. // order.DrordDrProfttl = ""
  11243. // order.CurrDrordFlag = "1"
  11244. // orders = append(orders, &order)
  11245. // }
  11246. // for _, subItem := range item.HisPrescriptionProject {
  11247. // if subItem.Type == 2 {
  11248. // var order models.FsiOrderDtos
  11249. // order.RxID = strconv.FormatInt(item.ID, 10)
  11250. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11251. // order.LongDrordFlag = "0"
  11252. // order.HilistType = "1"
  11253. // order.ChrgType = "1"
  11254. // order.DrordBhvr = "-"
  11255. // order.HilistCode = subItem.HisProject.MedicalCode
  11256. // order.HosplistName = subItem.HisProject.ProjectName
  11257. // order.HilistLv = "1"
  11258. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11259. // order.HosplistCode = subItem.HisProject.MedicalCode
  11260. // order.HosplistName = subItem.HisProject.ProjectName
  11261. // order.Cnt = subItem.Count
  11262. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11263. //
  11264. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11265. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11266. // order.OwnpayAmt = ""
  11267. // order.SelfpayAmt = ""
  11268. // order.Spec = ""
  11269. // order.SpecUnt = ""
  11270. // order.DrordBegnDate = s_tm
  11271. // order.DrordStopDate = ""
  11272. // order.DrordDrCodg = "1"
  11273. // order.DrordDeptName = department.Name
  11274. // order.DrordDrCodg = "1"
  11275. // order.DrordDrName = doctor_info.UserName
  11276. // order.DrordDrProfttl = ""
  11277. // order.CurrDrordFlag = "1"
  11278. // orders = append(orders, &order)
  11279. //
  11280. // }
  11281. // if subItem.Type == 3 {
  11282. //
  11283. // var order models.FsiOrderDtos
  11284. // order.RxID = strconv.FormatInt(item.ID, 10)
  11285. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11286. // order.LongDrordFlag = "0"
  11287. // order.HilistType = "1"
  11288. // order.ChrgType = "1"
  11289. // order.DrordBhvr = "-"
  11290. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11291. // order.HosplistName = subItem.GoodInfo.GoodName
  11292. // order.HilistLv = "1"
  11293. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11294. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11295. // order.HosplistName = subItem.GoodInfo.GoodName
  11296. // order.Cnt = subItem.Count
  11297. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11298. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11299. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11300. // order.OwnpayAmt = ""
  11301. // order.SelfpayAmt = ""
  11302. // order.Spec = ""
  11303. // order.SpecUnt = ""
  11304. // order.DrordBegnDate = s_tm
  11305. // order.DrordStopDate = ""
  11306. // order.DrordDrCodg = "1"
  11307. // order.DrordDeptName = department.Name
  11308. // order.DrordDrCodg = "1"
  11309. // order.DrordDrName = doctor_info.UserName
  11310. // order.DrordDrProfttl = ""
  11311. // order.CurrDrordFlag = "1"
  11312. // orders = append(orders, &order)
  11313. //
  11314. // }
  11315. // }
  11316. //}
  11317. for _, item := range prescriptions {
  11318. for _, subItem := range item.HisDoctorAdviceInfo {
  11319. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11320. var order models.FsiOrderDtos
  11321. order.RxID = strconv.FormatInt(item.ID, 10)
  11322. order.Rxno = strconv.FormatInt(item.ID, 10)
  11323. order.LongDrordFlag = "0"
  11324. order.HilistType = "1"
  11325. order.ChrgType = "1"
  11326. order.DrordBhvr = "-"
  11327. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11328. order.HosplistName = subItem.BaseDrugLib.DrugName
  11329. order.HilistLv = "1"
  11330. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11331. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11332. order.HosplistName = subItem.BaseDrugLib.DrugName
  11333. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11334. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11335. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11336. order.OwnpayAmt = ""
  11337. order.SelfpayAmt = ""
  11338. order.Spec = ""
  11339. order.SpecUnt = ""
  11340. order.DrordBegnDate = s_tm
  11341. order.DrordStopDate = ""
  11342. order.DrordDrCodg = doctor_info.DoctorNumber
  11343. order.DrordDeptName = department.Name
  11344. order.DrordDeptCodg = department.Number
  11345. order.DrordDrName = doctor_info.UserName
  11346. order.DrordDrProfttl = "234"
  11347. order.CurrDrordFlag = "1"
  11348. orders = append(orders, &order)
  11349. }
  11350. }
  11351. for _, subItem := range item.HisPrescriptionProject {
  11352. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11353. var order models.FsiOrderDtos
  11354. order.RxID = strconv.FormatInt(item.ID, 10)
  11355. order.Rxno = strconv.FormatInt(item.ID, 10)
  11356. order.LongDrordFlag = "0"
  11357. order.HilistType = "1"
  11358. order.ChrgType = "1"
  11359. order.DrordBhvr = "-"
  11360. order.HilistCode = subItem.HisProject.MedicalCode
  11361. order.HosplistName = subItem.HisProject.ProjectName
  11362. order.HilistLv = "1"
  11363. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11364. order.HosplistCode = subItem.HisProject.MedicalCode
  11365. order.HosplistName = subItem.HisProject.ProjectName
  11366. order.Cnt = subItem.Count
  11367. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11368. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11369. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11370. order.OwnpayAmt = ""
  11371. order.SelfpayAmt = ""
  11372. order.Spec = ""
  11373. order.SpecUnt = ""
  11374. order.DrordBegnDate = s_tm
  11375. order.DrordStopDate = ""
  11376. order.DrordDrCodg = doctor_info.DoctorNumber
  11377. order.DrordDeptName = department.Name
  11378. order.DrordDeptCodg = department.Number
  11379. order.DrordDrName = doctor_info.UserName
  11380. order.DrordDrProfttl = "234"
  11381. order.CurrDrordFlag = "1"
  11382. orders = append(orders, &order)
  11383. }
  11384. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11385. var order models.FsiOrderDtos
  11386. order.RxID = strconv.FormatInt(item.ID, 10)
  11387. order.Rxno = strconv.FormatInt(item.ID, 10)
  11388. order.LongDrordFlag = "0"
  11389. order.HilistType = "1"
  11390. order.ChrgType = "1"
  11391. order.DrordBhvr = "0"
  11392. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11393. order.HosplistName = subItem.GoodInfo.GoodName
  11394. order.HilistLv = "1"
  11395. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11396. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11397. order.HosplistName = subItem.GoodInfo.GoodName
  11398. order.Cnt = subItem.Count
  11399. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11400. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11401. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11402. order.OwnpayAmt = ""
  11403. order.SelfpayAmt = ""
  11404. order.Spec = ""
  11405. order.SpecUnt = ""
  11406. order.DrordBegnDate = s_tm
  11407. order.DrordStopDate = ""
  11408. order.DrordDrCodg = doctor_info.DoctorNumber
  11409. order.DrordDeptName = department.Name
  11410. order.DrordDeptCodg = department.Number
  11411. order.DrordDrName = doctor_info.UserName
  11412. order.DrordDrProfttl = "234"
  11413. order.CurrDrordFlag = "1"
  11414. orders = append(orders, &order)
  11415. }
  11416. }
  11417. }
  11418. //处方医嘱信息
  11419. fed.MatnStas = "0"
  11420. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11421. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11422. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11423. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11424. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11425. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11426. fed.SetlTotlnum = "1"
  11427. fed.Insutype = his.Insutype
  11428. fed.ReimFlag = "0"
  11429. fed.OutSetlFlag = "0"
  11430. var fopd []*models.FsiOperationDtosData
  11431. data := make(map[string]interface{})
  11432. data["fed"] = fed
  11433. data["fdd"] = fdds
  11434. data["fod"] = orders
  11435. data["pd"] = pd
  11436. data["pp"] = pp
  11437. data["fopd"] = fopd
  11438. data["trig_scen"] = trig_scen
  11439. client := &http.Client{}
  11440. bytesData, _ := json.Marshal(data)
  11441. var req *http.Request
  11442. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11443. if miConfig.MdtrtareaAdmvs == "320921" {
  11444. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11445. } else {
  11446. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11447. }
  11448. resp, _ := client.Do(req)
  11449. defer resp.Body.Close()
  11450. body, ioErr := ioutil.ReadAll(resp.Body)
  11451. if ioErr != nil {
  11452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11454. return res
  11455. }
  11456. var respJSON map[string]interface{}
  11457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11460. return res
  11461. }
  11462. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11463. result, _ := json.Marshal(respJSON)
  11464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11465. utils.ErrorLog("解析失败:%v", err)
  11466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11467. return res
  11468. }
  11469. return res
  11470. } else {
  11471. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11472. saveLog(output, input, "3102", "事中")
  11473. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11474. utils.ErrorLog("解析失败:%v", err)
  11475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11476. return
  11477. }
  11478. return res
  11479. }
  11480. return res
  11481. }
  11482. 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) {
  11483. var res Resultgd3101
  11484. adminUser := c.GetAdminUserInfo()
  11485. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11486. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11488. //record_time := c.GetString("record_time")
  11489. //trig_scen := c.GetString("trig_scen")
  11490. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11491. //psn_info, _ := service.GetPatientId(patient_id)
  11492. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11493. timeLayout := "2006-01-02"
  11494. loc, _ := time.LoadLocation("Local")
  11495. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11496. if err != nil {
  11497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11498. return res
  11499. }
  11500. recordDateTime := theTime.Unix()
  11501. var patientPrescription models.HisPrescriptionInfo
  11502. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11503. //if patientPrescription.ID == 0 {
  11504. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11505. //}
  11506. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11507. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11508. //
  11509. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11510. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11511. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11512. var pp models.PublicParams
  11513. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11514. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11515. pp.FixmedinsName = miConfig.OrgName
  11516. pp.FixmedinsCode = miConfig.Code
  11517. pp.RequestUrl = miConfig.Url
  11518. pp.Cainfo = miConfig.Cainfo
  11519. pp.SecretKey = miConfig.SecretKey
  11520. pp.AccessKey = miConfig.AccessKey
  11521. pp.OpterName = roles.UserName
  11522. var config []*models.HisXtDiagnoseConfig
  11523. for _, item := range diagnosis_ids {
  11524. id, _ := strconv.ParseInt(item, 10, 64)
  11525. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11526. config = append(config, &diagnosisConfig)
  11527. }
  11528. var pd models.PatientDtos
  11529. pd.PatnID = his.PsnNo
  11530. pd.PatnName = his.Name
  11531. pd.Gend = his.Gend
  11532. pd.Brdy = str
  11533. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11534. pd.CurrMdtrtID = his.Number
  11535. var fed models.FsiEncounterDtos
  11536. fed.MdtrtID = his.Number
  11537. fed.MedinsID = miConfig.Code
  11538. fed.MedinsName = miConfig.OrgName
  11539. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11540. fed.MedMdtrtType = "1"
  11541. fed.MedinsType = "1"
  11542. fed.MedinsLv = "11"
  11543. tm := time.Unix(his.RecordDate, 0)
  11544. s_tm := tm.Format("2006-01-02 15:04:05")
  11545. fed.AdmDate = s_tm
  11546. fed.DscgDate = s_tm
  11547. fed.DscgMainDiseCodg = config[0].CountryCode
  11548. fed.DscgMainDiseName = config[0].CountryContentName
  11549. //诊断信息
  11550. var fdds []*models.FsiDiagnoseDtos
  11551. for index, item := range config {
  11552. if index == 0 {
  11553. var fdd models.FsiDiagnoseDtos
  11554. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11555. fdd.InoutDiseType = "1"
  11556. fdd.MaindiseFlag = "1"
  11557. fdd.DiseDate = s_tm
  11558. fdd.DiasSrtNo = "1"
  11559. fdd.DiseName = item.CountryContentName
  11560. fdd.DiseCodg = item.CountryCode
  11561. fdds = append(fdds, &fdd)
  11562. } else {
  11563. var fdd models.FsiDiagnoseDtos
  11564. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11565. fdd.InoutDiseType = "1"
  11566. fdd.MaindiseFlag = "1"
  11567. fdd.DiseDate = s_tm
  11568. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11569. fdd.DiseName = item.CountryContentName
  11570. fdd.DiseCodg = item.CountryCode
  11571. fdds = append(fdds, &fdd)
  11572. }
  11573. }
  11574. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11575. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11576. fed.AdmDeptName = de.Name
  11577. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11578. fed.DscgDeptName = de.Name
  11579. fed.MedMdtrtType = "1"
  11580. fed.MedType = "11"
  11581. //if his.Insutype == "390" {
  11582. // fed.MedType = "1402"
  11583. //} else {
  11584. // fed.MedType = "9933"
  11585. //}
  11586. var orders []*models.FsiOrderDtos
  11587. if trig_scen == "2" {
  11588. //处方医嘱信息
  11589. for _, item := range prescriptions {
  11590. for _, subItem := range item.HisDoctorAdviceInfo {
  11591. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11592. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11593. var order models.FsiOrderDtos
  11594. order.RxID = strconv.FormatInt(item.ID, 10)
  11595. order.Rxno = strconv.FormatInt(item.ID, 10)
  11596. order.LongDrordFlag = "0"
  11597. order.HilistType = "1"
  11598. order.ChrgType = "1"
  11599. order.DrordBhvr = "0"
  11600. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11601. order.HosplistName = subItem.BaseDrugLib.DrugName
  11602. order.HilistLv = "1"
  11603. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11604. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11605. order.HosplistName = subItem.BaseDrugLib.DrugName
  11606. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11607. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11608. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11609. order.OwnpayAmt = ""
  11610. order.SelfpayAmt = ""
  11611. order.Spec = spec
  11612. order.SpecUnt = subItem.PrescribingNumberUnit
  11613. order.DrordBegnDate = s_tm
  11614. order.DrordStopDate = ""
  11615. order.DrordDrCodg = doctor_info.DoctorNumber
  11616. order.DrordDeptName = department.Name
  11617. order.DrordDeptCodg = department.Number
  11618. order.DrordDrName = doctor_info.UserName
  11619. order.DrordDrProfttl = "234"
  11620. order.CurrDrordFlag = "1"
  11621. orders = append(orders, &order)
  11622. }
  11623. }
  11624. for _, subItem := range item.HisPrescriptionProject {
  11625. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11626. var order models.FsiOrderDtos
  11627. order.RxID = strconv.FormatInt(item.ID, 10)
  11628. order.Rxno = strconv.FormatInt(item.ID, 10)
  11629. order.LongDrordFlag = "0"
  11630. order.HilistType = "1"
  11631. order.ChrgType = "1"
  11632. order.DrordBhvr = "0"
  11633. order.HilistCode = subItem.HisProject.MedicalCode
  11634. order.HosplistName = subItem.HisProject.ProjectName
  11635. order.HilistLv = "1"
  11636. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11637. order.HosplistCode = subItem.HisProject.MedicalCode
  11638. order.HosplistName = subItem.HisProject.ProjectName
  11639. order.Cnt = subItem.Count
  11640. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11641. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11642. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11643. order.OwnpayAmt = ""
  11644. order.SelfpayAmt = ""
  11645. order.Spec = subItem.Unit
  11646. order.SpecUnt = subItem.Unit
  11647. order.DrordBegnDate = s_tm
  11648. order.DrordStopDate = ""
  11649. order.DrordDrCodg = doctor_info.DoctorNumber
  11650. order.DrordDeptName = department.Name
  11651. order.DrordDeptCodg = department.Number
  11652. order.DrordDrName = doctor_info.UserName
  11653. order.DrordDrProfttl = "234"
  11654. order.CurrDrordFlag = "1"
  11655. orders = append(orders, &order)
  11656. }
  11657. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11658. var order models.FsiOrderDtos
  11659. order.RxID = strconv.FormatInt(item.ID, 10)
  11660. order.Rxno = strconv.FormatInt(item.ID, 10)
  11661. order.LongDrordFlag = "0"
  11662. order.HilistType = "1"
  11663. order.ChrgType = "1"
  11664. order.DrordBhvr = "0"
  11665. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11666. order.HosplistName = subItem.GoodInfo.GoodName
  11667. order.HilistLv = "1"
  11668. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11669. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11670. order.HosplistName = subItem.GoodInfo.GoodName
  11671. order.Cnt = subItem.Count
  11672. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11673. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11674. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11675. order.OwnpayAmt = ""
  11676. order.SelfpayAmt = ""
  11677. order.Spec = subItem.GoodInfo.SpecificationName
  11678. order.SpecUnt = subItem.Unit
  11679. order.DrordBegnDate = s_tm
  11680. order.DrordStopDate = ""
  11681. order.DrordDrCodg = doctor_info.DoctorNumber
  11682. order.DrordDeptName = department.Name
  11683. order.DrordDeptCodg = department.Number
  11684. order.DrordDrName = doctor_info.UserName
  11685. order.DrordDrProfttl = "234"
  11686. order.CurrDrordFlag = "1"
  11687. orders = append(orders, &order)
  11688. }
  11689. }
  11690. }
  11691. //处方医嘱信息
  11692. }
  11693. fed.MatnStas = "0"
  11694. fed.MedfeeSumamt = "0"
  11695. fed.OwnpayAmt = "0"
  11696. fed.SelfpayAmt = "0"
  11697. fed.AcctPayamt = "0"
  11698. fed.MaAmt = "0"
  11699. fed.HifpPayamt = "0"
  11700. fed.SetlTotlnum = "1"
  11701. fed.Insutype = his.Insutype
  11702. fed.ReimFlag = "0"
  11703. fed.OutSetlFlag = "0"
  11704. var fopd []*models.FsiOperationDtosData
  11705. data := make(map[string]interface{})
  11706. data["fed"] = fed
  11707. data["fdd"] = fdds
  11708. data["fod"] = orders
  11709. data["pd"] = pd
  11710. data["pp"] = pp
  11711. data["fopd"] = fopd
  11712. data["trig_scen"] = trig_scen
  11713. fmt.Println(data)
  11714. fmt.Println(fed)
  11715. fmt.Println(fdds)
  11716. fmt.Println(orders)
  11717. fmt.Println(pd)
  11718. fmt.Println(pp)
  11719. fmt.Println(fopd)
  11720. client := &http.Client{}
  11721. bytesData, _ := json.Marshal(data)
  11722. var req *http.Request
  11723. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11724. if miConfig.MdtrtareaAdmvs == "320921" {
  11725. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11726. } else {
  11727. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11728. }
  11729. resp, _ := client.Do(req)
  11730. defer resp.Body.Close()
  11731. body, ioErr := ioutil.ReadAll(resp.Body)
  11732. if ioErr != nil {
  11733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11735. return res
  11736. }
  11737. var respJSON map[string]interface{}
  11738. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11741. return res
  11742. }
  11743. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11744. fmt.Println(respJSON)
  11745. result, _ := json.Marshal(respJSON)
  11746. fmt.Println(result)
  11747. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11748. utils.ErrorLog("解析失败:%v", err)
  11749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11750. return res
  11751. }
  11752. return res
  11753. } else {
  11754. //if miConfig.MdtrtareaAdmvs == "441202" {
  11755. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11756. saveLog(output, input, "3101", "事前")
  11757. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11758. utils.ErrorLog("解析失败:%v", err)
  11759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11760. return
  11761. }
  11762. return res
  11763. //}
  11764. }
  11765. }
  11766. 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) {
  11767. adminUser := c.GetAdminUserInfo()
  11768. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11769. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11770. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11771. //record_time := c.GetString("record_time")
  11772. //trig_scen := c.GetString("trig_scen")
  11773. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11774. timeLayout := "2006-01-02"
  11775. loc, _ := time.LoadLocation("Local")
  11776. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11777. if err != nil {
  11778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11779. return res
  11780. }
  11781. recordDateTime := theTime.Unix()
  11782. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11783. var patientPrescription models.HisPrescriptionInfo
  11784. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11785. if patientPrescription.ID == 0 {
  11786. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11787. }
  11788. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11789. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11790. //
  11791. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11792. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11793. var pp models.PublicParams
  11794. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11795. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11796. pp.FixmedinsName = miConfig.OrgName
  11797. pp.FixmedinsCode = miConfig.Code
  11798. pp.RequestUrl = miConfig.Url
  11799. pp.Cainfo = miConfig.Cainfo
  11800. pp.SecretKey = miConfig.SecretKey
  11801. pp.AccessKey = miConfig.AccessKey
  11802. pp.OpterName = roles.UserName
  11803. var config []*models.HisXtDiagnoseConfig
  11804. for _, item := range diagnosis_ids {
  11805. id, _ := strconv.ParseInt(item, 10, 64)
  11806. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11807. config = append(config, &diagnosisConfig)
  11808. }
  11809. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11810. var pd models.PatientDtos
  11811. pd.PatnID = his.PsnNo
  11812. pd.PatnName = his.Name
  11813. pd.Gend = his.Gend
  11814. pd.Brdy = str
  11815. pd.Poolarea = his.InsuplcAdmdvs
  11816. pd.CurrMdtrtID = his.Number
  11817. var fed models.FsiEncounterDtos
  11818. fed.MdtrtID = his.Number
  11819. fed.MedinsID = miConfig.Code
  11820. fed.MedinsName = miConfig.OrgName
  11821. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11822. fed.MedMdtrtType = "1"
  11823. fed.MedinsType = "1"
  11824. fed.MedinsLv = "11"
  11825. tm := time.Unix(his.RecordDate, 0)
  11826. s_tm := tm.Format("2006-01-02 15:04:05")
  11827. fed.AdmDate = s_tm
  11828. fed.DscgDate = s_tm
  11829. fed.DscgMainDiseCodg = config[0].CountryCode
  11830. fed.DscgMainDiseName = config[0].CountryContentName
  11831. //诊断信息
  11832. var fdds []*models.FsiDiagnoseDtos
  11833. for index, item := range config {
  11834. if index == 0 {
  11835. var fdd models.FsiDiagnoseDtos
  11836. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11837. fdd.InoutDiseType = "1"
  11838. fdd.MaindiseFlag = "1"
  11839. fdd.DiseDate = s_tm
  11840. fdd.DiasSrtNo = "1"
  11841. fdd.DiseName = item.CountryContentName
  11842. fdd.DiseCodg = item.CountryCode
  11843. fdds = append(fdds, &fdd)
  11844. } else {
  11845. var fdd models.FsiDiagnoseDtos
  11846. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11847. fdd.InoutDiseType = "1"
  11848. fdd.MaindiseFlag = "1"
  11849. fdd.DiseDate = s_tm
  11850. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11851. fdd.DiseName = item.CountryContentName
  11852. fdd.DiseCodg = item.CountryCode
  11853. fdds = append(fdds, &fdd)
  11854. }
  11855. }
  11856. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11857. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11858. fed.AdmDeptName = department.Name
  11859. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11860. fed.DscgDeptName = department.Name
  11861. fed.MedMdtrtType = "1"
  11862. fed.MedType = "11"
  11863. //if his.Insutype == "390" {
  11864. // fed.MedType = "1402"
  11865. //} else {
  11866. // fed.MedType = "9933"
  11867. //}
  11868. var orders []*models.FsiOrderDtos
  11869. if trig_scen == "2" {
  11870. //处方医嘱信息
  11871. for _, item := range prescriptions {
  11872. for _, subItem := range item.HisDoctorAdviceInfo {
  11873. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11874. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11875. var order models.FsiOrderDtos
  11876. order.RxID = strconv.FormatInt(item.ID, 10)
  11877. order.Rxno = strconv.FormatInt(item.ID, 10)
  11878. order.LongDrordFlag = "0"
  11879. order.HilistType = "1"
  11880. order.ChrgType = "1"
  11881. order.DrordBhvr = "0"
  11882. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11883. order.HosplistName = subItem.BaseDrugLib.DrugName
  11884. order.HilistLv = "1"
  11885. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11886. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11887. order.HosplistName = subItem.BaseDrugLib.DrugName
  11888. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11889. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11890. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11891. order.OwnpayAmt = ""
  11892. order.SelfpayAmt = ""
  11893. order.Spec = spec
  11894. order.SpecUnt = subItem.PrescribingNumberUnit
  11895. order.DrordBegnDate = s_tm
  11896. order.DrordStopDate = ""
  11897. order.DrordDrCodg = doctor_info.DoctorNumber
  11898. order.DrordDeptName = department.Name
  11899. order.DrordDeptCodg = department.Number
  11900. order.DrordDrName = doctor_info.UserName
  11901. order.DrordDrProfttl = "234"
  11902. order.CurrDrordFlag = "1"
  11903. orders = append(orders, &order)
  11904. }
  11905. }
  11906. for _, subItem := range item.HisPrescriptionProject {
  11907. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11908. var order models.FsiOrderDtos
  11909. order.RxID = strconv.FormatInt(item.ID, 10)
  11910. order.Rxno = strconv.FormatInt(item.ID, 10)
  11911. order.LongDrordFlag = "0"
  11912. order.HilistType = "1"
  11913. order.ChrgType = "1"
  11914. order.DrordBhvr = "0"
  11915. order.HilistCode = subItem.HisProject.MedicalCode
  11916. order.HosplistName = subItem.HisProject.ProjectName
  11917. order.HilistLv = "1"
  11918. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11919. order.HosplistCode = subItem.HisProject.MedicalCode
  11920. order.HosplistName = subItem.HisProject.ProjectName
  11921. order.Cnt = subItem.Count
  11922. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11923. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11924. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11925. order.OwnpayAmt = ""
  11926. order.SelfpayAmt = ""
  11927. order.Spec = subItem.Unit
  11928. order.SpecUnt = subItem.Unit
  11929. order.DrordBegnDate = s_tm
  11930. order.DrordStopDate = ""
  11931. order.DrordDrCodg = doctor_info.DoctorNumber
  11932. order.DrordDeptName = department.Name
  11933. order.DrordDeptCodg = department.Number
  11934. order.DrordDrName = doctor_info.UserName
  11935. order.DrordDrProfttl = "234"
  11936. order.CurrDrordFlag = "1"
  11937. orders = append(orders, &order)
  11938. }
  11939. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11940. var order models.FsiOrderDtos
  11941. order.RxID = strconv.FormatInt(item.ID, 10)
  11942. order.Rxno = strconv.FormatInt(item.ID, 10)
  11943. order.LongDrordFlag = "0"
  11944. order.HilistType = "1"
  11945. order.ChrgType = "1"
  11946. order.DrordBhvr = "0"
  11947. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11948. order.HosplistName = subItem.GoodInfo.GoodName
  11949. order.HilistLv = "1"
  11950. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11951. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11952. order.HosplistName = subItem.GoodInfo.GoodName
  11953. order.Cnt = subItem.Count
  11954. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11955. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11956. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11957. order.OwnpayAmt = ""
  11958. order.SelfpayAmt = ""
  11959. order.Spec = subItem.GoodInfo.SpecificationName
  11960. order.SpecUnt = subItem.Unit
  11961. order.DrordBegnDate = s_tm
  11962. order.DrordStopDate = ""
  11963. order.DrordDrCodg = doctor_info.DoctorNumber
  11964. order.DrordDeptName = department.Name
  11965. order.DrordDeptCodg = department.Number
  11966. order.DrordDrName = doctor_info.UserName
  11967. order.DrordDrProfttl = "234"
  11968. order.CurrDrordFlag = "1"
  11969. orders = append(orders, &order)
  11970. }
  11971. }
  11972. }
  11973. //处方医嘱信息
  11974. }
  11975. fed.MatnStas = "0"
  11976. fed.MedfeeSumamt = "0"
  11977. fed.OwnpayAmt = "0"
  11978. fed.SelfpayAmt = "0"
  11979. fed.AcctPayamt = "0"
  11980. fed.MaAmt = "0"
  11981. fed.HifpPayamt = "0"
  11982. fed.SetlTotlnum = "1"
  11983. fed.Insutype = his.Insutype
  11984. fed.ReimFlag = "0"
  11985. fed.OutSetlFlag = "0"
  11986. var fopd []*models.FsiOperationDtosData
  11987. data := make(map[string]interface{})
  11988. data["fed"] = fed
  11989. data["fdd"] = fdds
  11990. data["fod"] = orders
  11991. data["pd"] = pd
  11992. data["pp"] = pp
  11993. data["fopd"] = fopd
  11994. data["trig_scen"] = trig_scen
  11995. fmt.Println(data)
  11996. fmt.Println(fed)
  11997. fmt.Println(fdds)
  11998. fmt.Println(orders)
  11999. fmt.Println(pd)
  12000. fmt.Println(pp)
  12001. fmt.Println(fopd)
  12002. client := &http.Client{}
  12003. bytesData, _ := json.Marshal(data)
  12004. var req *http.Request
  12005. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12006. if miConfig.MdtrtareaAdmvs == "320921" {
  12007. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12008. } else {
  12009. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12010. }
  12011. resp, _ := client.Do(req)
  12012. defer resp.Body.Close()
  12013. body, ioErr := ioutil.ReadAll(resp.Body)
  12014. if ioErr != nil {
  12015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12017. return res
  12018. }
  12019. var respJSON map[string]interface{}
  12020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12023. return res
  12024. }
  12025. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12026. fmt.Println(respJSON)
  12027. result, _ := json.Marshal(respJSON)
  12028. fmt.Println(result)
  12029. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12030. utils.ErrorLog("解析失败:%v", err)
  12031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12032. return res
  12033. }
  12034. return res
  12035. } else {
  12036. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12037. saveLog(output, input, "3101", "事前")
  12038. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12039. utils.ErrorLog("解析失败:%v", err)
  12040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12041. return
  12042. }
  12043. return res
  12044. }
  12045. return res
  12046. }
  12047. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12048. ////patient_id, _ := c.GetInt64("patient_id")
  12049. //order_id, _ := c.GetInt64("order_id")
  12050. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  12051. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  12052. //trig_scen := c.GetString("trig_scen")
  12053. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12054. //utils.ErrorLog("解析失败:%v", psn_info)
  12055. adminUser := c.GetAdminUserInfo()
  12056. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12057. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12058. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12059. record_time := c.GetString("record_time")
  12060. order, _ := service.GetHisOrderByID(order_id)
  12061. timeLayout := "2006-01-02"
  12062. loc, _ := time.LoadLocation("Local")
  12063. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12064. if err != nil {
  12065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12066. return
  12067. }
  12068. recordDateTime := theTime.Unix()
  12069. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12070. var patientPrescription models.HisPrescriptionInfo
  12071. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12072. if patientPrescription.ID == 0 {
  12073. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12074. }
  12075. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12076. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12077. //
  12078. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12079. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12080. var pp models.PublicParams
  12081. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12082. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12083. pp.FixmedinsName = miConfig.OrgName
  12084. pp.FixmedinsCode = miConfig.Code
  12085. pp.RequestUrl = miConfig.Url
  12086. pp.Cainfo = miConfig.Cainfo
  12087. pp.SecretKey = miConfig.SecretKey
  12088. pp.AccessKey = miConfig.AccessKey
  12089. pp.OpterName = roles.UserName
  12090. var config []*models.HisXtDiagnoseConfig
  12091. for _, item := range diagnosis_ids {
  12092. id, _ := strconv.ParseInt(item, 10, 64)
  12093. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12094. config = append(config, &diagnosisConfig)
  12095. }
  12096. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12097. var pd models.PatientDtos
  12098. pd.PatnID = his.PsnNo
  12099. pd.PatnName = his.Name
  12100. pd.Gend = his.Gend
  12101. pd.Brdy = str
  12102. pd.Poolarea = his.InsuplcAdmdvs
  12103. pd.CurrMdtrtID = his.Number
  12104. var fed models.FsiEncounterDtos
  12105. fed.MdtrtID = his.Number
  12106. fed.MedinsID = miConfig.Code
  12107. fed.MedinsName = miConfig.OrgName
  12108. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12109. fed.MedMdtrtType = "1"
  12110. fed.MedinsType = "1"
  12111. fed.MedinsLv = "11"
  12112. tm := time.Unix(his.RecordDate, 0)
  12113. s_tm := tm.Format("2006-01-02 15:04:05")
  12114. fed.AdmDate = s_tm
  12115. fed.DscgDate = s_tm
  12116. fed.DscgMainDiseCodg = config[0].CountryCode
  12117. fed.DscgMainDiseName = config[0].CountryContentName
  12118. //诊断信息
  12119. var fdds []*models.FsiDiagnoseDtos
  12120. for index, item := range config {
  12121. if index == 0 {
  12122. var fdd models.FsiDiagnoseDtos
  12123. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12124. fdd.InoutDiseType = "1"
  12125. fdd.MaindiseFlag = "1"
  12126. fdd.DiseDate = s_tm
  12127. fdd.DiasSrtNo = "1"
  12128. fdd.DiseName = item.CountryContentName
  12129. fdd.DiseCodg = item.CountryCode
  12130. fdds = append(fdds, &fdd)
  12131. } else {
  12132. var fdd models.FsiDiagnoseDtos
  12133. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12134. fdd.InoutDiseType = "1"
  12135. fdd.MaindiseFlag = "1"
  12136. fdd.DiseDate = s_tm
  12137. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12138. fdd.DiseName = item.CountryContentName
  12139. fdd.DiseCodg = item.CountryCode
  12140. fdds = append(fdds, &fdd)
  12141. }
  12142. }
  12143. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12144. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12145. fed.AdmDeptName = department.Name
  12146. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12147. fed.DscgDeptName = department.Name
  12148. fed.MedType = order.MedType
  12149. //处方医嘱信息
  12150. var orders []*models.FsiOrderDtos
  12151. //for _, item := range prescriptions {
  12152. // for _, subItem := range item.HisDoctorAdviceInfo {
  12153. // var order models.FsiOrderDtos
  12154. // order.RxID = strconv.FormatInt(item.ID, 10)
  12155. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12156. // order.LongDrordFlag = "0"
  12157. // order.HilistType = "1"
  12158. // order.ChrgType = "1"
  12159. // order.DrordBhvr = "-"
  12160. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12161. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12162. // order.HilistLv = "1"
  12163. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12164. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12165. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12166. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12167. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12168. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12169. // order.OwnpayAmt = ""
  12170. // order.SelfpayAmt = ""
  12171. // order.Spec = ""
  12172. // order.SpecUnt = ""
  12173. // order.DrordBegnDate = s_tm
  12174. // order.DrordStopDate = ""
  12175. // order.DrordDrCodg = "1"
  12176. // order.DrordDeptName = department.Name
  12177. // order.DrordDrCodg = "1"
  12178. // order.DrordDrName = doctor_info.UserName
  12179. // order.DrordDrProfttl = ""
  12180. // order.CurrDrordFlag = "1"
  12181. // orders = append(orders, &order)
  12182. // }
  12183. // for _, subItem := range item.HisPrescriptionProject {
  12184. // if subItem.Type == 2 {
  12185. // var order models.FsiOrderDtos
  12186. // order.RxID = strconv.FormatInt(item.ID, 10)
  12187. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12188. // order.LongDrordFlag = "0"
  12189. // order.HilistType = "1"
  12190. // order.ChrgType = "1"
  12191. // order.DrordBhvr = "-"
  12192. // order.HilistCode = subItem.HisProject.MedicalCode
  12193. // order.HosplistName = subItem.HisProject.ProjectName
  12194. // order.HilistLv = "1"
  12195. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12196. // order.HosplistCode = subItem.HisProject.MedicalCode
  12197. // order.HosplistName = subItem.HisProject.ProjectName
  12198. // order.Cnt = subItem.Count
  12199. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12200. //
  12201. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12202. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12203. // order.OwnpayAmt = ""
  12204. // order.SelfpayAmt = ""
  12205. // order.Spec = ""
  12206. // order.SpecUnt = ""
  12207. // order.DrordBegnDate = s_tm
  12208. // order.DrordStopDate = ""
  12209. // order.DrordDrCodg = "1"
  12210. // order.DrordDeptName = department.Name
  12211. // order.DrordDrCodg = "1"
  12212. // order.DrordDrName = doctor_info.UserName
  12213. // order.DrordDrProfttl = ""
  12214. // order.CurrDrordFlag = "1"
  12215. // orders = append(orders, &order)
  12216. //
  12217. // }
  12218. // if subItem.Type == 3 {
  12219. //
  12220. // var order models.FsiOrderDtos
  12221. // order.RxID = strconv.FormatInt(item.ID, 10)
  12222. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12223. // order.LongDrordFlag = "0"
  12224. // order.HilistType = "1"
  12225. // order.ChrgType = "1"
  12226. // order.DrordBhvr = "-"
  12227. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12228. // order.HosplistName = subItem.GoodInfo.GoodName
  12229. // order.HilistLv = "1"
  12230. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12231. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12232. // order.HosplistName = subItem.GoodInfo.GoodName
  12233. // order.Cnt = subItem.Count
  12234. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12235. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12236. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12237. // order.OwnpayAmt = ""
  12238. // order.SelfpayAmt = ""
  12239. // order.Spec = ""
  12240. // order.SpecUnt = ""
  12241. // order.DrordBegnDate = s_tm
  12242. // order.DrordStopDate = ""
  12243. // order.DrordDrCodg = "1"
  12244. // order.DrordDeptName = department.Name
  12245. // order.DrordDrCodg = "1"
  12246. // order.DrordDrName = doctor_info.UserName
  12247. // order.DrordDrProfttl = ""
  12248. // order.CurrDrordFlag = "1"
  12249. // orders = append(orders, &order)
  12250. //
  12251. // }
  12252. // }
  12253. //}
  12254. for _, item := range prescriptions {
  12255. for _, subItem := range item.HisDoctorAdviceInfo {
  12256. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12257. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12258. var order models.FsiOrderDtos
  12259. order.RxID = strconv.FormatInt(item.ID, 10)
  12260. order.Rxno = strconv.FormatInt(item.ID, 10)
  12261. order.LongDrordFlag = "0"
  12262. order.HilistType = "1"
  12263. order.ChrgType = "1"
  12264. order.DrordBhvr = "0"
  12265. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12266. order.HosplistName = subItem.BaseDrugLib.DrugName
  12267. order.HilistLv = "1"
  12268. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12269. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12270. order.HosplistName = subItem.BaseDrugLib.DrugName
  12271. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12272. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12273. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12274. order.OwnpayAmt = ""
  12275. order.SelfpayAmt = ""
  12276. order.Spec = spec
  12277. order.SpecUnt = subItem.PrescribingNumberUnit
  12278. order.DrordBegnDate = s_tm
  12279. order.DrordStopDate = ""
  12280. order.DrordDrCodg = doctor_info.DoctorNumber
  12281. order.DrordDeptName = department.Name
  12282. order.DrordDeptCodg = department.Number
  12283. order.DrordDrName = doctor_info.UserName
  12284. order.DrordDrProfttl = "234"
  12285. order.CurrDrordFlag = "1"
  12286. orders = append(orders, &order)
  12287. }
  12288. }
  12289. for _, subItem := range item.HisPrescriptionProject {
  12290. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12291. var order models.FsiOrderDtos
  12292. order.RxID = strconv.FormatInt(item.ID, 10)
  12293. order.Rxno = strconv.FormatInt(item.ID, 10)
  12294. order.LongDrordFlag = "0"
  12295. order.HilistType = "1"
  12296. order.ChrgType = "1"
  12297. order.DrordBhvr = "0"
  12298. order.HilistCode = subItem.HisProject.MedicalCode
  12299. order.HosplistName = subItem.HisProject.ProjectName
  12300. order.HilistLv = "1"
  12301. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12302. order.HosplistCode = subItem.HisProject.MedicalCode
  12303. order.HosplistName = subItem.HisProject.ProjectName
  12304. order.Cnt = subItem.Count
  12305. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12306. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12307. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12308. order.OwnpayAmt = ""
  12309. order.SelfpayAmt = ""
  12310. order.Spec = subItem.Unit
  12311. order.SpecUnt = subItem.Unit
  12312. order.DrordBegnDate = s_tm
  12313. order.DrordStopDate = ""
  12314. order.DrordDrCodg = doctor_info.DoctorNumber
  12315. order.DrordDeptName = department.Name
  12316. order.DrordDeptCodg = department.Number
  12317. order.DrordDrName = doctor_info.UserName
  12318. order.DrordDrProfttl = "234"
  12319. order.CurrDrordFlag = "1"
  12320. orders = append(orders, &order)
  12321. }
  12322. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12323. var order models.FsiOrderDtos
  12324. order.RxID = strconv.FormatInt(item.ID, 10)
  12325. order.Rxno = strconv.FormatInt(item.ID, 10)
  12326. order.LongDrordFlag = "0"
  12327. order.HilistType = "1"
  12328. order.ChrgType = "1"
  12329. order.DrordBhvr = "0"
  12330. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12331. order.HosplistName = subItem.GoodInfo.GoodName
  12332. order.HilistLv = "1"
  12333. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12334. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12335. order.HosplistName = subItem.GoodInfo.GoodName
  12336. order.Cnt = subItem.Count
  12337. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12338. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12339. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12340. order.OwnpayAmt = ""
  12341. order.SelfpayAmt = ""
  12342. order.Spec = subItem.GoodInfo.SpecificationName
  12343. order.SpecUnt = subItem.Unit
  12344. order.DrordBegnDate = s_tm
  12345. order.DrordStopDate = ""
  12346. order.DrordDrCodg = doctor_info.DoctorNumber
  12347. order.DrordDeptName = department.Name
  12348. order.DrordDeptCodg = department.Number
  12349. order.DrordDrName = doctor_info.UserName
  12350. order.DrordDrProfttl = "234"
  12351. order.CurrDrordFlag = "1"
  12352. orders = append(orders, &order)
  12353. }
  12354. }
  12355. }
  12356. //处方医嘱信息
  12357. fed.MatnStas = "0"
  12358. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12359. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12360. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12361. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12362. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12363. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12364. fed.SetlTotlnum = "1"
  12365. fed.Insutype = his.Insutype
  12366. fed.ReimFlag = "0"
  12367. fed.OutSetlFlag = "0"
  12368. var fopd []*models.FsiOperationDtosData
  12369. data := make(map[string]interface{})
  12370. data["fed"] = fed
  12371. data["fdd"] = fdds
  12372. data["fod"] = orders
  12373. data["pd"] = pd
  12374. data["pp"] = pp
  12375. data["fopd"] = fopd
  12376. data["trig_scen"] = trig_scen
  12377. client := &http.Client{}
  12378. bytesData, _ := json.Marshal(data)
  12379. var req *http.Request
  12380. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12381. if miConfig.MdtrtareaAdmvs == "320921" {
  12382. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12383. } else {
  12384. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12385. }
  12386. resp, _ := client.Do(req)
  12387. defer resp.Body.Close()
  12388. body, ioErr := ioutil.ReadAll(resp.Body)
  12389. if ioErr != nil {
  12390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12392. return res
  12393. }
  12394. var respJSON map[string]interface{}
  12395. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12398. return res
  12399. }
  12400. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12401. result, _ := json.Marshal(respJSON)
  12402. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12403. utils.ErrorLog("解析失败:%v", err)
  12404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12405. return res
  12406. }
  12407. return res
  12408. } else {
  12409. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12410. saveLog(output, input, "3102", "事中")
  12411. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12412. utils.ErrorLog("解析失败:%v", err)
  12413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12414. return
  12415. }
  12416. return res
  12417. }
  12418. return res
  12419. }
  12420. func (c *HisApiController) Check() {
  12421. psn_no := c.GetString("psn_no")
  12422. in := c.GetString("in")
  12423. mt := c.GetString("mt")
  12424. baseParams := models.BaseParams{
  12425. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12426. FixmedinsCode: "H15049901371",
  12427. InsuplcAdmdvs: "150499",
  12428. MdtrtareaAdmvs: "150499",
  12429. OrgName: "赤峰费森血液透析中心",
  12430. Doctor: "1111",
  12431. }
  12432. service.Gdyb2001(baseParams, psn_no, in, mt)
  12433. }
  12434. func (c *HisApiController) GetPsnNcdsInfo() {
  12435. admin_user_id, _ := c.GetInt64("admin_user_id")
  12436. patient_id, _ := c.GetInt64("patient_id")
  12437. //id, _ := c.GetInt64("id")
  12438. adminUser := c.GetAdminUserInfo()
  12439. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12440. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12441. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12442. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12443. //psn_record, _ := service.GetP(id)
  12444. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12445. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12446. //
  12447. //if psn_record.ID == 0 {
  12448. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12449. // return
  12450. //}
  12451. var res Result5301
  12452. var res10265 Result5301For10265
  12453. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12454. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12455. var api string
  12456. if miConfig.MdtrtareaAdmvs == "320921" {
  12457. 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 +
  12458. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12459. } else {
  12460. 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 +
  12461. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12462. }
  12463. resp, requestErr := http.Get(api)
  12464. if requestErr != nil {
  12465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12466. return
  12467. }
  12468. body, ioErr := ioutil.ReadAll(resp.Body)
  12469. if ioErr != nil {
  12470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12472. return
  12473. }
  12474. var respJSON map[string]interface{}
  12475. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12478. return
  12479. }
  12480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12481. result, _ := json.Marshal(respJSON)
  12482. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12483. utils.ErrorLog("解析失败:%v", err)
  12484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12485. return
  12486. }
  12487. res.ErrMsg = res10265.ErrMsg
  12488. res.Output = res10265.Output
  12489. res.InfRefmsgid = res10265.InfRefmsgid
  12490. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12491. res.Infcode = infocode
  12492. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12493. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12494. var api string
  12495. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12496. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12497. resp, requestErr := http.Get(api)
  12498. if requestErr != nil {
  12499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12500. return
  12501. }
  12502. body, ioErr := ioutil.ReadAll(resp.Body)
  12503. if ioErr != nil {
  12504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12506. return
  12507. }
  12508. var respJSON map[string]interface{}
  12509. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12512. return
  12513. }
  12514. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12515. if status == "0" {
  12516. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12517. c.ServeSuccessJSON(map[string]interface{}{
  12518. "failed_code": -10,
  12519. "msg": err_msg,
  12520. })
  12521. return
  12522. }
  12523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12524. result, _ := json.Marshal(respJSON)
  12525. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12526. utils.ErrorLog("解析失败:%v", err)
  12527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12528. return
  12529. }
  12530. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12531. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12532. var api string
  12533. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12534. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12535. resp, requestErr := http.Get(api)
  12536. if requestErr != nil {
  12537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12538. return
  12539. }
  12540. body, ioErr := ioutil.ReadAll(resp.Body)
  12541. if ioErr != nil {
  12542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12544. return
  12545. }
  12546. var respJSON map[string]interface{}
  12547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12550. return
  12551. }
  12552. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12553. if status == "0" {
  12554. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12555. c.ServeSuccessJSON(map[string]interface{}{
  12556. "failed_code": -10,
  12557. "msg": err_msg,
  12558. })
  12559. return
  12560. }
  12561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12562. result, _ := json.Marshal(respJSON)
  12563. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12564. utils.ErrorLog("解析失败:%v", err)
  12565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12566. return
  12567. }
  12568. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12569. p, _ := service.GetHisPatientById(patient_id)
  12570. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12571. var dat map[string]interface{}
  12572. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12573. fmt.Println(dat)
  12574. } else {
  12575. fmt.Println(err)
  12576. }
  12577. userJSONBytes, _ := json.Marshal(dat)
  12578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12579. utils.ErrorLog("解析失败:%v", err)
  12580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12581. return
  12582. }
  12583. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12584. p, _ := service.GetHisPatientById(patient_id)
  12585. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12586. var dat map[string]interface{}
  12587. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12588. fmt.Println(dat)
  12589. } else {
  12590. fmt.Println(err)
  12591. }
  12592. userJSONBytes, _ := json.Marshal(dat)
  12593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12594. utils.ErrorLog("解析失败:%v", err)
  12595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12596. return
  12597. }
  12598. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12599. p, _ := service.GetHisPatientById(patient_id)
  12600. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12601. var dat map[string]interface{}
  12602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12603. fmt.Println(dat)
  12604. } else {
  12605. fmt.Println(err)
  12606. }
  12607. userJSONBytes, _ := json.Marshal(dat)
  12608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12609. utils.ErrorLog("解析失败:%v", err)
  12610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12611. return
  12612. }
  12613. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12614. p, _ := service.GetHisPatientById(patient_id)
  12615. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12616. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12617. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12618. resp, requestErr := http.Get(api)
  12619. if requestErr != nil {
  12620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12621. return
  12622. }
  12623. body, ioErr := ioutil.ReadAll(resp.Body)
  12624. if ioErr != nil {
  12625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12627. return
  12628. }
  12629. var respJSON map[string]interface{}
  12630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12633. return
  12634. }
  12635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12636. result, _ := json.Marshal(respJSON)
  12637. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12638. utils.ErrorLog("解析失败:%v", err)
  12639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12640. return
  12641. }
  12642. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12643. p, _ := service.GetHisPatientById(patient_id)
  12644. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12645. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12646. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12647. resp, requestErr := http.Get(api)
  12648. if requestErr != nil {
  12649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12650. return
  12651. }
  12652. body, ioErr := ioutil.ReadAll(resp.Body)
  12653. if ioErr != nil {
  12654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12656. return
  12657. }
  12658. var respJSON map[string]interface{}
  12659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12662. return
  12663. }
  12664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12665. result, _ := json.Marshal(respJSON)
  12666. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12667. utils.ErrorLog("解析失败:%v", err)
  12668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12669. return
  12670. }
  12671. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12672. p, _ := service.GetHisPatientById(patient_id)
  12673. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12674. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12675. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12676. resp, requestErr := http.Get(api)
  12677. if requestErr != nil {
  12678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12679. return
  12680. }
  12681. body, ioErr := ioutil.ReadAll(resp.Body)
  12682. if ioErr != nil {
  12683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12685. return
  12686. }
  12687. var respJSON map[string]interface{}
  12688. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12691. return
  12692. }
  12693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12694. result, _ := json.Marshal(respJSON)
  12695. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12696. utils.ErrorLog("解析失败:%v", err)
  12697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12698. return
  12699. }
  12700. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12701. p, _ := service.GetHisPatientById(patient_id)
  12702. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12703. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12704. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12705. resp, requestErr := http.Get(api)
  12706. if requestErr != nil {
  12707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12708. return
  12709. }
  12710. body, ioErr := ioutil.ReadAll(resp.Body)
  12711. if ioErr != nil {
  12712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12714. return
  12715. }
  12716. var respJSON map[string]interface{}
  12717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12720. return
  12721. }
  12722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12723. result, _ := json.Marshal(respJSON)
  12724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12725. utils.ErrorLog("解析失败:%v", err)
  12726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12727. return
  12728. }
  12729. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12730. p, _ := service.GetHisPatientById(patient_id)
  12731. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12732. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12733. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12734. resp, requestErr := http.Get(api)
  12735. if requestErr != nil {
  12736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12737. return
  12738. }
  12739. body, ioErr := ioutil.ReadAll(resp.Body)
  12740. if ioErr != nil {
  12741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12743. return
  12744. }
  12745. var respJSON map[string]interface{}
  12746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12749. return
  12750. }
  12751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12752. result, _ := json.Marshal(respJSON)
  12753. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12754. utils.ErrorLog("解析失败:%v", err)
  12755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12756. return
  12757. }
  12758. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12759. p, _ := service.GetHisPatientById(patient_id)
  12760. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12761. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12762. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12763. resp, requestErr := http.Get(api)
  12764. if requestErr != nil {
  12765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12766. return
  12767. }
  12768. body, ioErr := ioutil.ReadAll(resp.Body)
  12769. if ioErr != nil {
  12770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12772. return
  12773. }
  12774. var respJSON map[string]interface{}
  12775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12778. return
  12779. }
  12780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12781. result, _ := json.Marshal(respJSON)
  12782. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12783. utils.ErrorLog("解析失败:%v", err)
  12784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12785. return
  12786. }
  12787. } else {
  12788. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12789. var dat map[string]interface{}
  12790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12791. fmt.Println(dat)
  12792. } else {
  12793. fmt.Println(err)
  12794. }
  12795. userJSONBytes, _ := json.Marshal(dat)
  12796. if miConfig.Code == "H15049901371" {
  12797. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12798. utils.ErrorLog("解析失败:%v", err)
  12799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12800. return
  12801. }
  12802. res.InfRefmsgid = res10265.InfRefmsgid
  12803. res.Output = res10265.Output
  12804. res.ErrMsg = res10265.ErrMsg
  12805. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12806. res.Infcode = infocode
  12807. } else {
  12808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12809. utils.ErrorLog("解析失败:%v", err)
  12810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12811. return
  12812. }
  12813. }
  12814. }
  12815. if res.Infcode == 0 {
  12816. c.ServeSuccessJSON(map[string]interface{}{
  12817. "result": res.Output.Result,
  12818. })
  12819. }
  12820. }
  12821. func (c *HisApiController) CheckInsutype() {
  12822. his_patient_id, _ := c.GetInt64("his_patient_id")
  12823. admin_user_id, _ := c.GetInt64("admin_user_id")
  12824. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12825. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12827. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12828. var dat map[string]interface{}
  12829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12830. fmt.Println(dat)
  12831. } else {
  12832. fmt.Println(err)
  12833. }
  12834. userJSONBytes, _ := json.Marshal(dat)
  12835. var res Result90100
  12836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12837. utils.ErrorLog("解析失败:%v", err)
  12838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12839. return
  12840. }
  12841. if res.Infcode != 0 {
  12842. c.ServeSuccessJSON(map[string]interface{}{
  12843. "failed_code": -10,
  12844. "msg": res.ErrMsg,
  12845. })
  12846. return
  12847. } else {
  12848. fmt.Println(res)
  12849. }
  12850. }
  12851. func (c *HisApiController) CheckCardPWD() {
  12852. card_pwd := c.GetString("card_pwd")
  12853. his_patient_id, _ := c.GetInt64("his_patient_id")
  12854. admin_user_id, _ := c.GetInt64("admin_user_id")
  12855. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12857. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12858. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12859. bas := strings.Split(psn.CardInfo, "|")
  12860. basNumber := bas[2]
  12861. if psn.InsuplcAdmdvs[:4] == "4403" {
  12862. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12863. var dat map[string]interface{}
  12864. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12865. fmt.Println(dat)
  12866. } else {
  12867. fmt.Println(err)
  12868. }
  12869. userJSONBytes, _ := json.Marshal(dat)
  12870. var res Result90991
  12871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12872. utils.ErrorLog("解析失败:%v", err)
  12873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12874. return
  12875. }
  12876. if res.Infcode != 0 {
  12877. c.ServeSuccessJSON(map[string]interface{}{
  12878. "failed_code": -10,
  12879. "msg": res.ErrMsg,
  12880. })
  12881. return
  12882. } else {
  12883. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12884. var msg string
  12885. switch res.Output.Result.CardStat {
  12886. case "00":
  12887. msg = "未激活"
  12888. break
  12889. case "10":
  12890. msg = "激活"
  12891. break
  12892. case "20":
  12893. msg = "窗口挂失"
  12894. break
  12895. case "21":
  12896. msg = "电话挂失"
  12897. break
  12898. case "22":
  12899. msg = "单位网上申报挂失"
  12900. break
  12901. case "23":
  12902. msg = "保健办挂失"
  12903. break
  12904. case "24":
  12905. msg = "个人网上挂失"
  12906. break
  12907. case "25":
  12908. msg = "网上服务大厅挂失"
  12909. break
  12910. case "30":
  12911. msg = "注销"
  12912. break
  12913. case "40":
  12914. msg = "回收"
  12915. break
  12916. case "99":
  12917. msg = "制卡中(无效卡)"
  12918. break
  12919. }
  12920. c.ServeSuccessJSON(map[string]interface{}{
  12921. "failed_code": -10,
  12922. "msg": msg,
  12923. })
  12924. return
  12925. } else {
  12926. c.ServeSuccessJSON(map[string]interface{}{
  12927. "msg": "校验成功",
  12928. })
  12929. return
  12930. }
  12931. }
  12932. } else {
  12933. c.ServeSuccessJSON(map[string]interface{}{
  12934. "msg": "校验成功",
  12935. })
  12936. return
  12937. }
  12938. }
  12939. func (c *HisApiController) CheckCardPWDTwo() {
  12940. //card_pwd := c.GetString("card_pwd")
  12941. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12942. admin_user_id, _ := c.GetInt64("admin_user_id")
  12943. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12944. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12945. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12946. var dat map[string]interface{}
  12947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12948. fmt.Println(dat)
  12949. } else {
  12950. fmt.Println(err)
  12951. }
  12952. userJSONBytes, _ := json.Marshal(dat)
  12953. var res Result90991
  12954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12955. utils.ErrorLog("解析失败:%v", err)
  12956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12957. return
  12958. }
  12959. if res.Infcode != 0 {
  12960. c.ServeSuccessJSON(map[string]interface{}{
  12961. "failed_code": -10,
  12962. "msg": res.ErrMsg,
  12963. })
  12964. return
  12965. } else {
  12966. if res.Output.Result.SscnoCheckStat == "0" {
  12967. var msg string
  12968. switch res.Output.Result.CardStat {
  12969. case "00":
  12970. msg = "未激活"
  12971. break
  12972. case "10":
  12973. msg = "激活"
  12974. break
  12975. case "20":
  12976. msg = "窗口挂失"
  12977. break
  12978. case "21":
  12979. msg = "电话挂失"
  12980. break
  12981. case "22":
  12982. msg = "单位网上申报挂失"
  12983. break
  12984. case "23":
  12985. msg = "保健办挂失"
  12986. break
  12987. case "24":
  12988. msg = "个人网上挂失"
  12989. break
  12990. case "25":
  12991. msg = "网上服务大厅挂失"
  12992. break
  12993. case "30":
  12994. msg = "注销"
  12995. break
  12996. case "40":
  12997. msg = "回收"
  12998. break
  12999. case "99":
  13000. msg = "制卡中(无效卡)"
  13001. break
  13002. }
  13003. c.ServeSuccessJSON(map[string]interface{}{
  13004. "failed_code": -10,
  13005. "msg": msg,
  13006. })
  13007. return
  13008. } else {
  13009. c.ServeSuccessJSON(map[string]interface{}{
  13010. "msg": "校验成功",
  13011. })
  13012. return
  13013. }
  13014. }
  13015. }
  13016. type ELeCertData struct {
  13017. Data struct {
  13018. Extra string `json:"extra"`
  13019. IDNo string `json:"idNo"`
  13020. IDType string `json:"idType"`
  13021. EcToken string `json:"ecToken"`
  13022. InsuOrg string `json:"insuOrg"`
  13023. UserName string `json:"userName"`
  13024. EcIndexNo string `json:"ecIndexNo"`
  13025. Gender string `json:"gender"`
  13026. Birthday string `json:"birthday"`
  13027. Nationality string `json:"nationality"`
  13028. Email string `json:"email"`
  13029. } `json:"OutData"`
  13030. }
  13031. func (c *HisApiController) ReadCard() {
  13032. id_card_type, _ := c.GetInt64("id_card_type")
  13033. admin_user_id, _ := c.GetInt64("admin_user_id")
  13034. certificates, _ := c.GetInt64("certificates")
  13035. //
  13036. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13037. id_card_no := c.GetString("id_card_no")
  13038. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13039. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13041. switch id_card_type {
  13042. case 1:
  13043. if miConfig.MdtrtareaAdmvs == "421300" {
  13044. var res ResultTwo
  13045. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13046. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13047. "&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)
  13048. resp, requestErr := http.Get(api)
  13049. if requestErr != nil {
  13050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13051. return
  13052. }
  13053. body, ioErr := ioutil.ReadAll(resp.Body)
  13054. if ioErr != nil {
  13055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13057. return
  13058. }
  13059. var respJSON map[string]interface{}
  13060. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13063. return
  13064. }
  13065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13066. result, _ := json.Marshal(respJSON)
  13067. fmt.Println("log")
  13068. fmt.Println(string(result))
  13069. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13070. utils.ErrorLog("解析失败:%v", err)
  13071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13072. return
  13073. }
  13074. if res.Infcode == 0 {
  13075. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13076. if err == gorm.ErrRecordNotFound {
  13077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13078. return
  13079. } else if err != nil {
  13080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13081. return
  13082. } else {
  13083. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13084. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13085. infoStr := string(Iinfos)
  13086. idetinfoStr := string(Idetinfos)
  13087. var rf []*ResultFive
  13088. json.Unmarshal([]byte(infoStr), &rf)
  13089. var insutypes []*ResultFive
  13090. var insutype string
  13091. var is390 int = 0
  13092. var is310 int = 0
  13093. for _, item := range rf {
  13094. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13095. insutypes = append(insutypes, item)
  13096. }
  13097. }
  13098. if len(insutypes) == 1 {
  13099. insutype = insutypes[0].Insutype
  13100. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13101. } else {
  13102. for _, i := range insutypes {
  13103. if i.Insutype == "390" {
  13104. is390 = 1
  13105. }
  13106. if i.Insutype == "310" {
  13107. is310 = 1
  13108. }
  13109. }
  13110. }
  13111. if is390 == 1 {
  13112. insutype = "390"
  13113. }
  13114. if is310 == 1 {
  13115. insutype = "310"
  13116. }
  13117. if len(insutypes) == 0 {
  13118. insutype = "390"
  13119. }
  13120. var insuplc_admdvs string
  13121. for _, item := range rf {
  13122. if item.Insutype == insutype {
  13123. insuplc_admdvs = item.InsuplcAdmdvs
  13124. }
  13125. }
  13126. if strings.Contains(insuplc_admdvs, "4213") {
  13127. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13128. }
  13129. psn := &models.HisPsn{
  13130. PsnNo: res.Output.Baseinfo.PsnNo,
  13131. PatientId: patient.ID,
  13132. Certno: res.Output.Baseinfo.Certno,
  13133. Gend: res.Output.Baseinfo.Gend,
  13134. Naty: res.Output.Baseinfo.Naty,
  13135. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13136. PsnName: res.Output.Baseinfo.PsnName,
  13137. Idetinfo: idetinfoStr,
  13138. Insuinfo: infoStr,
  13139. InsuplcAdmdvs: insuplc_admdvs,
  13140. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13141. }
  13142. service.CreateHisPsn(psn)
  13143. c.ServeSuccessJSON(map[string]interface{}{
  13144. "patient": patient,
  13145. "number": res.Output.Baseinfo.Certno,
  13146. })
  13147. }
  13148. } else {
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13150. return
  13151. }
  13152. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13153. var res ResultTwo
  13154. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13155. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13156. "&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)
  13157. resp, requestErr := http.Get(api)
  13158. if requestErr != nil {
  13159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13160. return
  13161. }
  13162. body, ioErr := ioutil.ReadAll(resp.Body)
  13163. if ioErr != nil {
  13164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13166. return
  13167. }
  13168. var respJSON map[string]interface{}
  13169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13172. return
  13173. }
  13174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13175. result, _ := json.Marshal(respJSON)
  13176. fmt.Println("log")
  13177. fmt.Println(string(result))
  13178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13179. utils.ErrorLog("解析失败:%v", err)
  13180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13181. return
  13182. }
  13183. if res.Infcode == 0 {
  13184. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13185. if err == gorm.ErrRecordNotFound {
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13187. return
  13188. } else if err != nil {
  13189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13190. return
  13191. } else {
  13192. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13193. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13194. infoStr := string(Iinfos)
  13195. idetinfoStr := string(Idetinfos)
  13196. psn := &models.HisPsn{
  13197. PsnNo: res.Output.Baseinfo.PsnNo,
  13198. PatientId: patient.ID,
  13199. Certno: res.Output.Baseinfo.Certno,
  13200. Gend: res.Output.Baseinfo.Gend,
  13201. Naty: res.Output.Baseinfo.Naty,
  13202. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13203. PsnName: res.Output.Baseinfo.PsnName,
  13204. Idetinfo: idetinfoStr,
  13205. Insuinfo: infoStr,
  13206. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13207. }
  13208. service.CreateHisPsn(psn)
  13209. var rf []*ResultFive
  13210. json.Unmarshal([]byte(infoStr), &rf)
  13211. var insutypes []*ResultFive
  13212. var insutype string
  13213. var is390 int = 0
  13214. var is310 int = 0
  13215. for _, item := range rf {
  13216. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13217. insutypes = append(insutypes, item)
  13218. }
  13219. }
  13220. if len(insutypes) == 1 {
  13221. insutype = insutypes[0].Insutype
  13222. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13223. } else {
  13224. for _, i := range insutypes {
  13225. if i.Insutype == "390" {
  13226. is390 = 1
  13227. }
  13228. if i.Insutype == "310" {
  13229. is310 = 1
  13230. }
  13231. }
  13232. }
  13233. if is390 == 1 {
  13234. insutype = "390"
  13235. }
  13236. if is310 == 1 {
  13237. insutype = "310"
  13238. }
  13239. if len(insutypes) == 0 {
  13240. insutype = "310"
  13241. }
  13242. c.ServeSuccessJSON(map[string]interface{}{
  13243. "patient": patient,
  13244. "number": res.Output.Baseinfo.Certno,
  13245. "insutype": insutype,
  13246. })
  13247. }
  13248. } else {
  13249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13250. return
  13251. }
  13252. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13253. var res ResultTwo
  13254. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13255. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13256. "&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)
  13257. resp, requestErr := http.Get(api)
  13258. if requestErr != nil {
  13259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13260. return
  13261. }
  13262. body, ioErr := ioutil.ReadAll(resp.Body)
  13263. if ioErr != nil {
  13264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13266. return
  13267. }
  13268. var respJSON map[string]interface{}
  13269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13272. return
  13273. }
  13274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13275. result, _ := json.Marshal(respJSON)
  13276. fmt.Println("log")
  13277. fmt.Println(string(result))
  13278. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13279. utils.ErrorLog("解析失败:%v", err)
  13280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13281. return
  13282. }
  13283. if res.Infcode == 0 {
  13284. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13285. if err == gorm.ErrRecordNotFound {
  13286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13287. return
  13288. } else if err != nil {
  13289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13290. return
  13291. } else {
  13292. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13293. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13294. infoStr := string(Iinfos)
  13295. idetinfoStr := string(Idetinfos)
  13296. var rf []*ResultFive
  13297. json.Unmarshal([]byte(infoStr), &rf)
  13298. var insutypes []*ResultFive
  13299. var insutype string
  13300. var is390 int = 0
  13301. var is310 int = 0
  13302. for _, item := range rf {
  13303. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13304. insutypes = append(insutypes, item)
  13305. }
  13306. }
  13307. if len(insutypes) == 1 {
  13308. insutype = insutypes[0].Insutype
  13309. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13310. } else {
  13311. for _, i := range insutypes {
  13312. if i.Insutype == "390" {
  13313. is390 = 1
  13314. }
  13315. if i.Insutype == "310" {
  13316. is310 = 1
  13317. }
  13318. }
  13319. }
  13320. if is390 == 1 {
  13321. insutype = "390"
  13322. }
  13323. if is310 == 1 {
  13324. insutype = "310"
  13325. }
  13326. if len(insutypes) == 0 {
  13327. insutype = "390"
  13328. }
  13329. var insuplc_admdvs string
  13330. for _, item := range rf {
  13331. if item.Insutype == insutype {
  13332. insuplc_admdvs = item.InsuplcAdmdvs
  13333. }
  13334. }
  13335. psn := &models.HisPsn{
  13336. PsnNo: res.Output.Baseinfo.PsnNo,
  13337. PatientId: patient.ID,
  13338. Certno: res.Output.Baseinfo.Certno,
  13339. Gend: res.Output.Baseinfo.Gend,
  13340. Naty: res.Output.Baseinfo.Naty,
  13341. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13342. PsnName: res.Output.Baseinfo.PsnName,
  13343. Idetinfo: idetinfoStr,
  13344. Insuinfo: infoStr,
  13345. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13346. InsuplcAdmdvs: insuplc_admdvs,
  13347. }
  13348. service.CreateHisPsn(psn)
  13349. for _, item := range rf {
  13350. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13351. insutypes = append(insutypes, item)
  13352. }
  13353. }
  13354. if len(insutypes) == 1 {
  13355. insutype = insutypes[0].Insutype
  13356. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13357. } else {
  13358. for _, i := range insutypes {
  13359. if i.Insutype == "390" {
  13360. is390 = 1
  13361. }
  13362. if i.Insutype == "310" {
  13363. is310 = 1
  13364. }
  13365. }
  13366. }
  13367. if is390 == 1 {
  13368. insutype = "390"
  13369. }
  13370. if is310 == 1 {
  13371. insutype = "310"
  13372. }
  13373. if len(insutypes) == 0 {
  13374. insutype = "310"
  13375. }
  13376. c.ServeSuccessJSON(map[string]interface{}{
  13377. "patient": patient,
  13378. "number": res.Output.Baseinfo.Certno,
  13379. "insutype": insutype,
  13380. })
  13381. }
  13382. } else {
  13383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13384. return
  13385. }
  13386. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13387. var res ResultTwo
  13388. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13389. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13390. "&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)
  13391. resp, requestErr := http.Get(api)
  13392. if requestErr != nil {
  13393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13394. return
  13395. }
  13396. body, ioErr := ioutil.ReadAll(resp.Body)
  13397. if ioErr != nil {
  13398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13400. return
  13401. }
  13402. var respJSON map[string]interface{}
  13403. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13409. result, _ := json.Marshal(respJSON)
  13410. fmt.Println("log")
  13411. fmt.Println(string(result))
  13412. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13413. utils.ErrorLog("解析失败:%v", err)
  13414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13415. return
  13416. }
  13417. if res.Infcode == 0 {
  13418. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13419. if err == gorm.ErrRecordNotFound {
  13420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13421. return
  13422. } else if err != nil {
  13423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13424. return
  13425. } else {
  13426. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13427. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13428. infoStr := string(Iinfos)
  13429. idetinfoStr := string(Idetinfos)
  13430. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13431. psn := &models.HisPsn{
  13432. PsnNo: res.Output.Baseinfo.PsnNo,
  13433. PatientId: patient.ID,
  13434. Certno: res.Output.Baseinfo.Certno,
  13435. Brdy: b,
  13436. Age: float64(age),
  13437. Gend: res.Output.Baseinfo.Gend,
  13438. Naty: res.Output.Baseinfo.Naty,
  13439. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13440. PsnName: res.Output.Baseinfo.PsnName,
  13441. Idetinfo: idetinfoStr,
  13442. Insuinfo: infoStr,
  13443. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13444. }
  13445. service.CreateHisPsn(psn)
  13446. var rf []*ResultFive
  13447. json.Unmarshal([]byte(infoStr), &rf)
  13448. var insutypes []*ResultFive
  13449. var insutype string
  13450. var is390 int = 0
  13451. var is310 int = 0
  13452. for _, item := range rf {
  13453. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13454. insutypes = append(insutypes, item)
  13455. }
  13456. }
  13457. if len(insutypes) == 1 {
  13458. insutype = insutypes[0].Insutype
  13459. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13460. } else {
  13461. for _, i := range insutypes {
  13462. if i.Insutype == "390" {
  13463. is390 = 1
  13464. }
  13465. if i.Insutype == "310" {
  13466. is310 = 1
  13467. }
  13468. }
  13469. }
  13470. if is390 == 1 {
  13471. insutype = "390"
  13472. }
  13473. if is310 == 1 {
  13474. insutype = "310"
  13475. }
  13476. if len(insutypes) == 0 {
  13477. insutype = "310"
  13478. }
  13479. c.ServeSuccessJSON(map[string]interface{}{
  13480. "patient": patient,
  13481. "number": res.Output.Baseinfo.Certno,
  13482. "insutype": insutype,
  13483. })
  13484. }
  13485. } else {
  13486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13487. return
  13488. }
  13489. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13490. var api string
  13491. if miConfig.MdtrtareaAdmvs == "320921" {
  13492. 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 +
  13493. "&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
  13494. fmt.Println(api)
  13495. } else {
  13496. 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 +
  13497. "&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)
  13498. }
  13499. resp, requestErr := http.Get(api)
  13500. if requestErr != nil {
  13501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13502. return
  13503. }
  13504. body, ioErr := ioutil.ReadAll(resp.Body)
  13505. if ioErr != nil {
  13506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13508. return
  13509. }
  13510. var respJSON map[string]interface{}
  13511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13514. return
  13515. }
  13516. var status string
  13517. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13518. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13519. //console.log()
  13520. fmt.Println("type===")
  13521. fmt.Println(card_type)
  13522. var token string
  13523. var res ResultTwo //1101结果
  13524. var res10265 ResultTwo10265 //1101结果
  13525. var card_info string //卡信息
  13526. var busi_card_info string
  13527. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13528. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13529. if status == "0" { //读卡成功
  13530. if card_type == "1" {
  13531. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13532. result, _ := json.Marshal(respJSON)
  13533. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13534. utils.ErrorLog("解析失败:%v", err)
  13535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13536. return
  13537. }
  13538. res.ErrMsg = res10265.ErrMsg
  13539. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13540. res.Infcode = infocode
  13541. res.Output = res10265.Output
  13542. res.InfRefmsgid = res10265.InfRefmsgid
  13543. } else {
  13544. //var card_info string //卡信息
  13545. //var busi_card_info string
  13546. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13547. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13548. //fmt.Println(card_info)
  13549. //fmt.Println(busi_card_info)
  13550. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13551. result, _ := json.Marshal(respJSON)
  13552. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13553. utils.ErrorLog("解析失败:%v", err)
  13554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13555. return
  13556. }
  13557. res.ErrMsg = res10265.ErrMsg
  13558. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13559. res.Infcode = infocode
  13560. res.Output = res10265.Output
  13561. res.InfRefmsgid = res10265.InfRefmsgid
  13562. }
  13563. if res.Infcode == 0 {
  13564. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13565. if err == gorm.ErrRecordNotFound {
  13566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13567. return
  13568. } else if err != nil {
  13569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13570. return
  13571. } else {
  13572. if card_type == "1" {
  13573. bas := strings.Split(card_info, "|")
  13574. basNumber := bas[2]
  13575. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13576. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13577. infoStr := string(Iinfos)
  13578. idetinfoStr := string(Idetinfos)
  13579. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13580. psn := &models.HisPsn{
  13581. PsnNo: res.Output.Baseinfo.PsnNo,
  13582. PatientId: patient.ID,
  13583. Certno: res.Output.Baseinfo.Certno,
  13584. Brdy: b,
  13585. Age: float64(age),
  13586. Gend: res.Output.Baseinfo.Gend,
  13587. Naty: res.Output.Baseinfo.Naty,
  13588. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13589. PsnName: res.Output.Baseinfo.PsnName,
  13590. Idetinfo: idetinfoStr,
  13591. Insuinfo: infoStr,
  13592. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13593. CardInfo: card_info,
  13594. VerifyNumber: busi_card_info,
  13595. }
  13596. service.CreateHisPsn(psn)
  13597. var rf []*ResultFive
  13598. json.Unmarshal([]byte(infoStr), &rf)
  13599. var insutypes []*ResultFive
  13600. var insutype string
  13601. var is390 int = 0
  13602. var is310 int = 0
  13603. for _, item := range rf {
  13604. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13605. insutypes = append(insutypes, item)
  13606. }
  13607. }
  13608. if len(insutypes) == 1 {
  13609. insutype = insutypes[0].Insutype
  13610. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13611. } else {
  13612. for _, i := range insutypes {
  13613. if i.Insutype == "390" {
  13614. is390 = 1
  13615. }
  13616. if i.Insutype == "310" {
  13617. is310 = 1
  13618. }
  13619. }
  13620. }
  13621. if is390 == 1 {
  13622. insutype = "390"
  13623. }
  13624. if is310 == 1 {
  13625. insutype = "310"
  13626. }
  13627. if len(insutypes) == 0 {
  13628. insutype = "310"
  13629. }
  13630. c.ServeSuccessJSON(map[string]interface{}{
  13631. "patient": patient,
  13632. "number": basNumber,
  13633. "insutype": insutype,
  13634. })
  13635. } else {
  13636. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13637. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13638. infoStr := string(Iinfos)
  13639. idetinfoStr := string(Idetinfos)
  13640. psn := &models.HisPsn{
  13641. PsnNo: res.Output.Baseinfo.PsnNo,
  13642. PatientId: patient.ID,
  13643. Certno: res.Output.Baseinfo.Certno,
  13644. Gend: res.Output.Baseinfo.Gend,
  13645. Naty: res.Output.Baseinfo.Naty,
  13646. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13647. PsnName: res.Output.Baseinfo.PsnName,
  13648. Idetinfo: idetinfoStr,
  13649. Insuinfo: infoStr,
  13650. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13651. CardInfo: card_info,
  13652. VerifyNumber: token,
  13653. }
  13654. service.CreateHisPsn(psn)
  13655. c.ServeSuccessJSON(map[string]interface{}{
  13656. "patient": patient,
  13657. "number": token,
  13658. })
  13659. }
  13660. }
  13661. } else {
  13662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13663. return
  13664. }
  13665. } else { //读卡失败
  13666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13667. return
  13668. }
  13669. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13670. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13671. cardnum = DeleteExtraSpaceTwo(cardnum)
  13672. cardCode = DeleteExtraSpaceTwo(cardCode)
  13673. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13674. name = DeleteExtraSpaceTwo(name)
  13675. errmsg = DeleteExtraSpaceTwo(errmsg)
  13676. cardnum = Remove0000(cardnum)
  13677. cardCode = Remove0000(cardCode)
  13678. id_card_no = Remove0000(id_card_no)
  13679. name = Remove0000(name)
  13680. errmsg = Remove0000(errmsg)
  13681. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13682. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13683. //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)
  13684. //fmt.Println(result2)
  13685. //fmt.Println(requestLog2)
  13686. //fmt.Println(errMsgLog2)
  13687. 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)
  13688. saveLog(result, requestLog, "1101", "获取人员信息")
  13689. fmt.Println(errMsgLog)
  13690. if len(errMsgLog) > 0 {
  13691. } else {
  13692. var dat map[string]interface{}
  13693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13694. fmt.Println(dat)
  13695. } else {
  13696. fmt.Println(err)
  13697. }
  13698. userJSONBytes, _ := json.Marshal(dat)
  13699. var res ResultTwo
  13700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13701. utils.ErrorLog("解析失败:%v", err)
  13702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13703. return
  13704. }
  13705. res.ErrMsg = errMsgLog
  13706. if res.Infcode == 0 {
  13707. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13708. if err == gorm.ErrRecordNotFound {
  13709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13710. return
  13711. } else if err != nil {
  13712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13713. return
  13714. } else {
  13715. fmt.Println(res)
  13716. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13717. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13718. infoStr := string(Iinfos)
  13719. idetinfoStr := string(Idetinfos)
  13720. var rf []*ResultFive
  13721. json.Unmarshal([]byte(infoStr), &rf)
  13722. var insutypes []*ResultFive
  13723. var insutype string
  13724. var is390 int = 0
  13725. var is310 int = 0
  13726. for _, item := range rf {
  13727. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13728. insutypes = append(insutypes, item)
  13729. }
  13730. }
  13731. if len(insutypes) == 1 {
  13732. insutype = insutypes[0].Insutype
  13733. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13734. } else {
  13735. for _, i := range insutypes {
  13736. if i.Insutype == "390" {
  13737. is390 = 1
  13738. }
  13739. if i.Insutype == "310" {
  13740. is310 = 1
  13741. }
  13742. }
  13743. }
  13744. if is390 == 1 {
  13745. insutype = "390"
  13746. }
  13747. if is310 == 1 {
  13748. insutype = "310"
  13749. }
  13750. if len(insutypes) == 0 {
  13751. insutype = "390"
  13752. }
  13753. var insuplc_admdvs string
  13754. for _, item := range rf {
  13755. if item.Insutype == insutype {
  13756. insuplc_admdvs = item.InsuplcAdmdvs
  13757. }
  13758. }
  13759. psn := &models.HisPsn{
  13760. PsnNo: res.Output.Baseinfo.PsnNo,
  13761. PatientId: patient.ID,
  13762. Certno: res.Output.Baseinfo.Certno,
  13763. Gend: res.Output.Baseinfo.Gend,
  13764. Naty: res.Output.Baseinfo.Naty,
  13765. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13766. PsnName: res.Output.Baseinfo.PsnName,
  13767. Idetinfo: idetinfoStr,
  13768. Insuinfo: infoStr,
  13769. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13770. CardInfo: basStr,
  13771. VerifyNumber: "",
  13772. InsuplcAdmdvs: insuplc_admdvs,
  13773. }
  13774. service.CreateHisPsn(psn)
  13775. c.ServeSuccessJSON(map[string]interface{}{
  13776. "patient": patient,
  13777. "number": cardnum,
  13778. "insutype": insutype,
  13779. })
  13780. }
  13781. } else {
  13782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13783. return
  13784. }
  13785. }
  13786. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13787. fmt.Println(initFlag)
  13788. fmt.Println("initFlag")
  13789. if initFlag == 0 {
  13790. c.TestGetJiangXiBasBaseInit()
  13791. }
  13792. basStr := c.GetBasBaseInfo()
  13793. if len(basStr) == 0 {
  13794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13795. return
  13796. }
  13797. fmt.Println(basStr)
  13798. bas := strings.Split(basStr, "|")
  13799. basNumber := bas[1]
  13800. fmt.Println(basNumber)
  13801. card_sn := bas[3]
  13802. fmt.Println(card_sn)
  13803. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13804. 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)
  13805. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13806. var dat map[string]interface{}
  13807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13808. fmt.Println(dat)
  13809. } else {
  13810. fmt.Println(err)
  13811. }
  13812. userJSONBytes, _ := json.Marshal(dat)
  13813. var res ResultTwo
  13814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13815. utils.ErrorLog("解析失败:%v", err)
  13816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13817. return
  13818. }
  13819. if res.Infcode == 0 {
  13820. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13821. if err == gorm.ErrRecordNotFound {
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13823. return
  13824. } else if err != nil {
  13825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13826. return
  13827. } else {
  13828. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13829. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13830. infoStr := string(Iinfos)
  13831. idetinfoStr := string(Idetinfos)
  13832. var rf []*ResultFive
  13833. json.Unmarshal([]byte(infoStr), &rf)
  13834. var insutypes []*ResultFive
  13835. var insutype string
  13836. var is390 int = 0
  13837. var is310 int = 0
  13838. var insuplc_admdvs string
  13839. for _, item := range rf {
  13840. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13841. insutypes = append(insutypes, item)
  13842. }
  13843. }
  13844. if len(insutypes) == 1 {
  13845. insutype = insutypes[0].Insutype
  13846. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13847. } else {
  13848. for _, i := range insutypes {
  13849. if i.Insutype == "390" {
  13850. is390 = 1
  13851. }
  13852. if i.Insutype == "310" {
  13853. is310 = 1
  13854. }
  13855. }
  13856. }
  13857. if is390 == 1 {
  13858. insutype = "390"
  13859. }
  13860. if is310 == 1 {
  13861. insutype = "310"
  13862. }
  13863. if len(insutypes) == 0 {
  13864. insutype = "310"
  13865. }
  13866. for _, item := range rf {
  13867. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13868. insuplc_admdvs = item.InsuplcAdmdvs
  13869. }
  13870. }
  13871. psn := &models.HisPsn{
  13872. PsnNo: res.Output.Baseinfo.PsnNo,
  13873. PatientId: patient.ID,
  13874. Certno: res.Output.Baseinfo.Certno,
  13875. Gend: res.Output.Baseinfo.Gend,
  13876. Naty: res.Output.Baseinfo.Naty,
  13877. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13878. PsnName: res.Output.Baseinfo.PsnName,
  13879. Idetinfo: idetinfoStr,
  13880. Insuinfo: infoStr,
  13881. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13882. CardInfo: basStr,
  13883. InsuplcAdmdvs: insuplc_admdvs,
  13884. VerifyNumber: "",
  13885. }
  13886. service.CreateHisPsn(psn)
  13887. c.ServeSuccessJSON(map[string]interface{}{
  13888. "patient": patient,
  13889. "number": basNumber,
  13890. "insutype": insutype,
  13891. })
  13892. }
  13893. } else {
  13894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13895. return
  13896. }
  13897. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13898. basStr := c.GetBasBaseInfo22222()
  13899. fmt.Println(basStr)
  13900. if len(basStr) == 0 {
  13901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13902. return
  13903. }
  13904. fmt.Println(basStr)
  13905. bas := strings.Split(basStr, "|")
  13906. basNumber := bas[2] //卡号
  13907. card_sn := bas[3] //
  13908. id_card_No := bas[1] //卡号
  13909. fmt.Println(basNumber)
  13910. fmt.Println(card_sn)
  13911. fmt.Println(id_card_No)
  13912. var patient service.Patients
  13913. if len(id_card_No) == 0{
  13914. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13915. }else{
  13916. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13917. }
  13918. 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)
  13919. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13920. var dat map[string]interface{}
  13921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13922. fmt.Println(dat)
  13923. } else {
  13924. fmt.Println(err)
  13925. }
  13926. userJSONBytes, _ := json.Marshal(dat)
  13927. var res ResultTwo
  13928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13929. utils.ErrorLog("解析失败:%v", err)
  13930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13931. return
  13932. }
  13933. if res.Infcode == 0 {
  13934. var pateint2 service.Patients
  13935. var err error
  13936. if len(id_card_No) == 0{
  13937. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13938. }else{
  13939. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13940. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13941. }
  13942. if err == gorm.ErrRecordNotFound {
  13943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13944. return
  13945. } else if err != nil {
  13946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13947. return
  13948. } else {
  13949. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13950. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13951. infoStr := string(Iinfos)
  13952. idetinfoStr := string(Idetinfos)
  13953. var rf []*ResultFive
  13954. json.Unmarshal([]byte(infoStr), &rf)
  13955. var insutypes []*ResultFive
  13956. var insutype string
  13957. var is390 int = 0
  13958. var is310 int = 0
  13959. var insuplc_admdvs string
  13960. for _, item := range rf {
  13961. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13962. insutypes = append(insutypes, item)
  13963. }
  13964. }
  13965. if len(insutypes) == 1 {
  13966. insutype = insutypes[0].Insutype
  13967. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13968. } else {
  13969. for _, i := range insutypes {
  13970. if i.Insutype == "390" {
  13971. is390 = 1
  13972. }
  13973. if i.Insutype == "310" {
  13974. is310 = 1
  13975. }
  13976. }
  13977. }
  13978. if is390 == 1 {
  13979. insutype = "390"
  13980. }
  13981. if is310 == 1 {
  13982. insutype = "310"
  13983. }
  13984. if len(insutypes) == 0 {
  13985. insutype = "310"
  13986. }
  13987. for _, item := range rf {
  13988. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13989. insuplc_admdvs = item.InsuplcAdmdvs
  13990. }
  13991. }
  13992. psn := &models.HisPsn{
  13993. PsnNo: res.Output.Baseinfo.PsnNo,
  13994. PatientId: pateint2.ID,
  13995. Certno: res.Output.Baseinfo.Certno,
  13996. Gend: res.Output.Baseinfo.Gend,
  13997. Naty: res.Output.Baseinfo.Naty,
  13998. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13999. PsnName: res.Output.Baseinfo.PsnName,
  14000. Idetinfo: idetinfoStr,
  14001. Insuinfo: infoStr,
  14002. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14003. CardInfo: basStr,
  14004. InsuplcAdmdvs: insuplc_admdvs,
  14005. VerifyNumber: "",
  14006. }
  14007. service.CreateHisPsn(psn)
  14008. c.ServeSuccessJSON(map[string]interface{}{
  14009. "patient": patient,
  14010. "number": basNumber,
  14011. "insutype": insutype,
  14012. })
  14013. }
  14014. } else {
  14015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14016. return
  14017. }
  14018. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14019. fmt.Println(initFlag)
  14020. fmt.Println("initFlag")
  14021. if initFlag == 0 {
  14022. c.TestGetHnBasBaseInit()
  14023. }
  14024. basStr := c.GetBasBaseInfo()
  14025. if len(basStr) == 0 {
  14026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14027. return
  14028. }
  14029. fmt.Println(basStr)
  14030. bas := strings.Split(basStr, "|")
  14031. basNumber := bas[1]
  14032. fmt.Println(basNumber)
  14033. card_sn := bas[3]
  14034. card_no := bas[2]
  14035. fmt.Println(card_sn)
  14036. name := bas[4]
  14037. name = ConvertToString(name, "gbk", "utf-8")
  14038. 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)
  14039. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14040. var dat map[string]interface{}
  14041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14042. fmt.Println(dat)
  14043. } else {
  14044. fmt.Println(err)
  14045. }
  14046. userJSONBytes, _ := json.Marshal(dat)
  14047. var res ResultTwo
  14048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14049. utils.ErrorLog("解析失败:%v", err)
  14050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14051. return
  14052. }
  14053. if res.Infcode == 0 {
  14054. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14055. if err == gorm.ErrRecordNotFound {
  14056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14057. return
  14058. } else if err != nil {
  14059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14060. return
  14061. } else {
  14062. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14063. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14064. infoStr := string(Iinfos)
  14065. idetinfoStr := string(Idetinfos)
  14066. psn := &models.HisPsn{
  14067. PsnNo: res.Output.Baseinfo.PsnNo,
  14068. PatientId: patient.ID,
  14069. Certno: res.Output.Baseinfo.Certno,
  14070. Gend: res.Output.Baseinfo.Gend,
  14071. Naty: res.Output.Baseinfo.Naty,
  14072. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14073. PsnName: res.Output.Baseinfo.PsnName,
  14074. Idetinfo: idetinfoStr,
  14075. Insuinfo: infoStr,
  14076. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14077. CardInfo: basStr,
  14078. VerifyNumber: "",
  14079. }
  14080. service.CreateHisPsn(psn)
  14081. var rf []*ResultFive
  14082. json.Unmarshal([]byte(infoStr), &rf)
  14083. var insutypes []*ResultFive
  14084. var insutype string
  14085. var is390 int = 0
  14086. var is310 int = 0
  14087. for _, item := range rf {
  14088. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14089. insutypes = append(insutypes, item)
  14090. }
  14091. }
  14092. if len(insutypes) == 1 {
  14093. insutype = insutypes[0].Insutype
  14094. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14095. } else {
  14096. for _, i := range insutypes {
  14097. if i.Insutype == "390" {
  14098. is390 = 1
  14099. }
  14100. if i.Insutype == "310" {
  14101. is310 = 1
  14102. }
  14103. }
  14104. }
  14105. if is390 == 1 {
  14106. insutype = "390"
  14107. }
  14108. if is310 == 1 {
  14109. insutype = "310"
  14110. }
  14111. if len(insutypes) == 0 {
  14112. insutype = "310"
  14113. }
  14114. c.ServeSuccessJSON(map[string]interface{}{
  14115. "patient": patient,
  14116. "number": basNumber,
  14117. "insutype": insutype,
  14118. })
  14119. }
  14120. } else {
  14121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14122. return
  14123. }
  14124. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14125. var api string
  14126. 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 +
  14127. "&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
  14128. fmt.Println(api)
  14129. resp, requestErr := http.Get(api)
  14130. if requestErr != nil {
  14131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14132. return
  14133. }
  14134. body, ioErr := ioutil.ReadAll(resp.Body)
  14135. if ioErr != nil {
  14136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14138. return
  14139. }
  14140. var respJSON map[string]interface{}
  14141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14144. return
  14145. }
  14146. var res ResultTwo //1101结果
  14147. var res10265 ResultTwo10265 //1101结果
  14148. var card_info string //卡信息
  14149. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14150. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14151. result, _ := json.Marshal(respJSON)
  14152. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14153. utils.ErrorLog("解析失败:%v", err)
  14154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14155. return
  14156. }
  14157. res.ErrMsg = res10265.ErrMsg
  14158. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14159. res.Infcode = infocode
  14160. res.Output = res10265.Output
  14161. res.InfRefmsgid = res10265.InfRefmsgid
  14162. if res.Infcode == 0 {
  14163. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14164. if err == gorm.ErrRecordNotFound {
  14165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14166. return
  14167. } else if err != nil {
  14168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14169. return
  14170. } else {
  14171. bas := strings.Split(card_info, "|")
  14172. basNumber := bas[2]
  14173. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14174. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14175. infoStr := string(Iinfos)
  14176. idetinfoStr := string(Idetinfos)
  14177. psn := &models.HisPsn{
  14178. PsnNo: res.Output.Baseinfo.PsnNo,
  14179. PatientId: patient.ID,
  14180. Certno: res.Output.Baseinfo.Certno,
  14181. Gend: res.Output.Baseinfo.Gend,
  14182. Naty: res.Output.Baseinfo.Naty,
  14183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14184. PsnName: res.Output.Baseinfo.PsnName,
  14185. Idetinfo: idetinfoStr,
  14186. Insuinfo: infoStr,
  14187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14188. CardInfo: card_info,
  14189. VerifyNumber: token,
  14190. }
  14191. service.CreateHisPsn(psn)
  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") {
  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 = "310"
  14224. }
  14225. c.ServeSuccessJSON(map[string]interface{}{
  14226. "patient": patient,
  14227. "number": basNumber,
  14228. "insutype": insutype,
  14229. })
  14230. }
  14231. } else {
  14232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14233. return
  14234. }
  14235. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14236. res := c.GetoleInfo()
  14237. if res.Infcode == 0 {
  14238. var result string
  14239. if res.Output.MdtrtCertType == "01" {
  14240. 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)
  14241. } else if res.Output.MdtrtCertType == "02" {
  14242. 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)
  14243. } else if res.Output.MdtrtCertType == "03" {
  14244. 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)
  14245. }
  14246. var dat map[string]interface{}
  14247. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14248. fmt.Println(dat)
  14249. } else {
  14250. fmt.Println(err)
  14251. }
  14252. userJSONBytes, _ := json.Marshal(dat)
  14253. var res2 ResultTwo
  14254. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14255. utils.ErrorLog("解析失败:%v", err)
  14256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14257. return
  14258. }
  14259. if res2.Infcode == 0 {
  14260. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14261. if err == gorm.ErrRecordNotFound {
  14262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14263. return
  14264. } else if err != nil {
  14265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14266. return
  14267. } else {
  14268. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14269. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14270. infoStr := string(Iinfos)
  14271. idetinfoStr := string(Idetinfos)
  14272. var rf []*ResultFive
  14273. json.Unmarshal([]byte(infoStr), &rf)
  14274. var insutypes []*ResultFive
  14275. var insutype string
  14276. var is390 int = 0
  14277. var is310 int = 0
  14278. //var insuplc_admdvs string
  14279. for _, item := range rf {
  14280. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14281. insutypes = append(insutypes, item)
  14282. }
  14283. }
  14284. if len(insutypes) == 1 {
  14285. insutype = insutypes[0].Insutype
  14286. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14287. } else {
  14288. for _, i := range insutypes {
  14289. if i.Insutype == "390" {
  14290. is390 = 1
  14291. }
  14292. if i.Insutype == "310" {
  14293. is310 = 1
  14294. }
  14295. }
  14296. }
  14297. if is390 == 1 {
  14298. insutype = "390"
  14299. }
  14300. if is310 == 1 {
  14301. insutype = "310"
  14302. }
  14303. if len(insutypes) == 0 {
  14304. insutype = "310"
  14305. }
  14306. psn := &models.HisPsn{
  14307. PsnNo: res2.Output.Baseinfo.PsnNo,
  14308. PatientId: patient.ID,
  14309. Certno: res2.Output.Baseinfo.Certno,
  14310. Gend: res2.Output.Baseinfo.Gend,
  14311. Naty: res2.Output.Baseinfo.Naty,
  14312. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14313. PsnName: res2.Output.Baseinfo.PsnName,
  14314. Idetinfo: idetinfoStr,
  14315. Insuinfo: infoStr,
  14316. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14317. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14318. VerifyNumber: res.Output.EcToken,
  14319. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14320. }
  14321. if res.Output.MdtrtCertType == "01" {
  14322. psn.VerifyNumber = res.Output.EcToken
  14323. //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)
  14324. } else if res.Output.MdtrtCertType == "02" {
  14325. psn.VerifyNumber = res.Output.MdtrtCertNo
  14326. //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)
  14327. } else if res.Output.MdtrtCertType == "03" {
  14328. psn.VerifyNumber = res.Output.MdtrtCertNo
  14329. //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)
  14330. }
  14331. var balc float64
  14332. for _, item := range rf {
  14333. if item.Insutype == insutype {
  14334. balc = item.Balc
  14335. }
  14336. }
  14337. service.CreateHisPsn(psn)
  14338. c.ServeSuccessJSON(map[string]interface{}{
  14339. "patient": patient,
  14340. "number": res.Output.CardNo,
  14341. "insutype": insutype,
  14342. "blac": balc,
  14343. "desc": idetinfoStr,
  14344. })
  14345. }
  14346. } else {
  14347. c.ServeSuccessJSON(map[string]interface{}{
  14348. "failed_code": -10,
  14349. "msg": res2.ErrMsg,
  14350. })
  14351. }
  14352. } else {
  14353. c.ServeSuccessJSON(map[string]interface{}{
  14354. "failed_code": -10,
  14355. "msg": res.ErrMsg,
  14356. })
  14357. }
  14358. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14359. var api string
  14360. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14361. "&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
  14362. fmt.Println(api)
  14363. resp, requestErr := http.Get(api)
  14364. if requestErr != nil {
  14365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14366. return
  14367. }
  14368. body, ioErr := ioutil.ReadAll(resp.Body)
  14369. if ioErr != nil {
  14370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14372. return
  14373. }
  14374. var respJSON map[string]interface{}
  14375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14378. return
  14379. }
  14380. var status string
  14381. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14382. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14383. //console.log()
  14384. fmt.Println("type===")
  14385. fmt.Println(card_type)
  14386. var token string
  14387. var res ResultTwo //1101结果
  14388. //var res10265 ResultTwoesultTwo10265 //1101结果
  14389. var card_info string //卡信息
  14390. var busi_card_info string
  14391. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14392. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14393. if status == "0" { //读卡成功
  14394. if card_type == "1" {
  14395. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14396. result, _ := json.Marshal(respJSON)
  14397. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14398. utils.ErrorLog("解析失败:%v", err)
  14399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14400. return
  14401. }
  14402. } else {
  14403. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14404. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14405. result, _ := json.Marshal(respJSON)
  14406. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14407. utils.ErrorLog("解析失败:%v", err)
  14408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14409. return
  14410. }
  14411. }
  14412. if res.Infcode == 0 {
  14413. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14414. if err == gorm.ErrRecordNotFound {
  14415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14416. return
  14417. } else if err != nil {
  14418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14419. return
  14420. } else {
  14421. if card_type == "1" {
  14422. bas := strings.Split(card_info, "|")
  14423. basNumber := bas[2]
  14424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14426. infoStr := string(Iinfos)
  14427. idetinfoStr := string(Idetinfos)
  14428. psn := &models.HisPsn{
  14429. PsnNo: res.Output.Baseinfo.PsnNo,
  14430. PatientId: patient.ID,
  14431. Certno: res.Output.Baseinfo.Certno,
  14432. Gend: res.Output.Baseinfo.Gend,
  14433. Naty: res.Output.Baseinfo.Naty,
  14434. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14435. PsnName: res.Output.Baseinfo.PsnName,
  14436. Idetinfo: idetinfoStr,
  14437. Insuinfo: infoStr,
  14438. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14439. CardInfo: card_info,
  14440. VerifyNumber: busi_card_info,
  14441. }
  14442. service.CreateHisPsn(psn)
  14443. var rf []*ResultFive
  14444. json.Unmarshal([]byte(infoStr), &rf)
  14445. var insutypes []*ResultFive
  14446. var insutype string
  14447. var is390 int = 0
  14448. var is310 int = 0
  14449. for _, item := range rf {
  14450. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14451. insutypes = append(insutypes, item)
  14452. }
  14453. }
  14454. if len(insutypes) == 1 {
  14455. insutype = insutypes[0].Insutype
  14456. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14457. } else {
  14458. for _, i := range insutypes {
  14459. if i.Insutype == "390" {
  14460. is390 = 1
  14461. }
  14462. if i.Insutype == "310" {
  14463. is310 = 1
  14464. }
  14465. }
  14466. }
  14467. if is390 == 1 {
  14468. insutype = "390"
  14469. }
  14470. if is310 == 1 {
  14471. insutype = "310"
  14472. }
  14473. if len(insutypes) == 0 {
  14474. insutype = "310"
  14475. }
  14476. c.ServeSuccessJSON(map[string]interface{}{
  14477. "patient": patient,
  14478. "number": basNumber,
  14479. "insutype": insutype,
  14480. })
  14481. } else {
  14482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14483. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14484. infoStr := string(Iinfos)
  14485. idetinfoStr := string(Idetinfos)
  14486. psn := &models.HisPsn{
  14487. PsnNo: res.Output.Baseinfo.PsnNo,
  14488. PatientId: patient.ID,
  14489. Certno: res.Output.Baseinfo.Certno,
  14490. Gend: res.Output.Baseinfo.Gend,
  14491. Naty: res.Output.Baseinfo.Naty,
  14492. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14493. PsnName: res.Output.Baseinfo.PsnName,
  14494. Idetinfo: idetinfoStr,
  14495. Insuinfo: infoStr,
  14496. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14497. CardInfo: card_info,
  14498. VerifyNumber: token,
  14499. }
  14500. service.CreateHisPsn(psn)
  14501. c.ServeSuccessJSON(map[string]interface{}{
  14502. "patient": patient,
  14503. "number": token,
  14504. })
  14505. }
  14506. }
  14507. } else {
  14508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14509. return
  14510. }
  14511. } else { //读卡失败
  14512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14513. return
  14514. }
  14515. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14516. var api string
  14517. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14518. "&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
  14519. fmt.Println(api)
  14520. resp, requestErr := http.Get(api)
  14521. if requestErr != nil {
  14522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14523. return
  14524. }
  14525. body, ioErr := ioutil.ReadAll(resp.Body)
  14526. if ioErr != nil {
  14527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14529. return
  14530. }
  14531. var respJSON map[string]interface{}
  14532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14535. return
  14536. }
  14537. var status string
  14538. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14539. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14540. //console.log()
  14541. fmt.Println("type===")
  14542. fmt.Println(card_type)
  14543. var token string
  14544. var res ResultTwo //1101结果
  14545. //var res10265 ResultTwoesultTwo10265 //1101结果
  14546. var card_info string //卡信息
  14547. //var busi_card_info string
  14548. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14549. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14550. if status == "0" { //读卡成功
  14551. if card_type == "1" {
  14552. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14553. result, _ := json.Marshal(respJSON)
  14554. fmt.Println(result)
  14555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14556. utils.ErrorLog("解析失败:%v", err)
  14557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14558. return
  14559. }
  14560. fmt.Println(res)
  14561. } else {
  14562. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14563. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14564. result, _ := json.Marshal(respJSON)
  14565. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14566. utils.ErrorLog("解析失败:%v", err)
  14567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14568. return
  14569. }
  14570. }
  14571. if res.Infcode == 0 {
  14572. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14573. if err == gorm.ErrRecordNotFound {
  14574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14575. return
  14576. } else if err != nil {
  14577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14578. return
  14579. } else {
  14580. if card_type == "1" {
  14581. bas := strings.Split(card_info, "|")
  14582. basNumber := bas[2]
  14583. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14584. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14585. infoStr := string(Iinfos)
  14586. idetinfoStr := string(Idetinfos)
  14587. psn := &models.HisPsn{
  14588. PsnNo: res.Output.Baseinfo.PsnNo,
  14589. PatientId: patient.ID,
  14590. Certno: res.Output.Baseinfo.Certno,
  14591. Gend: res.Output.Baseinfo.Gend,
  14592. Naty: res.Output.Baseinfo.Naty,
  14593. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14594. PsnName: res.Output.Baseinfo.PsnName,
  14595. Idetinfo: idetinfoStr,
  14596. Insuinfo: infoStr,
  14597. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14598. CardInfo: card_info,
  14599. //VerifyNumber: busi_card_info,
  14600. }
  14601. service.CreateHisPsn(psn)
  14602. var rf []*ResultFive
  14603. json.Unmarshal([]byte(infoStr), &rf)
  14604. var insutypes []*ResultFive
  14605. var insutype string
  14606. var is390 int = 0
  14607. var is310 int = 0
  14608. for _, item := range rf {
  14609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14610. insutypes = append(insutypes, item)
  14611. }
  14612. }
  14613. if len(insutypes) == 1 {
  14614. insutype = insutypes[0].Insutype
  14615. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14616. } else {
  14617. for _, i := range insutypes {
  14618. if i.Insutype == "390" {
  14619. is390 = 1
  14620. }
  14621. if i.Insutype == "310" {
  14622. is310 = 1
  14623. }
  14624. }
  14625. }
  14626. if is390 == 1 {
  14627. insutype = "390"
  14628. }
  14629. if is310 == 1 {
  14630. insutype = "310"
  14631. }
  14632. if len(insutypes) == 0 {
  14633. insutype = "310"
  14634. }
  14635. c.ServeSuccessJSON(map[string]interface{}{
  14636. "patient": patient,
  14637. "number": basNumber,
  14638. "insutype": insutype,
  14639. })
  14640. } else {
  14641. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14642. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14643. infoStr := string(Iinfos)
  14644. idetinfoStr := string(Idetinfos)
  14645. psn := &models.HisPsn{
  14646. PsnNo: res.Output.Baseinfo.PsnNo,
  14647. PatientId: patient.ID,
  14648. Certno: res.Output.Baseinfo.Certno,
  14649. Gend: res.Output.Baseinfo.Gend,
  14650. Naty: res.Output.Baseinfo.Naty,
  14651. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14652. PsnName: res.Output.Baseinfo.PsnName,
  14653. Idetinfo: idetinfoStr,
  14654. Insuinfo: infoStr,
  14655. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14656. CardInfo: card_info,
  14657. VerifyNumber: token,
  14658. }
  14659. service.CreateHisPsn(psn)
  14660. c.ServeSuccessJSON(map[string]interface{}{
  14661. "patient": patient,
  14662. "number": token,
  14663. })
  14664. }
  14665. }
  14666. } else {
  14667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14668. return
  14669. }
  14670. } else { //读卡失败
  14671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14672. return
  14673. }
  14674. } else {
  14675. if initFlag == 0 {
  14676. c.TestGetBasBaseInit()
  14677. }
  14678. basStr := c.GetBasBaseInfo()
  14679. if len(basStr) == 0 {
  14680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14681. return
  14682. }
  14683. fmt.Println(basStr)
  14684. bas := strings.Split(basStr, "|")
  14685. basNumber := bas[1]
  14686. fmt.Println(basNumber)
  14687. card_sn := bas[3]
  14688. fmt.Println(card_sn)
  14689. cardNumber := bas[2]
  14690. fmt.Println(cardNumber)
  14691. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14692. var result string
  14693. if bas[0][:2] == "44" {
  14694. 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)
  14695. } else {
  14696. 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)
  14697. }
  14698. var dat map[string]interface{}
  14699. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14700. fmt.Println(dat)
  14701. } else {
  14702. fmt.Println(err)
  14703. }
  14704. userJSONBytes, _ := json.Marshal(dat)
  14705. var res ResultTwo
  14706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14707. utils.ErrorLog("解析失败:%v", err)
  14708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14709. return
  14710. }
  14711. if res.Infcode == 0 {
  14712. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14713. if err == gorm.ErrRecordNotFound {
  14714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14715. return
  14716. } else if err != nil {
  14717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14718. return
  14719. } else {
  14720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14722. infoStr := string(Iinfos)
  14723. idetinfoStr := string(Idetinfos)
  14724. var rf []*ResultFive
  14725. json.Unmarshal([]byte(infoStr), &rf)
  14726. var insutypes []*ResultFive
  14727. var insutype string
  14728. var is390 int = 0
  14729. var is310 int = 0
  14730. var insuplc_admdvs string
  14731. for _, item := range rf {
  14732. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14733. insutypes = append(insutypes, item)
  14734. }
  14735. }
  14736. if len(insutypes) == 1 {
  14737. insutype = insutypes[0].Insutype
  14738. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14739. } else {
  14740. for _, i := range insutypes {
  14741. if i.Insutype == "390" {
  14742. is390 = 1
  14743. }
  14744. if i.Insutype == "310" {
  14745. is310 = 1
  14746. }
  14747. }
  14748. }
  14749. if is390 == 1 {
  14750. insutype = "390"
  14751. }
  14752. if is310 == 1 {
  14753. insutype = "310"
  14754. }
  14755. if len(insutypes) == 0 {
  14756. insutype = "310"
  14757. }
  14758. for _, item := range rf {
  14759. if item.Insutype == insutype {
  14760. insuplc_admdvs = item.InsuplcAdmdvs
  14761. }
  14762. }
  14763. psn := &models.HisPsn{
  14764. PsnNo: res.Output.Baseinfo.PsnNo,
  14765. PatientId: patient.ID,
  14766. Certno: res.Output.Baseinfo.Certno,
  14767. Gend: res.Output.Baseinfo.Gend,
  14768. Naty: res.Output.Baseinfo.Naty,
  14769. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14770. PsnName: res.Output.Baseinfo.PsnName,
  14771. Idetinfo: idetinfoStr,
  14772. Insuinfo: infoStr,
  14773. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14774. CardInfo: basStr,
  14775. VerifyNumber: "",
  14776. InsuplcAdmdvs: insuplc_admdvs,
  14777. }
  14778. service.CreateHisPsn(psn)
  14779. c.ServeSuccessJSON(map[string]interface{}{
  14780. "patient": patient,
  14781. "number": basNumber,
  14782. })
  14783. }
  14784. } else {
  14785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14786. return
  14787. }
  14788. break
  14789. }
  14790. case 2:
  14791. if miConfig.MdtrtareaAdmvs == "430800" {
  14792. if initFlag == 0 {
  14793. c.TestGetHnBasBaseInit()
  14794. }
  14795. SFZStr := c.GetSFZBaseInfo()
  14796. if len(SFZStr) == 0 {
  14797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14798. return
  14799. }
  14800. fmt.Println(SFZStr)
  14801. id_card_str := strings.Split(SFZStr, "^")
  14802. card_no := id_card_str[0]
  14803. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14804. //name := id_card_str[1]
  14805. //name = ConvertToString(name, "gbk", "utf-8")
  14806. 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)
  14807. var dat map[string]interface{}
  14808. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14809. fmt.Println(dat)
  14810. } else {
  14811. fmt.Println(err)
  14812. }
  14813. userJSONBytes, _ := json.Marshal(dat)
  14814. var res ResultTwo
  14815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14816. utils.ErrorLog("解析失败:%v", err)
  14817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14818. return
  14819. }
  14820. if res.Infcode == 0 {
  14821. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14822. if err == gorm.ErrRecordNotFound {
  14823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14824. return
  14825. } else if err != nil {
  14826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14827. return
  14828. } else {
  14829. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14830. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14831. infoStr := string(Iinfos)
  14832. idetinfoStr := string(Idetinfos)
  14833. var rf []*ResultFive
  14834. json.Unmarshal([]byte(infoStr), &rf)
  14835. var insutypes []*ResultFive
  14836. var insutype string
  14837. var is390 int = 0
  14838. var is310 int = 0
  14839. for _, item := range rf {
  14840. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14841. insutypes = append(insutypes, item)
  14842. }
  14843. }
  14844. if len(insutypes) == 1 {
  14845. insutype = insutypes[0].Insutype
  14846. } else {
  14847. for _, i := range insutypes {
  14848. if i.Insutype == "390" {
  14849. is390 = 1
  14850. }
  14851. if i.Insutype == "310" {
  14852. is310 = 1
  14853. }
  14854. }
  14855. }
  14856. if is390 == 1 {
  14857. insutype = "390"
  14858. }
  14859. if is310 == 1 {
  14860. insutype = "310"
  14861. }
  14862. if len(insutypes) == 0 {
  14863. insutype = "310"
  14864. }
  14865. var InsuplcAdmdvs string
  14866. for _, item := range rf {
  14867. if item.Insutype == insutype {
  14868. InsuplcAdmdvs = item.InsuplcAdmdvs
  14869. }
  14870. }
  14871. psn := &models.HisPsn{
  14872. PsnNo: res.Output.Baseinfo.PsnNo,
  14873. PatientId: patient.ID,
  14874. Certno: res.Output.Baseinfo.Certno,
  14875. Gend: res.Output.Baseinfo.Gend,
  14876. Naty: res.Output.Baseinfo.Naty,
  14877. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14878. PsnName: res.Output.Baseinfo.PsnName,
  14879. Idetinfo: idetinfoStr,
  14880. Insuinfo: infoStr,
  14881. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14882. CardInfo: SFZStr,
  14883. VerifyNumber: "",
  14884. InsuplcAdmdvs: InsuplcAdmdvs,
  14885. }
  14886. service.CreateHisPsn(psn)
  14887. c.ServeSuccessJSON(map[string]interface{}{
  14888. "patient": patient,
  14889. "number": card_no,
  14890. "insutype": insutype,
  14891. })
  14892. }
  14893. } else {
  14894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14895. return
  14896. }
  14897. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14898. var res ResultTwo
  14899. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14900. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14901. "&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)
  14902. resp, requestErr := http.Get(api)
  14903. if requestErr != nil {
  14904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14905. return
  14906. }
  14907. body, ioErr := ioutil.ReadAll(resp.Body)
  14908. if ioErr != nil {
  14909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14911. return
  14912. }
  14913. var respJSON map[string]interface{}
  14914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14917. return
  14918. }
  14919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14920. result, _ := json.Marshal(respJSON)
  14921. fmt.Println("log")
  14922. fmt.Println(string(result))
  14923. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14924. utils.ErrorLog("解析失败:%v", err)
  14925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14926. return
  14927. }
  14928. if res.Infcode == 0 {
  14929. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14930. if err == gorm.ErrRecordNotFound {
  14931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14932. return
  14933. } else if err != nil {
  14934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14935. return
  14936. } else {
  14937. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14938. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14939. infoStr := string(Iinfos)
  14940. idetinfoStr := string(Idetinfos)
  14941. psn := &models.HisPsn{
  14942. PsnNo: res.Output.Baseinfo.PsnNo,
  14943. PatientId: patient.ID,
  14944. Certno: res.Output.Baseinfo.Certno,
  14945. Gend: res.Output.Baseinfo.Gend,
  14946. Naty: res.Output.Baseinfo.Naty,
  14947. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14948. PsnName: res.Output.Baseinfo.PsnName,
  14949. Idetinfo: idetinfoStr,
  14950. Insuinfo: infoStr,
  14951. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14952. }
  14953. service.CreateHisPsn(psn)
  14954. c.ServeSuccessJSON(map[string]interface{}{
  14955. "patient": patient,
  14956. "number": res.Output.Baseinfo.Certno,
  14957. })
  14958. }
  14959. } else {
  14960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14961. return
  14962. }
  14963. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14964. var res ResultTwo
  14965. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14966. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14967. "&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)
  14968. resp, requestErr := http.Get(api)
  14969. if requestErr != nil {
  14970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14971. return
  14972. }
  14973. body, ioErr := ioutil.ReadAll(resp.Body)
  14974. if ioErr != nil {
  14975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14977. return
  14978. }
  14979. var respJSON map[string]interface{}
  14980. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14983. return
  14984. }
  14985. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14986. result, _ := json.Marshal(respJSON)
  14987. fmt.Println("log")
  14988. fmt.Println(string(result))
  14989. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14990. utils.ErrorLog("解析失败:%v", err)
  14991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14992. return
  14993. }
  14994. if res.Infcode == 0 {
  14995. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14996. if err == gorm.ErrRecordNotFound {
  14997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14998. return
  14999. } else if err != nil {
  15000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15001. return
  15002. } else {
  15003. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15004. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15005. infoStr := string(Iinfos)
  15006. idetinfoStr := string(Idetinfos)
  15007. psn := &models.HisPsn{
  15008. PsnNo: res.Output.Baseinfo.PsnNo,
  15009. PatientId: patient.ID,
  15010. Certno: res.Output.Baseinfo.Certno,
  15011. Gend: res.Output.Baseinfo.Gend,
  15012. Naty: res.Output.Baseinfo.Naty,
  15013. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15014. PsnName: res.Output.Baseinfo.PsnName,
  15015. Idetinfo: idetinfoStr,
  15016. Insuinfo: infoStr,
  15017. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15018. }
  15019. service.CreateHisPsn(psn)
  15020. c.ServeSuccessJSON(map[string]interface{}{
  15021. "patient": patient,
  15022. "number": res.Output.Baseinfo.Certno,
  15023. })
  15024. }
  15025. } else {
  15026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15027. return
  15028. }
  15029. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15030. var res ResultTwo
  15031. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15032. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15033. "&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)
  15034. resp, requestErr := http.Get(api)
  15035. if requestErr != nil {
  15036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15037. return
  15038. }
  15039. body, ioErr := ioutil.ReadAll(resp.Body)
  15040. if ioErr != nil {
  15041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15043. return
  15044. }
  15045. var respJSON map[string]interface{}
  15046. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15049. return
  15050. }
  15051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15052. result, _ := json.Marshal(respJSON)
  15053. fmt.Println("log")
  15054. fmt.Println(string(result))
  15055. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15056. utils.ErrorLog("解析失败:%v", err)
  15057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15058. return
  15059. }
  15060. if res.Infcode == 0 {
  15061. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15062. if err == gorm.ErrRecordNotFound {
  15063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15064. return
  15065. } else if err != nil {
  15066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15067. return
  15068. } else {
  15069. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15070. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15071. infoStr := string(Iinfos)
  15072. idetinfoStr := string(Idetinfos)
  15073. var rf []*ResultFive
  15074. json.Unmarshal([]byte(infoStr), &rf)
  15075. var insutypes []*ResultFive
  15076. var insutype string
  15077. var is390 int = 0
  15078. var is310 int = 0
  15079. for _, item := range rf {
  15080. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15081. insutypes = append(insutypes, item)
  15082. }
  15083. }
  15084. if len(insutypes) == 1 {
  15085. insutype = insutypes[0].Insutype
  15086. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15087. } else {
  15088. for _, i := range insutypes {
  15089. if i.Insutype == "390" {
  15090. is390 = 1
  15091. }
  15092. if i.Insutype == "310" {
  15093. is310 = 1
  15094. }
  15095. }
  15096. }
  15097. if is390 == 1 {
  15098. insutype = "390"
  15099. }
  15100. if is310 == 1 {
  15101. insutype = "310"
  15102. }
  15103. if len(insutypes) == 0 {
  15104. insutype = "390"
  15105. }
  15106. var insuplc_admdvs string
  15107. for _, item := range rf {
  15108. if item.Insutype == insutype {
  15109. insuplc_admdvs = item.InsuplcAdmdvs
  15110. }
  15111. }
  15112. psn := &models.HisPsn{
  15113. PsnNo: res.Output.Baseinfo.PsnNo,
  15114. PatientId: patient.ID,
  15115. Certno: res.Output.Baseinfo.Certno,
  15116. Gend: res.Output.Baseinfo.Gend,
  15117. Naty: res.Output.Baseinfo.Naty,
  15118. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15119. PsnName: res.Output.Baseinfo.PsnName,
  15120. Idetinfo: idetinfoStr,
  15121. Insuinfo: infoStr,
  15122. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15123. InsuplcAdmdvs: insuplc_admdvs,
  15124. }
  15125. service.CreateHisPsn(psn)
  15126. c.ServeSuccessJSON(map[string]interface{}{
  15127. "patient": patient,
  15128. "number": res.Output.Baseinfo.Certno,
  15129. })
  15130. }
  15131. } else {
  15132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15133. return
  15134. }
  15135. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15136. res := c.GetoleInfo()
  15137. if res.Infcode == 0 {
  15138. var result string
  15139. if res.Output.MdtrtCertType == "01" {
  15140. 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)
  15141. } else if res.Output.MdtrtCertType == "02" {
  15142. 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)
  15143. } else if res.Output.MdtrtCertType == "03" {
  15144. 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)
  15145. }
  15146. var dat map[string]interface{}
  15147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15148. fmt.Println(dat)
  15149. } else {
  15150. fmt.Println(err)
  15151. }
  15152. userJSONBytes, _ := json.Marshal(dat)
  15153. var res2 ResultTwo
  15154. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15155. utils.ErrorLog("解析失败:%v", err)
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15157. return
  15158. }
  15159. if res2.Infcode == 0 {
  15160. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15161. if err == gorm.ErrRecordNotFound {
  15162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15163. return
  15164. } else if err != nil {
  15165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15166. return
  15167. } else {
  15168. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15169. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15170. infoStr := string(Iinfos)
  15171. idetinfoStr := string(Idetinfos)
  15172. var rf []*ResultFive
  15173. json.Unmarshal([]byte(infoStr), &rf)
  15174. var insutypes []*ResultFive
  15175. var insutype string
  15176. var is390 int = 0
  15177. var is310 int = 0
  15178. //var insuplc_admdvs string
  15179. for _, item := range rf {
  15180. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15181. insutypes = append(insutypes, item)
  15182. }
  15183. }
  15184. if len(insutypes) == 1 {
  15185. insutype = insutypes[0].Insutype
  15186. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15187. } else {
  15188. for _, i := range insutypes {
  15189. if i.Insutype == "390" {
  15190. is390 = 1
  15191. }
  15192. if i.Insutype == "310" {
  15193. is310 = 1
  15194. }
  15195. }
  15196. }
  15197. if is390 == 1 {
  15198. insutype = "390"
  15199. }
  15200. if is310 == 1 {
  15201. insutype = "310"
  15202. }
  15203. if len(insutypes) == 0 {
  15204. insutype = "310"
  15205. }
  15206. psn := &models.HisPsn{
  15207. PsnNo: res2.Output.Baseinfo.PsnNo,
  15208. PatientId: patient.ID,
  15209. //Brdy: res2.Output.Baseinfo.Brdy,
  15210. Certno: res2.Output.Baseinfo.Certno,
  15211. Gend: res2.Output.Baseinfo.Gend,
  15212. Naty: res2.Output.Baseinfo.Naty,
  15213. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15214. PsnName: res2.Output.Baseinfo.PsnName,
  15215. Idetinfo: idetinfoStr,
  15216. Insuinfo: infoStr,
  15217. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15218. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15219. VerifyNumber: res.Output.EcToken,
  15220. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15221. }
  15222. service.CreateHisPsn(psn)
  15223. var balc float64
  15224. for _, item := range rf {
  15225. if item.Insutype == insutype {
  15226. balc = item.Balc
  15227. }
  15228. }
  15229. c.ServeSuccessJSON(map[string]interface{}{
  15230. "patient": patient,
  15231. "number": res.Output.CardNo,
  15232. "insutype": insutype,
  15233. "blac": balc,
  15234. "desc": idetinfoStr,
  15235. })
  15236. }
  15237. } else {
  15238. c.ServeSuccessJSON(map[string]interface{}{
  15239. "failed_code": -10,
  15240. "msg": res2.ErrMsg,
  15241. })
  15242. }
  15243. } else {
  15244. c.ServeSuccessJSON(map[string]interface{}{
  15245. "failed_code": -10,
  15246. "msg": res.ErrMsg,
  15247. })
  15248. }
  15249. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15250. var insuplc_admdvs string
  15251. if len(patient.InsuplcAdmdvs) > 0 {
  15252. insuplc_admdvs = patient.InsuplcAdmdvs
  15253. } else {
  15254. if len(insuplc_admdvs_str) > 0{
  15255. insuplc_admdvs = insuplc_admdvs_str
  15256. }else{
  15257. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15258. }
  15259. }
  15260. //请求内网数据
  15261. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15262. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15263. "&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="+""
  15264. resp, requestErr := http.Get(api)
  15265. if requestErr != nil {
  15266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15267. return
  15268. }
  15269. body, ioErr := ioutil.ReadAll(resp.Body)
  15270. if ioErr != nil {
  15271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15273. return
  15274. }
  15275. var respJSON map[string]interface{}
  15276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15279. return
  15280. }
  15281. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15282. if status == "0"{
  15283. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15284. c.ServeSuccessJSON(map[string]interface{}{
  15285. "failed_code": -10,
  15286. "msg": err_msg,
  15287. })
  15288. return
  15289. }
  15290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15291. var res ResultTwo
  15292. result, _ := json.Marshal(respJSON)
  15293. fmt.Println("log")
  15294. fmt.Println(string(result))
  15295. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15296. utils.ErrorLog("解析失败:%v", err)
  15297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15298. return
  15299. }
  15300. if res.Infcode == 0 {
  15301. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15302. if err == gorm.ErrRecordNotFound {
  15303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15304. return
  15305. } else if err != nil {
  15306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15307. return
  15308. } else {
  15309. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15310. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15311. infoStr := string(Iinfos)
  15312. idetinfoStr := string(Idetinfos)
  15313. psn := &models.HisPsn{
  15314. PsnNo: res.Output.Baseinfo.PsnNo,
  15315. PatientId: patient.ID,
  15316. Certno: res.Output.Baseinfo.Certno,
  15317. Gend: res.Output.Baseinfo.Gend,
  15318. Naty: res.Output.Baseinfo.Naty,
  15319. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15320. PsnName: res.Output.Baseinfo.PsnName,
  15321. Idetinfo: idetinfoStr,
  15322. Insuinfo: infoStr,
  15323. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15324. }
  15325. service.CreateHisPsn(psn)
  15326. var rf []*ResultFive
  15327. json.Unmarshal([]byte(infoStr), &rf)
  15328. var insutypes []*ResultFive
  15329. var is390 int = 0
  15330. var is310 int = 0
  15331. var insutype string
  15332. for _, item := range rf {
  15333. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15334. insutypes = append(insutypes, item)
  15335. }
  15336. }
  15337. if len(insutypes) == 1 {
  15338. insutype = insutypes[0].Insutype
  15339. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15340. } else {
  15341. for _, i := range insutypes {
  15342. if i.Insutype == "390" {
  15343. is390 = 1
  15344. }
  15345. if i.Insutype == "310" {
  15346. is310 = 1
  15347. }
  15348. }
  15349. }
  15350. if is390 == 1 {
  15351. insutype = "390"
  15352. }
  15353. if is310 == 1 {
  15354. insutype = "310"
  15355. }
  15356. if len(insutypes) == 0 {
  15357. insutype = "390"
  15358. }
  15359. c.ServeSuccessJSON(map[string]interface{}{
  15360. "patient": patient,
  15361. "insutype": insutype,
  15362. "number": res.Output.Baseinfo.Certno,
  15363. "info": res,
  15364. })
  15365. }
  15366. } else {
  15367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15368. return
  15369. }
  15370. }else {
  15371. SFZStr := c.GetSFZBaseInfo()
  15372. id_card_str := strings.Split(SFZStr, "^")
  15373. id_card_number := id_card_str[0]
  15374. card_sn := ""
  15375. 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)
  15376. var dat map[string]interface{}
  15377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15378. fmt.Println(dat)
  15379. } else {
  15380. fmt.Println(err)
  15381. }
  15382. userJSONBytes, _ := json.Marshal(dat)
  15383. var res ResultTwo
  15384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15385. utils.ErrorLog("解析失败:%v", err)
  15386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15387. return
  15388. }
  15389. if res.Infcode == 0 {
  15390. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15391. if err == gorm.ErrRecordNotFound {
  15392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15393. return
  15394. } else if err != nil {
  15395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15396. return
  15397. } else {
  15398. c.ServeSuccessJSON(map[string]interface{}{
  15399. "patient": patient,
  15400. "number": id_card_number,
  15401. })
  15402. }
  15403. } else {
  15404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15405. return
  15406. }
  15407. }
  15408. break
  15409. case 3:
  15410. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15411. var api string
  15412. if miConfig.MdtrtareaAdmvs == "320921" {
  15413. 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 +
  15414. "&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
  15415. fmt.Println(api)
  15416. } else {
  15417. 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 +
  15418. "&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)
  15419. }
  15420. resp, requestErr := http.Get(api)
  15421. if requestErr != nil {
  15422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15423. return
  15424. }
  15425. body, ioErr := ioutil.ReadAll(resp.Body)
  15426. if ioErr != nil {
  15427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15429. return
  15430. }
  15431. var respJSON map[string]interface{}
  15432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15435. return
  15436. }
  15437. var status string
  15438. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15439. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15440. var token string
  15441. var res ResultTwo //1101结果
  15442. var res10265 ResultTwo10265 //1101结果
  15443. var card_info string //卡信息
  15444. var busi_card_info string
  15445. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15446. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15447. if status == "0" { //读卡成功
  15448. if card_type == "1" {
  15449. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15450. result, _ := json.Marshal(respJSON)
  15451. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15452. utils.ErrorLog("解析失败:%v", err)
  15453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15454. return
  15455. }
  15456. res.ErrMsg = res10265.ErrMsg
  15457. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15458. res.Infcode = infocode
  15459. res.Output = res10265.Output
  15460. res.InfRefmsgid = res10265.InfRefmsgid
  15461. } else {
  15462. //var card_info string //卡信息
  15463. //var busi_card_info string
  15464. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15465. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15466. //fmt.Println(card_info)
  15467. //fmt.Println(busi_card_info)
  15468. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15469. result, _ := json.Marshal(respJSON)
  15470. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15471. utils.ErrorLog("解析失败:%v", err)
  15472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15473. return
  15474. }
  15475. res.ErrMsg = res10265.ErrMsg
  15476. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15477. res.Infcode = infocode
  15478. res.Output = res10265.Output
  15479. res.InfRefmsgid = res10265.InfRefmsgid
  15480. }
  15481. if res.Infcode == 0 {
  15482. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15483. if err == gorm.ErrRecordNotFound {
  15484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15485. return
  15486. } else if err != nil {
  15487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15488. return
  15489. } else {
  15490. if card_type == "1" {
  15491. bas := strings.Split(card_info, "|")
  15492. basNumber := bas[2]
  15493. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15494. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15495. infoStr := string(Iinfos)
  15496. idetinfoStr := string(Idetinfos)
  15497. psn := &models.HisPsn{
  15498. PsnNo: res.Output.Baseinfo.PsnNo,
  15499. PatientId: patient.ID,
  15500. Certno: res.Output.Baseinfo.Certno,
  15501. //Brdy: res.Output.Baseinfo.Brdy,
  15502. Gend: res.Output.Baseinfo.Gend,
  15503. Naty: res.Output.Baseinfo.Naty,
  15504. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15505. PsnName: res.Output.Baseinfo.PsnName,
  15506. Idetinfo: idetinfoStr,
  15507. Insuinfo: infoStr,
  15508. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15509. CardInfo: card_info,
  15510. VerifyNumber: busi_card_info,
  15511. }
  15512. service.CreateHisPsn(psn)
  15513. c.ServeSuccessJSON(map[string]interface{}{
  15514. "patient": patient,
  15515. "number": basNumber,
  15516. })
  15517. } else {
  15518. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15519. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15520. infoStr := string(Iinfos)
  15521. idetinfoStr := string(Idetinfos)
  15522. psn := &models.HisPsn{
  15523. PsnNo: res.Output.Baseinfo.PsnNo,
  15524. PatientId: patient.ID,
  15525. Certno: res.Output.Baseinfo.Certno,
  15526. Gend: res.Output.Baseinfo.Gend,
  15527. Naty: res.Output.Baseinfo.Naty,
  15528. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15529. PsnName: res.Output.Baseinfo.PsnName,
  15530. Idetinfo: idetinfoStr,
  15531. Insuinfo: infoStr,
  15532. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15533. CardInfo: card_info,
  15534. VerifyNumber: token,
  15535. }
  15536. service.CreateHisPsn(psn)
  15537. var rf []*ResultFive
  15538. json.Unmarshal([]byte(infoStr), &rf)
  15539. var insutypes []*ResultFive
  15540. var insutype string
  15541. var is390 int = 0
  15542. var is310 int = 0
  15543. for _, item := range rf {
  15544. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15545. insutypes = append(insutypes, item)
  15546. }
  15547. }
  15548. if len(insutypes) == 1 {
  15549. insutype = insutypes[0].Insutype
  15550. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15551. } else {
  15552. for _, i := range insutypes {
  15553. if i.Insutype == "390" {
  15554. is390 = 1
  15555. }
  15556. if i.Insutype == "310" {
  15557. is310 = 1
  15558. }
  15559. }
  15560. }
  15561. if is390 == 1 {
  15562. insutype = "390"
  15563. }
  15564. if is310 == 1 {
  15565. insutype = "310"
  15566. }
  15567. if len(insutypes) == 0 {
  15568. insutype = "310"
  15569. }
  15570. c.ServeSuccessJSON(map[string]interface{}{
  15571. "patient": patient,
  15572. "number": token,
  15573. "insutype": insutype,
  15574. })
  15575. }
  15576. }
  15577. } else {
  15578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15579. return
  15580. }
  15581. } else { //读卡失败
  15582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15583. return
  15584. }
  15585. }
  15586. break
  15587. case 4:
  15588. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15589. var api string
  15590. if miConfig.MdtrtareaAdmvs == "320921" {
  15591. 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 +
  15592. "&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
  15593. fmt.Println(api)
  15594. } else {
  15595. 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 +
  15596. "&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)
  15597. }
  15598. resp, requestErr := http.Get(api)
  15599. if requestErr != nil {
  15600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15601. return
  15602. }
  15603. body, ioErr := ioutil.ReadAll(resp.Body)
  15604. if ioErr != nil {
  15605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15607. return
  15608. }
  15609. var respJSON map[string]interface{}
  15610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15613. return
  15614. }
  15615. var status string
  15616. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15617. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15618. var token string
  15619. var res ResultTwo //1101结果
  15620. var res10265 ResultTwo10265 //1101结果
  15621. if status == "0" { //读卡成功
  15622. var card_info string //卡信息
  15623. var busi_card_info string
  15624. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15625. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15626. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15627. fmt.Println(card_info)
  15628. fmt.Println(busi_card_info)
  15629. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15630. result, _ := json.Marshal(respJSON)
  15631. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15632. utils.ErrorLog("解析失败:%v", err)
  15633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15634. return
  15635. }
  15636. res.ErrMsg = res10265.ErrMsg
  15637. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15638. res.Infcode = infocode
  15639. res.Output = res10265.Output
  15640. res.InfRefmsgid = res10265.InfRefmsgid
  15641. if res.Infcode == 0 {
  15642. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15643. if err == gorm.ErrRecordNotFound {
  15644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15645. return
  15646. } else if err != nil {
  15647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15648. return
  15649. } else {
  15650. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15651. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15652. infoStr := string(Iinfos)
  15653. idetinfoStr := string(Idetinfos)
  15654. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15655. psn := &models.HisPsn{
  15656. PsnNo: res.Output.Baseinfo.PsnNo,
  15657. PatientId: patient.ID,
  15658. Certno: res.Output.Baseinfo.Certno,
  15659. Brdy: b,
  15660. Age: float64(age),
  15661. //Brdy: res.Output.Baseinfo.Brdy,
  15662. Gend: res.Output.Baseinfo.Gend,
  15663. Naty: res.Output.Baseinfo.Naty,
  15664. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15665. PsnName: res.Output.Baseinfo.PsnName,
  15666. Idetinfo: idetinfoStr,
  15667. Insuinfo: infoStr,
  15668. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15669. CardInfo: card_info,
  15670. VerifyNumber: token,
  15671. }
  15672. var rf []*ResultFive
  15673. json.Unmarshal([]byte(infoStr), &rf)
  15674. var insutypes []*ResultFive
  15675. var insutype string
  15676. var is390 int = 0
  15677. var is310 int = 0
  15678. for _, item := range rf {
  15679. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15680. insutypes = append(insutypes, item)
  15681. }
  15682. }
  15683. if len(insutypes) == 1 {
  15684. insutype = insutypes[0].Insutype
  15685. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15686. } else {
  15687. for _, i := range insutypes {
  15688. if i.Insutype == "390" {
  15689. is390 = 1
  15690. }
  15691. if i.Insutype == "310" {
  15692. is310 = 1
  15693. }
  15694. }
  15695. }
  15696. if is390 == 1 {
  15697. insutype = "390"
  15698. }
  15699. if is310 == 1 {
  15700. insutype = "310"
  15701. }
  15702. if len(insutypes) == 0 {
  15703. insutype = "310"
  15704. }
  15705. service.CreateHisPsn(psn)
  15706. c.ServeSuccessJSON(map[string]interface{}{
  15707. "patient": patient,
  15708. "number": token,
  15709. "insutype": insutype,
  15710. })
  15711. }
  15712. } else {
  15713. c.ServeSuccessJSON(map[string]interface{}{
  15714. "failed_code": -10,
  15715. "msg": res.ErrMsg,
  15716. })
  15717. }
  15718. } else { //读卡失败
  15719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15720. return
  15721. }
  15722. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15723. var api string
  15724. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15725. "&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
  15726. resp, requestErr := http.Get(api)
  15727. if requestErr != nil {
  15728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15729. return
  15730. }
  15731. body, ioErr := ioutil.ReadAll(resp.Body)
  15732. if ioErr != nil {
  15733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15735. return
  15736. }
  15737. var respJSON map[string]interface{}
  15738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15741. return
  15742. }
  15743. var status string
  15744. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15745. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15746. var token string
  15747. var res ResultTwo //1101结果
  15748. if status == "1" { //读卡成功
  15749. var card_info string //卡信息
  15750. var busi_card_info string
  15751. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15752. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15753. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15754. fmt.Println(card_info)
  15755. fmt.Println(busi_card_info)
  15756. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15757. result, _ := json.Marshal(respJSON)
  15758. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15759. utils.ErrorLog("解析失败:%v", err)
  15760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15761. return
  15762. }
  15763. if res.Infcode == 0 {
  15764. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15765. if err == gorm.ErrRecordNotFound {
  15766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15767. return
  15768. } else if err != nil {
  15769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15770. return
  15771. } else {
  15772. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15773. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15774. infoStr := string(Iinfos)
  15775. idetinfoStr := string(Idetinfos)
  15776. psn := &models.HisPsn{
  15777. PsnNo: res.Output.Baseinfo.PsnNo,
  15778. PatientId: patient.ID,
  15779. Certno: res.Output.Baseinfo.Certno,
  15780. Gend: res.Output.Baseinfo.Gend,
  15781. Naty: res.Output.Baseinfo.Naty,
  15782. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15783. PsnName: res.Output.Baseinfo.PsnName,
  15784. Idetinfo: idetinfoStr,
  15785. Insuinfo: infoStr,
  15786. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15787. CardInfo: card_info,
  15788. VerifyNumber: token,
  15789. }
  15790. var rf []*ResultFive
  15791. json.Unmarshal([]byte(infoStr), &rf)
  15792. var insutypes []*ResultFive
  15793. var insutype string
  15794. var is390 int = 0
  15795. var is310 int = 0
  15796. for _, item := range rf {
  15797. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15798. insutypes = append(insutypes, item)
  15799. }
  15800. }
  15801. if len(insutypes) == 1 {
  15802. insutype = insutypes[0].Insutype
  15803. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15804. } else {
  15805. for _, i := range insutypes {
  15806. if i.Insutype == "390" {
  15807. is390 = 1
  15808. }
  15809. if i.Insutype == "310" {
  15810. is310 = 1
  15811. }
  15812. }
  15813. }
  15814. if is390 == 1 {
  15815. insutype = "390"
  15816. }
  15817. if is310 == 1 {
  15818. insutype = "310"
  15819. }
  15820. if len(insutypes) == 0 {
  15821. insutype = "310"
  15822. }
  15823. service.CreateHisPsn(psn)
  15824. c.ServeSuccessJSON(map[string]interface{}{
  15825. "patient": patient,
  15826. "number": token,
  15827. "insutype": insutype,
  15828. })
  15829. }
  15830. } else {
  15831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15832. return
  15833. }
  15834. } else { //读卡失败
  15835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15836. return
  15837. }
  15838. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15839. var api string
  15840. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15841. "&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
  15842. resp, requestErr := http.Get(api)
  15843. if requestErr != nil {
  15844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15845. return
  15846. }
  15847. body, ioErr := ioutil.ReadAll(resp.Body)
  15848. if ioErr != nil {
  15849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15851. return
  15852. }
  15853. var respJSON map[string]interface{}
  15854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15857. return
  15858. }
  15859. var status string
  15860. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15861. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15862. var token string
  15863. var res ResultTwo //1101结果
  15864. if status == "1" { //读卡成功
  15865. var card_info string //卡信息
  15866. var busi_card_info string
  15867. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15868. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15869. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15870. fmt.Println(card_info)
  15871. fmt.Println(busi_card_info)
  15872. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15873. result, _ := json.Marshal(respJSON)
  15874. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15875. utils.ErrorLog("解析失败:%v", err)
  15876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15877. return
  15878. }
  15879. if res.Infcode == 0 {
  15880. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15881. if err == gorm.ErrRecordNotFound {
  15882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15883. return
  15884. } else if err != nil {
  15885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15886. return
  15887. } else {
  15888. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15889. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15890. infoStr := string(Iinfos)
  15891. idetinfoStr := string(Idetinfos)
  15892. psn := &models.HisPsn{
  15893. PsnNo: res.Output.Baseinfo.PsnNo,
  15894. PatientId: patient.ID,
  15895. Certno: res.Output.Baseinfo.Certno,
  15896. Gend: res.Output.Baseinfo.Gend,
  15897. Naty: res.Output.Baseinfo.Naty,
  15898. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15899. PsnName: res.Output.Baseinfo.PsnName,
  15900. Idetinfo: idetinfoStr,
  15901. Insuinfo: infoStr,
  15902. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15903. CardInfo: card_info,
  15904. VerifyNumber: token,
  15905. }
  15906. var rf []*ResultFive
  15907. json.Unmarshal([]byte(infoStr), &rf)
  15908. var insutypes []*ResultFive
  15909. var insutype string
  15910. var is390 int = 0
  15911. var is310 int = 0
  15912. for _, item := range rf {
  15913. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15914. insutypes = append(insutypes, item)
  15915. }
  15916. }
  15917. if len(insutypes) == 1 {
  15918. insutype = insutypes[0].Insutype
  15919. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15920. } else {
  15921. for _, i := range insutypes {
  15922. if i.Insutype == "390" {
  15923. is390 = 1
  15924. }
  15925. if i.Insutype == "310" {
  15926. is310 = 1
  15927. }
  15928. }
  15929. }
  15930. if is390 == 1 {
  15931. insutype = "390"
  15932. }
  15933. if is310 == 1 {
  15934. insutype = "310"
  15935. }
  15936. if len(insutypes) == 0 {
  15937. insutype = "310"
  15938. }
  15939. service.CreateHisPsn(psn)
  15940. c.ServeSuccessJSON(map[string]interface{}{
  15941. "patient": patient,
  15942. "number": token,
  15943. "insutype": insutype,
  15944. })
  15945. }
  15946. } else {
  15947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15948. return
  15949. }
  15950. } else { //读卡失败
  15951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15952. return
  15953. }
  15954. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15955. //idNo := c.GetString("idNo")
  15956. //userName := c.GetString("userName")
  15957. //ecToken := c.GetString("ecToken")
  15958. //insuOrg := c.GetString("insuOrg")
  15959. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15960. utils.ErrorLog("解析失败:%v", json_result)
  15961. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15962. type ELeData struct {
  15963. Data struct {
  15964. IdNo string `json:"idNo"`
  15965. IdType string `json:"idType"`
  15966. UserName string `json:"userName"`
  15967. EcToken string `json:"ecToken"`
  15968. InsuOrg string `json:"insuOrg"`
  15969. Gender string `json:"gender"`
  15970. Birthday string `json:"birthday"`
  15971. Nationality string `json:"nationality"`
  15972. Email string `json:"email"`
  15973. Extra string `json:"extra"`
  15974. } `json:"data"`
  15975. Code int `json:"code"`
  15976. Message string `json:"message"`
  15977. }
  15978. var ele ELeData
  15979. err := json.Unmarshal([]byte(json_result), &ele)
  15980. if err != nil {
  15981. utils.ErrorLog("解析失败:%v", err)
  15982. }
  15983. token := ele.Data.EcToken
  15984. token = Remove0000(token)
  15985. 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)
  15986. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15987. var res ResultTwo
  15988. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15989. utils.ErrorLog("解析失败:%v", err)
  15990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15991. return
  15992. }
  15993. if res.Infcode == 0 {
  15994. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15995. if err == gorm.ErrRecordNotFound {
  15996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15997. return
  15998. } else if err != nil {
  15999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16000. return
  16001. } else {
  16002. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16003. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16004. infoStr := string(Iinfos)
  16005. idetinfoStr := string(Idetinfos)
  16006. psn := &models.HisPsn{
  16007. PsnNo: res.Output.Baseinfo.PsnNo,
  16008. PatientId: patient.ID,
  16009. Certno: res.Output.Baseinfo.Certno,
  16010. Gend: res.Output.Baseinfo.Gend,
  16011. Naty: res.Output.Baseinfo.Naty,
  16012. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16013. PsnName: res.Output.Baseinfo.PsnName,
  16014. Idetinfo: idetinfoStr,
  16015. Insuinfo: infoStr,
  16016. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16017. CardInfo: "",
  16018. Stage: "1",
  16019. VerifyNumber: token,
  16020. InsuplcAdmdvs: ele.Data.InsuOrg,
  16021. }
  16022. service.CreateHisPsn(psn)
  16023. var rf []*ResultFive
  16024. json.Unmarshal([]byte(infoStr), &rf)
  16025. var insutypes []*ResultFive
  16026. var insutype string
  16027. var is390 int = 0
  16028. var is310 int = 0
  16029. for _, item := range rf {
  16030. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16031. insutypes = append(insutypes, item)
  16032. }
  16033. }
  16034. if len(insutypes) == 1 {
  16035. insutype = insutypes[0].Insutype
  16036. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16037. } else {
  16038. for _, i := range insutypes {
  16039. if i.Insutype == "390" {
  16040. is390 = 1
  16041. }
  16042. if i.Insutype == "310" {
  16043. is310 = 1
  16044. }
  16045. }
  16046. }
  16047. if is390 == 1 {
  16048. insutype = "390"
  16049. }
  16050. if is310 == 1 {
  16051. insutype = "310"
  16052. }
  16053. if len(insutypes) == 0 {
  16054. insutype = "310"
  16055. }
  16056. c.ServeSuccessJSON(map[string]interface{}{
  16057. "patient": patient,
  16058. "number": token,
  16059. "insutype": insutype,
  16060. })
  16061. }
  16062. } else {
  16063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16064. return
  16065. }
  16066. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16067. //if initFlag == 0 {
  16068. //c.TestGetJiangXiBasBaseInit()
  16069. //}
  16070. //if initEleFlag == 0 {
  16071. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16072. //}
  16073. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16074. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16075. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16076. type ELeData struct {
  16077. Data struct {
  16078. IdNo string `json:"idNo"`
  16079. IdType string `json:"idType"`
  16080. UserName string `json:"userName"`
  16081. EcToken string `json:"ecToken"`
  16082. InsuOrg string `json:"insuOrg"`
  16083. Gender string `json:"gender"`
  16084. Birthday string `json:"birthday"`
  16085. Nationality string `json:"nationality"`
  16086. Email string `json:"email"`
  16087. Extra string `json:"extra"`
  16088. } `json:"data"`
  16089. Code int `json:"code"`
  16090. Message string `json:"message"`
  16091. }
  16092. var ele ELeData
  16093. err := json.Unmarshal([]byte(result), &ele)
  16094. if err != nil {
  16095. utils.ErrorLog("解析失败:%v", err)
  16096. }
  16097. token := ele.Data.EcToken
  16098. token = Remove0000(token)
  16099. 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)
  16100. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16101. var res ResultTwo
  16102. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16103. utils.ErrorLog("解析失败:%v", err)
  16104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16105. return
  16106. }
  16107. if res.Infcode == 0 {
  16108. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16109. if err == gorm.ErrRecordNotFound {
  16110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16111. return
  16112. } else if err != nil {
  16113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16114. return
  16115. } else {
  16116. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16117. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16118. infoStr := string(Iinfos)
  16119. idetinfoStr := string(Idetinfos)
  16120. psn := &models.HisPsn{
  16121. PsnNo: res.Output.Baseinfo.PsnNo,
  16122. PatientId: patient.ID,
  16123. Certno: res.Output.Baseinfo.Certno,
  16124. Gend: res.Output.Baseinfo.Gend,
  16125. Naty: res.Output.Baseinfo.Naty,
  16126. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16127. PsnName: res.Output.Baseinfo.PsnName,
  16128. Idetinfo: idetinfoStr,
  16129. Insuinfo: infoStr,
  16130. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16131. CardInfo: "",
  16132. VerifyNumber: token,
  16133. InsuplcAdmdvs: ele.Data.InsuOrg,
  16134. }
  16135. service.CreateHisPsn(psn)
  16136. var rf []*ResultFive
  16137. json.Unmarshal([]byte(infoStr), &rf)
  16138. var insutypes []*ResultFive
  16139. var insutype string
  16140. var is390 int = 0
  16141. var is310 int = 0
  16142. for _, item := range rf {
  16143. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16144. insutypes = append(insutypes, item)
  16145. }
  16146. }
  16147. if len(insutypes) == 1 {
  16148. insutype = insutypes[0].Insutype
  16149. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16150. } else {
  16151. for _, i := range insutypes {
  16152. if i.Insutype == "390" {
  16153. is390 = 1
  16154. }
  16155. if i.Insutype == "310" {
  16156. is310 = 1
  16157. }
  16158. }
  16159. }
  16160. if is390 == 1 {
  16161. insutype = "390"
  16162. }
  16163. if is310 == 1 {
  16164. insutype = "310"
  16165. }
  16166. if len(insutypes) == 0 {
  16167. insutype = "310"
  16168. }
  16169. c.ServeSuccessJSON(map[string]interface{}{
  16170. "patient": patient,
  16171. "number": token,
  16172. "insutype": insutype,
  16173. })
  16174. }
  16175. } else {
  16176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16177. return
  16178. }
  16179. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16180. //if initFlag == 0 {
  16181. //c.TestGetJiangXiBasBaseInit()
  16182. //}
  16183. //if initEleFlag == 0 {
  16184. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16185. //}
  16186. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16187. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16188. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16189. type ELeData struct {
  16190. Data struct {
  16191. IdNo string `json:"idNo"`
  16192. IdType string `json:"idType"`
  16193. UserName string `json:"userName"`
  16194. EcToken string `json:"ecToken"`
  16195. InsuOrg string `json:"insuOrg"`
  16196. Gender string `json:"gender"`
  16197. Birthday string `json:"birthday"`
  16198. Nationality string `json:"nationality"`
  16199. Email string `json:"email"`
  16200. Extra string `json:"extra"`
  16201. } `json:"data"`
  16202. Code int `json:"code"`
  16203. Message string `json:"message"`
  16204. }
  16205. var ele ELeData
  16206. err := json.Unmarshal([]byte(result), &ele)
  16207. if err != nil {
  16208. utils.ErrorLog("解析失败:%v", err)
  16209. }
  16210. token := ele.Data.EcToken
  16211. token = Remove0000(token)
  16212. 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)
  16213. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16214. var res ResultTwo
  16215. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16216. utils.ErrorLog("解析失败:%v", err)
  16217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16218. return
  16219. }
  16220. if res.Infcode == 0 {
  16221. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16222. if err == gorm.ErrRecordNotFound {
  16223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16224. return
  16225. } else if err != nil {
  16226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16227. return
  16228. } else {
  16229. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16230. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16231. infoStr := string(Iinfos)
  16232. idetinfoStr := string(Idetinfos)
  16233. psn := &models.HisPsn{
  16234. PsnNo: res.Output.Baseinfo.PsnNo,
  16235. PatientId: patient.ID,
  16236. Certno: res.Output.Baseinfo.Certno,
  16237. Gend: res.Output.Baseinfo.Gend,
  16238. Naty: res.Output.Baseinfo.Naty,
  16239. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16240. PsnName: res.Output.Baseinfo.PsnName,
  16241. Idetinfo: idetinfoStr,
  16242. Insuinfo: infoStr,
  16243. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16244. CardInfo: "",
  16245. VerifyNumber: token,
  16246. InsuplcAdmdvs: ele.Data.InsuOrg,
  16247. }
  16248. service.CreateHisPsn(psn)
  16249. var rf []*ResultFive
  16250. json.Unmarshal([]byte(infoStr), &rf)
  16251. var insutypes []*ResultFive
  16252. var insutype string
  16253. var is390 int = 0
  16254. var is310 int = 0
  16255. for _, item := range rf {
  16256. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16257. insutypes = append(insutypes, item)
  16258. }
  16259. }
  16260. if len(insutypes) == 1 {
  16261. insutype = insutypes[0].Insutype
  16262. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16263. } else {
  16264. for _, i := range insutypes {
  16265. if i.Insutype == "390" {
  16266. is390 = 1
  16267. }
  16268. if i.Insutype == "310" {
  16269. is310 = 1
  16270. }
  16271. }
  16272. }
  16273. if is390 == 1 {
  16274. insutype = "390"
  16275. }
  16276. if is310 == 1 {
  16277. insutype = "310"
  16278. }
  16279. if len(insutypes) == 0 {
  16280. insutype = "310"
  16281. }
  16282. c.ServeSuccessJSON(map[string]interface{}{
  16283. "patient": patient,
  16284. "number": token,
  16285. "insutype": insutype,
  16286. })
  16287. }
  16288. } else {
  16289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16290. return
  16291. }
  16292. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16293. //if initFlag == 0 {
  16294. c.TestGetJiangXiBasBaseInit()
  16295. //}
  16296. //if initEleFlag == 0 {
  16297. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16298. //}
  16299. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16300. type ELeData struct {
  16301. Data struct {
  16302. IdNo string `json:"idNo"`
  16303. IdType string `json:"idType"`
  16304. UserName string `json:"userName"`
  16305. EcToken string `json:"ecToken"`
  16306. InsuOrg string `json:"insuOrg"`
  16307. Gender string `json:"gender"`
  16308. Birthday string `json:"birthday"`
  16309. Nationality string `json:"nationality"`
  16310. Email string `json:"email"`
  16311. Extra string `json:"extra"`
  16312. } `json:"data"`
  16313. Code int `json:"code"`
  16314. Message string `json:"message"`
  16315. }
  16316. var ele ELeData
  16317. err := json.Unmarshal([]byte(json_result), &ele)
  16318. if err != nil {
  16319. utils.ErrorLog("解析失败:%v", err)
  16320. }
  16321. token := ele.Data.EcToken
  16322. token = Remove0000(token)
  16323. 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)
  16324. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16325. var res ResultTwo
  16326. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16327. utils.ErrorLog("解析失败:%v", err)
  16328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16329. return
  16330. }
  16331. if res.Infcode == 0 {
  16332. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16333. if err == gorm.ErrRecordNotFound {
  16334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16335. return
  16336. } else if err != nil {
  16337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16338. return
  16339. } else {
  16340. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16341. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16342. infoStr := string(Iinfos)
  16343. idetinfoStr := string(Idetinfos)
  16344. psn := &models.HisPsn{
  16345. PsnNo: res.Output.Baseinfo.PsnNo,
  16346. PatientId: patient.ID,
  16347. Certno: res.Output.Baseinfo.Certno,
  16348. Gend: res.Output.Baseinfo.Gend,
  16349. Naty: res.Output.Baseinfo.Naty,
  16350. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16351. PsnName: res.Output.Baseinfo.PsnName,
  16352. Idetinfo: idetinfoStr,
  16353. Insuinfo: infoStr,
  16354. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16355. CardInfo: "",
  16356. VerifyNumber: token,
  16357. }
  16358. service.CreateHisPsn(psn)
  16359. var rf []*ResultFive
  16360. json.Unmarshal([]byte(infoStr), &rf)
  16361. var insutypes []*ResultFive
  16362. var insutype string
  16363. var is390 int = 0
  16364. var is310 int = 0
  16365. for _, item := range rf {
  16366. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16367. insutypes = append(insutypes, item)
  16368. }
  16369. }
  16370. if len(insutypes) == 1 {
  16371. insutype = insutypes[0].Insutype
  16372. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16373. } else {
  16374. for _, i := range insutypes {
  16375. if i.Insutype == "390" {
  16376. is390 = 1
  16377. }
  16378. if i.Insutype == "310" {
  16379. is310 = 1
  16380. }
  16381. }
  16382. }
  16383. if is390 == 1 {
  16384. insutype = "390"
  16385. }
  16386. if is310 == 1 {
  16387. insutype = "310"
  16388. }
  16389. if len(insutypes) == 0 {
  16390. insutype = "310"
  16391. }
  16392. c.ServeSuccessJSON(map[string]interface{}{
  16393. "patient": patient,
  16394. "number": token,
  16395. "insutype": insutype,
  16396. })
  16397. }
  16398. } else {
  16399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16400. return
  16401. }
  16402. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16403. type ELeData struct {
  16404. Code string `json:"code"`
  16405. Data struct {
  16406. Aac002 string `json:"aac002"`
  16407. Aaz500 string `json:"aaz500"`
  16408. ActCardNo string `json:"actCardNo"`
  16409. Bab520 string `json:"bab520"`
  16410. Bkz543 string `json:"bkz543"`
  16411. BusinessType string `json:"businessType"`
  16412. CertfCodg string `json:"certfCodg"`
  16413. EcIndexNo string `json:"ecIndexNo"`
  16414. EcToken string `json:"ecToken"`
  16415. ID0000 string `json:"id0000"`
  16416. IDNo string `json:"idNo"`
  16417. IDType string `json:"idType"`
  16418. Idcode string `json:"idcode"`
  16419. IdentityToken string `json:"identity_token"`
  16420. InsuOrg string `json:"insuOrg"`
  16421. OfficeID string `json:"officeId"`
  16422. OfficeName string `json:"officeName"`
  16423. OperatorID string `json:"operatorId"`
  16424. OperatorName string `json:"operatorName"`
  16425. OrgID string `json:"orgId"`
  16426. UserName string `json:"userName"`
  16427. } `json:"data"`
  16428. Infno interface{} `json:"infno"`
  16429. Message string `json:"message"`
  16430. OrgID string `json:"orgId"`
  16431. TransType string `json:"transType"`
  16432. }
  16433. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16434. outPutInfo = Remove0000(outPutInfo)
  16435. if len(outPutInfo) > 0 {
  16436. var ele ELeData
  16437. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16438. if err != nil {
  16439. utils.ErrorLog("解析失败:%v", err)
  16440. }
  16441. token := ele.Data.EcToken
  16442. fmt.Println(inputInfo)
  16443. fmt.Println(outPutInfo)
  16444. 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)
  16445. saveLog(result, requestLog, "1101", "获取人员信息")
  16446. var dat map[string]interface{}
  16447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16448. fmt.Println(dat)
  16449. } else {
  16450. fmt.Println(err)
  16451. }
  16452. userJSONBytes, _ := json.Marshal(dat)
  16453. var res ResultTwo
  16454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16455. utils.ErrorLog("解析失败:%v", err)
  16456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16457. return
  16458. }
  16459. res.ErrMsg = errMsgLog
  16460. if res.Infcode == 0 {
  16461. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16462. if err == gorm.ErrRecordNotFound {
  16463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16464. return
  16465. } else if err != nil {
  16466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16467. return
  16468. } else {
  16469. fmt.Println(res)
  16470. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16471. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16472. infoStr := string(Iinfos)
  16473. idetinfoStr := string(Idetinfos)
  16474. psn := &models.HisPsn{
  16475. PsnNo: res.Output.Baseinfo.PsnNo,
  16476. PatientId: patient.ID,
  16477. Certno: res.Output.Baseinfo.Certno,
  16478. Gend: res.Output.Baseinfo.Gend,
  16479. Naty: res.Output.Baseinfo.Naty,
  16480. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16481. PsnName: res.Output.Baseinfo.PsnName,
  16482. Idetinfo: idetinfoStr,
  16483. Insuinfo: infoStr,
  16484. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16485. CardInfo: outPutInfo,
  16486. VerifyNumber: token,
  16487. InsuplcAdmdvs: ele.Data.InsuOrg,
  16488. }
  16489. service.CreateHisPsn(psn)
  16490. var rf []*ResultFive
  16491. json.Unmarshal([]byte(infoStr), &rf)
  16492. var insutypes []*ResultFive
  16493. var insutype string
  16494. var is390 int = 0
  16495. var is310 int = 0
  16496. for _, item := range rf {
  16497. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16498. insutypes = append(insutypes, item)
  16499. }
  16500. }
  16501. if len(insutypes) == 1 {
  16502. insutype = insutypes[0].Insutype
  16503. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16504. } else {
  16505. for _, i := range insutypes {
  16506. if i.Insutype == "390" {
  16507. is390 = 1
  16508. }
  16509. if i.Insutype == "310" {
  16510. is310 = 1
  16511. }
  16512. }
  16513. }
  16514. if is390 == 1 {
  16515. insutype = "390"
  16516. }
  16517. if is310 == 1 {
  16518. insutype = "310"
  16519. }
  16520. if len(insutypes) == 0 {
  16521. insutype = "310"
  16522. }
  16523. c.ServeSuccessJSON(map[string]interface{}{
  16524. "patient": patient,
  16525. "number": token,
  16526. "insutype": insutype,
  16527. })
  16528. }
  16529. } else {
  16530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16531. return
  16532. }
  16533. }
  16534. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16535. var api string
  16536. 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 +
  16537. "&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
  16538. resp, requestErr := http.Get(api)
  16539. if requestErr != nil {
  16540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16541. return
  16542. }
  16543. body, ioErr := ioutil.ReadAll(resp.Body)
  16544. if ioErr != nil {
  16545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16547. return
  16548. }
  16549. var respJSON map[string]interface{}
  16550. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16553. return
  16554. }
  16555. var status string
  16556. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16557. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16558. var token string
  16559. var res ResultTwo //1101结果
  16560. var res10265 ResultTwo10265 //1101结果
  16561. if status == "0" { //读卡成功
  16562. var card_info string //卡信息
  16563. var busi_card_info string
  16564. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16565. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16566. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16567. fmt.Println(card_info)
  16568. fmt.Println(busi_card_info)
  16569. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16570. result, _ := json.Marshal(respJSON)
  16571. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16572. utils.ErrorLog("解析失败:%v", err)
  16573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16574. return
  16575. }
  16576. res.ErrMsg = res10265.ErrMsg
  16577. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16578. res.Infcode = infocode
  16579. res.Output = res10265.Output
  16580. res.InfRefmsgid = res10265.InfRefmsgid
  16581. if res.Infcode == 0 {
  16582. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16583. if err == gorm.ErrRecordNotFound {
  16584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16585. return
  16586. } else if err != nil {
  16587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16588. return
  16589. } else {
  16590. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16591. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16592. infoStr := string(Iinfos)
  16593. idetinfoStr := string(Idetinfos)
  16594. psn := &models.HisPsn{
  16595. PsnNo: res.Output.Baseinfo.PsnNo,
  16596. PatientId: patient.ID,
  16597. Certno: res.Output.Baseinfo.Certno,
  16598. Gend: res.Output.Baseinfo.Gend,
  16599. Naty: res.Output.Baseinfo.Naty,
  16600. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16601. PsnName: res.Output.Baseinfo.PsnName,
  16602. Idetinfo: idetinfoStr,
  16603. Insuinfo: infoStr,
  16604. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16605. CardInfo: card_info,
  16606. VerifyNumber: token,
  16607. }
  16608. var rf []*ResultFive
  16609. json.Unmarshal([]byte(infoStr), &rf)
  16610. var insutypes []*ResultFive
  16611. var insutype string
  16612. var is390 int = 0
  16613. var is310 int = 0
  16614. for _, item := range rf {
  16615. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16616. insutypes = append(insutypes, item)
  16617. }
  16618. }
  16619. if len(insutypes) == 1 {
  16620. insutype = insutypes[0].Insutype
  16621. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16622. } else {
  16623. for _, i := range insutypes {
  16624. if i.Insutype == "390" {
  16625. is390 = 1
  16626. }
  16627. if i.Insutype == "310" {
  16628. is310 = 1
  16629. }
  16630. }
  16631. }
  16632. if is390 == 1 {
  16633. insutype = "390"
  16634. }
  16635. if is310 == 1 {
  16636. insutype = "310"
  16637. }
  16638. if len(insutypes) == 0 {
  16639. insutype = "310"
  16640. }
  16641. service.CreateHisPsn(psn)
  16642. c.ServeSuccessJSON(map[string]interface{}{
  16643. "patient": patient,
  16644. "number": token,
  16645. "insutype": insutype,
  16646. })
  16647. }
  16648. } else {
  16649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16650. return
  16651. }
  16652. } else { //读卡失败
  16653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16654. return
  16655. }
  16656. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16657. res := c.GetoleInfo()
  16658. if res.Infcode == 0 {
  16659. var result string
  16660. if res.Output.MdtrtCertType == "01" {
  16661. 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)
  16662. } else if res.Output.MdtrtCertType == "02" {
  16663. 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)
  16664. } else if res.Output.MdtrtCertType == "03" {
  16665. 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)
  16666. }
  16667. var dat map[string]interface{}
  16668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16669. fmt.Println(dat)
  16670. } else {
  16671. fmt.Println(err)
  16672. }
  16673. userJSONBytes, _ := json.Marshal(dat)
  16674. var res2 ResultTwo
  16675. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16676. utils.ErrorLog("解析失败:%v", err)
  16677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16678. return
  16679. }
  16680. if res2.Infcode == 0 {
  16681. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16682. if err == gorm.ErrRecordNotFound {
  16683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16684. return
  16685. } else if err != nil {
  16686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16687. return
  16688. } else {
  16689. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16690. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16691. infoStr := string(Iinfos)
  16692. idetinfoStr := string(Idetinfos)
  16693. var rf []*ResultFive
  16694. json.Unmarshal([]byte(infoStr), &rf)
  16695. var insutypes []*ResultFive
  16696. var insutype string
  16697. var is390 int = 0
  16698. var is310 int = 0
  16699. //var insuplc_admdvs string
  16700. for _, item := range rf {
  16701. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16702. insutypes = append(insutypes, item)
  16703. }
  16704. }
  16705. if len(insutypes) == 1 {
  16706. insutype = insutypes[0].Insutype
  16707. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16708. } else {
  16709. for _, i := range insutypes {
  16710. if i.Insutype == "390" {
  16711. is390 = 1
  16712. }
  16713. if i.Insutype == "310" {
  16714. is310 = 1
  16715. }
  16716. }
  16717. }
  16718. if is390 == 1 {
  16719. insutype = "390"
  16720. }
  16721. if is310 == 1 {
  16722. insutype = "310"
  16723. }
  16724. if len(insutypes) == 0 {
  16725. insutype = "310"
  16726. }
  16727. psn := &models.HisPsn{
  16728. PsnNo: res2.Output.Baseinfo.PsnNo,
  16729. PatientId: patient.ID,
  16730. Certno: res2.Output.Baseinfo.Certno,
  16731. Gend: res2.Output.Baseinfo.Gend,
  16732. Naty: res2.Output.Baseinfo.Naty,
  16733. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16734. PsnName: res2.Output.Baseinfo.PsnName,
  16735. Idetinfo: idetinfoStr,
  16736. Insuinfo: infoStr,
  16737. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16738. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16739. VerifyNumber: res.Output.EcToken,
  16740. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16741. }
  16742. if res.Output.MdtrtCertType == "01" {
  16743. psn.VerifyNumber = res.Output.EcToken
  16744. //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)
  16745. } else if res.Output.MdtrtCertType == "02" {
  16746. psn.VerifyNumber = res.Output.CardNo
  16747. //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)
  16748. } else if res.Output.MdtrtCertType == "03" {
  16749. psn.VerifyNumber = res.Output.MdtrtCertNo
  16750. //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)
  16751. }
  16752. service.CreateHisPsn(psn)
  16753. var balc float64
  16754. for _, item := range rf {
  16755. if item.Insutype == insutype {
  16756. balc = item.Balc
  16757. }
  16758. }
  16759. c.ServeSuccessJSON(map[string]interface{}{
  16760. "patient": patient,
  16761. "number": res.Output.CardNo,
  16762. "insutype": insutype,
  16763. "blac": balc,
  16764. "desc": idetinfoStr,
  16765. })
  16766. }
  16767. } else {
  16768. c.ServeSuccessJSON(map[string]interface{}{
  16769. "failed_code": -10,
  16770. "msg": res2.ErrMsg,
  16771. })
  16772. }
  16773. } else {
  16774. c.ServeSuccessJSON(map[string]interface{}{
  16775. "failed_code": -10,
  16776. "msg": res.ErrMsg,
  16777. })
  16778. }
  16779. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16780. var res ResultTwo
  16781. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16782. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16783. "&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)
  16784. resp, requestErr := http.Get(api)
  16785. if requestErr != nil {
  16786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16787. return
  16788. }
  16789. body, ioErr := ioutil.ReadAll(resp.Body)
  16790. if ioErr != nil {
  16791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16793. return
  16794. }
  16795. var respJSON map[string]interface{}
  16796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16799. return
  16800. }
  16801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16802. result, _ := json.Marshal(respJSON)
  16803. fmt.Println("log")
  16804. fmt.Println(string(result))
  16805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16806. utils.ErrorLog("解析失败:%v", err)
  16807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16808. return
  16809. }
  16810. if res.Infcode == 0 {
  16811. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16812. if err == gorm.ErrRecordNotFound {
  16813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16814. return
  16815. } else if err != nil {
  16816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16817. return
  16818. } else {
  16819. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16820. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16821. infoStr := string(Iinfos)
  16822. idetinfoStr := string(Idetinfos)
  16823. var rf []*ResultFive
  16824. json.Unmarshal([]byte(infoStr), &rf)
  16825. var insutypes []*ResultFive
  16826. var insutype string
  16827. var is390 int = 0
  16828. var is310 int = 0
  16829. for _, item := range rf {
  16830. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16831. insutypes = append(insutypes, item)
  16832. }
  16833. }
  16834. if len(insutypes) == 1 {
  16835. insutype = insutypes[0].Insutype
  16836. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16837. } else {
  16838. for _, i := range insutypes {
  16839. if i.Insutype == "390" {
  16840. is390 = 1
  16841. }
  16842. if i.Insutype == "310" {
  16843. is310 = 1
  16844. }
  16845. }
  16846. }
  16847. if is390 == 1 {
  16848. insutype = "390"
  16849. }
  16850. if is310 == 1 {
  16851. insutype = "310"
  16852. }
  16853. if len(insutypes) == 0 {
  16854. insutype = "390"
  16855. }
  16856. var insuplc_admdvs string
  16857. for _, item := range rf {
  16858. if item.Insutype == insutype {
  16859. insuplc_admdvs = item.InsuplcAdmdvs
  16860. }
  16861. }
  16862. psn := &models.HisPsn{
  16863. PsnNo: res.Output.Baseinfo.PsnNo,
  16864. PatientId: patient.ID,
  16865. Certno: res.Output.Baseinfo.Certno,
  16866. Gend: res.Output.Baseinfo.Gend,
  16867. Naty: res.Output.Baseinfo.Naty,
  16868. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16869. PsnName: res.Output.Baseinfo.PsnName,
  16870. Idetinfo: idetinfoStr,
  16871. Insuinfo: infoStr,
  16872. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16873. InsuplcAdmdvs: insuplc_admdvs,
  16874. }
  16875. service.CreateHisPsn(psn)
  16876. c.ServeSuccessJSON(map[string]interface{}{
  16877. "patient": patient,
  16878. "number": res.Output.Baseinfo.Certno,
  16879. })
  16880. }
  16881. } else {
  16882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16883. return
  16884. }
  16885. } else {
  16886. type ELeData struct {
  16887. Code string `json:"code"`
  16888. Data struct {
  16889. Aac002 string `json:"aac002"`
  16890. Aaz500 string `json:"aaz500"`
  16891. ActCardNo string `json:"actCardNo"`
  16892. Bab520 string `json:"bab520"`
  16893. Bkz543 string `json:"bkz543"`
  16894. BusinessType string `json:"businessType"`
  16895. CertfCodg string `json:"certfCodg"`
  16896. EcIndexNo string `json:"ecIndexNo"`
  16897. EcToken string `json:"ecToken"`
  16898. ID0000 string `json:"id0000"`
  16899. IDNo string `json:"idNo"`
  16900. IDType string `json:"idType"`
  16901. Idcode string `json:"idcode"`
  16902. IdentityToken string `json:"identity_token"`
  16903. InsuOrg string `json:"insuOrg"`
  16904. OfficeID string `json:"officeId"`
  16905. OfficeName string `json:"officeName"`
  16906. OperatorID string `json:"operatorId"`
  16907. OperatorName string `json:"operatorName"`
  16908. OrgID string `json:"orgId"`
  16909. UserName string `json:"userName"`
  16910. } `json:"data"`
  16911. Infno interface{} `json:"infno"`
  16912. Message string `json:"message"`
  16913. OrgID string `json:"orgId"`
  16914. TransType string `json:"transType"`
  16915. }
  16916. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16917. fmt.Println(result)
  16918. outPutInfo := Remove0000(result)
  16919. fmt.Println(outPutInfo)
  16920. if len(outPutInfo) > 0 {
  16921. var ele ELeData
  16922. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16923. if err != nil {
  16924. utils.ErrorLog("解析失败:%v", err)
  16925. }
  16926. token := ele.Data.EcToken
  16927. fmt.Println(outPutInfo)
  16928. 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)
  16929. saveLog(result, requestLog, "1101", "获取人员信息")
  16930. var dat map[string]interface{}
  16931. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16932. fmt.Println(dat)
  16933. } else {
  16934. fmt.Println(err)
  16935. }
  16936. userJSONBytes, _ := json.Marshal(dat)
  16937. var res ResultTwo
  16938. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16939. utils.ErrorLog("解析失败:%v", err)
  16940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16941. return
  16942. }
  16943. if res.Infcode == 0 {
  16944. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16945. if err == gorm.ErrRecordNotFound {
  16946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16947. return
  16948. } else if err != nil {
  16949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16950. return
  16951. } else {
  16952. fmt.Println(res)
  16953. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16954. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16955. infoStr := string(Iinfos)
  16956. idetinfoStr := string(Idetinfos)
  16957. psn := &models.HisPsn{
  16958. PsnNo: res.Output.Baseinfo.PsnNo,
  16959. PatientId: patient.ID,
  16960. Certno: res.Output.Baseinfo.Certno,
  16961. Gend: res.Output.Baseinfo.Gend,
  16962. Naty: res.Output.Baseinfo.Naty,
  16963. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16964. PsnName: res.Output.Baseinfo.PsnName,
  16965. Idetinfo: idetinfoStr,
  16966. Insuinfo: infoStr,
  16967. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16968. CardInfo: outPutInfo,
  16969. VerifyNumber: token,
  16970. InsuplcAdmdvs: ele.Data.InsuOrg,
  16971. }
  16972. service.CreateHisPsn(psn)
  16973. var rf []*ResultFive
  16974. json.Unmarshal([]byte(infoStr), &rf)
  16975. var insutypes []*ResultFive
  16976. var insutype string
  16977. var is390 int = 0
  16978. var is310 int = 0
  16979. for _, item := range rf {
  16980. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16981. insutypes = append(insutypes, item)
  16982. }
  16983. }
  16984. if len(insutypes) == 1 {
  16985. insutype = insutypes[0].Insutype
  16986. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16987. } else {
  16988. for _, i := range insutypes {
  16989. if i.Insutype == "390" {
  16990. is390 = 1
  16991. }
  16992. if i.Insutype == "310" {
  16993. is310 = 1
  16994. }
  16995. }
  16996. }
  16997. if is390 == 1 {
  16998. insutype = "390"
  16999. }
  17000. if is310 == 1 {
  17001. insutype = "310"
  17002. }
  17003. if len(insutypes) == 0 {
  17004. insutype = "310"
  17005. }
  17006. c.ServeSuccessJSON(map[string]interface{}{
  17007. "patient": patient,
  17008. "number": token,
  17009. "insutype": insutype,
  17010. })
  17011. }
  17012. } else {
  17013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17014. return
  17015. }
  17016. }
  17017. //fmt.Println(result)
  17018. //
  17019. //if initFlag == 0 {
  17020. // c.TestGetBasBaseInit()
  17021. //}
  17022. //token := c.GetEleBaseInfo()
  17023. //
  17024. //token = Remove0000(token)
  17025. //
  17026. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17027. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17028. ////
  17029. //var res ResultTwo
  17030. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17031. // utils.ErrorLog("解析失败:%v", err)
  17032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17033. // return
  17034. //}
  17035. //
  17036. //if res.Infcode == 0 {
  17037. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17038. // if err == gorm.ErrRecordNotFound {
  17039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17040. // return
  17041. // } else if err != nil {
  17042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17043. // return
  17044. //
  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. //
  17051. //
  17052. //
  17053. //
  17054. // var rf []*ResultFive
  17055. // json.Unmarshal([]byte(infoStr), &rf)
  17056. //
  17057. // var insutypes []*ResultFive
  17058. // var insutype string
  17059. // var is390 int = 0
  17060. // var is310 int = 0
  17061. // var insuplc_admdvs string
  17062. //
  17063. // for _, item := range rf {
  17064. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17065. // insutypes = append(insutypes, item)
  17066. // }
  17067. // }
  17068. //
  17069. // if len(insutypes) == 1 {
  17070. // insutype = insutypes[0].Insutype
  17071. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17072. // } else {
  17073. // for _, i := range insutypes {
  17074. // if i.Insutype == "390" {
  17075. // is390 = 1
  17076. // }
  17077. //
  17078. // if i.Insutype == "310" {
  17079. // is310 = 1
  17080. // }
  17081. // }
  17082. // }
  17083. // if is390 == 1 {
  17084. // insutype = "390"
  17085. // }
  17086. //
  17087. // if is310 == 1 {
  17088. // insutype = "310"
  17089. // }
  17090. // if len(insutypes) == 0 {
  17091. // insutype = "310"
  17092. // }
  17093. // for _, item := range rf {
  17094. // if item.Insutype == insutype {
  17095. // insuplc_admdvs = item.InsuplcAdmdvs
  17096. // }
  17097. // }
  17098. // psn := &models.HisPsn{
  17099. // PsnNo: res.Output.Baseinfo.PsnNo,
  17100. // Age: res.Output.Baseinfo.Age,
  17101. // PatientId: patient.ID,
  17102. // Certno: res.Output.Baseinfo.Certno,
  17103. // Brdy: res.Output.Baseinfo.Brdy,
  17104. // Gend: res.Output.Baseinfo.Gend,
  17105. // Naty: res.Output.Baseinfo.Naty,
  17106. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17107. // PsnName: res.Output.Baseinfo.PsnName,
  17108. // Idetinfo: idetinfoStr,
  17109. // Insuinfo: infoStr,
  17110. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17111. // CardInfo: "",
  17112. // VerifyNumber: token,
  17113. // InsuplcAdmdvs: insuplc_admdvs,
  17114. // }
  17115. // service.CreateHisPsn(psn)
  17116. //
  17117. // c.ServeSuccessJSON(map[string]interface{}{
  17118. // "patient": patient,
  17119. // "number": token,
  17120. // })
  17121. // }
  17122. //} else {
  17123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17124. // return
  17125. //}
  17126. }
  17127. break
  17128. case 5:
  17129. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17130. var api string
  17131. if miConfig.MdtrtareaAdmvs == "320921" {
  17132. 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 +
  17133. "&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
  17134. fmt.Println(api)
  17135. } else {
  17136. 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 +
  17137. "&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)
  17138. }
  17139. resp, requestErr := http.Get(api)
  17140. if requestErr != nil {
  17141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17142. return
  17143. }
  17144. body, ioErr := ioutil.ReadAll(resp.Body)
  17145. if ioErr != nil {
  17146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17148. return
  17149. }
  17150. var respJSON map[string]interface{}
  17151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17154. return
  17155. }
  17156. var status string
  17157. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17158. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17159. var token string
  17160. var res ResultTwo //1101结果
  17161. var res10265 ResultTwo10265 //1101结果
  17162. if status == "0" { //读卡成功
  17163. var card_info string //卡信息
  17164. //var busi_card_info string
  17165. var auth_info string
  17166. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17167. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17168. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17169. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17170. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17171. result, _ := json.Marshal(respJSON)
  17172. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17173. utils.ErrorLog("解析失败:%v", err)
  17174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17175. return
  17176. }
  17177. res.ErrMsg = res10265.ErrMsg
  17178. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17179. res.Infcode = infocode
  17180. res.Output = res10265.Output
  17181. res.InfRefmsgid = res10265.InfRefmsgid
  17182. if res.Infcode == 0 {
  17183. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17184. if err == gorm.ErrRecordNotFound {
  17185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17186. return
  17187. } else if err != nil {
  17188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17189. return
  17190. } else {
  17191. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17192. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17193. infoStr := string(Iinfos)
  17194. idetinfoStr := string(Idetinfos)
  17195. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17196. psn := &models.HisPsn{
  17197. PsnNo: res.Output.Baseinfo.PsnNo,
  17198. PatientId: patient.ID,
  17199. Certno: res.Output.Baseinfo.Certno,
  17200. Gend: res.Output.Baseinfo.Gend,
  17201. Brdy: b,
  17202. Age: float64(age),
  17203. Naty: res.Output.Baseinfo.Naty,
  17204. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17205. PsnName: res.Output.Baseinfo.PsnName,
  17206. Idetinfo: idetinfoStr,
  17207. Insuinfo: infoStr,
  17208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17209. CardInfo: card_info,
  17210. VerifyNumber: token,
  17211. AuthInfo: auth_info,
  17212. }
  17213. var rf []*ResultFive
  17214. json.Unmarshal([]byte(infoStr), &rf)
  17215. var insutypes []*ResultFive
  17216. var insutype string
  17217. var is390 int = 0
  17218. var is310 int = 0
  17219. for _, item := range rf {
  17220. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17221. insutypes = append(insutypes, item)
  17222. }
  17223. }
  17224. if len(insutypes) == 1 {
  17225. insutype = insutypes[0].Insutype
  17226. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17227. } else {
  17228. for _, i := range insutypes {
  17229. if i.Insutype == "390" {
  17230. is390 = 1
  17231. }
  17232. if i.Insutype == "310" {
  17233. is310 = 1
  17234. }
  17235. }
  17236. }
  17237. if is390 == 1 {
  17238. insutype = "390"
  17239. }
  17240. if is310 == 1 {
  17241. insutype = "310"
  17242. }
  17243. if len(insutypes) == 0 {
  17244. insutype = "310"
  17245. }
  17246. service.CreateHisPsn(psn)
  17247. c.ServeSuccessJSON(map[string]interface{}{
  17248. "patient": patient,
  17249. "number": token,
  17250. "insutype": insutype,
  17251. })
  17252. }
  17253. } else {
  17254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17255. return
  17256. }
  17257. } else { //读卡失败
  17258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17259. return
  17260. }
  17261. }
  17262. break
  17263. }
  17264. }
  17265. var initFlag int64 = 0
  17266. var initEleFlag int64 = 0
  17267. func (c *HisApiController) TestGetBasBaseInit() {
  17268. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17269. Iinit := DllDef.MustFindProc("Init")
  17270. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17271. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17272. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17273. if ret != 0 {
  17274. fmt.Println("SSCard的报错原因:", err)
  17275. fmt.Println("SSCard的运算结果为:", ret)
  17276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17277. return
  17278. }
  17279. result := int(ret)
  17280. fmt.Println("SSCard的运算结果为1:", result)
  17281. initFlag = 1
  17282. return
  17283. }
  17284. func (c *HisApiController) HandleJiangXiReadCard() {
  17285. fmt.Println("~~~~~~")
  17286. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17287. admin_user_id, _ := c.GetInt64("admin_user_id")
  17288. id_card_type, _ := c.GetInt64("id_card_type")
  17289. //certificates, _ := c.GetInt64("certificates")
  17290. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17291. if initFlag == 0 {
  17292. c.TestGetJiangXiBasBaseInit()
  17293. }
  17294. basStr := c.GetBasBaseInfo()
  17295. if len(basStr) == 0 {
  17296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17297. return
  17298. }
  17299. fmt.Println(basStr)
  17300. bas := strings.Split(basStr, "|")
  17301. basNumber := bas[1]
  17302. fmt.Println(basNumber)
  17303. card_sn := bas[3]
  17304. fmt.Println(card_sn)
  17305. 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, "")
  17306. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17307. var dat map[string]interface{}
  17308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17309. fmt.Println(dat)
  17310. } else {
  17311. fmt.Println(err)
  17312. }
  17313. userJSONBytes, _ := json.Marshal(dat)
  17314. var res ResultTwo
  17315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17316. utils.ErrorLog("解析失败:%v", err)
  17317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17318. return
  17319. }
  17320. if res.Infcode == 0 {
  17321. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17322. if err == gorm.ErrRecordNotFound {
  17323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17324. return
  17325. } else if err != nil {
  17326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17327. return
  17328. } else {
  17329. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17330. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17331. infoStr := string(Iinfos)
  17332. idetinfoStr := string(Idetinfos)
  17333. psn := &models.HisPsn{
  17334. PsnNo: res.Output.Baseinfo.PsnNo,
  17335. PatientId: patient.ID,
  17336. Certno: res.Output.Baseinfo.Certno,
  17337. Gend: res.Output.Baseinfo.Gend,
  17338. Naty: res.Output.Baseinfo.Naty,
  17339. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17340. PsnName: res.Output.Baseinfo.PsnName,
  17341. Idetinfo: idetinfoStr,
  17342. Insuinfo: infoStr,
  17343. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17344. CardInfo: basStr,
  17345. VerifyNumber: "",
  17346. }
  17347. service.CreateHisPsn(psn)
  17348. c.ServeSuccessJSON(map[string]interface{}{
  17349. "patient": patient,
  17350. "number": basNumber,
  17351. })
  17352. }
  17353. } else {
  17354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17355. return
  17356. }
  17357. }
  17358. func (c *HisApiController) TestGetHnBasBaseInit() {
  17359. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17360. Iinit := DllDef.MustFindProc("Init")
  17361. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17362. //http://10.77.211.236/CSB/hsa-fsi-1303
  17363. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17364. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17365. // 调用 Init 函数
  17366. 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"))))
  17367. //if ret != 0 {
  17368. fmt.Println("SSCard的报错原因:", err)
  17369. fmt.Println("SSCard的运算结果为:", ret)
  17370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17371. // return
  17372. //}
  17373. result := int(ret)
  17374. fmt.Println("SSCard的运算结果为1:", result)
  17375. initFlag = 1
  17376. return
  17377. }
  17378. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17379. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17380. Iinit := DllDef.MustFindProc("Init")
  17381. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17382. //http://10.77.211.236/CSB/hsa-fsi-1303
  17383. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  17384. if ret != 0 {
  17385. fmt.Println("SSCard的报错原因:", err)
  17386. fmt.Println("SSCard的运算结果为:", ret)
  17387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17388. return
  17389. }
  17390. result := int(ret)
  17391. fmt.Println("SSCard的运算结果为1:", result)
  17392. initFlag = 1
  17393. return
  17394. }
  17395. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17396. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17397. Iinit := DllDef.MustFindProc("Init")
  17398. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17399. //http://10.77.211.236/CSB/hsa-fsi-1303
  17400. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17401. if ret != 0 {
  17402. fmt.Println("SSCard的报错原因:", err)
  17403. fmt.Println("SSCard的运算结果为:", ret)
  17404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17405. return
  17406. }
  17407. result := int(ret)
  17408. fmt.Println("SSCard的运算结果为1:", result)
  17409. initFlag = 1
  17410. return
  17411. }
  17412. func (c *HisApiController) GetSFZBaseInfo() string {
  17413. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17414. readCard := DllDef.MustFindProc("ReadSFZ")
  17415. if readCard == nil {
  17416. fmt.Println("readcard is nil")
  17417. readCard = DllDef.MustFindProc("ReadSFZ")
  17418. }
  17419. str := make([]byte, 8096)
  17420. str1 := make([]byte, 8096)
  17421. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17422. fmt.Println(r)
  17423. return Remove0000(string(str))
  17424. }
  17425. func (c *HisApiController) GetEleBaseInfo() string {
  17426. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17427. readCard := DllDef.MustFindProc("GetQRBase")
  17428. fmt.Println(readCard)
  17429. if readCard == nil {
  17430. fmt.Println("readcard is nil")
  17431. readCard = DllDef.MustFindProc("GetQRBase")
  17432. }
  17433. str := make([]byte, 1024)
  17434. str1 := make([]byte, 1024)
  17435. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17436. fmt.Println(ret2)
  17437. fmt.Println(string(str1))
  17438. fmt.Println(string(str))
  17439. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17440. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17441. if ret2 != 0 {
  17442. return ""
  17443. }
  17444. return string(str)
  17445. }
  17446. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17447. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17448. readCard := DllDef.MustFindProc("NationEcTrans")
  17449. fmt.Println(readCard)
  17450. fmt.Println("!!!!!")
  17451. pBusiCardInfo := make([]byte, 2048)
  17452. input := make(map[string]interface{})
  17453. inputData := make(map[string]interface{})
  17454. inputData["orgId"] = code
  17455. inputData["businessType"] = "01101"
  17456. inputData["operatorId"] = "1"
  17457. inputData["operatorName"] = "admin"
  17458. inputData["officeId"] = "001"
  17459. inputData["officeName"] = "血透室"
  17460. inputData["deviceType"] = ""
  17461. input["data"] = inputData
  17462. input["orgId"] = code
  17463. input["transType"] = "ec.query"
  17464. bytesData, _ := json.Marshal(input)
  17465. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17466. fmt.Println(ret2)
  17467. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17468. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17469. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17470. }
  17471. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17472. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17473. readCard := DllDef.MustFindProc("NationEcTrans")
  17474. fmt.Println(readCard)
  17475. fmt.Println("!!!!!")
  17476. pBusiCardInfo := make([]byte, 2048)
  17477. input := make(map[string]interface{})
  17478. inputData := make(map[string]interface{})
  17479. inputData["orgId"] = code
  17480. inputData["businessType"] = "01101"
  17481. inputData["operatorId"] = "9"
  17482. inputData["operatorName"] = "admin"
  17483. inputData["officeId"] = "001"
  17484. inputData["officeName"] = "血透室"
  17485. inputData["deviceType"] = ""
  17486. input["data"] = inputData
  17487. input["orgId"] = code
  17488. input["transType"] = "ec.query"
  17489. bytesData, _ := json.Marshal(input)
  17490. 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])))
  17491. fmt.Println(ret2)
  17492. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17493. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17494. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17495. }
  17496. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17497. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17498. readCard := DllDef.MustFindProc("NationEcTrans")
  17499. fmt.Println(readCard)
  17500. fmt.Println("!!!!!")
  17501. pBusiCardInfo := make([]byte, 2048)
  17502. input := make(map[string]interface{})
  17503. inputData := make(map[string]interface{})
  17504. inputData["orgId"] = code
  17505. inputData["businessType"] = "01301"
  17506. inputData["operatorId"] = "9"
  17507. inputData["operatorName"] = "admin"
  17508. inputData["officeId"] = "001"
  17509. inputData["officeName"] = "血透室"
  17510. inputData["deviceType"] = ""
  17511. input["data"] = inputData
  17512. input["orgId"] = code
  17513. input["transType"] = "ec.query"
  17514. bytesData, _ := json.Marshal(input)
  17515. 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])))
  17516. fmt.Println(ret2)
  17517. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17518. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17519. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17520. }
  17521. func GetJxEleBaseInfo(org_id int64) string {
  17522. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17523. readCard := DllDef.MustFindProc("NationEcTrans")
  17524. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17525. if readCard == nil {
  17526. fmt.Println("readcard is nil")
  17527. readCard = DllDef.MustFindProc("NationEcTrans")
  17528. }
  17529. str1 := make([]byte, 1024)
  17530. data := make(map[string]interface{})
  17531. inputData := make(map[string]interface{})
  17532. inputData["orgId"] = miConfig.Code
  17533. inputData["businessType"] = "01101"
  17534. inputData["operatorId"] = "test001"
  17535. inputData["operatorName"] = "cn"
  17536. inputData["officeId"] = "32760"
  17537. inputData["officeName"] = "waike"
  17538. inputData["deviceType"] = ""
  17539. data["data"] = inputData
  17540. data["transType"] = "ec.query"
  17541. data["extra "] = ""
  17542. data["orgId"] = miConfig.Code
  17543. bytesData, _ := json.Marshal(data)
  17544. //bytesData, _ := json.Marshal(data)
  17545. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17546. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17547. fmt.Println(ret2)
  17548. fmt.Println(string(str1))
  17549. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17550. if ret2 != 0 {
  17551. return ""
  17552. }
  17553. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17554. }
  17555. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17556. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17557. // readCard := DllDef.MustFindProc("NationEcTrans")
  17558. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17559. //
  17560. // if readCard == nil {
  17561. // fmt.Println("readcard is nil")
  17562. // readCard = DllDef.MustFindProc("NationEcTrans")
  17563. // }
  17564. // str1 := make([]byte, 1024)
  17565. //
  17566. // data := make(map[string]interface{})
  17567. //
  17568. // inputData := make(map[string]interface{})
  17569. // inputData["orgId"] = miConfig.Code
  17570. // inputData["businessType"] = "01101"
  17571. // inputData["operatorId"] = "test001"
  17572. // inputData["operatorName"] = "cn"
  17573. // inputData["officeId"] = "32760"
  17574. // inputData["officeName"] = "waike"
  17575. // inputData["deviceType"] = ""
  17576. //
  17577. // data["data"] = inputData
  17578. // data["transType"] = "ec.query"
  17579. // data["extra "] = ""
  17580. // data["orgId"] = miConfig.Code
  17581. // bytesData, _ := json.Marshal(data)
  17582. // //bytesData, _ := json.Marshal(data)
  17583. //
  17584. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17585. //
  17586. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17587. // fmt.Println(ret2)
  17588. // fmt.Println(string(str1))
  17589. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17590. //
  17591. // if ret2 != 0 {
  17592. // return ""
  17593. // }
  17594. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17595. //}
  17596. func GetJxEleBaseInitInfo(org_id int64) string {
  17597. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17598. readCard := DllDef.MustFindProc("NationEcTrans")
  17599. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17600. if readCard == nil {
  17601. fmt.Println("readcard is nil")
  17602. readCard = DllDef.MustFindProc("NationEcTrans")
  17603. }
  17604. str1 := make([]byte, 2048)
  17605. data := make(map[string]interface{})
  17606. inputData := make(map[string]interface{})
  17607. inputData["orgId"] = miConfig.Code
  17608. inputData["businessType"] = "01101"
  17609. inputData["operatorId"] = "1"
  17610. inputData["operatorName"] = "huangchuang"
  17611. inputData["officeId"] = "101"
  17612. inputData["officeName"] = "xuetou"
  17613. inputData["deviceType"] = ""
  17614. data["data"] = inputData
  17615. data["transType"] = "ec.query"
  17616. data["orgId"] = miConfig.Code
  17617. bytesData, _ := json.Marshal(data)
  17618. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17619. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17620. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17621. fmt.Println(ret2)
  17622. fmt.Println(string(str1))
  17623. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17624. if ret2 != 0 {
  17625. return ""
  17626. }
  17627. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17628. initEleFlag = 1
  17629. }
  17630. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17631. }
  17632. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17633. // // 构建命令
  17634. // cmd := exec.Command("python", "b.py")
  17635. //
  17636. // // 执行命令并等待完成
  17637. // output, err := cmd.CombinedOutput()
  17638. // if err != nil {
  17639. // fmt.Println("Error executing Python script:", err)
  17640. // return
  17641. // }
  17642. //
  17643. // // 打印Python脚本的输出
  17644. // fmt.Println(string(output))
  17645. //}
  17646. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17647. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17648. readCard := DllDef.MustFindProc("gxyb_call")
  17649. if readCard == nil {
  17650. fmt.Println("readcard is nil")
  17651. readCard = DllDef.MustFindProc("gxyb_call")
  17652. }
  17653. str := make([]byte, 1024)
  17654. str1 := make([]byte, 1024)
  17655. //data := make(map[string]interface{})
  17656. currentTime := time.Now()
  17657. // 格式化时间为 "YYYYMMDDHH24MISS"
  17658. formattedTime := currentTime.Format("20060102150405")
  17659. inputData := make(map[string]interface{})
  17660. inputData2 := make(map[string]interface{})
  17661. inputData["transNo"] = "1401"
  17662. inputData["transType"] = "passwordCheck"
  17663. inputData["timestamp"] = formattedTime
  17664. inputData2["fixmedinsCode"] = code
  17665. inputData2["psnNo"] = ""
  17666. inputData["data"] = inputData2
  17667. jsonBytes, err := json.Marshal(inputData)
  17668. if err != nil {
  17669. fmt.Println("Error encoding map to JSON:", err)
  17670. }
  17671. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17672. fmt.Println(string(str1))
  17673. fmt.Println(string(str))
  17674. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17675. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17676. if ret2 != 0 {
  17677. return ""
  17678. }
  17679. return string(str)
  17680. }
  17681. func (c *HisApiController) GetoleInfo() Response {
  17682. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17683. defer ole.CoUninitialize()
  17684. // Replace with the ProgID or CLSID of your COM object
  17685. progID := "YinHai.XJ.Actual.Interface.New"
  17686. // Create COM object
  17687. unknown, err := oleutil.CreateObject(progID)
  17688. if err != nil {
  17689. fmt.Println("Unable to create COM object:", err)
  17690. }
  17691. defer unknown.Release()
  17692. // Query for the IDispatch interface
  17693. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17694. if err != nil {
  17695. fmt.Println("Unable to get IDispatch interface:", err)
  17696. }
  17697. defer dispatch.Release()
  17698. // Prepare parameters
  17699. transNo := "1401"
  17700. transType := "passwordCheck"
  17701. timestamp := time.Now().Unix()
  17702. fixmedinsCode := "H45072101171"
  17703. psnNo := ""
  17704. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17705. result2 := ""
  17706. // Call COM object's method using the IDispatch interface
  17707. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17708. fmt.Println(resulr)
  17709. fmt.Println(result2)
  17710. if err != nil {
  17711. fmt.Println("调用COM对象方法失败:", err)
  17712. }
  17713. var response Response
  17714. err2 := json.Unmarshal([]byte(result2), &response)
  17715. if err2 != nil {
  17716. fmt.Println("解析JSON失败:", err)
  17717. }
  17718. return response
  17719. }
  17720. func (c *HisApiController) GetBasBaseInfo() string {
  17721. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17722. readCard := DllDef.MustFindProc("ReadCardBas")
  17723. if readCard == nil {
  17724. fmt.Println("readcard is nil")
  17725. readCard = DllDef.MustFindProc("ReadCardBas")
  17726. }
  17727. str := make([]byte, 1024)
  17728. str1 := make([]byte, 1024)
  17729. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17730. fmt.Println(string(str1))
  17731. fmt.Println(string(str))
  17732. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17733. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17734. if ret2 != 0 {
  17735. return ""
  17736. }
  17737. return string(str)
  17738. }
  17739. type Program struct {
  17740. FunctionID string `xml:"function_id"`
  17741. CardInfo string `xml:"cardinfo"`
  17742. User string `xml:"user"`
  17743. }
  17744. func (c *HisApiController) GetBasBaseInfo1111() string {
  17745. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17746. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17747. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17748. if readCard == nil {
  17749. fmt.Println("readcard is nil")
  17750. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17751. }
  17752. if readCard2 == nil {
  17753. fmt.Println("readcard is nil")
  17754. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17755. }
  17756. str := make([]byte, 1024)
  17757. str1 := make([]byte, 1024)
  17758. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17759. str3 := make([]byte, 1024)
  17760. str4 := make([]byte, 1024)
  17761. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17762. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17763. //if err != nil {
  17764. // fmt.Println("Error opening file:", err)
  17765. //}
  17766. //defer file.Close()
  17767. //
  17768. //var lastProgram Program
  17769. //scanner := bufio.NewScanner(file)
  17770. //inProgram := false
  17771. //
  17772. //for scanner.Scan() {
  17773. // line := scanner.Text()
  17774. // if strings.Contains(line, "<program>") {
  17775. // inProgram = true
  17776. // programXML := "<program>"
  17777. // for scanner.Scan() {
  17778. // line = scanner.Text()
  17779. // programXML += line
  17780. // if strings.Contains(line, "</program>") {
  17781. // programXML += "</program>"
  17782. // break
  17783. // }
  17784. // }
  17785. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17786. // // 解析成功,更新最后的 Program
  17787. // }
  17788. // inProgram = false
  17789. // }
  17790. //}
  17791. //
  17792. // fmt.Println("Error reading file:", inProgram)
  17793. //
  17794. //if err := scanner.Err(); err != nil {
  17795. // fmt.Println("Error reading file:", err)
  17796. //}
  17797. // 输出最后一次的 Program
  17798. //fmt.Printf("最后一次的 <program>:\n")
  17799. //fmt.Printf("<program>\n")
  17800. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17801. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17802. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17803. //fmt.Printf("</program>\n")
  17804. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17805. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17806. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17807. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17808. return ConvertToString(string(str), "gbk", "utf-8")
  17809. }
  17810. func (c *HisApiController) GetBasBaseInfo22222() string {
  17811. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17812. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17813. if readCard == nil {
  17814. fmt.Println("readcard is nil")
  17815. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17816. }
  17817. str := make([]byte, 1024)
  17818. str1 := make([]byte, 1024)
  17819. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17820. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17821. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17822. //if err != nil {
  17823. // fmt.Println("Error opening file:", err)
  17824. //}
  17825. //defer file.Close()
  17826. //
  17827. //var lastProgram Program
  17828. //scanner := bufio.NewScanner(file)
  17829. //inProgram := false
  17830. //
  17831. //for scanner.Scan() {
  17832. // line := scanner.Text()
  17833. // if strings.Contains(line, "<program>") {
  17834. // inProgram = true
  17835. // programXML := "<program>"
  17836. // for scanner.Scan() {
  17837. // line = scanner.Text()
  17838. // programXML += line
  17839. // if strings.Contains(line, "</program>") {
  17840. // programXML += "</program>"
  17841. // break
  17842. // }
  17843. // }
  17844. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17845. // // 解析成功,更新最后的 Program
  17846. // }
  17847. // inProgram = false
  17848. // }
  17849. //}
  17850. //
  17851. // fmt.Println("Error reading file:", inProgram)
  17852. //
  17853. //if err := scanner.Err(); err != nil {
  17854. // fmt.Println("Error reading file:", err)
  17855. //}
  17856. // 输出最后一次的 Program
  17857. //fmt.Printf("最后一次的 <program>:\n")
  17858. //fmt.Printf("<program>\n")
  17859. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17860. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17861. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17862. //fmt.Printf("</program>\n")
  17863. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17864. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17865. return ConvertToString(string(str1), "gbk", "utf-8")
  17866. }
  17867. func (c *HisApiController) GetahBasBaseInfo() string {
  17868. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17869. readCard := DllDef.MustFindProc("iReadCardBas")
  17870. if readCard == nil {
  17871. fmt.Println("readcard is nil")
  17872. readCard = DllDef.MustFindProc("iReadCardBas")
  17873. }
  17874. //str := make([]byte, 1024)
  17875. str1 := make([]byte, 1024)
  17876. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17877. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17878. //if err != nil {
  17879. // fmt.Println("Error opening file:", err)
  17880. //}
  17881. //defer file.Close()
  17882. //
  17883. //var lastProgram Program
  17884. //scanner := bufio.NewScanner(file)
  17885. //inProgram := false
  17886. //
  17887. //for scanner.Scan() {
  17888. // line := scanner.Text()
  17889. // if strings.Contains(line, "<program>") {
  17890. // inProgram = true
  17891. // programXML := "<program>"
  17892. // for scanner.Scan() {
  17893. // line = scanner.Text()
  17894. // programXML += line
  17895. // if strings.Contains(line, "</program>") {
  17896. // programXML += "</program>"
  17897. // break
  17898. // }
  17899. // }
  17900. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17901. // // 解析成功,更新最后的 Program
  17902. // }
  17903. // inProgram = false
  17904. // }
  17905. //}
  17906. //
  17907. // fmt.Println("Error reading file:", inProgram)
  17908. //
  17909. //if err := scanner.Err(); err != nil {
  17910. // fmt.Println("Error reading file:", err)
  17911. //}
  17912. // 输出最后一次的 Program
  17913. //fmt.Printf("最后一次的 <program>:\n")
  17914. //fmt.Printf("<program>\n")
  17915. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17916. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17917. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17918. //fmt.Printf("</program>\n")
  17919. fmt.Println(string(str1))
  17920. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17921. if ret2 != 0 {
  17922. return ""
  17923. }
  17924. return string(str1)
  17925. }
  17926. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17927. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17928. readCard := DllDef.MustFindProc("read_cardinfo")
  17929. if readCard == nil {
  17930. fmt.Println("readcard is nil")
  17931. readCard = DllDef.MustFindProc("read_cardinfo")
  17932. }
  17933. str := make([]byte, 1024) //卡号
  17934. str1 := make([]byte, 1024) //卡识别码
  17935. str2 := make([]byte, 1024) //身份证号
  17936. str3 := make([]byte, 1024) //姓名
  17937. str4 := make([]byte, 1024) //错误信息
  17938. 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])))
  17939. fmt.Println(string(str1))
  17940. fmt.Println(string(str))
  17941. fmt.Println(string(str2))
  17942. fmt.Println(string(str3))
  17943. fmt.Println(string(str4))
  17944. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17945. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17946. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17947. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17948. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17949. if ret2 != 0 {
  17950. return "", "", "", "", ""
  17951. }
  17952. return string(str), string(str1), string(str2), string(str3), string(str4)
  17953. }
  17954. type CustomFundPay struct {
  17955. FundPayType string `json:"fund_pay_type"`
  17956. FundPayamt float64 `json:"fund_payamt"`
  17957. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17958. }
  17959. //func (c *HisApiController) GetBatchSettleList() {
  17960. // start_time_str := c.GetString("start_time")
  17961. // //end_time_str := c.GetString("end_time")
  17962. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17963. //
  17964. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17965. //
  17966. // for _, item := range orders {
  17967. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17968. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17969. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17970. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17971. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17972. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17973. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17974. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17975. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17976. //
  17977. // if order.ID == 0 {
  17978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17979. // return
  17980. // }
  17981. //
  17982. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17983. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17984. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17985. // //fmt.Println(count)
  17986. // //var zero string
  17987. // //number := count + 1
  17988. // //if number >= 1000 {
  17989. // // zero = "0000" + strconv.FormatInt(number, 10)
  17990. // //} else if number >= 10000 {
  17991. // // zero = "000" + strconv.FormatInt(number, 10)
  17992. // //} else if number >= 100000 {
  17993. // // zero = "00" + strconv.FormatInt(number, 10)
  17994. // //} else if number >= 1000000 {
  17995. // // zero = "0" + strconv.FormatInt(number, 10)
  17996. // //} else {
  17997. // // zero = strconv.FormatInt(number, 10)
  17998. // //}
  17999. // //fmt.Println(zero)
  18000. //
  18001. // struct4101 := service.Struct4101{
  18002. // PsnNo: order.PsnNo,
  18003. // MdtrtId: order.MdtrtId,
  18004. // SetlId: order.SetlId,
  18005. // PsnName: order.PsnName,
  18006. // Gend: order.Gend,
  18007. // Brdy: his.Brdy,
  18008. // Age: his.Age,
  18009. // Naty: order.Naty,
  18010. // PatnCertType: "01",
  18011. // Certno: order.Certno,
  18012. // Prfs: "90",
  18013. // ConerName: roles[0].UserName,
  18014. // PatnRlts: "99",
  18015. // ConerAddr: miConfig.OrgName,
  18016. // ConerTel: admin.Mobile,
  18017. // HiType: order.Insutype,
  18018. // Insuplc: miConfig.InsuplcAdmdvs,
  18019. // MaindiagFlag: "1",
  18020. // BillCode: order.SetlId,
  18021. // BillNo: order.SetlId,
  18022. // BizSn: order.Number,
  18023. // PsnSelfPay: order.PsnPartAmt,
  18024. // PsnOwnPay: order.PsnPartAmt,
  18025. // AcctPay: order.AcctPay,
  18026. // PsnCashpay: order.PsnCashPay,
  18027. // HiPaymtd: "1",
  18028. // Hsorg: miConfig.InsuplcAdmdvs,
  18029. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18030. // MedinsFillPsn: curRoles.UserName,
  18031. // MedinsFillDept: miConfig.OrgName,
  18032. // IptMedType: "2",
  18033. // }
  18034. // struct4101.SetlBegnDate = order.SetlTime
  18035. // struct4101.SetlEndDate = order.SetlTime
  18036. // time_arr := strings.Split(order.SetlTime, " ")
  18037. // struct4101.AdmTime = time_arr[0]
  18038. // struct4101.AdmEndTime = time_arr[0]
  18039. //
  18040. // var rf []CustomFundPay
  18041. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18042. //
  18043. // var tempFunPays []service.CustomStruct
  18044. // for _, item := range rf {
  18045. // var tempFunPay service.CustomStruct
  18046. // tempFunPay.FundPayamt = item.FundPayamt
  18047. // tempFunPay.FundPayType = item.FundPayType
  18048. // tempFunPays = append(tempFunPays, tempFunPay)
  18049. // }
  18050. // struct4101.CustomStruct = tempFunPays
  18051. //
  18052. // var tempDiaginfos []service.DiaginfoStructTwo
  18053. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18054. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18055. //
  18056. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18057. // var config []*models.HisXtDiagnoseConfig
  18058. // for _, item := range diagnosis_ids {
  18059. // id, _ := strconv.ParseInt(item, 10, 64)
  18060. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18061. // config = append(config, &diagnosisConfig)
  18062. // }
  18063. //
  18064. // for index, item := range config {
  18065. // if index == 0 {
  18066. // var tempDiaginfo service.DiaginfoStructTwo
  18067. // tempDiaginfo.DiagCode = item.CountryCode
  18068. // tempDiaginfo.DiagName = item.CountryContentName
  18069. // tempDiaginfo.DiagType = "1"
  18070. // tempDiaginfo.MaindiagFlag = "1"
  18071. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18072. // } else {
  18073. // var tempDiaginfo service.DiaginfoStructTwo
  18074. // tempDiaginfo.DiagCode = item.CountryCode
  18075. // tempDiaginfo.DiagName = item.CountryContentName
  18076. // tempDiaginfo.DiagType = "1"
  18077. // tempDiaginfo.MaindiagFlag = "0"
  18078. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18079. // }
  18080. // }
  18081. // struct4101.Diseinfo = tempDiaginfos
  18082. //
  18083. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18084. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18085. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18086. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18087. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18088. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18089. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18090. //
  18091. // var iteminfo service.IteminfoStruct
  18092. //
  18093. // var bedCostTotal float64 = 0 //床位总费
  18094. // var bedCostSelfTotal float64 = 0 //床位自费
  18095. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18096. //
  18097. // var operationCostTotal float64 = 0 //手术费
  18098. // var operationCostSelfTotal float64 = 0 //手术费
  18099. // var operationCostPartSelfTotal float64 = 0 //手术费
  18100. //
  18101. // var otherCostTotal float64 = 0 //其他费用
  18102. // var otherCostSelfTotal float64 = 0 //其他费用
  18103. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18104. //
  18105. // var materialCostTotal float64 = 0 //材料费
  18106. // var materialCostSelfTotal float64 = 0 //材料费
  18107. // var materialCostPartSelfTotal float64 = 0 //材料费
  18108. //
  18109. // var westernMedicineCostTotal float64 = 0 //西药费
  18110. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18111. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18112. //
  18113. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18114. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18115. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18116. //
  18117. // var checkCostTotal float64 = 0 //检查费
  18118. // var checkCostSelfTotal float64 = 0 //检查费
  18119. // var checkCostPartSelfTotal float64 = 0 //检查费
  18120. //
  18121. // var laboratoryCostTotal float64 = 0 //化验费
  18122. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18123. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18124. //
  18125. // var treatCostTotal float64 = 0 //治疗费用
  18126. // var treatCostSelfTotal float64 = 0 //治疗费用
  18127. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18128. //
  18129. // decimal.DivisionPrecision = 2
  18130. //
  18131. // var bed_fulamt_ownpay_amt float64 = 0
  18132. // var operation_fulamt_ownpay_amt float64 = 0
  18133. // var other_fulamt_ownpay_amt float64 = 0
  18134. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18135. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18136. // var check_fulamt_ownpay_amt float64 = 0
  18137. // var material_fulamt_ownpay_amt float64 = 0
  18138. // var laboratory_fulamt_ownpay_amt float64 = 0
  18139. // var treat_fulamt_ownpay_amt float64 = 0
  18140. //
  18141. // var bed_claa_sunmfee float64 = 0
  18142. // var bed_clab_amt float64 = 0
  18143. // var bed_other_amt float64 = 0
  18144. //
  18145. // var operation_claa_sunmfee float64 = 0
  18146. // var operation_clab_amt float64 = 0
  18147. // var operation_other_amt float64 = 0
  18148. //
  18149. // var other_claa_sunmfee float64 = 0
  18150. // var other_clab_amt float64 = 0
  18151. // var other_other_amt float64 = 0
  18152. //
  18153. // var westernMedicine_claa_sunmfee float64 = 0
  18154. // var westernMedicine_clab_amt float64 = 0
  18155. // var westernMedicine_other_amt float64 = 0
  18156. //
  18157. // var chineseTraditional_claa_sunmfee float64 = 0
  18158. // var chineseTraditional_clab_amt float64 = 0
  18159. // var chineseTraditional_other_amt float64 = 0
  18160. //
  18161. // var check_claa_sunmfee float64 = 0
  18162. // var check_clab_amt float64 = 0
  18163. // var check_other_amt float64 = 0
  18164. //
  18165. // var material_claa_sunmfee float64 = 0
  18166. // var material_clab_amt float64 = 0
  18167. // var material_other_amt float64 = 0
  18168. //
  18169. // var laboratory_claa_sunmfee float64 = 0
  18170. // var laboratory_clab_amt float64 = 0
  18171. // var laboratory_other_amt float64 = 0
  18172. //
  18173. // var treat_claa_sunmfee float64 = 0
  18174. // var treat_clab_amt float64 = 0
  18175. // var treat_other_amt float64 = 0
  18176. //
  18177. // for _, item := range order.HisOrderInfo {
  18178. // if item.MedChrgitmType == "01" { //床位费
  18179. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18180. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18181. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18182. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18183. // if item.ChrgitmLv == "1" {
  18184. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18185. // }
  18186. // if item.ChrgitmLv == "2" {
  18187. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18188. //
  18189. // }
  18190. // if item.ChrgitmLv == "3" {
  18191. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18192. // }
  18193. //
  18194. // }
  18195. //
  18196. // if item.MedChrgitmType == "03" { //检查费
  18197. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18198. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18199. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18200. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18201. // if item.ChrgitmLv == "1" {
  18202. //
  18203. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18204. //
  18205. // }
  18206. // if item.ChrgitmLv == "2" {
  18207. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18208. //
  18209. // }
  18210. // if item.ChrgitmLv == "3" {
  18211. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18212. // }
  18213. // }
  18214. //
  18215. // if item.MedChrgitmType == "04" { //化验费
  18216. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18217. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18218. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18219. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18220. // if item.ChrgitmLv == "1" {
  18221. //
  18222. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18223. //
  18224. // }
  18225. // if item.ChrgitmLv == "2" {
  18226. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18227. //
  18228. // }
  18229. // if item.ChrgitmLv == "3" {
  18230. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18231. // }
  18232. // }
  18233. //
  18234. // if item.MedChrgitmType == "05" { //治疗费
  18235. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18236. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18237. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18238. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18239. // if item.ChrgitmLv == "1" {
  18240. //
  18241. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18242. //
  18243. // }
  18244. // if item.ChrgitmLv == "2" {
  18245. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18246. //
  18247. // }
  18248. // if item.ChrgitmLv == "3" {
  18249. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18250. // }
  18251. // }
  18252. //
  18253. // if item.MedChrgitmType == "06" { //手术费
  18254. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18255. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18256. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18257. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18258. //
  18259. // if item.ChrgitmLv == "1" {
  18260. //
  18261. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18262. //
  18263. // }
  18264. // if item.ChrgitmLv == "2" {
  18265. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18266. //
  18267. // }
  18268. // if item.ChrgitmLv == "3" {
  18269. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18270. // }
  18271. // }
  18272. //
  18273. // if item.MedChrgitmType == "08" { //材料费
  18274. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18275. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18276. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18277. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18278. // if item.ChrgitmLv == "1" {
  18279. //
  18280. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18281. //
  18282. // }
  18283. // if item.ChrgitmLv == "2" {
  18284. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18285. //
  18286. // }
  18287. // if item.ChrgitmLv == "3" {
  18288. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18289. // }
  18290. // }
  18291. //
  18292. // if item.MedChrgitmType == "09" { //西药费
  18293. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18294. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18295. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18296. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18297. // if item.ChrgitmLv == "1" {
  18298. //
  18299. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18300. //
  18301. // }
  18302. // if item.ChrgitmLv == "2" {
  18303. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18304. //
  18305. // }
  18306. // if item.ChrgitmLv == "3" {
  18307. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18308. // }
  18309. // }
  18310. //
  18311. // if item.MedChrgitmType == "11" { //中成费
  18312. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18313. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18314. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18315. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18316. // if item.ChrgitmLv == "1" {
  18317. //
  18318. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18319. //
  18320. // }
  18321. // if item.ChrgitmLv == "2" {
  18322. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18323. //
  18324. // }
  18325. // if item.ChrgitmLv == "3" {
  18326. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18327. // }
  18328. // }
  18329. //
  18330. // if item.MedChrgitmType == "14" { //其他费
  18331. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18332. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18333. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18334. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18335. // if item.ChrgitmLv == "1" {
  18336. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18337. //
  18338. // }
  18339. // if item.ChrgitmLv == "2" {
  18340. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18341. //
  18342. // }
  18343. // if item.ChrgitmLv == "3" {
  18344. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18345. // }
  18346. // }
  18347. //
  18348. // }
  18349. //
  18350. // var iteminfoStructs []service.IteminfoStruct
  18351. //
  18352. // if bedCostTotal != 0 {
  18353. // iteminfo.MedChrgitm = "01"
  18354. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18355. // iteminfo.Amt = bedCostTotal
  18356. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18357. // iteminfo.ClabAmt = bed_clab_amt
  18358. // iteminfo.OthAmt = bed_other_amt
  18359. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18360. // }
  18361. //
  18362. // if checkCostTotal != 0 {
  18363. // iteminfo.MedChrgitm = "03"
  18364. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18365. // iteminfo.Amt = checkCostTotal
  18366. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18367. // iteminfo.ClabAmt = check_clab_amt
  18368. // iteminfo.OthAmt = check_other_amt
  18369. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18370. //
  18371. // }
  18372. //
  18373. // if laboratoryCostTotal != 0 {
  18374. // iteminfo.MedChrgitm = "04"
  18375. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18376. // iteminfo.Amt = laboratoryCostTotal
  18377. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18378. // iteminfo.ClabAmt = laboratory_clab_amt
  18379. // iteminfo.OthAmt = laboratory_other_amt
  18380. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18381. //
  18382. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18383. //
  18384. // }
  18385. //
  18386. // if treatCostTotal != 0 {
  18387. // iteminfo.MedChrgitm = "05"
  18388. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18389. // iteminfo.Amt = treatCostTotal
  18390. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18391. // iteminfo.ClabAmt = treat_clab_amt
  18392. // iteminfo.OthAmt = treat_other_amt
  18393. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18394. // //(struct4101.IteminfoStruct, iteminfo)
  18395. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18396. // }
  18397. //
  18398. // if operationCostTotal != 0 {
  18399. // iteminfo.MedChrgitm = "06"
  18400. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18401. // iteminfo.Amt = operationCostTotal
  18402. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18403. // iteminfo.ClabAmt = operation_clab_amt
  18404. // iteminfo.OthAmt = operation_other_amt
  18405. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18406. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18407. // }
  18408. //
  18409. // if materialCostTotal != 0 {
  18410. // iteminfo.MedChrgitm = "08"
  18411. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18412. // iteminfo.Amt = materialCostTotal
  18413. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18414. // iteminfo.ClabAmt = material_clab_amt
  18415. // iteminfo.OthAmt = material_other_amt
  18416. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18417. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18418. // }
  18419. //
  18420. // if westernMedicineCostTotal != 0 {
  18421. // iteminfo.MedChrgitm = "09"
  18422. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18423. // iteminfo.Amt = westernMedicineCostTotal
  18424. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18425. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18426. // iteminfo.OthAmt = westernMedicine_other_amt
  18427. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18428. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18429. //
  18430. // }
  18431. // if chineseTraditionalMedicineCostTotal != 0 {
  18432. // iteminfo.MedChrgitm = "11"
  18433. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18434. // iteminfo.Amt = westernMedicineCostTotal
  18435. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18436. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18437. // iteminfo.OthAmt = westernMedicine_other_amt
  18438. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18439. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18440. //
  18441. // }
  18442. // if otherCostTotal != 0 {
  18443. // iteminfo.MedChrgitm = "14"
  18444. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18445. // iteminfo.Amt = otherCostTotal
  18446. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18447. // iteminfo.ClabAmt = other_clab_amt
  18448. // iteminfo.OthAmt = other_other_amt
  18449. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18450. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18451. //
  18452. // }
  18453. // struct4101.IteminfoStruct = iteminfoStructs
  18454. // struct4101.Ntly = "中国"
  18455. // struct4101.AdmCaty = "A03.06"
  18456. //
  18457. // struct4101.DoctorName = doctor.UserName
  18458. // struct4101.DoctorCode = doctor.DoctorNumber
  18459. //
  18460. // var res ResultSeventeen
  18461. //
  18462. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18463. // struct4101.BillCode = order.Number
  18464. // struct4101.BillNo = order.SetlId
  18465. // var resOther ResultSeventeenOther
  18466. // var pp models.PublicParams
  18467. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18468. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18469. // pp.FixmedinsName = miConfig.OrgName
  18470. // pp.FixmedinsCode = miConfig.Code
  18471. // pp.RequestUrl = miConfig.Url
  18472. // pp.Cainfo = miConfig.Cainfo
  18473. // pp.SecretKey = miConfig.SecretKey
  18474. // pp.AccessKey = miConfig.AccessKey
  18475. // pp.OpterName = curRoles.UserName
  18476. //
  18477. // client := &http.Client{}
  18478. // var req *http.Request
  18479. // data := make(map[string]interface{})
  18480. // data["struct4101"] = struct4101
  18481. // data["pp"] = pp
  18482. // bytesData, _ := json.Marshal(data)
  18483. // if miConfig.MdtrtareaAdmvs == "320921" {
  18484. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18485. // } else {
  18486. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18487. // }
  18488. // resp, _ := client.Do(req)
  18489. // defer resp.Body.Close()
  18490. // body, ioErr := ioutil.ReadAll(resp.Body)
  18491. // if ioErr != nil {
  18492. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18494. // return
  18495. // }
  18496. // var respJSON map[string]interface{}
  18497. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18498. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18500. // return
  18501. // }
  18502. //
  18503. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18504. // userJSONBytes, _ := json.Marshal(respJSON)
  18505. // fmt.Println("log")
  18506. // fmt.Println(string(userJSONBytes))
  18507. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18508. // utils.ErrorLog("解析失败:%v", err)
  18509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18510. // return
  18511. // }
  18512. // res.InfRefmsgid = resOther.InfRefmsgid
  18513. // res.Output = resOther.Output
  18514. // res.ErrMsg = resOther.ErrMsg
  18515. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18516. // res.Infcode = infocode
  18517. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18518. //
  18519. // var pp models.PublicParams
  18520. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18521. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18522. // pp.FixmedinsName = miConfig.OrgName
  18523. // pp.FixmedinsCode = miConfig.Code
  18524. // pp.RequestUrl = miConfig.Url
  18525. // pp.Cainfo = miConfig.Cainfo
  18526. // pp.SecretKey = miConfig.SecretKey
  18527. // pp.AccessKey = miConfig.AccessKey
  18528. // pp.OpterName = curRoles.UserName
  18529. // result, _ := service.Jxyb4101(struct4101, pp)
  18530. // var dat map[string]interface{}
  18531. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18532. // fmt.Println(dat)
  18533. // } else {
  18534. // fmt.Println(err)
  18535. // }
  18536. // userJSONBytes, _ := json.Marshal(dat)
  18537. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18538. // utils.ErrorLog("解析失败:%v", err)
  18539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18540. // return
  18541. // }
  18542. //
  18543. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18544. // var pp models.PublicParams
  18545. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18546. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18547. // pp.FixmedinsName = miConfig.OrgName
  18548. // pp.FixmedinsCode = miConfig.Code
  18549. // pp.RequestUrl = miConfig.Url
  18550. // pp.Cainfo = miConfig.Cainfo
  18551. // pp.SecretKey = miConfig.SecretKey
  18552. // pp.AccessKey = miConfig.AccessKey
  18553. // pp.OpterName = curRoles.UserName
  18554. // result, _ := service.Hnyb4101(struct4101, pp)
  18555. // var dat map[string]interface{}
  18556. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18557. // fmt.Println(dat)
  18558. // } else {
  18559. // fmt.Println(err)
  18560. // }
  18561. // userJSONBytes, _ := json.Marshal(dat)
  18562. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18563. // utils.ErrorLog("解析失败:%v", err)
  18564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18565. // return
  18566. // }
  18567. //
  18568. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18569. // var resOther ResultSeventeenOther
  18570. //
  18571. // var pp models.PublicParams
  18572. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18573. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18574. // pp.FixmedinsName = miConfig.OrgName
  18575. // pp.FixmedinsCode = miConfig.Code
  18576. // pp.RequestUrl = miConfig.Url
  18577. // pp.Cainfo = miConfig.Cainfo
  18578. // pp.SecretKey = miConfig.SecretKey
  18579. // pp.AccessKey = miConfig.AccessKey
  18580. // pp.OpterName = curRoles.UserName
  18581. // client := &http.Client{}
  18582. // var req *http.Request
  18583. // data := make(map[string]interface{})
  18584. // data["struct4101"] = struct4101
  18585. // data["pp"] = pp
  18586. // bytesData, _ := json.Marshal(data)
  18587. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18588. // resp, _ := client.Do(req)
  18589. // defer resp.Body.Close()
  18590. // body, ioErr := ioutil.ReadAll(resp.Body)
  18591. // if ioErr != nil {
  18592. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18594. // return
  18595. // }
  18596. // var respJSON map[string]interface{}
  18597. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18598. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18600. // return
  18601. // }
  18602. //
  18603. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18604. // userJSONBytes, _ := json.Marshal(respJSON)
  18605. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18606. // utils.ErrorLog("解析失败:%v", err)
  18607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18608. // return
  18609. // }
  18610. // res.InfRefmsgid = resOther.InfRefmsgid
  18611. // res.Output = resOther.Output
  18612. // res.ErrMsg = resOther.ErrMsg
  18613. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18614. // res.Infcode = infocode
  18615. //
  18616. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18617. // var pp models.PublicParams
  18618. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18619. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18620. // pp.FixmedinsName = miConfig.OrgName
  18621. // pp.FixmedinsCode = miConfig.Code
  18622. // pp.RequestUrl = miConfig.Url
  18623. // pp.Cainfo = miConfig.Cainfo
  18624. // pp.SecretKey = miConfig.SecretKey
  18625. // pp.AccessKey = miConfig.AccessKey
  18626. // pp.OpterName = curRoles.UserName
  18627. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18628. // fmt.Println(requestLog)
  18629. // fmt.Println(errMsgLog)
  18630. //
  18631. // saveLog(result, requestLog, "4101a", "上传清单")
  18632. //
  18633. // var dat map[string]interface{}
  18634. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18635. // fmt.Println(dat)
  18636. // } else {
  18637. // fmt.Println(err)
  18638. // }
  18639. // userJSONBytes, _ := json.Marshal(dat)
  18640. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18641. // utils.ErrorLog("解析失败:%v", err)
  18642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18643. // return
  18644. // }
  18645. //
  18646. // } else {
  18647. //
  18648. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18649. // var dat map[string]interface{}
  18650. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18651. // fmt.Println(dat)
  18652. // } else {
  18653. // fmt.Println(err)
  18654. // }
  18655. // userJSONBytes, _ := json.Marshal(dat)
  18656. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18657. // utils.ErrorLog("解析失败:%v", err)
  18658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18659. // return
  18660. // }
  18661. // }
  18662. //
  18663. // if res.Infcode != 0 {
  18664. // adminUser := c.GetAdminUserInfo()
  18665. // errlog := &models.HisOrderError{
  18666. // UserOrgId: adminUser.CurrentOrgId,
  18667. // Ctime: time.Now().Unix(),
  18668. // Mtime: time.Now().Unix(),
  18669. // ErrMsg: res.ErrMsg,
  18670. // Status: 1,
  18671. // PatientId: order.ID,
  18672. // Stage: 10265,
  18673. // }
  18674. // service.CreateErrMsgLog(errlog)
  18675. // continue
  18676. // } else {
  18677. // //order.FaPiaoNumber = zero
  18678. // //order.FaPiaoCode = last_order.FaPiaoCode
  18679. // //service.UpdateOrder(order)
  18680. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18681. // Number: res.Output.SetlListId,
  18682. // Status: 1,
  18683. // Ctime: time.Now().Unix(),
  18684. // Mtime: time.Now().Unix(),
  18685. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18686. // IsUpload: 1,
  18687. // OrderId: order.ID,
  18688. // }
  18689. // service.CreateUploadRecord(hisFundSettleListResult)
  18690. // c.ServeSuccessJSON(map[string]interface{}{
  18691. // "msg": "上传成功",
  18692. // "result": hisFundSettleListResult,
  18693. // })
  18694. // continue
  18695. // }
  18696. // }
  18697. //}
  18698. func (c *HisApiController) GetbatchSettleList() {
  18699. //order_id, _ := c.GetInt64("order_id")
  18700. admin_user_id, _ := c.GetInt64("admin_user_id")
  18701. orders, _ := service.GetAllHisOrderTwo10485()
  18702. for _, item := range orders {
  18703. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18704. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18705. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18706. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18707. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18708. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18710. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18711. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18712. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18713. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18714. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18715. //fmt.Println(count)
  18716. //var zero string
  18717. //number := count + 1
  18718. //if number >= 1000 {
  18719. // zero = "0000" + strconv.FormatInt(number, 10)
  18720. //} else if number >= 10000 {
  18721. // zero = "000" + strconv.FormatInt(number, 10)
  18722. //} else if number >= 100000 {
  18723. // zero = "00" + strconv.FormatInt(number, 10)
  18724. //} else if number >= 1000000 {
  18725. // zero = "0" + strconv.FormatInt(number, 10)
  18726. //} else {
  18727. // zero = strconv.FormatInt(number, 10)
  18728. //}
  18729. //fmt.Println(zero)
  18730. struct4101 := service.Struct4101{
  18731. PsnNo: order.PsnNo,
  18732. MdtrtId: order.MdtrtId,
  18733. SetlId: order.SetlId,
  18734. PsnName: order.PsnName,
  18735. Gend: order.Gend,
  18736. Brdy: his.Brdy,
  18737. Age: his.Age,
  18738. Naty: order.Naty,
  18739. PatnCertType: "01",
  18740. Certno: order.Certno,
  18741. Prfs: "90",
  18742. ConerName: roles[0].UserName,
  18743. PatnRlts: "99",
  18744. ConerAddr: miConfig.OrgName,
  18745. ConerTel: admin.Mobile,
  18746. HiType: order.Insutype,
  18747. Insuplc: miConfig.InsuplcAdmdvs,
  18748. MaindiagFlag: "1",
  18749. BillCode: order.SetlId,
  18750. BillNo: order.SetlId,
  18751. BizSn: order.Number,
  18752. PsnSelfPay: order.PsnPartAmt,
  18753. PsnOwnPay: order.PsnPartAmt,
  18754. AcctPay: order.AcctPay,
  18755. PsnCashpay: order.PsnCashPay,
  18756. HiPaymtd: "1",
  18757. Hsorg: miConfig.InsuplcAdmdvs,
  18758. HsorgOpter: miConfig.InsuplcAdmdvs,
  18759. MedinsFillPsn: curRoles.UserName,
  18760. MedinsFillDept: miConfig.OrgName,
  18761. IptMedType: "2",
  18762. }
  18763. struct4101.SetlBegnDate = order.SetlTime
  18764. struct4101.SetlEndDate = order.SetlTime
  18765. time_arr := strings.Split(order.SetlTime, " ")
  18766. struct4101.AdmTime = time_arr[0]
  18767. struct4101.AdmEndTime = time_arr[0]
  18768. //var rf []CustomFundPay
  18769. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18770. //
  18771. //var tempFunPays []service.CustomStruct
  18772. //for _, item := range rf {
  18773. // var tempFunPay service.CustomStruct
  18774. // tempFunPay.FundPayamt = item.FundPayamt
  18775. // tempFunPay.FundPayType = item.FundPayType
  18776. // tempFunPays = append(tempFunPays, tempFunPay)
  18777. //}
  18778. //struct4101.CustomStruct = tempFunPays
  18779. var tempDiaginfos []service.DiaginfoStructTwo
  18780. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18781. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18782. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18783. var config []*models.HisXtDiagnoseConfig
  18784. for _, item := range diagnosis_ids {
  18785. id, _ := strconv.ParseInt(item, 10, 64)
  18786. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18787. config = append(config, &diagnosisConfig)
  18788. }
  18789. for index, item := range config {
  18790. if index == 0 {
  18791. var tempDiaginfo service.DiaginfoStructTwo
  18792. tempDiaginfo.DiagCode = item.CountryCode
  18793. tempDiaginfo.DiagName = item.CountryContentName
  18794. tempDiaginfo.DiagType = "1"
  18795. tempDiaginfo.MaindiagFlag = "1"
  18796. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18797. } else {
  18798. var tempDiaginfo service.DiaginfoStructTwo
  18799. tempDiaginfo.DiagCode = item.CountryCode
  18800. tempDiaginfo.DiagName = item.CountryContentName
  18801. tempDiaginfo.DiagType = "1"
  18802. tempDiaginfo.MaindiagFlag = "0"
  18803. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18804. }
  18805. }
  18806. struct4101.Diseinfo = tempDiaginfos
  18807. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18808. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18809. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18810. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18811. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18812. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18813. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18814. var iteminfo service.IteminfoStruct
  18815. var bedCostTotal float64 = 0 //床位总费
  18816. var bedCostSelfTotal float64 = 0 //床位自费
  18817. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18818. var operationCostTotal float64 = 0 //手术费
  18819. var operationCostSelfTotal float64 = 0 //手术费
  18820. var operationCostPartSelfTotal float64 = 0 //手术费
  18821. var otherCostTotal float64 = 0 //其他费用
  18822. var otherCostSelfTotal float64 = 0 //其他费用
  18823. var otherCostPartSelfTotal float64 = 0 //其他费用
  18824. var materialCostTotal float64 = 0 //材料费
  18825. var materialCostSelfTotal float64 = 0 //材料费
  18826. var materialCostPartSelfTotal float64 = 0 //材料费
  18827. var westernMedicineCostTotal float64 = 0 //西药费
  18828. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18829. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18830. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18831. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18832. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18833. var checkCostTotal float64 = 0 //检查费
  18834. var checkCostSelfTotal float64 = 0 //检查费
  18835. var checkCostPartSelfTotal float64 = 0 //检查费
  18836. var laboratoryCostTotal float64 = 0 //化验费
  18837. var laboratoryCostSelfTotal float64 = 0 //化验费
  18838. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18839. var treatCostTotal float64 = 0 //治疗费用
  18840. var treatCostSelfTotal float64 = 0 //治疗费用
  18841. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18842. decimal.DivisionPrecision = 2
  18843. var bed_fulamt_ownpay_amt float64 = 0
  18844. var operation_fulamt_ownpay_amt float64 = 0
  18845. var other_fulamt_ownpay_amt float64 = 0
  18846. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18847. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18848. var check_fulamt_ownpay_amt float64 = 0
  18849. var material_fulamt_ownpay_amt float64 = 0
  18850. var laboratory_fulamt_ownpay_amt float64 = 0
  18851. var treat_fulamt_ownpay_amt float64 = 0
  18852. var bed_claa_sunmfee float64 = 0
  18853. var bed_clab_amt float64 = 0
  18854. var bed_other_amt float64 = 0
  18855. var operation_claa_sunmfee float64 = 0
  18856. var operation_clab_amt float64 = 0
  18857. var operation_other_amt float64 = 0
  18858. var other_claa_sunmfee float64 = 0
  18859. var other_clab_amt float64 = 0
  18860. var other_other_amt float64 = 0
  18861. var westernMedicine_claa_sunmfee float64 = 0
  18862. var westernMedicine_clab_amt float64 = 0
  18863. var westernMedicine_other_amt float64 = 0
  18864. var chineseTraditional_claa_sunmfee float64 = 0
  18865. var chineseTraditional_clab_amt float64 = 0
  18866. var chineseTraditional_other_amt float64 = 0
  18867. var check_claa_sunmfee float64 = 0
  18868. var check_clab_amt float64 = 0
  18869. var check_other_amt float64 = 0
  18870. var material_claa_sunmfee float64 = 0
  18871. var material_clab_amt float64 = 0
  18872. var material_other_amt float64 = 0
  18873. var laboratory_claa_sunmfee float64 = 0
  18874. var laboratory_clab_amt float64 = 0
  18875. var laboratory_other_amt float64 = 0
  18876. var treat_claa_sunmfee float64 = 0
  18877. var treat_clab_amt float64 = 0
  18878. var treat_other_amt float64 = 0
  18879. for _, item := range order.HisOrderInfo {
  18880. if item.MedChrgitmType == "01" { //床位费
  18881. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18882. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18883. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18884. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18885. if item.ChrgitmLv == "1" {
  18886. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18887. }
  18888. if item.ChrgitmLv == "2" {
  18889. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18890. }
  18891. if item.ChrgitmLv == "3" {
  18892. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18893. }
  18894. }
  18895. if item.MedChrgitmType == "03" { //检查费
  18896. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18897. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18898. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18899. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18900. if item.ChrgitmLv == "1" {
  18901. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18902. }
  18903. if item.ChrgitmLv == "2" {
  18904. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18905. }
  18906. if item.ChrgitmLv == "3" {
  18907. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18908. }
  18909. }
  18910. if item.MedChrgitmType == "04" { //化验费
  18911. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18912. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18913. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18914. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18915. if item.ChrgitmLv == "1" {
  18916. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18917. }
  18918. if item.ChrgitmLv == "2" {
  18919. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18920. }
  18921. if item.ChrgitmLv == "3" {
  18922. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18923. }
  18924. }
  18925. if item.MedChrgitmType == "05" { //治疗费
  18926. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18927. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18928. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18929. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18930. if item.ChrgitmLv == "1" {
  18931. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18932. }
  18933. if item.ChrgitmLv == "2" {
  18934. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18935. }
  18936. if item.ChrgitmLv == "3" {
  18937. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18938. }
  18939. }
  18940. if item.MedChrgitmType == "06" { //手术费
  18941. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18942. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18943. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18944. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18945. if item.ChrgitmLv == "1" {
  18946. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18947. }
  18948. if item.ChrgitmLv == "2" {
  18949. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18950. }
  18951. if item.ChrgitmLv == "3" {
  18952. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18953. }
  18954. }
  18955. if item.MedChrgitmType == "08" { //材料费
  18956. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18957. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18958. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18959. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18960. if item.ChrgitmLv == "1" {
  18961. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18962. }
  18963. if item.ChrgitmLv == "2" {
  18964. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. }
  18966. if item.ChrgitmLv == "3" {
  18967. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18968. }
  18969. }
  18970. if item.MedChrgitmType == "09" { //西药费
  18971. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18972. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18973. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18974. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18975. if item.ChrgitmLv == "1" {
  18976. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18977. }
  18978. if item.ChrgitmLv == "2" {
  18979. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18980. }
  18981. if item.ChrgitmLv == "3" {
  18982. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18983. }
  18984. }
  18985. if item.MedChrgitmType == "11" { //中成费
  18986. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18987. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18988. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18989. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18990. if item.ChrgitmLv == "1" {
  18991. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18992. }
  18993. if item.ChrgitmLv == "2" {
  18994. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18995. }
  18996. if item.ChrgitmLv == "3" {
  18997. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18998. }
  18999. }
  19000. if item.MedChrgitmType == "14" { //其他费
  19001. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19002. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19003. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19004. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19005. if item.ChrgitmLv == "1" {
  19006. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19007. }
  19008. if item.ChrgitmLv == "2" {
  19009. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19010. }
  19011. if item.ChrgitmLv == "3" {
  19012. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19013. }
  19014. }
  19015. }
  19016. var iteminfoStructs []service.IteminfoStruct
  19017. if bedCostTotal != 0 {
  19018. iteminfo.MedChrgitm = "01"
  19019. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19020. iteminfo.Amt = bedCostTotal
  19021. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19022. iteminfo.ClabAmt = bed_clab_amt
  19023. iteminfo.OthAmt = bed_other_amt
  19024. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19025. }
  19026. if checkCostTotal != 0 {
  19027. iteminfo.MedChrgitm = "03"
  19028. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19029. iteminfo.Amt = checkCostTotal
  19030. iteminfo.ClaaSumfee = check_claa_sunmfee
  19031. iteminfo.ClabAmt = check_clab_amt
  19032. iteminfo.OthAmt = check_other_amt
  19033. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19034. }
  19035. if laboratoryCostTotal != 0 {
  19036. iteminfo.MedChrgitm = "04"
  19037. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19038. iteminfo.Amt = laboratoryCostTotal
  19039. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19040. iteminfo.ClabAmt = laboratory_clab_amt
  19041. iteminfo.OthAmt = laboratory_other_amt
  19042. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19043. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19044. }
  19045. if treatCostTotal != 0 {
  19046. iteminfo.MedChrgitm = "05"
  19047. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19048. iteminfo.Amt = treatCostTotal
  19049. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19050. iteminfo.ClabAmt = treat_clab_amt
  19051. iteminfo.OthAmt = treat_other_amt
  19052. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19053. //(struct4101.IteminfoStruct, iteminfo)
  19054. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19055. }
  19056. if operationCostTotal != 0 {
  19057. iteminfo.MedChrgitm = "06"
  19058. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19059. iteminfo.Amt = operationCostTotal
  19060. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19061. iteminfo.ClabAmt = operation_clab_amt
  19062. iteminfo.OthAmt = operation_other_amt
  19063. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19064. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19065. }
  19066. if materialCostTotal != 0 {
  19067. iteminfo.MedChrgitm = "08"
  19068. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19069. iteminfo.Amt = materialCostTotal
  19070. iteminfo.ClaaSumfee = material_claa_sunmfee
  19071. iteminfo.ClabAmt = material_clab_amt
  19072. iteminfo.OthAmt = material_other_amt
  19073. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19074. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19075. }
  19076. if westernMedicineCostTotal != 0 {
  19077. iteminfo.MedChrgitm = "09"
  19078. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19079. iteminfo.Amt = westernMedicineCostTotal
  19080. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19081. iteminfo.ClabAmt = westernMedicine_clab_amt
  19082. iteminfo.OthAmt = westernMedicine_other_amt
  19083. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19084. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19085. }
  19086. if chineseTraditionalMedicineCostTotal != 0 {
  19087. iteminfo.MedChrgitm = "11"
  19088. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19089. iteminfo.Amt = westernMedicineCostTotal
  19090. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19091. iteminfo.ClabAmt = westernMedicine_clab_amt
  19092. iteminfo.OthAmt = westernMedicine_other_amt
  19093. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19094. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19095. }
  19096. if otherCostTotal != 0 {
  19097. iteminfo.MedChrgitm = "14"
  19098. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19099. iteminfo.Amt = otherCostTotal
  19100. iteminfo.ClaaSumfee = other_claa_sunmfee
  19101. iteminfo.ClabAmt = other_clab_amt
  19102. iteminfo.OthAmt = other_other_amt
  19103. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19104. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19105. }
  19106. struct4101.IteminfoStruct = iteminfoStructs
  19107. struct4101.Ntly = "中国"
  19108. struct4101.AdmCaty = "A03.06"
  19109. struct4101.DoctorName = doctor.UserName
  19110. struct4101.DoctorCode = doctor.DoctorNumber
  19111. var res ResultSeventeen
  19112. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19113. struct4101.BillCode = order.Number
  19114. struct4101.BillNo = order.SetlId
  19115. var resOther ResultSeventeenOther
  19116. var pp models.PublicParams
  19117. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19118. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19119. pp.FixmedinsName = miConfig.OrgName
  19120. pp.FixmedinsCode = miConfig.Code
  19121. pp.RequestUrl = miConfig.Url
  19122. pp.Cainfo = miConfig.Cainfo
  19123. pp.SecretKey = miConfig.SecretKey
  19124. pp.AccessKey = miConfig.AccessKey
  19125. pp.OpterName = curRoles.UserName
  19126. client := &http.Client{}
  19127. var req *http.Request
  19128. data := make(map[string]interface{})
  19129. data["struct4101"] = struct4101
  19130. data["pp"] = pp
  19131. bytesData, _ := json.Marshal(data)
  19132. if miConfig.MdtrtareaAdmvs == "320921" {
  19133. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19134. } else {
  19135. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19136. }
  19137. resp, _ := client.Do(req)
  19138. defer resp.Body.Close()
  19139. body, ioErr := ioutil.ReadAll(resp.Body)
  19140. if ioErr != nil {
  19141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19143. return
  19144. }
  19145. var respJSON map[string]interface{}
  19146. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19149. return
  19150. }
  19151. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19152. userJSONBytes, _ := json.Marshal(respJSON)
  19153. fmt.Println("log")
  19154. fmt.Println(string(userJSONBytes))
  19155. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19156. utils.ErrorLog("解析失败:%v", err)
  19157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19158. return
  19159. }
  19160. res.InfRefmsgid = resOther.InfRefmsgid
  19161. res.Output = resOther.Output
  19162. res.ErrMsg = resOther.ErrMsg
  19163. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19164. res.Infcode = infocode
  19165. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19166. var pp models.PublicParams
  19167. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19168. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19169. pp.FixmedinsName = miConfig.OrgName
  19170. pp.FixmedinsCode = miConfig.Code
  19171. pp.RequestUrl = miConfig.Url
  19172. pp.Cainfo = miConfig.Cainfo
  19173. pp.SecretKey = miConfig.SecretKey
  19174. pp.AccessKey = miConfig.AccessKey
  19175. pp.OpterName = curRoles.UserName
  19176. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19177. result, _ := service.Jxyb4101(struct4101, pp)
  19178. var dat map[string]interface{}
  19179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19180. fmt.Println(dat)
  19181. } else {
  19182. fmt.Println(err)
  19183. }
  19184. userJSONBytes, _ := json.Marshal(dat)
  19185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19186. utils.ErrorLog("解析失败:%v", err)
  19187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19188. return
  19189. }
  19190. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19191. var pp models.PublicParams
  19192. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19193. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19194. pp.FixmedinsName = miConfig.OrgName
  19195. pp.FixmedinsCode = miConfig.Code
  19196. pp.RequestUrl = miConfig.Url
  19197. pp.Cainfo = miConfig.Cainfo
  19198. pp.SecretKey = miConfig.SecretKey
  19199. pp.AccessKey = miConfig.AccessKey
  19200. pp.OpterName = curRoles.UserName
  19201. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19202. result, _ := service.Jxyb4101(struct4101, pp)
  19203. var dat map[string]interface{}
  19204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19205. fmt.Println(dat)
  19206. } else {
  19207. fmt.Println(err)
  19208. }
  19209. userJSONBytes, _ := json.Marshal(dat)
  19210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19211. utils.ErrorLog("解析失败:%v", err)
  19212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19213. return
  19214. }
  19215. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19216. var pp models.PublicParams
  19217. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19218. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19219. pp.FixmedinsName = miConfig.OrgName
  19220. pp.FixmedinsCode = miConfig.Code
  19221. pp.RequestUrl = miConfig.Url
  19222. pp.Cainfo = miConfig.Cainfo
  19223. pp.SecretKey = miConfig.SecretKey
  19224. pp.AccessKey = miConfig.AccessKey
  19225. pp.OpterName = curRoles.UserName
  19226. result, _ := service.Hnyb4101(struct4101, pp)
  19227. var dat map[string]interface{}
  19228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19229. fmt.Println(dat)
  19230. } else {
  19231. fmt.Println(err)
  19232. }
  19233. userJSONBytes, _ := json.Marshal(dat)
  19234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19235. utils.ErrorLog("解析失败:%v", err)
  19236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19237. return
  19238. }
  19239. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19240. var resOther ResultSeventeenOther
  19241. var pp models.PublicParams
  19242. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19243. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19244. pp.FixmedinsName = miConfig.OrgName
  19245. pp.FixmedinsCode = miConfig.Code
  19246. pp.RequestUrl = miConfig.Url
  19247. pp.Cainfo = miConfig.Cainfo
  19248. pp.SecretKey = miConfig.SecretKey
  19249. pp.AccessKey = miConfig.AccessKey
  19250. pp.OpterName = curRoles.UserName
  19251. client := &http.Client{}
  19252. var req *http.Request
  19253. data := make(map[string]interface{})
  19254. data["struct4101"] = struct4101
  19255. data["pp"] = pp
  19256. bytesData, _ := json.Marshal(data)
  19257. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19258. resp, _ := client.Do(req)
  19259. defer resp.Body.Close()
  19260. body, ioErr := ioutil.ReadAll(resp.Body)
  19261. if ioErr != nil {
  19262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19264. return
  19265. }
  19266. var respJSON map[string]interface{}
  19267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19270. return
  19271. }
  19272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19273. userJSONBytes, _ := json.Marshal(respJSON)
  19274. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19275. utils.ErrorLog("解析失败:%v", err)
  19276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19277. return
  19278. }
  19279. res.InfRefmsgid = resOther.InfRefmsgid
  19280. res.Output = resOther.Output
  19281. res.ErrMsg = resOther.ErrMsg
  19282. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19283. res.Infcode = infocode
  19284. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19285. var pp models.PublicParams
  19286. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19287. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19288. pp.FixmedinsName = miConfig.OrgName
  19289. pp.FixmedinsCode = miConfig.Code
  19290. pp.RequestUrl = miConfig.Url
  19291. pp.Cainfo = miConfig.Cainfo
  19292. pp.SecretKey = miConfig.SecretKey
  19293. pp.AccessKey = miConfig.AccessKey
  19294. pp.OpterName = curRoles.UserName
  19295. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19296. fmt.Println(requestLog)
  19297. fmt.Println(errMsgLog)
  19298. saveLog(result, requestLog, "4101a", "上传清单")
  19299. var dat map[string]interface{}
  19300. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19301. fmt.Println(dat)
  19302. } else {
  19303. fmt.Println(err)
  19304. }
  19305. userJSONBytes, _ := json.Marshal(dat)
  19306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19307. utils.ErrorLog("解析失败:%v", err)
  19308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19309. return
  19310. }
  19311. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19312. var pp models.PublicParams
  19313. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19314. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19315. pp.FixmedinsName = miConfig.OrgName
  19316. pp.FixmedinsCode = miConfig.Code
  19317. pp.RequestUrl = miConfig.Url
  19318. pp.Cainfo = miConfig.Cainfo
  19319. pp.SecretKey = miConfig.SecretKey
  19320. pp.AccessKey = miConfig.AccessKey
  19321. pp.OpterName = curRoles.UserName
  19322. client := &http.Client{}
  19323. var req *http.Request
  19324. data := make(map[string]interface{})
  19325. data["struct4101"] = struct4101
  19326. data["pp"] = pp
  19327. bytesData, _ := json.Marshal(data)
  19328. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19329. resp, _ := client.Do(req)
  19330. defer resp.Body.Close()
  19331. body, ioErr := ioutil.ReadAll(resp.Body)
  19332. if ioErr != nil {
  19333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19335. return
  19336. }
  19337. var respJSON map[string]interface{}
  19338. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19341. return
  19342. }
  19343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19344. userJSONBytes, _ := json.Marshal(respJSON)
  19345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19346. utils.ErrorLog("解析失败:%v", err)
  19347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19348. return
  19349. }
  19350. } else {
  19351. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  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. if res.Infcode != 0 {
  19366. errlog := &models.HisOrderError{
  19367. UserOrgId: order.UserOrgId,
  19368. Ctime: time.Now().Unix(),
  19369. Mtime: time.Now().Unix(),
  19370. ErrMsg: res.ErrMsg + "解析失败",
  19371. Status: 1,
  19372. PatientId: order.ID,
  19373. Stage: 10485,
  19374. }
  19375. service.CreateErrMsgLog(errlog)
  19376. continue
  19377. //c.ServeSuccessJSON(map[string]interface{}{
  19378. // "failed_code": -10,
  19379. // "msg": res.ErrMsg,
  19380. //})
  19381. } else {
  19382. //order.FaPiaoNumber = zero
  19383. //order.FaPiaoCode = last_order.FaPiaoCode
  19384. //service.UpdateOrder(order)
  19385. hisFundSettleListResult := &models.HisFundSettleListResult{
  19386. Number: res.Output.SetlListId,
  19387. Status: 1,
  19388. Ctime: time.Now().Unix(),
  19389. Mtime: time.Now().Unix(),
  19390. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19391. IsUpload: 1,
  19392. OrderId: order.ID,
  19393. }
  19394. service.CreateUploadRecord(hisFundSettleListResult)
  19395. continue
  19396. }
  19397. }
  19398. }
  19399. func (c *HisApiController) GetSettleList() {
  19400. order_id, _ := c.GetInt64("order_id")
  19401. admin_user_id, _ := c.GetInt64("admin_user_id")
  19402. order, _ := service.GetHisOrderByIDTwo(order_id)
  19403. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19404. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19405. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19406. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19407. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19409. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19410. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19411. if order.ID == 0 {
  19412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19413. return
  19414. }
  19415. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19416. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19417. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19418. //fmt.Println(count)
  19419. //var zero string
  19420. //number := count + 1
  19421. //if number >= 1000 {
  19422. // zero = "0000" + strconv.FormatInt(number, 10)
  19423. //} else if number >= 10000 {
  19424. // zero = "000" + strconv.FormatInt(number, 10)
  19425. //} else if number >= 100000 {
  19426. // zero = "00" + strconv.FormatInt(number, 10)
  19427. //} else if number >= 1000000 {
  19428. // zero = "0" + strconv.FormatInt(number, 10)
  19429. //} else {
  19430. // zero = strconv.FormatInt(number, 10)
  19431. //}
  19432. //fmt.Println(zero)
  19433. struct4101 := service.Struct4101{
  19434. PsnNo: order.PsnNo,
  19435. MdtrtId: order.MdtrtId,
  19436. SetlId: order.SetlId,
  19437. PsnName: order.PsnName,
  19438. Gend: order.Gend,
  19439. Brdy: his.Brdy,
  19440. Age: his.Age,
  19441. Naty: order.Naty,
  19442. PatnCertType: "01",
  19443. Certno: order.Certno,
  19444. Prfs: "90",
  19445. ConerName: roles[0].UserName,
  19446. PatnRlts: "99",
  19447. ConerAddr: miConfig.OrgName,
  19448. ConerTel: admin.Mobile,
  19449. HiType: order.Insutype,
  19450. Insuplc: miConfig.InsuplcAdmdvs,
  19451. MaindiagFlag: "1",
  19452. BillCode: order.SetlId,
  19453. BillNo: order.SetlId,
  19454. BizSn: order.Number,
  19455. PsnSelfPay: order.PsnPartAmt,
  19456. PsnOwnPay: order.PsnPartAmt,
  19457. AcctPay: order.AcctPay,
  19458. PsnCashpay: order.PsnCashPay,
  19459. HiPaymtd: "1",
  19460. Hsorg: miConfig.InsuplcAdmdvs,
  19461. HsorgOpter: miConfig.InsuplcAdmdvs,
  19462. MedinsFillPsn: curRoles.UserName,
  19463. MedinsFillDept: miConfig.OrgName,
  19464. IptMedType: "2",
  19465. }
  19466. struct4101.SetlBegnDate = order.SetlTime
  19467. struct4101.SetlEndDate = order.SetlTime
  19468. time_arr := strings.Split(order.SetlTime, " ")
  19469. struct4101.AdmTime = time_arr[0]
  19470. struct4101.AdmEndTime = time_arr[0]
  19471. //
  19472. //var rf []CustomFundPay
  19473. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19474. //
  19475. //var tempFunPays []service.CustomStruct
  19476. //for _, item := range rf {
  19477. // var tempFunPay service.CustomStruct
  19478. // tempFunPay.FundPayamt = item.FundPayamt
  19479. // tempFunPay.FundPayType = item.FundPayType
  19480. // tempFunPays = append(tempFunPays, tempFunPay)
  19481. //}
  19482. //struct4101.CustomStruct = tempFunPays
  19483. var tempDiaginfos []service.DiaginfoStructTwo
  19484. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19485. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19486. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19487. var config []*models.HisXtDiagnoseConfig
  19488. for _, item := range diagnosis_ids {
  19489. id, _ := strconv.ParseInt(item, 10, 64)
  19490. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19491. config = append(config, &diagnosisConfig)
  19492. }
  19493. if miConfig.Code == "H15049901371" {
  19494. //for _, item := range config {
  19495. // if item.ID == 138 {
  19496. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19497. var tempDiaginfo service.DiaginfoStructTwo
  19498. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19499. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19500. tempDiaginfo.DiagType = "1"
  19501. tempDiaginfo.MaindiagFlag = "1"
  19502. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19503. //}
  19504. //}
  19505. for _, item := range config {
  19506. if item.ID != 138 {
  19507. var tempDiaginfo service.DiaginfoStructTwo
  19508. tempDiaginfo.DiagCode = item.CountryCode
  19509. tempDiaginfo.DiagName = item.CountryContentName
  19510. tempDiaginfo.DiagType = "1"
  19511. tempDiaginfo.MaindiagFlag = "0"
  19512. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19513. }
  19514. }
  19515. } else {
  19516. for index, item := range config {
  19517. if index == 0 {
  19518. var tempDiaginfo service.DiaginfoStructTwo
  19519. tempDiaginfo.DiagCode = item.CountryCode
  19520. tempDiaginfo.DiagName = item.CountryContentName
  19521. tempDiaginfo.DiagType = "1"
  19522. tempDiaginfo.MaindiagFlag = "1"
  19523. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19524. } else {
  19525. var tempDiaginfo service.DiaginfoStructTwo
  19526. tempDiaginfo.DiagCode = item.CountryCode
  19527. tempDiaginfo.DiagName = item.CountryContentName
  19528. tempDiaginfo.DiagType = "1"
  19529. tempDiaginfo.MaindiagFlag = "0"
  19530. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19531. }
  19532. }
  19533. }
  19534. struct4101.Diseinfo = tempDiaginfos
  19535. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19536. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19537. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19538. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19539. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19540. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19541. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19542. var iteminfo service.IteminfoStruct
  19543. var bedCostTotal float64 = 0 //床位总费
  19544. var bedCostSelfTotal float64 = 0 //床位自费
  19545. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19546. var operationCostTotal float64 = 0 //手术费
  19547. var operationCostSelfTotal float64 = 0 //手术费
  19548. var operationCostPartSelfTotal float64 = 0 //手术费
  19549. var otherCostTotal float64 = 0 //其他费用
  19550. var otherCostSelfTotal float64 = 0 //其他费用
  19551. var otherCostPartSelfTotal float64 = 0 //其他费用
  19552. var materialCostTotal float64 = 0 //材料费
  19553. var materialCostSelfTotal float64 = 0 //材料费
  19554. var materialCostPartSelfTotal float64 = 0 //材料费
  19555. var westernMedicineCostTotal float64 = 0 //西药费
  19556. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19557. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19558. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19559. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19560. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19561. var checkCostTotal float64 = 0 //检查费
  19562. var checkCostSelfTotal float64 = 0 //检查费
  19563. var checkCostPartSelfTotal float64 = 0 //检查费
  19564. var laboratoryCostTotal float64 = 0 //化验费
  19565. var laboratoryCostSelfTotal float64 = 0 //化验费
  19566. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19567. var treatCostTotal float64 = 0 //治疗费用
  19568. var treatCostSelfTotal float64 = 0 //治疗费用
  19569. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19570. decimal.DivisionPrecision = 2
  19571. var bed_fulamt_ownpay_amt float64 = 0
  19572. var operation_fulamt_ownpay_amt float64 = 0
  19573. var other_fulamt_ownpay_amt float64 = 0
  19574. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19575. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19576. var check_fulamt_ownpay_amt float64 = 0
  19577. var material_fulamt_ownpay_amt float64 = 0
  19578. var laboratory_fulamt_ownpay_amt float64 = 0
  19579. var treat_fulamt_ownpay_amt float64 = 0
  19580. var bed_claa_sunmfee float64 = 0
  19581. var bed_clab_amt float64 = 0
  19582. var bed_other_amt float64 = 0
  19583. var operation_claa_sunmfee float64 = 0
  19584. var operation_clab_amt float64 = 0
  19585. var operation_other_amt float64 = 0
  19586. var other_claa_sunmfee float64 = 0
  19587. var other_clab_amt float64 = 0
  19588. var other_other_amt float64 = 0
  19589. var westernMedicine_claa_sunmfee float64 = 0
  19590. var westernMedicine_clab_amt float64 = 0
  19591. var westernMedicine_other_amt float64 = 0
  19592. var chineseTraditional_claa_sunmfee float64 = 0
  19593. var chineseTraditional_clab_amt float64 = 0
  19594. var chineseTraditional_other_amt float64 = 0
  19595. var check_claa_sunmfee float64 = 0
  19596. var check_clab_amt float64 = 0
  19597. var check_other_amt float64 = 0
  19598. var material_claa_sunmfee float64 = 0
  19599. var material_clab_amt float64 = 0
  19600. var material_other_amt float64 = 0
  19601. var laboratory_claa_sunmfee float64 = 0
  19602. var laboratory_clab_amt float64 = 0
  19603. var laboratory_other_amt float64 = 0
  19604. var treat_claa_sunmfee float64 = 0
  19605. var treat_clab_amt float64 = 0
  19606. var treat_other_amt float64 = 0
  19607. for _, item := range order.HisOrderInfo {
  19608. if item.MedChrgitmType == "01" { //床位费
  19609. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19610. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19611. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19612. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19613. if item.ChrgitmLv == "1" {
  19614. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19615. }
  19616. if item.ChrgitmLv == "2" {
  19617. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19618. }
  19619. if item.ChrgitmLv == "3" {
  19620. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19621. }
  19622. }
  19623. if item.MedChrgitmType == "03" { //检查费
  19624. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19625. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19626. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19627. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19628. if item.ChrgitmLv == "1" {
  19629. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19630. }
  19631. if item.ChrgitmLv == "2" {
  19632. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19633. }
  19634. if item.ChrgitmLv == "3" {
  19635. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19636. }
  19637. }
  19638. if item.MedChrgitmType == "04" { //化验费
  19639. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19640. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19641. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19642. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19643. if item.ChrgitmLv == "1" {
  19644. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19645. }
  19646. if item.ChrgitmLv == "2" {
  19647. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19648. }
  19649. if item.ChrgitmLv == "3" {
  19650. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19651. }
  19652. }
  19653. if item.MedChrgitmType == "05" { //治疗费
  19654. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19655. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19656. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19657. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19658. if item.ChrgitmLv == "1" {
  19659. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19660. }
  19661. if item.ChrgitmLv == "2" {
  19662. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19663. }
  19664. if item.ChrgitmLv == "3" {
  19665. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19666. }
  19667. }
  19668. if item.MedChrgitmType == "06" { //手术费
  19669. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19670. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19671. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19672. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19673. if item.ChrgitmLv == "1" {
  19674. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19675. }
  19676. if item.ChrgitmLv == "2" {
  19677. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19678. }
  19679. if item.ChrgitmLv == "3" {
  19680. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19681. }
  19682. }
  19683. if item.MedChrgitmType == "08" { //材料费
  19684. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19685. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19686. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19687. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19688. if item.ChrgitmLv == "1" {
  19689. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19690. }
  19691. if item.ChrgitmLv == "2" {
  19692. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19693. }
  19694. if item.ChrgitmLv == "3" {
  19695. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19696. }
  19697. }
  19698. if item.MedChrgitmType == "09" { //西药费
  19699. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19700. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19701. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19702. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19703. if item.ChrgitmLv == "1" {
  19704. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19705. }
  19706. if item.ChrgitmLv == "2" {
  19707. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19708. }
  19709. if item.ChrgitmLv == "3" {
  19710. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19711. }
  19712. }
  19713. if item.MedChrgitmType == "11" { //中成费
  19714. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19715. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19716. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19717. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19718. if item.ChrgitmLv == "1" {
  19719. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19720. }
  19721. if item.ChrgitmLv == "2" {
  19722. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19723. }
  19724. if item.ChrgitmLv == "3" {
  19725. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19726. }
  19727. }
  19728. if item.MedChrgitmType == "14" { //其他费
  19729. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19730. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19731. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19732. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19733. if item.ChrgitmLv == "1" {
  19734. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19735. }
  19736. if item.ChrgitmLv == "2" {
  19737. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19738. }
  19739. if item.ChrgitmLv == "3" {
  19740. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19741. }
  19742. }
  19743. }
  19744. var iteminfoStructs []service.IteminfoStruct
  19745. if bedCostTotal != 0 {
  19746. iteminfo.MedChrgitm = "01"
  19747. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19748. iteminfo.Amt = bedCostTotal
  19749. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19750. iteminfo.ClabAmt = bed_clab_amt
  19751. iteminfo.OthAmt = bed_other_amt
  19752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19753. }
  19754. if checkCostTotal != 0 {
  19755. iteminfo.MedChrgitm = "03"
  19756. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19757. iteminfo.Amt = checkCostTotal
  19758. iteminfo.ClaaSumfee = check_claa_sunmfee
  19759. iteminfo.ClabAmt = check_clab_amt
  19760. iteminfo.OthAmt = check_other_amt
  19761. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19762. }
  19763. if laboratoryCostTotal != 0 {
  19764. iteminfo.MedChrgitm = "04"
  19765. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19766. iteminfo.Amt = laboratoryCostTotal
  19767. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19768. iteminfo.ClabAmt = laboratory_clab_amt
  19769. iteminfo.OthAmt = laboratory_other_amt
  19770. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19771. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19772. }
  19773. if treatCostTotal != 0 {
  19774. iteminfo.MedChrgitm = "05"
  19775. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19776. iteminfo.Amt = treatCostTotal
  19777. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19778. iteminfo.ClabAmt = treat_clab_amt
  19779. iteminfo.OthAmt = treat_other_amt
  19780. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19781. //(struct4101.IteminfoStruct, iteminfo)
  19782. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19783. }
  19784. if operationCostTotal != 0 {
  19785. iteminfo.MedChrgitm = "06"
  19786. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19787. iteminfo.Amt = operationCostTotal
  19788. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19789. iteminfo.ClabAmt = operation_clab_amt
  19790. iteminfo.OthAmt = operation_other_amt
  19791. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19792. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19793. }
  19794. if materialCostTotal != 0 {
  19795. iteminfo.MedChrgitm = "08"
  19796. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19797. iteminfo.Amt = materialCostTotal
  19798. iteminfo.ClaaSumfee = material_claa_sunmfee
  19799. iteminfo.ClabAmt = material_clab_amt
  19800. iteminfo.OthAmt = material_other_amt
  19801. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19802. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19803. }
  19804. if westernMedicineCostTotal != 0 {
  19805. iteminfo.MedChrgitm = "09"
  19806. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19807. iteminfo.Amt = westernMedicineCostTotal
  19808. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19809. iteminfo.ClabAmt = westernMedicine_clab_amt
  19810. iteminfo.OthAmt = westernMedicine_other_amt
  19811. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19812. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19813. }
  19814. if chineseTraditionalMedicineCostTotal != 0 {
  19815. iteminfo.MedChrgitm = "11"
  19816. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19817. iteminfo.Amt = westernMedicineCostTotal
  19818. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19819. iteminfo.ClabAmt = westernMedicine_clab_amt
  19820. iteminfo.OthAmt = westernMedicine_other_amt
  19821. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19822. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19823. }
  19824. if otherCostTotal != 0 {
  19825. iteminfo.MedChrgitm = "14"
  19826. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19827. iteminfo.Amt = otherCostTotal
  19828. iteminfo.ClaaSumfee = other_claa_sunmfee
  19829. iteminfo.ClabAmt = other_clab_amt
  19830. iteminfo.OthAmt = other_other_amt
  19831. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19832. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19833. }
  19834. struct4101.IteminfoStruct = iteminfoStructs
  19835. struct4101.Ntly = "中国"
  19836. struct4101.AdmCaty = "A03.06"
  19837. struct4101.DoctorName = doctor.UserName
  19838. struct4101.DoctorCode = doctor.DoctorNumber
  19839. var res ResultSeventeen
  19840. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19841. struct4101.BillCode = order.Number
  19842. struct4101.BillNo = order.SetlId
  19843. var resOther ResultSeventeenOther
  19844. var pp models.PublicParams
  19845. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19846. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19847. pp.FixmedinsName = miConfig.OrgName
  19848. pp.FixmedinsCode = miConfig.Code
  19849. pp.RequestUrl = miConfig.Url
  19850. pp.Cainfo = miConfig.Cainfo
  19851. pp.SecretKey = miConfig.SecretKey
  19852. pp.AccessKey = miConfig.AccessKey
  19853. pp.OpterName = curRoles.UserName
  19854. client := &http.Client{}
  19855. var req *http.Request
  19856. data := make(map[string]interface{})
  19857. data["struct4101"] = struct4101
  19858. data["pp"] = pp
  19859. bytesData, _ := json.Marshal(data)
  19860. if miConfig.MdtrtareaAdmvs == "320921" {
  19861. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19862. } else {
  19863. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19864. }
  19865. resp, _ := client.Do(req)
  19866. defer resp.Body.Close()
  19867. body, ioErr := ioutil.ReadAll(resp.Body)
  19868. if ioErr != nil {
  19869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19871. return
  19872. }
  19873. var respJSON map[string]interface{}
  19874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19877. return
  19878. }
  19879. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19880. userJSONBytes, _ := json.Marshal(respJSON)
  19881. fmt.Println("log")
  19882. fmt.Println(string(userJSONBytes))
  19883. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19884. utils.ErrorLog("解析失败:%v", err)
  19885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19886. return
  19887. }
  19888. res.InfRefmsgid = resOther.InfRefmsgid
  19889. res.Output = resOther.Output
  19890. res.ErrMsg = resOther.ErrMsg
  19891. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19892. res.Infcode = infocode
  19893. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19894. var pp models.PublicParams
  19895. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19896. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19897. pp.FixmedinsName = miConfig.OrgName
  19898. pp.FixmedinsCode = miConfig.Code
  19899. pp.RequestUrl = miConfig.Url
  19900. pp.Cainfo = miConfig.Cainfo
  19901. pp.SecretKey = miConfig.SecretKey
  19902. pp.AccessKey = miConfig.AccessKey
  19903. pp.OpterName = curRoles.UserName
  19904. result, _ := service.Jxyb4101(struct4101, pp)
  19905. var dat map[string]interface{}
  19906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19907. fmt.Println(dat)
  19908. } else {
  19909. fmt.Println(err)
  19910. }
  19911. userJSONBytes, _ := json.Marshal(dat)
  19912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19913. utils.ErrorLog("解析失败:%v", err)
  19914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19915. return
  19916. }
  19917. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19918. var pp models.PublicParams
  19919. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19920. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19921. pp.FixmedinsName = miConfig.OrgName
  19922. pp.FixmedinsCode = miConfig.Code
  19923. pp.RequestUrl = miConfig.Url
  19924. pp.Cainfo = miConfig.Cainfo
  19925. pp.SecretKey = miConfig.SecretKey
  19926. pp.AccessKey = miConfig.AccessKey
  19927. pp.OpterName = curRoles.UserName
  19928. result, _ := service.Jxyb4101(struct4101, pp)
  19929. var dat map[string]interface{}
  19930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19931. fmt.Println(dat)
  19932. } else {
  19933. fmt.Println(err)
  19934. }
  19935. userJSONBytes, _ := json.Marshal(dat)
  19936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19937. utils.ErrorLog("解析失败:%v", err)
  19938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19939. return
  19940. }
  19941. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19942. var pp models.PublicParams
  19943. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19944. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19945. pp.FixmedinsName = miConfig.OrgName
  19946. pp.FixmedinsCode = miConfig.Code
  19947. pp.RequestUrl = miConfig.Url
  19948. pp.Cainfo = miConfig.Cainfo
  19949. pp.SecretKey = miConfig.SecretKey
  19950. pp.AccessKey = miConfig.AccessKey
  19951. pp.OpterName = curRoles.UserName
  19952. result, _ := service.Hnyb4101(struct4101, pp)
  19953. var dat map[string]interface{}
  19954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19955. fmt.Println(dat)
  19956. } else {
  19957. fmt.Println(err)
  19958. }
  19959. userJSONBytes, _ := json.Marshal(dat)
  19960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19961. utils.ErrorLog("解析失败:%v", err)
  19962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19963. return
  19964. }
  19965. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19966. var resOther ResultSeventeenOther
  19967. var pp models.PublicParams
  19968. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19969. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19970. pp.FixmedinsName = miConfig.OrgName
  19971. pp.FixmedinsCode = miConfig.Code
  19972. pp.RequestUrl = miConfig.Url
  19973. pp.Cainfo = miConfig.Cainfo
  19974. pp.SecretKey = miConfig.SecretKey
  19975. pp.AccessKey = miConfig.AccessKey
  19976. pp.OpterName = curRoles.UserName
  19977. client := &http.Client{}
  19978. var req *http.Request
  19979. data := make(map[string]interface{})
  19980. data["struct4101"] = struct4101
  19981. data["pp"] = pp
  19982. bytesData, _ := json.Marshal(data)
  19983. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19984. resp, _ := client.Do(req)
  19985. defer resp.Body.Close()
  19986. body, ioErr := ioutil.ReadAll(resp.Body)
  19987. if ioErr != nil {
  19988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19990. return
  19991. }
  19992. var respJSON map[string]interface{}
  19993. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19996. return
  19997. }
  19998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19999. userJSONBytes, _ := json.Marshal(respJSON)
  20000. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20001. utils.ErrorLog("解析失败:%v", err)
  20002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20003. return
  20004. }
  20005. res.InfRefmsgid = resOther.InfRefmsgid
  20006. res.Output = resOther.Output
  20007. res.ErrMsg = resOther.ErrMsg
  20008. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20009. res.Infcode = infocode
  20010. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20011. var pp models.PublicParams
  20012. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20013. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20014. pp.FixmedinsName = miConfig.OrgName
  20015. pp.FixmedinsCode = miConfig.Code
  20016. pp.RequestUrl = miConfig.Url
  20017. pp.Cainfo = miConfig.Cainfo
  20018. pp.SecretKey = miConfig.SecretKey
  20019. pp.AccessKey = miConfig.AccessKey
  20020. pp.OpterName = curRoles.UserName
  20021. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20022. fmt.Println(requestLog)
  20023. fmt.Println(errMsgLog)
  20024. saveLog(result, requestLog, "4101a", "上传清单")
  20025. var dat map[string]interface{}
  20026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20027. fmt.Println(dat)
  20028. } else {
  20029. fmt.Println(err)
  20030. }
  20031. userJSONBytes, _ := json.Marshal(dat)
  20032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20033. utils.ErrorLog("解析失败:%v", err)
  20034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20035. return
  20036. }
  20037. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20038. var pp models.PublicParams
  20039. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20040. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20041. pp.FixmedinsName = miConfig.OrgName
  20042. pp.FixmedinsCode = miConfig.Code
  20043. pp.RequestUrl = miConfig.Url
  20044. pp.Cainfo = miConfig.Cainfo
  20045. pp.SecretKey = miConfig.SecretKey
  20046. pp.AccessKey = miConfig.AccessKey
  20047. pp.OpterName = curRoles.UserName
  20048. client := &http.Client{}
  20049. var req *http.Request
  20050. data := make(map[string]interface{})
  20051. data["struct4101"] = struct4101
  20052. data["pp"] = pp
  20053. bytesData, _ := json.Marshal(data)
  20054. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20055. resp, _ := client.Do(req)
  20056. defer resp.Body.Close()
  20057. body, ioErr := ioutil.ReadAll(resp.Body)
  20058. if ioErr != nil {
  20059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20061. return
  20062. }
  20063. var respJSON map[string]interface{}
  20064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20067. return
  20068. }
  20069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20070. userJSONBytes, _ := json.Marshal(respJSON)
  20071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20072. utils.ErrorLog("解析失败:%v", err)
  20073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20074. return
  20075. }
  20076. } else {
  20077. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20078. var dat map[string]interface{}
  20079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20080. fmt.Println(dat)
  20081. } else {
  20082. fmt.Println(err)
  20083. }
  20084. userJSONBytes, _ := json.Marshal(dat)
  20085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20086. utils.ErrorLog("解析失败:%v", err)
  20087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20088. return
  20089. }
  20090. }
  20091. if res.Infcode != 0 {
  20092. c.ServeSuccessJSON(map[string]interface{}{
  20093. "failed_code": -10,
  20094. "msg": res.ErrMsg,
  20095. })
  20096. return
  20097. } else {
  20098. //order.FaPiaoNumber = zero
  20099. //order.FaPiaoCode = last_order.FaPiaoCode
  20100. //service.UpdateOrder(order)
  20101. hisFundSettleListResult := &models.HisFundSettleListResult{
  20102. Number: res.Output.SetlListId,
  20103. Status: 1,
  20104. Ctime: time.Now().Unix(),
  20105. Mtime: time.Now().Unix(),
  20106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20107. IsUpload: 1,
  20108. OrderId: order_id,
  20109. }
  20110. service.CreateUploadRecord(hisFundSettleListResult)
  20111. c.ServeSuccessJSON(map[string]interface{}{
  20112. "msg": "上传成功",
  20113. "result": hisFundSettleListResult,
  20114. })
  20115. return
  20116. }
  20117. }
  20118. func (c *HisApiController) GetSettleListHospital() {
  20119. order_id, _ := c.GetInt64("order_id")
  20120. admin_user_id, _ := c.GetInt64("admin_user_id")
  20121. order, _ := service.GetHisOrderByIDTwo(order_id)
  20122. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20123. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20124. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20125. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20126. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20127. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20128. if order.ID == 0 {
  20129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20130. return
  20131. }
  20132. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20133. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20134. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20135. fmt.Println(count)
  20136. var zero string
  20137. number := count + 1
  20138. if number >= 1000 {
  20139. zero = "0000" + strconv.FormatInt(number, 10)
  20140. } else if number >= 10000 {
  20141. zero = "000" + strconv.FormatInt(number, 10)
  20142. } else if number >= 100000 {
  20143. zero = "00" + strconv.FormatInt(number, 10)
  20144. } else if number >= 1000000 {
  20145. zero = "0" + strconv.FormatInt(number, 10)
  20146. } else {
  20147. zero = strconv.FormatInt(number, 10)
  20148. }
  20149. fmt.Println(zero)
  20150. struct4101 := service.Struct4101{
  20151. PsnNo: order.PsnNo,
  20152. MdtrtId: order.MdtrtId,
  20153. SetlId: order.SetlId,
  20154. PsnName: order.PsnName,
  20155. Gend: order.Gend,
  20156. Brdy: his.Brdy,
  20157. Age: int64(order.Age),
  20158. Naty: order.Naty,
  20159. PatnCertType: "01",
  20160. Certno: order.Certno,
  20161. Prfs: "90",
  20162. ConerName: roles[0].UserName,
  20163. PatnRlts: "99",
  20164. ConerAddr: miConfig.OrgName,
  20165. ConerTel: admin.Mobile,
  20166. HiType: order.Insutype,
  20167. Insuplc: miConfig.InsuplcAdmdvs,
  20168. MaindiagFlag: "1",
  20169. BillCode: order.SetlId,
  20170. BillNo: order.SetlId,
  20171. BizSn: order.Number,
  20172. PsnSelfPay: order.PsnPartAmt,
  20173. PsnOwnPay: order.PsnPartAmt,
  20174. AcctPay: order.AcctPay,
  20175. PsnCashpay: order.PsnCashPay,
  20176. HiPaymtd: "1",
  20177. Hsorg: miConfig.InsuplcAdmdvs,
  20178. HsorgOpter: miConfig.InsuplcAdmdvs,
  20179. MedinsFillPsn: curRoles.UserName,
  20180. MedinsFillDept: depart.Name,
  20181. IptMedType: "2",
  20182. AdmTime: his.InHosptialTime,
  20183. AdmEndTime: his.OutHosptialTime,
  20184. }
  20185. struct4101.SetlBegnDate = order.SetlTime
  20186. struct4101.SetlEndDate = order.SetlTime
  20187. //var rf []CustomFundPay
  20188. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20189. //
  20190. //var tempFunPays []service.CustomStruct
  20191. //for _, item := range rf {
  20192. // var tempFunPay service.CustomStruct
  20193. // tempFunPay.FundPayamt = item.FundPayamt
  20194. // tempFunPay.FundPayType = item.FundPayType
  20195. // tempFunPays = append(tempFunPays, tempFunPay)
  20196. //}
  20197. //struct4101.CustomStruct = tempFunPays
  20198. var tempDiaginfos []service.DiaginfoStructTwo
  20199. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20200. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20201. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  20202. //for _, item := range infos {
  20203. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  20204. //}
  20205. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  20206. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  20207. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20208. fmt.Println(diagnosis_ids_arr)
  20209. if order.UserOrgId == 10210 {
  20210. var diagnosis_ids_arr_two []int64
  20211. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  20212. var config []*models.HisXtDiagnoseConfig
  20213. for _, id := range diagnosis_ids_arr_two {
  20214. //id, _ := strconv.ParseInt(item, 10, 64)
  20215. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20216. if diagnosisConfig.ID > 0 {
  20217. config = append(config, &diagnosisConfig)
  20218. }
  20219. }
  20220. for index, item := range config {
  20221. if item.ID > 0 {
  20222. if index == 0 {
  20223. var tempDiaginfo service.DiaginfoStructTwo
  20224. tempDiaginfo.DiagCode = item.CountryCode
  20225. tempDiaginfo.DiagName = item.CountryContentName
  20226. tempDiaginfo.DiagType = "1"
  20227. tempDiaginfo.MaindiagFlag = "1"
  20228. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20229. } else {
  20230. var tempDiaginfo service.DiaginfoStructTwo
  20231. tempDiaginfo.DiagCode = item.CountryCode
  20232. tempDiaginfo.DiagName = item.CountryContentName
  20233. tempDiaginfo.DiagType = "1"
  20234. tempDiaginfo.MaindiagFlag = "0"
  20235. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20236. }
  20237. }
  20238. }
  20239. struct4101.Diseinfo = tempDiaginfos
  20240. } else {
  20241. var config []*models.HisXtDiagnoseConfig
  20242. for _, item := range diagnosis_ids_arr {
  20243. id, _ := strconv.ParseInt(item, 10, 64)
  20244. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20245. if diagnosisConfig.ID > 0 {
  20246. config = append(config, &diagnosisConfig)
  20247. }
  20248. }
  20249. for index, item := range config {
  20250. if item.ID > 0 {
  20251. if index == 0 {
  20252. var tempDiaginfo service.DiaginfoStructTwo
  20253. tempDiaginfo.DiagCode = item.CountryCode
  20254. tempDiaginfo.DiagName = item.CountryContentName
  20255. tempDiaginfo.DiagType = "1"
  20256. tempDiaginfo.MaindiagFlag = "1"
  20257. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20258. } else {
  20259. var tempDiaginfo service.DiaginfoStructTwo
  20260. tempDiaginfo.DiagCode = item.CountryCode
  20261. tempDiaginfo.DiagName = item.CountryContentName
  20262. tempDiaginfo.DiagType = "1"
  20263. tempDiaginfo.MaindiagFlag = "0"
  20264. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20265. }
  20266. }
  20267. }
  20268. struct4101.Diseinfo = tempDiaginfos
  20269. }
  20270. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20271. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20272. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20273. tempOpspdiseinfo2.OprnOprtCode = ""
  20274. tempOpspdiseinfo2.OprnOprtName = ""
  20275. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20276. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20277. var iteminfo service.IteminfoStruct
  20278. var bedCostTotal float64 = 0 //床位总费
  20279. var bedCostSelfTotal float64 = 0 //床位自费
  20280. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20281. var operationCostTotal float64 = 0 //手术费
  20282. var operationCostSelfTotal float64 = 0 //手术费
  20283. var operationCostPartSelfTotal float64 = 0 //手术费
  20284. var otherCostTotal float64 = 0 //其他费用
  20285. var otherCostSelfTotal float64 = 0 //其他费用
  20286. var otherCostPartSelfTotal float64 = 0 //其他费用
  20287. var materialCostTotal float64 = 0 //材料费
  20288. var materialCostSelfTotal float64 = 0 //材料费
  20289. var materialCostPartSelfTotal float64 = 0 //材料费
  20290. var westernMedicineCostTotal float64 = 0 //西药费
  20291. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20292. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20293. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20294. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20295. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20296. var checkCostTotal float64 = 0 //检查费
  20297. var checkCostSelfTotal float64 = 0 //检查费
  20298. var checkCostPartSelfTotal float64 = 0 //检查费
  20299. var laboratoryCostTotal float64 = 0 //化验费
  20300. var laboratoryCostSelfTotal float64 = 0 //化验费
  20301. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20302. var treatCostTotal float64 = 0 //治疗费用
  20303. var treatCostSelfTotal float64 = 0 //治疗费用
  20304. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20305. decimal.DivisionPrecision = 2
  20306. var bed_fulamt_ownpay_amt float64 = 0
  20307. var operation_fulamt_ownpay_amt float64 = 0
  20308. var other_fulamt_ownpay_amt float64 = 0
  20309. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20310. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20311. var check_fulamt_ownpay_amt float64 = 0
  20312. var material_fulamt_ownpay_amt float64 = 0
  20313. var laboratory_fulamt_ownpay_amt float64 = 0
  20314. var treat_fulamt_ownpay_amt float64 = 0
  20315. var bed_claa_sunmfee float64 = 0
  20316. var bed_clab_amt float64 = 0
  20317. var bed_other_amt float64 = 0
  20318. var operation_claa_sunmfee float64 = 0
  20319. var operation_clab_amt float64 = 0
  20320. var operation_other_amt float64 = 0
  20321. var other_claa_sunmfee float64 = 0
  20322. var other_clab_amt float64 = 0
  20323. var other_other_amt float64 = 0
  20324. var westernMedicine_claa_sunmfee float64 = 0
  20325. var westernMedicine_clab_amt float64 = 0
  20326. var westernMedicine_other_amt float64 = 0
  20327. var chineseTraditional_claa_sunmfee float64 = 0
  20328. var chineseTraditional_clab_amt float64 = 0
  20329. var chineseTraditional_other_amt float64 = 0
  20330. var check_claa_sunmfee float64 = 0
  20331. var check_clab_amt float64 = 0
  20332. var check_other_amt float64 = 0
  20333. var material_claa_sunmfee float64 = 0
  20334. var material_clab_amt float64 = 0
  20335. var material_other_amt float64 = 0
  20336. var laboratory_claa_sunmfee float64 = 0
  20337. var laboratory_clab_amt float64 = 0
  20338. var laboratory_other_amt float64 = 0
  20339. var treat_claa_sunmfee float64 = 0
  20340. var treat_clab_amt float64 = 0
  20341. var treat_other_amt float64 = 0
  20342. for _, item := range order.HisOrderInfo {
  20343. if item.MedChrgitmType == "01" { //床位费
  20344. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20345. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20346. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20347. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20348. if item.ChrgitmLv == "1" {
  20349. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20350. }
  20351. if item.ChrgitmLv == "2" {
  20352. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20353. }
  20354. if item.ChrgitmLv == "3" {
  20355. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20356. }
  20357. }
  20358. if item.MedChrgitmType == "03" { //检查费
  20359. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20360. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20361. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20362. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20363. if item.ChrgitmLv == "1" {
  20364. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20365. }
  20366. if item.ChrgitmLv == "2" {
  20367. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20368. }
  20369. if item.ChrgitmLv == "3" {
  20370. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20371. }
  20372. }
  20373. if item.MedChrgitmType == "04" { //化验费
  20374. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20375. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20376. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20377. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20378. if item.ChrgitmLv == "1" {
  20379. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20380. }
  20381. if item.ChrgitmLv == "2" {
  20382. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20383. }
  20384. if item.ChrgitmLv == "3" {
  20385. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20386. }
  20387. }
  20388. if item.MedChrgitmType == "05" { //治疗费
  20389. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20390. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20391. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20392. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20393. if item.ChrgitmLv == "1" {
  20394. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20395. }
  20396. if item.ChrgitmLv == "2" {
  20397. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20398. }
  20399. if item.ChrgitmLv == "3" {
  20400. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20401. }
  20402. }
  20403. if item.MedChrgitmType == "06" { //手术费
  20404. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20405. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20406. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20407. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20408. if item.ChrgitmLv == "1" {
  20409. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20410. }
  20411. if item.ChrgitmLv == "2" {
  20412. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20413. }
  20414. if item.ChrgitmLv == "3" {
  20415. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20416. }
  20417. }
  20418. if item.MedChrgitmType == "08" { //材料费
  20419. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20420. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20421. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20422. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20423. if item.ChrgitmLv == "1" {
  20424. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20425. }
  20426. if item.ChrgitmLv == "2" {
  20427. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20428. }
  20429. if item.ChrgitmLv == "3" {
  20430. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20431. }
  20432. }
  20433. if item.MedChrgitmType == "09" { //西药费
  20434. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20435. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20436. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20437. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20438. if item.ChrgitmLv == "1" {
  20439. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20440. }
  20441. if item.ChrgitmLv == "2" {
  20442. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20443. }
  20444. if item.ChrgitmLv == "3" {
  20445. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20446. }
  20447. }
  20448. if item.MedChrgitmType == "11" { //中成费
  20449. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20450. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20451. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20452. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20453. if item.ChrgitmLv == "1" {
  20454. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20455. }
  20456. if item.ChrgitmLv == "2" {
  20457. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20458. }
  20459. if item.ChrgitmLv == "3" {
  20460. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20461. }
  20462. }
  20463. if item.MedChrgitmType == "14" { //其他费
  20464. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20465. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20466. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20467. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20468. if item.ChrgitmLv == "1" {
  20469. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20470. }
  20471. if item.ChrgitmLv == "2" {
  20472. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20473. }
  20474. if item.ChrgitmLv == "3" {
  20475. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20476. }
  20477. }
  20478. }
  20479. var iteminfoStructs []service.IteminfoStruct
  20480. if bedCostTotal != 0 {
  20481. iteminfo.MedChrgitm = "01"
  20482. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20483. iteminfo.Amt = bedCostTotal
  20484. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20485. iteminfo.ClabAmt = bed_clab_amt
  20486. iteminfo.OthAmt = bed_other_amt
  20487. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20488. }
  20489. if checkCostTotal != 0 {
  20490. iteminfo.MedChrgitm = "03"
  20491. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20492. iteminfo.Amt = checkCostTotal
  20493. iteminfo.ClaaSumfee = check_claa_sunmfee
  20494. iteminfo.ClabAmt = check_clab_amt
  20495. iteminfo.OthAmt = check_other_amt
  20496. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20497. }
  20498. if laboratoryCostTotal != 0 {
  20499. iteminfo.MedChrgitm = "04"
  20500. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20501. iteminfo.Amt = laboratoryCostTotal
  20502. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20503. iteminfo.ClabAmt = laboratory_clab_amt
  20504. iteminfo.OthAmt = laboratory_other_amt
  20505. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20506. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20507. }
  20508. if treatCostTotal != 0 {
  20509. iteminfo.MedChrgitm = "05"
  20510. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20511. iteminfo.Amt = treatCostTotal
  20512. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20513. iteminfo.ClabAmt = treat_clab_amt
  20514. iteminfo.OthAmt = treat_other_amt
  20515. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20516. //(struct4101.IteminfoStruct, iteminfo)
  20517. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20518. }
  20519. if operationCostTotal != 0 {
  20520. iteminfo.MedChrgitm = "06"
  20521. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20522. iteminfo.Amt = operationCostTotal
  20523. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20524. iteminfo.ClabAmt = operation_clab_amt
  20525. iteminfo.OthAmt = operation_other_amt
  20526. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20527. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20528. }
  20529. if materialCostTotal != 0 {
  20530. iteminfo.MedChrgitm = "08"
  20531. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20532. iteminfo.Amt = materialCostTotal
  20533. iteminfo.ClaaSumfee = material_claa_sunmfee
  20534. iteminfo.ClabAmt = material_clab_amt
  20535. iteminfo.OthAmt = material_other_amt
  20536. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20537. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20538. }
  20539. if westernMedicineCostTotal != 0 {
  20540. iteminfo.MedChrgitm = "09"
  20541. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20542. iteminfo.Amt = westernMedicineCostTotal
  20543. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20544. iteminfo.ClabAmt = westernMedicine_clab_amt
  20545. iteminfo.OthAmt = westernMedicine_other_amt
  20546. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20547. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20548. }
  20549. if chineseTraditionalMedicineCostTotal != 0 {
  20550. iteminfo.MedChrgitm = "11"
  20551. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20552. iteminfo.Amt = westernMedicineCostTotal
  20553. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20554. iteminfo.ClabAmt = westernMedicine_clab_amt
  20555. iteminfo.OthAmt = westernMedicine_other_amt
  20556. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20557. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20558. }
  20559. if otherCostTotal != 0 {
  20560. iteminfo.MedChrgitm = "14"
  20561. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20562. iteminfo.Amt = otherCostTotal
  20563. iteminfo.ClaaSumfee = other_claa_sunmfee
  20564. iteminfo.ClabAmt = other_clab_amt
  20565. iteminfo.OthAmt = other_other_amt
  20566. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20567. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20568. }
  20569. struct4101.IteminfoStruct = iteminfoStructs
  20570. struct4101.Ntly = "中国"
  20571. struct4101.AdmCaty = "A03.06"
  20572. var resOther ResultSeventeenOther
  20573. var res ResultSeventeen
  20574. if miConfig.MdtrtareaAdmvs == "150499" {
  20575. var pp models.PublicParams
  20576. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20577. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20578. pp.FixmedinsName = miConfig.OrgName
  20579. pp.FixmedinsCode = miConfig.Code
  20580. pp.RequestUrl = miConfig.Url
  20581. pp.Cainfo = miConfig.Cainfo
  20582. pp.SecretKey = miConfig.SecretKey
  20583. pp.AccessKey = miConfig.AccessKey
  20584. pp.OpterName = curRoles.UserName
  20585. client := &http.Client{}
  20586. var req *http.Request
  20587. data := make(map[string]interface{})
  20588. data["struct4101"] = struct4101
  20589. data["pp"] = pp
  20590. bytesData, _ := json.Marshal(data)
  20591. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20592. resp, _ := client.Do(req)
  20593. defer resp.Body.Close()
  20594. body, ioErr := ioutil.ReadAll(resp.Body)
  20595. if ioErr != nil {
  20596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20598. return
  20599. }
  20600. var respJSON map[string]interface{}
  20601. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20604. return
  20605. }
  20606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20607. userJSONBytes, _ := json.Marshal(respJSON)
  20608. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20609. utils.ErrorLog("解析失败:%v", err)
  20610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20611. return
  20612. }
  20613. res.InfRefmsgid = resOther.InfRefmsgid
  20614. res.Output = resOther.Output
  20615. res.ErrMsg = resOther.ErrMsg
  20616. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20617. res.Infcode = infocode
  20618. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20619. var pp models.PublicParams
  20620. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20621. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20622. pp.FixmedinsName = miConfig.OrgName
  20623. pp.FixmedinsCode = miConfig.Code
  20624. pp.RequestUrl = miConfig.Url
  20625. pp.Cainfo = miConfig.Cainfo
  20626. pp.SecretKey = miConfig.SecretKey
  20627. pp.AccessKey = miConfig.AccessKey
  20628. pp.OpterName = curRoles.UserName
  20629. result, _ := service.Jxyb4101(struct4101, pp)
  20630. var dat map[string]interface{}
  20631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20632. fmt.Println(dat)
  20633. } else {
  20634. fmt.Println(err)
  20635. }
  20636. userJSONBytes, _ := json.Marshal(dat)
  20637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20638. utils.ErrorLog("解析失败:%v", err)
  20639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20640. return
  20641. }
  20642. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20643. var pp models.PublicParams
  20644. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20645. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20646. pp.FixmedinsName = miConfig.OrgName
  20647. pp.FixmedinsCode = miConfig.Code
  20648. pp.RequestUrl = miConfig.Url
  20649. pp.Cainfo = miConfig.Cainfo
  20650. pp.SecretKey = miConfig.SecretKey
  20651. pp.AccessKey = miConfig.AccessKey
  20652. pp.OpterName = curRoles.UserName
  20653. result, _ := service.Jxyb4101(struct4101, pp)
  20654. var dat map[string]interface{}
  20655. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20656. fmt.Println(dat)
  20657. } else {
  20658. fmt.Println(err)
  20659. }
  20660. userJSONBytes, _ := json.Marshal(dat)
  20661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20662. utils.ErrorLog("解析失败:%v", err)
  20663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20664. return
  20665. }
  20666. } else {
  20667. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20668. var dat map[string]interface{}
  20669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20670. fmt.Println(dat)
  20671. } else {
  20672. fmt.Println(err)
  20673. }
  20674. userJSONBytes, _ := json.Marshal(dat)
  20675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20676. utils.ErrorLog("解析失败:%v", err)
  20677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20678. return
  20679. }
  20680. }
  20681. if res.Infcode != 0 {
  20682. c.ServeSuccessJSON(map[string]interface{}{
  20683. "failed_code": -10,
  20684. "msg": res.ErrMsg,
  20685. })
  20686. return
  20687. } else {
  20688. if miConfig.MdtrtareaAdmvs != "150499" {
  20689. order.FaPiaoNumber = zero
  20690. order.FaPiaoCode = last_order.FaPiaoCode
  20691. service.UpdateOrder(order)
  20692. }
  20693. hisFundSettleListResult := &models.HisFundSettleListResult{
  20694. Number: res.Output.SetlListId,
  20695. Status: 1,
  20696. Ctime: time.Now().Unix(),
  20697. Mtime: time.Now().Unix(),
  20698. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20699. IsUpload: 1,
  20700. OrderId: order_id,
  20701. }
  20702. service.CreateUploadRecord(hisFundSettleListResult)
  20703. c.ServeSuccessJSON(map[string]interface{}{
  20704. "msg": "上传成功",
  20705. "result": hisFundSettleListResult,
  20706. })
  20707. return
  20708. }
  20709. }
  20710. //func (c *HisApiController) GetBatchSettleList() {
  20711. // orders, _ := service.GetAllHisOrder(10106)
  20712. // for _, item := range orders {
  20713. // order_id := item.ID
  20714. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20715. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20716. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20717. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20718. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20719. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20720. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20721. //
  20722. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20723. //
  20724. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20725. //
  20726. // if order.ID == 0 {
  20727. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20728. // return
  20729. // }
  20730. // if his.BalanceAccountsType == 2 {
  20731. // continue
  20732. // }
  20733. // struct4101 := service.Struct4101{
  20734. // PsnNo: order.PsnNo,
  20735. // MdtrtId: order.MdtrtId,
  20736. // SetlId: order.SetlId,
  20737. // PsnName: order.PsnName,
  20738. // Gend: order.Gend,
  20739. // Brdy: his.Brdy,
  20740. // Age: his.Age,
  20741. // Naty: order.Naty,
  20742. // PatnCertType: "01",
  20743. // Certno: order.Certno,
  20744. // Prfs: "90",
  20745. // ConerName: roles[0].UserName,
  20746. // PatnRlts: "99",
  20747. // ConerAddr: miConfig.OrgName,
  20748. // ConerTel: admin.Mobile,
  20749. // HiType: order.Insutype,
  20750. // Insuplc: his.InsuplcAdmdvs,
  20751. // MaindiagFlag: "1",
  20752. // BillCode: order.SetlId,
  20753. // BillNo: order.SetlId,
  20754. // BizSn: order.Number,
  20755. // PsnSelfPay: order.PsnPartAmt,
  20756. // PsnOwnPay: order.PsnPartAmt,
  20757. // AcctPay: order.AcctPay,
  20758. // PsnCashpay: order.PsnCashPay,
  20759. // HiPaymtd: "1",
  20760. // Hsorg: his.InsuplcAdmdvs,
  20761. // HsorgOpter: his.InsuplcAdmdvs,
  20762. // MedinsFillPsn: curRoles.UserName,
  20763. // MedinsFillDept: depart.Name,
  20764. // IptMedType: "2",
  20765. // }
  20766. // struct4101.SetlBegnDate = order.SetlTime
  20767. // struct4101.SetlEndDate = order.SetlTime
  20768. // //if order.SettleType == 1 {
  20769. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20770. // // dateStr := t.Format("2006-01-02")
  20771. // // struct4101.SetlBegnDate = dateStr
  20772. // // struct4101.SetlEndDate = dateStr
  20773. // //} else {
  20774. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20775. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20776. // // dateStartStr := t.Format("2006-01-02")
  20777. // // dateEndStr := t2.Format("2006-01-02")
  20778. // // struct4101.SetlBegnDate = dateStartStr
  20779. // // struct4101.SetlEndDate = dateEndStr
  20780. // //}
  20781. //
  20782. // var rf []CustomFundPay
  20783. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20784. //
  20785. // var tempFunPays []service.CustomStruct
  20786. // var tempFunPay610100 service.CustomStruct
  20787. //
  20788. // for _, item := range rf {
  20789. // if item.FundPayType == "610100" {
  20790. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20791. // tempFunPay610100.FundPayType = item.FundPayType
  20792. // } else {
  20793. // var tempFunPay service.CustomStruct
  20794. // tempFunPay.FundPayamt = item.FundPayamt
  20795. // tempFunPay.FundPayType = item.FundPayType
  20796. // tempFunPays = append(tempFunPays, tempFunPay)
  20797. // }
  20798. // }
  20799. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20800. // struct4101.CustomStruct = tempFunPays
  20801. //
  20802. // var tempDiaginfos []service.DiaginfoStructTwo
  20803. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20804. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20805. //
  20806. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20807. // var config []*models.HisXtDiagnoseConfig
  20808. // for _, item := range diagnosis_ids {
  20809. // id, _ := strconv.ParseInt(item, 10, 64)
  20810. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20811. // config = append(config, &diagnosisConfig)
  20812. // }
  20813. //
  20814. // for index, item := range config {
  20815. // if index == 0 {
  20816. // var tempDiaginfo service.DiaginfoStructTwo
  20817. // tempDiaginfo.DiagCode = item.CountryCode
  20818. // tempDiaginfo.DiagName = item.CountryContentName
  20819. // tempDiaginfo.DiagType = "1"
  20820. // tempDiaginfo.MaindiagFlag = "1"
  20821. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20822. // } else {
  20823. //
  20824. // var tempDiaginfo service.DiaginfoStructTwo
  20825. // tempDiaginfo.DiagCode = item.CountryCode
  20826. // tempDiaginfo.DiagName = item.CountryContentName
  20827. // tempDiaginfo.DiagType = "2"
  20828. // tempDiaginfo.MaindiagFlag = "0"
  20829. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20830. // }
  20831. // }
  20832. // struct4101.Diseinfo = tempDiaginfos
  20833. //
  20834. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20835. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20836. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20837. // tempOpspdiseinfo2.OprnOprtCode = ""
  20838. // tempOpspdiseinfo2.OprnOprtName = ""
  20839. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20840. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20841. //
  20842. // var iteminfo service.IteminfoStruct
  20843. //
  20844. // var bedCostTotal float64 = 0 //床位总费
  20845. // var bedCostSelfTotal float64 = 0 //床位自费
  20846. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20847. //
  20848. // var examineCostTotal float64 = 0 //诊查总费
  20849. // var examineCostSelfTotal float64 = 0 //诊查自费
  20850. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20851. //
  20852. // var nursingCostTotal float64 = 0 //护理总费
  20853. // var nursingCostSelfTotal float64 = 0 //护理自费
  20854. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20855. //
  20856. // var chineseMedicineCostTotal float64 = 0 //中成药
  20857. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20858. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20859. //
  20860. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20861. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20862. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20863. //
  20864. // var registerCostTotal float64 = 0 //一般诊疗费
  20865. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20866. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20867. //
  20868. // var operationCostTotal float64 = 0 //手术费
  20869. // var operationCostSelfTotal float64 = 0 //手术费
  20870. // var operationCostPartSelfTotal float64 = 0 //手术费
  20871. //
  20872. // var otherCostTotal float64 = 0 //其他费用
  20873. // var otherCostSelfTotal float64 = 0 //其他费用
  20874. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20875. //
  20876. // var materialCostTotal float64 = 0 //材料费
  20877. // var materialCostSelfTotal float64 = 0 //材料费
  20878. // var materialCostPartSelfTotal float64 = 0 //材料费
  20879. //
  20880. // var westernMedicineCostTotal float64 = 0 //西药费
  20881. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20882. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20883. //
  20884. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20885. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20886. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20887. //
  20888. // var checkCostTotal float64 = 0 //检查费
  20889. // var checkCostSelfTotal float64 = 0 //检查费
  20890. // var checkCostPartSelfTotal float64 = 0 //检查费
  20891. //
  20892. // var laboratoryCostTotal float64 = 0 //化验费
  20893. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20894. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20895. //
  20896. // var treatCostTotal float64 = 0 //治疗费用
  20897. // var treatCostSelfTotal float64 = 0 //治疗费用
  20898. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20899. //
  20900. // decimal.DivisionPrecision = 2
  20901. //
  20902. // var bed_fulamt_ownpay_amt float64 = 0
  20903. //
  20904. // var examine_fulamt_ownpay_amt float64 = 0
  20905. //
  20906. // var nursing_fulamt_ownpay_amt float64 = 0
  20907. //
  20908. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20909. //
  20910. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20911. //
  20912. // var register_fulamt_ownpay_amt float64 = 0
  20913. //
  20914. // var operation_fulamt_ownpay_amt float64 = 0
  20915. // var other_fulamt_ownpay_amt float64 = 0
  20916. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20917. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20918. // var check_fulamt_ownpay_amt float64 = 0
  20919. // var material_fulamt_ownpay_amt float64 = 0
  20920. // var laboratory_fulamt_ownpay_amt float64 = 0
  20921. // var treat_fulamt_ownpay_amt float64 = 0
  20922. //
  20923. // var bed_claa_sunmfee float64 = 0
  20924. // var bed_clab_amt float64 = 0
  20925. // var bed_other_amt float64 = 0
  20926. //
  20927. // var examine_claa_sunmfee float64 = 0
  20928. // var examine_clab_amt float64 = 0
  20929. // var examine_other_amt float64 = 0
  20930. //
  20931. // var nursing_claa_sunmfee float64 = 0
  20932. // var nursing_clab_amt float64 = 0
  20933. // var nursing_other_amt float64 = 0
  20934. //
  20935. // var chinese_medicine_claa_sunmfee float64 = 0
  20936. // var chinese_medicine_clab_amt float64 = 0
  20937. // var chinese_medicine_other_amt float64 = 0
  20938. //
  20939. // var commonly_treatment_claa_sunmfee float64 = 0
  20940. // var commonly_treatment_clab_amt float64 = 0
  20941. // var commonly_treatment_other_amt float64 = 0
  20942. //
  20943. // var operation_claa_sunmfee float64 = 0
  20944. // var operation_clab_amt float64 = 0
  20945. // var operation_other_amt float64 = 0
  20946. //
  20947. // var other_claa_sunmfee float64 = 0
  20948. // var other_clab_amt float64 = 0
  20949. // var other_other_amt float64 = 0
  20950. //
  20951. // var westernMedicine_claa_sunmfee float64 = 0
  20952. // var westernMedicine_clab_amt float64 = 0
  20953. // var westernMedicine_other_amt float64 = 0
  20954. //
  20955. // var chineseTraditional_claa_sunmfee float64 = 0
  20956. // var chineseTraditional_clab_amt float64 = 0
  20957. // var chineseTraditional_other_amt float64 = 0
  20958. //
  20959. // var check_claa_sunmfee float64 = 0
  20960. // var check_clab_amt float64 = 0
  20961. // var check_other_amt float64 = 0
  20962. //
  20963. // var material_claa_sunmfee float64 = 0
  20964. // var material_clab_amt float64 = 0
  20965. // var material_other_amt float64 = 0
  20966. //
  20967. // var laboratory_claa_sunmfee float64 = 0
  20968. // var laboratory_clab_amt float64 = 0
  20969. // var laboratory_other_amt float64 = 0
  20970. //
  20971. // var treat_claa_sunmfee float64 = 0
  20972. // var treat_clab_amt float64 = 0
  20973. // var treat_other_amt float64 = 0
  20974. //
  20975. // var register_claa_sunmfee float64 = 0
  20976. // var register_clab_amt float64 = 0
  20977. // var register_other_amt float64 = 0
  20978. //
  20979. // for _, item := range order.HisOrderInfo {
  20980. // if item.MedChrgitmType == "01" { //床位费
  20981. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20982. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20983. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20984. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20985. // if item.ChrgitmLv == "1" {
  20986. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20987. // }
  20988. // if item.ChrgitmLv == "2" {
  20989. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20990. //
  20991. // }
  20992. // if item.ChrgitmLv == "3" {
  20993. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20994. // }
  20995. //
  20996. // }
  20997. //
  20998. // if item.MedChrgitmType == "02" { //诊查
  20999. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21000. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21001. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21002. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21003. // if item.ChrgitmLv == "1" {
  21004. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21005. // }
  21006. // if item.ChrgitmLv == "2" {
  21007. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21008. //
  21009. // }
  21010. // if item.ChrgitmLv == "3" {
  21011. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21012. // }
  21013. //
  21014. // }
  21015. //
  21016. // if item.MedChrgitmType == "03" { //检查费
  21017. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21018. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21019. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21020. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21021. // if item.ChrgitmLv == "1" {
  21022. //
  21023. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21024. //
  21025. // }
  21026. // if item.ChrgitmLv == "2" {
  21027. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21028. //
  21029. // }
  21030. // if item.ChrgitmLv == "3" {
  21031. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21032. // }
  21033. // }
  21034. //
  21035. // if item.MedChrgitmType == "04" { //化验费
  21036. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21037. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21038. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21039. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21040. // if item.ChrgitmLv == "1" {
  21041. //
  21042. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21043. //
  21044. // }
  21045. // if item.ChrgitmLv == "2" {
  21046. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21047. //
  21048. // }
  21049. // if item.ChrgitmLv == "3" {
  21050. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21051. // }
  21052. // }
  21053. //
  21054. // if item.MedChrgitmType == "05" { //治疗费
  21055. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21056. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21057. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21058. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21059. // if item.ChrgitmLv == "1" {
  21060. //
  21061. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21062. //
  21063. // }
  21064. // if item.ChrgitmLv == "2" {
  21065. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21066. //
  21067. // }
  21068. // if item.ChrgitmLv == "3" {
  21069. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21070. // }
  21071. // }
  21072. //
  21073. // if item.MedChrgitmType == "06" { //手术费
  21074. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21075. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21076. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21077. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21078. //
  21079. // if item.ChrgitmLv == "1" {
  21080. //
  21081. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21082. //
  21083. // }
  21084. // if item.ChrgitmLv == "2" {
  21085. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21086. //
  21087. // }
  21088. // if item.ChrgitmLv == "3" {
  21089. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21090. // }
  21091. // }
  21092. //
  21093. // if item.MedChrgitmType == "07" { //手术费
  21094. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21095. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21096. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21097. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21098. //
  21099. // if item.ChrgitmLv == "1" {
  21100. //
  21101. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21102. //
  21103. // }
  21104. // if item.ChrgitmLv == "2" {
  21105. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21106. //
  21107. // }
  21108. // if item.ChrgitmLv == "3" {
  21109. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21110. // }
  21111. // }
  21112. //
  21113. // if item.MedChrgitmType == "08" { //材料费
  21114. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21115. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21116. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21117. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21118. // if item.ChrgitmLv == "1" {
  21119. //
  21120. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21121. //
  21122. // }
  21123. // if item.ChrgitmLv == "2" {
  21124. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21125. //
  21126. // }
  21127. // if item.ChrgitmLv == "3" {
  21128. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21129. // }
  21130. // }
  21131. // if item.MedChrgitmType == "09" { //西药费
  21132. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21133. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21134. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21135. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21136. // if item.ChrgitmLv == "1" {
  21137. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21138. // }
  21139. // if item.ChrgitmLv == "2" {
  21140. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21141. // }
  21142. // if item.ChrgitmLv == "3" {
  21143. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21144. // }
  21145. // }
  21146. // if item.MedChrgitmType == "10" { //中药饮片
  21147. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21148. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21149. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21150. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21151. // if item.ChrgitmLv == "1" {
  21152. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21153. // }
  21154. // if item.ChrgitmLv == "2" {
  21155. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21156. // }
  21157. // if item.ChrgitmLv == "3" {
  21158. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21159. // }
  21160. // }
  21161. //
  21162. // if item.MedChrgitmType == "11" { //中成费
  21163. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21164. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21165. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21166. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21167. // if item.ChrgitmLv == "1" {
  21168. //
  21169. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21170. //
  21171. // }
  21172. // if item.ChrgitmLv == "2" {
  21173. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21174. //
  21175. // }
  21176. // if item.ChrgitmLv == "3" {
  21177. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21178. // }
  21179. // }
  21180. //
  21181. // if item.MedChrgitmType == "12" { //中成费
  21182. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21183. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21184. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21185. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21186. // if item.ChrgitmLv == "1" {
  21187. //
  21188. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21189. //
  21190. // }
  21191. // if item.ChrgitmLv == "2" {
  21192. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21193. //
  21194. // }
  21195. // if item.ChrgitmLv == "3" {
  21196. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21197. // }
  21198. // }
  21199. //
  21200. // if item.MedChrgitmType == "13" { //中成费
  21201. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21202. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21203. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21204. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21205. // if item.ChrgitmLv == "1" {
  21206. //
  21207. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21208. //
  21209. // }
  21210. // if item.ChrgitmLv == "2" {
  21211. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21212. //
  21213. // }
  21214. // if item.ChrgitmLv == "3" {
  21215. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21216. // }
  21217. // }
  21218. //
  21219. // if item.MedChrgitmType == "14" { //其他费
  21220. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21221. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21222. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21223. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21224. // if item.ChrgitmLv == "1" {
  21225. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21226. //
  21227. // }
  21228. // if item.ChrgitmLv == "2" {
  21229. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21230. //
  21231. // }
  21232. // if item.ChrgitmLv == "3" {
  21233. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21234. // }
  21235. // }
  21236. //
  21237. // }
  21238. //
  21239. // var iteminfoStructs []service.IteminfoStruct
  21240. //
  21241. // if bedCostTotal != 0 {
  21242. // iteminfo.MedChrgitm = "01"
  21243. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21244. // iteminfo.Amt = bedCostTotal
  21245. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21246. // iteminfo.ClabAmt = bed_clab_amt
  21247. // iteminfo.OthAmt = bed_other_amt
  21248. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21249. // }
  21250. //
  21251. // if examineCostTotal != 0 {
  21252. // iteminfo.MedChrgitm = "02"
  21253. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21254. // iteminfo.Amt = examineCostTotal
  21255. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21256. // iteminfo.ClabAmt = examine_clab_amt
  21257. // iteminfo.OthAmt = examine_other_amt
  21258. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21259. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21260. // }
  21261. //
  21262. // if checkCostTotal != 0 {
  21263. // iteminfo.MedChrgitm = "03"
  21264. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21265. // iteminfo.Amt = checkCostTotal
  21266. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21267. // iteminfo.ClabAmt = check_clab_amt
  21268. // iteminfo.OthAmt = check_other_amt
  21269. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21270. //
  21271. // }
  21272. //
  21273. // if laboratoryCostTotal != 0 {
  21274. // iteminfo.MedChrgitm = "04"
  21275. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21276. // iteminfo.Amt = laboratoryCostTotal
  21277. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21278. // iteminfo.ClabAmt = laboratory_clab_amt
  21279. // iteminfo.OthAmt = laboratory_other_amt
  21280. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21281. //
  21282. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21283. //
  21284. // }
  21285. //
  21286. // if treatCostTotal != 0 {
  21287. // iteminfo.MedChrgitm = "05"
  21288. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21289. // iteminfo.Amt = treatCostTotal
  21290. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21291. // iteminfo.ClabAmt = treat_clab_amt
  21292. // iteminfo.OthAmt = treat_other_amt
  21293. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21294. // //(struct4101.IteminfoStruct, iteminfo)
  21295. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21296. // }
  21297. //
  21298. // if operationCostTotal != 0 {
  21299. // iteminfo.MedChrgitm = "06"
  21300. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21301. // iteminfo.Amt = operationCostTotal
  21302. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21303. // iteminfo.ClabAmt = operation_clab_amt
  21304. // iteminfo.OthAmt = operation_other_amt
  21305. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21306. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21307. // }
  21308. //
  21309. // if nursingCostTotal != 0 {
  21310. // iteminfo.MedChrgitm = "07"
  21311. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21312. // iteminfo.Amt = nursingCostTotal
  21313. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21314. // iteminfo.ClabAmt = nursing_clab_amt
  21315. // iteminfo.OthAmt = nursing_other_amt
  21316. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21317. // }
  21318. //
  21319. // if materialCostTotal != 0 {
  21320. // iteminfo.MedChrgitm = "08"
  21321. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21322. // iteminfo.Amt = materialCostTotal
  21323. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21324. // iteminfo.ClabAmt = material_clab_amt
  21325. // iteminfo.OthAmt = material_other_amt
  21326. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21327. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21328. // }
  21329. //
  21330. // if westernMedicineCostTotal != 0 {
  21331. // iteminfo.MedChrgitm = "09"
  21332. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21333. // iteminfo.Amt = westernMedicineCostTotal
  21334. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21335. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21336. // iteminfo.OthAmt = westernMedicine_other_amt
  21337. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21338. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21339. //
  21340. // }
  21341. //
  21342. // if chineseMedicineCostTotal != 0 {
  21343. // iteminfo.MedChrgitm = "10"
  21344. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21345. // iteminfo.Amt = chineseMedicineCostTotal
  21346. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21347. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21348. // iteminfo.OthAmt = chinese_medicine_other_amt
  21349. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21350. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21351. //
  21352. // }
  21353. //
  21354. // if chineseTraditionalMedicineCostTotal != 0 {
  21355. // iteminfo.MedChrgitm = "11"
  21356. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21357. // iteminfo.Amt = westernMedicineCostTotal
  21358. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21359. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21360. // iteminfo.OthAmt = westernMedicine_other_amt
  21361. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21362. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21363. //
  21364. // }
  21365. //
  21366. // if commonlyTreatmentCostTotal != 0 {
  21367. // iteminfo.MedChrgitm = "12"
  21368. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21369. // iteminfo.Amt = commonlyTreatmentCostTotal
  21370. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21371. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21372. // iteminfo.OthAmt = commonly_treatment_other_amt
  21373. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21374. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21375. //
  21376. // }
  21377. //
  21378. // if registerCostTotal != 0 {
  21379. // iteminfo.MedChrgitm = "13"
  21380. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21381. // iteminfo.Amt = registerCostTotal
  21382. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21383. // iteminfo.ClabAmt = register_clab_amt
  21384. // iteminfo.OthAmt = register_other_amt
  21385. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21386. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21387. //
  21388. // }
  21389. //
  21390. // if otherCostTotal != 0 {
  21391. // iteminfo.MedChrgitm = "14"
  21392. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21393. // iteminfo.Amt = otherCostTotal
  21394. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21395. // iteminfo.ClabAmt = other_clab_amt
  21396. // iteminfo.OthAmt = other_other_amt
  21397. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21398. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21399. //
  21400. // }
  21401. // struct4101.IteminfoStruct = iteminfoStructs
  21402. // time_arr := strings.Split(order.SetlTime, " ")
  21403. // struct4101.AdmTime = time_arr[0]
  21404. // struct4101.AdmEndTime = time_arr[0]
  21405. //
  21406. // struct4101.DoctorName = doctor.UserName
  21407. // struct4101.DoctorCode = doctor.DoctorNumber
  21408. //
  21409. // struct4101.Ntly = "中国"
  21410. // struct4101.AdmCaty = "A03.06"
  21411. // var res ResultSeventeen
  21412. // if miConfig.MdtrtareaAdmvs == "421300" {
  21413. // data := make(map[string]interface{})
  21414. // data["struct4101"] = struct4101
  21415. // data["secret_key"] = miConfig.SecretKey
  21416. // data["org_name"] = miConfig.OrgName
  21417. // data["opera"] = curRoles.UserName
  21418. // data["code"] = miConfig.Code
  21419. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21420. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21421. //
  21422. // client := &http.Client{}
  21423. // bytesData, _ := json.Marshal(data)
  21424. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21425. // resp, _ := client.Do(req)
  21426. // defer resp.Body.Close()
  21427. // body, ioErr := ioutil.ReadAll(resp.Body)
  21428. // if ioErr != nil {
  21429. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21431. // return
  21432. // }
  21433. // var respJSON map[string]interface{}
  21434. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21435. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21437. // return
  21438. // }
  21439. //
  21440. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21441. // userJSONBytes, _ := json.Marshal(respJSON)
  21442. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21443. // utils.ErrorLog("解析失败:%v", err)
  21444. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21445. // adminUser := c.GetAdminUserInfo()
  21446. // errlog := &models.HisOrderError{
  21447. // UserOrgId: adminUser.CurrentOrgId,
  21448. // Ctime: time.Now().Unix(),
  21449. // Mtime: time.Now().Unix(),
  21450. // ErrMsg: res.ErrMsg + "解析失败",
  21451. // Status: 1,
  21452. // PatientId: order_id,
  21453. // Stage: 10088,
  21454. // }
  21455. // service.CreateErrMsgLog(errlog)
  21456. // continue
  21457. // }
  21458. //
  21459. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21460. // data := make(map[string]interface{})
  21461. // data["struct4101"] = struct4101
  21462. // data["secret_key"] = miConfig.SecretKey
  21463. // data["org_name"] = miConfig.OrgName
  21464. // data["opera"] = curRoles.UserName
  21465. // data["code"] = miConfig.Code
  21466. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21467. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21468. //
  21469. // client := &http.Client{}
  21470. // bytesData, _ := json.Marshal(data)
  21471. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21472. // resp, _ := client.Do(req)
  21473. // defer resp.Body.Close()
  21474. // body, ioErr := ioutil.ReadAll(resp.Body)
  21475. // if ioErr != nil {
  21476. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21478. // return
  21479. // }
  21480. // var respJSON map[string]interface{}
  21481. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21482. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21484. // return
  21485. // }
  21486. //
  21487. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21488. // userJSONBytes, _ := json.Marshal(respJSON)
  21489. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21490. // utils.ErrorLog("解析失败:%v", err)
  21491. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21492. // adminUser := c.GetAdminUserInfo()
  21493. // errlog := &models.HisOrderError{
  21494. // UserOrgId: adminUser.CurrentOrgId,
  21495. // Ctime: time.Now().Unix(),
  21496. // Mtime: time.Now().Unix(),
  21497. // ErrMsg: res.ErrMsg + "解析失败",
  21498. // Status: 1,
  21499. // PatientId: order_id,
  21500. // Stage: 10088,
  21501. // }
  21502. // service.CreateErrMsgLog(errlog)
  21503. // continue
  21504. // }
  21505. //
  21506. // } else {
  21507. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21508. // fmt.Println(result)
  21509. //
  21510. // var dat map[string]interface{}
  21511. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21512. // fmt.Println(dat)
  21513. // } else {
  21514. // fmt.Println(err)
  21515. // }
  21516. // userJSONBytes, _ := json.Marshal(dat)
  21517. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21518. // utils.ErrorLog("解析失败:%v", err)
  21519. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21520. // adminUser := c.GetAdminUserInfo()
  21521. // errlog := &models.HisOrderError{
  21522. // UserOrgId: adminUser.CurrentOrgId,
  21523. // Ctime: time.Now().Unix(),
  21524. // Mtime: time.Now().Unix(),
  21525. // ErrMsg: res.ErrMsg + "解析失败",
  21526. // Status: 1,
  21527. // PatientId: order_id,
  21528. // Stage: 10106,
  21529. // }
  21530. // service.CreateErrMsgLog(errlog)
  21531. // continue
  21532. // }
  21533. // }
  21534. //
  21535. // if res.Infcode != 0 {
  21536. // adminUser := c.GetAdminUserInfo()
  21537. // errlog := &models.HisOrderError{
  21538. // UserOrgId: adminUser.CurrentOrgId,
  21539. // Ctime: time.Now().Unix(),
  21540. // Mtime: time.Now().Unix(),
  21541. // ErrMsg: res.ErrMsg,
  21542. // Status: 1,
  21543. // PatientId: order_id,
  21544. // Stage: 10106,
  21545. // }
  21546. // service.CreateErrMsgLog(errlog)
  21547. // continue
  21548. // } else {
  21549. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21550. // Number: res.Output.SetlListId,
  21551. // Status: 1,
  21552. // Ctime: time.Now().Unix(),
  21553. // Mtime: time.Now().Unix(),
  21554. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21555. // IsUpload: 1,
  21556. // OrderId: order_id,
  21557. // }
  21558. // service.CreateUploadRecord(hisFundSettleListResult)
  21559. // continue
  21560. // }
  21561. // }
  21562. //}
  21563. func (c *HisApiController) GetOrgInfo() {
  21564. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21565. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21566. }
  21567. func (c *HisApiController) GetHisPatientInfo() {
  21568. medical_insurance_card := c.GetString("medical_insurance_card")
  21569. id_card_type, _ := c.GetInt64("id_card_type")
  21570. id_card := c.GetString("id_card")
  21571. adminInfo := c.GetAdminUserInfo()
  21572. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21573. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21574. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21575. IdCardNo := ""
  21576. if id_card_type == 1 {
  21577. IdCardNo = medical_insurance_card
  21578. } else if id_card_type == 2 {
  21579. IdCardNo = id_card
  21580. }
  21581. if config.IsOpen == 1 {
  21582. 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
  21583. resp, requestErr := http.Get(api)
  21584. if requestErr != nil {
  21585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21586. return
  21587. }
  21588. defer resp.Body.Close()
  21589. body, ioErr := ioutil.ReadAll(resp.Body)
  21590. if ioErr != nil {
  21591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21593. return
  21594. }
  21595. var respJSON map[string]interface{}
  21596. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21599. return
  21600. }
  21601. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21602. userJSONBytes, _ := json.Marshal(userJSON)
  21603. var res ResultTwo
  21604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21605. utils.ErrorLog("解析失败:%v", err)
  21606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21607. return
  21608. }
  21609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21611. infoStr := string(Iinfos)
  21612. idetinfoStr := string(Idetinfos)
  21613. if res.Infcode == 0 {
  21614. his := models.VMHisPatient{
  21615. Status: 1,
  21616. Ctime: time.Now().Unix(),
  21617. Mtime: time.Now().Unix(),
  21618. PsnNo: res.Output.Baseinfo.PsnNo,
  21619. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21620. Certno: res.Output.Baseinfo.Certno,
  21621. PsnName: res.Output.Baseinfo.PsnName,
  21622. Gend: res.Output.Baseinfo.Gend,
  21623. Naty: res.Output.Baseinfo.Naty,
  21624. Iinfo: infoStr,
  21625. Idetinfo: idetinfoStr,
  21626. UserOrgId: adminInfo.CurrentOrgId,
  21627. IsReturn: 1,
  21628. IdCardType: id_card_type,
  21629. }
  21630. c.ServeSuccessJSON(map[string]interface{}{
  21631. "info": his,
  21632. })
  21633. } else {
  21634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21635. return
  21636. }
  21637. }
  21638. }
  21639. //func GetBasBaseInfo() (jsonStr string, err error) {
  21640. //
  21641. // handle := syscall.NewLazyDLL("SSCard.dll")
  21642. // add := handle.NewProc("ReadCardBas")
  21643. // str := make([]byte, 1024)
  21644. // str1 := make([]byte, 1024)
  21645. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21646. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21647. //
  21648. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21649. //
  21650. // fmt.Println("> Add(4,5)的结果为:", ret)
  21651. // handle.Release()
  21652. //
  21653. // return "", nil
  21654. //
  21655. //}
  21656. //func GetQRBaseInfo() (jsonStr string, err error) {
  21657. // handle := syscall.LoadDLL("SSCard.dll")
  21658. // ReadCardBas := handle.FindProc("GetQRBase")
  21659. //
  21660. // str := make([]byte, 256)
  21661. // str1 := make([]byte, 256)
  21662. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21663. //
  21664. // fmt.Println(string(str))
  21665. // fmt.Println(r)
  21666. // return string(str), nil
  21667. //}
  21668. //func CardInit() int {
  21669. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21670. // add := DllTestDef.MustFindProc("Init")
  21671. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21672. // if err != nil {
  21673. // fmt.Println("SSCard的运算结果为:", ret)
  21674. // }
  21675. // result := int(ret)
  21676. // return result
  21677. //}
  21678. //func CardInit() int {
  21679. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21680. // if err != nil {
  21681. // fmt.Println("SSCard的运算结果为:", ret)
  21682. // }
  21683. // fmt.Println(err)
  21684. // result := int(ret)
  21685. // return result
  21686. //}
  21687. func IntPtr(n int) uintptr {
  21688. return uintptr(n)
  21689. }
  21690. func StrPtr(s string) uintptr {
  21691. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21692. }
  21693. type Result2001 struct {
  21694. Cainfo interface{} `json:"cainfo"`
  21695. ErrMsg string `json:"err_msg"`
  21696. InfRefmsgid string `json:"inf_refmsgid"`
  21697. Infcode int64 `json:"infcode"`
  21698. Output struct {
  21699. Trtinfo struct {
  21700. PsnNo string `json:"psn_no"`
  21701. TrtChkType string `json:"trt_chk_type"`
  21702. FundPayType string `json:"fund_pay_type"`
  21703. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21704. Begndate string `json:"begndate"`
  21705. Enddate string `json:"enddate"`
  21706. TrtChkRslt string `json:"trt_chk_rslt"`
  21707. } `json:"trtinfo"`
  21708. } `json:"output"`
  21709. RefmsgTime string `json:"refmsg_time"`
  21710. RespondTime string `json:"respond_time"`
  21711. Signtype interface{} `json:"signtype"`
  21712. WarnMsg interface{} `json:"warn_msg"`
  21713. }
  21714. type Result2001Org10265 struct {
  21715. Cainfo interface{} `json:"cainfo"`
  21716. ErrMsg string `json:"err_msg"`
  21717. InfRefmsgid string `json:"inf_refmsgid"`
  21718. Infcode string `json:"infcode"`
  21719. Output struct {
  21720. Trtinfo struct {
  21721. PsnNo string `json:"psn_no"`
  21722. TrtChkType string `json:"trt_chk_type"`
  21723. FundPayType string `json:"fund_pay_type"`
  21724. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21725. Begndate string `json:"begndate"`
  21726. Enddate string `json:"enddate"`
  21727. TrtChkRslt string `json:"trt_chk_rslt"`
  21728. } `json:"trtinfo"`
  21729. } `json:"output"`
  21730. RefmsgTime string `json:"refmsg_time"`
  21731. RespondTime string `json:"respond_time"`
  21732. Signtype interface{} `json:"signtype"`
  21733. WarnMsg interface{} `json:"warn_msg"`
  21734. }
  21735. type ResultTwo struct {
  21736. ErrMsg string `json:"err_msg"`
  21737. InfRefmsgid string `json:"inf_refmsgid"`
  21738. Infcode int64 `json:"infcode"`
  21739. Output struct {
  21740. Baseinfo struct {
  21741. //Brdy string `json:"brdy"`
  21742. Certno string `json:"certno"`
  21743. Gend string `json:"gend"`
  21744. Naty string `json:"naty"`
  21745. PsnCertType string `json:"psn_cert_type"`
  21746. PsnName string `json:"psn_name"`
  21747. PsnNo string `json:"psn_no"`
  21748. } `json:"baseinfo"`
  21749. Idetinfo []interface{} `json:"idetinfo"`
  21750. Iinfo []struct {
  21751. Balc float64 `json:"balc"`
  21752. CvlservFlag string `json:"cvlserv_flag"`
  21753. EmpName string `json:"emp_name"`
  21754. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21755. Insutype string `json:"insutype"`
  21756. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21757. //PausInsuDate string `json:"paus_insu_date"`
  21758. //PsnInsuDate string `json:"psn_insu_date"`
  21759. PsnInsuStas string `json:"psn_insu_stas"`
  21760. PsnType string `json:"psn_type"`
  21761. } `json:"insuinfo"`
  21762. } `json:"output"`
  21763. RefmsgTime string `json:"refmsg_time"`
  21764. RespondTime string `json:"respond_time"`
  21765. Signtype interface{} `json:"signtype"`
  21766. WarnInfo interface{} `json:"warn_info"`
  21767. }
  21768. type ResultTwo10265 struct {
  21769. ErrMsg string `json:"err_msg"`
  21770. InfRefmsgid string `json:"inf_refmsgid"`
  21771. Infcode string `json:"infcode"`
  21772. Output struct {
  21773. Baseinfo struct {
  21774. //Brdy string `json:"brdy"`
  21775. Certno string `json:"certno"`
  21776. Gend string `json:"gend"`
  21777. Naty string `json:"naty"`
  21778. PsnCertType string `json:"psn_cert_type"`
  21779. PsnName string `json:"psn_name"`
  21780. PsnNo string `json:"psn_no"`
  21781. } `json:"baseinfo"`
  21782. Idetinfo []interface{} `json:"idetinfo"`
  21783. Iinfo []struct {
  21784. Balc float64 `json:"balc"`
  21785. CvlservFlag string `json:"cvlserv_flag"`
  21786. EmpName string `json:"emp_name"`
  21787. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21788. Insutype string `json:"insutype"`
  21789. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21790. PsnInsuStas string `json:"psn_insu_stas"`
  21791. PsnType string `json:"psn_type"`
  21792. } `json:"insuinfo"`
  21793. } `json:"output"`
  21794. RefmsgTime string `json:"refmsg_time"`
  21795. RespondTime string `json:"respond_time"`
  21796. Signtype interface{} `json:"signtype"`
  21797. WarnInfo interface{} `json:"warn_info"`
  21798. }
  21799. type ResultThree struct {
  21800. Cainfo interface{} `json:"cainfo"`
  21801. ErrMsg string `json:"err_msg"`
  21802. InfRefmsgid string `json:"inf_refmsgid"`
  21803. Infcode int64 `json:"infcode"`
  21804. Output struct {
  21805. Data struct {
  21806. IptOtpNo string `json:"ipt_otp_no"`
  21807. MdtrtID string `json:"mdtrt_id"`
  21808. PsnNo string `json:"psn_no"`
  21809. } `json:"data"`
  21810. } `json:"output"`
  21811. RefmsgTime string `json:"refmsg_time"`
  21812. RespondTime string `json:"respond_time"`
  21813. Signtype interface{} `json:"signtype"`
  21814. WarnMsg interface{} `json:"warn_msg"`
  21815. }
  21816. type ResultThree10265 struct {
  21817. Cainfo interface{} `json:"cainfo"`
  21818. ErrMsg string `json:"err_msg"`
  21819. InfRefmsgid string `json:"inf_refmsgid"`
  21820. Infcode string `json:"infcode"`
  21821. Output struct {
  21822. Data struct {
  21823. IptOtpNo string `json:"ipt_otp_no"`
  21824. MdtrtID string `json:"mdtrt_id"`
  21825. PsnNo string `json:"psn_no"`
  21826. } `json:"data"`
  21827. } `json:"output"`
  21828. RefmsgTime string `json:"refmsg_time"`
  21829. RespondTime string `json:"respond_time"`
  21830. Signtype interface{} `json:"signtype"`
  21831. WarnMsg interface{} `json:"warn_msg"`
  21832. }
  21833. type ResultFour struct {
  21834. Cainfo string `json:"cainfo"`
  21835. ErrMsg string `json:"err_msg"`
  21836. InfRefmsgid string `json:"inf_refmsgid"`
  21837. Infcode int64 `json:"infcode"`
  21838. Output struct {
  21839. Result []struct {
  21840. BasMednFlag string `json:"bas_medn_flag"`
  21841. ChldMedcFlag string `json:"chld_medc_flag"`
  21842. ChrgitmLv string `json:"chrgitm_lv"`
  21843. Cnt float64 `json:"cnt"`
  21844. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21845. DrtReimFlag string `json:"drt_reim_flag"`
  21846. FeedetlSn string `json:"feedetl_sn"`
  21847. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21848. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21849. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21850. ListSpItemFlag string `json:"list_sp_item_flag"`
  21851. LmtUsedFlag string `json:"lmt_used_flag"`
  21852. MedChrgitmType string `json:"med_chrgitm_type"`
  21853. Memo string `json:"memo"`
  21854. OverlmtAmt float64 `json:"overlmt_amt"`
  21855. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21856. Pric float64 `json:"pric"`
  21857. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21858. SelfpayProp float64 `json:"selfpay_prop"`
  21859. } `json:"result"`
  21860. } `json:"output"`
  21861. RefmsgTime string `json:"refmsg_time"`
  21862. RespondTime string `json:"respond_time"`
  21863. Signtype string `json:"signtype"`
  21864. WarnMsg string `json:"warn_msg"`
  21865. }
  21866. type ResultFour10265 struct {
  21867. Cainfo string `json:"cainfo"`
  21868. ErrMsg string `json:"err_msg"`
  21869. InfRefmsgid string `json:"inf_refmsgid"`
  21870. Infcode string `json:"infcode"`
  21871. Output struct {
  21872. Result []struct {
  21873. BasMednFlag string `json:"bas_medn_flag"`
  21874. ChldMedcFlag string `json:"chld_medc_flag"`
  21875. ChrgitmLv string `json:"chrgitm_lv"`
  21876. Cnt float64 `json:"cnt"`
  21877. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21878. DrtReimFlag string `json:"drt_reim_flag"`
  21879. FeedetlSn string `json:"feedetl_sn"`
  21880. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21881. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21882. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21883. ListSpItemFlag string `json:"list_sp_item_flag"`
  21884. LmtUsedFlag string `json:"lmt_used_flag"`
  21885. MedChrgitmType string `json:"med_chrgitm_type"`
  21886. Memo string `json:"memo"`
  21887. OverlmtAmt float64 `json:"overlmt_amt"`
  21888. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21889. Pric float64 `json:"pric"`
  21890. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21891. SelfpayProp float64 `json:"selfpay_prop"`
  21892. } `json:"result"`
  21893. } `json:"output"`
  21894. RefmsgTime string `json:"refmsg_time"`
  21895. RespondTime string `json:"respond_time"`
  21896. Signtype string `json:"signtype"`
  21897. WarnMsg string `json:"warn_msg"`
  21898. }
  21899. type ResultMemo struct {
  21900. InsuAdmdvs string `json:"insuAdmdvs"`
  21901. }
  21902. // [{"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}]
  21903. type ResultIDInfo struct {
  21904. Begntime string `json:"begntime"`
  21905. Endtime string `json:"endtime"`
  21906. Memo string `json:"memo"`
  21907. }
  21908. type ResultFive struct {
  21909. Balc float64 `json:"balc"`
  21910. CvlservFlag string `json:"cvlserv_flag"`
  21911. EmpName string `json:"emp_name"`
  21912. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21913. Insutype string `json:"insutype"`
  21914. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21915. PausInsuDate string `json:"paus_insu_date"`
  21916. PsnInsuDate string `json:"psn_insu_date"`
  21917. PsnInsuStas string `json:"psn_insu_stas"`
  21918. PsnType string `json:"psn_type"`
  21919. }
  21920. type ResultSix struct {
  21921. Cainfo interface{} `json:"cainfo"`
  21922. ErrMsg string `json:"err_msg"`
  21923. InfRefmsgid string `json:"inf_refmsgid"`
  21924. Infcode int64 `json:"infcode"`
  21925. Output struct {
  21926. } `json:"output"`
  21927. RefmsgTime string `json:"refmsg_time"`
  21928. RespondTime string `json:"respond_time"`
  21929. Signtype interface{} `json:"signtype"`
  21930. WarnMsg interface{} `json:"warn_msg"`
  21931. }
  21932. type FJ3507Result struct {
  21933. Cainfo interface{} `json:"cainfo"`
  21934. ErrMsg string `json:"err_msg"`
  21935. InfRefmsgid string `json:"inf_refmsgid"`
  21936. Infcode int64 `json:"infcode"`
  21937. Output struct {
  21938. retRslt string `json:"retRslt"`
  21939. msgRslt string `json:"msgRslt"`
  21940. } `json:"output"`
  21941. RefmsgTime string `json:"refmsg_time"`
  21942. RespondTime string `json:"respond_time"`
  21943. Signtype interface{} `json:"signtype"`
  21944. WarnMsg interface{} `json:"warn_msg"`
  21945. }
  21946. type FJ3507ResultFor10188 struct {
  21947. Cainfo interface{} `json:"cainfo"`
  21948. ErrMsg string `json:"err_msg"`
  21949. InfRefmsgid string `json:"inf_refmsgid"`
  21950. Infcode string `json:"infcode"`
  21951. RefmsgTime string `json:"refmsg_time"`
  21952. RespondTime string `json:"respond_time"`
  21953. Signtype interface{} `json:"signtype"`
  21954. WarnMsg interface{} `json:"warn_msg"`
  21955. }
  21956. type Result2406 struct {
  21957. Cainfo interface{} `json:"cainfo"`
  21958. ErrMsg string `json:"err_msg"`
  21959. InfRefmsgid string `json:"inf_refmsgid"`
  21960. Infcode int64 `json:"infcode"`
  21961. Output struct {
  21962. Result struct {
  21963. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21964. } `json:"result"`
  21965. } `json:"output"`
  21966. RefmsgTime string `json:"refmsg_time"`
  21967. RespondTime string `json:"respond_time"`
  21968. Signtype interface{} `json:"signtype"`
  21969. WarnMsg interface{} `json:"warn_msg"`
  21970. }
  21971. type GZResultSix struct {
  21972. Cainfo interface{} `json:"cainfo"`
  21973. ErrMsg string `json:"err_msg"`
  21974. InfRefmsgid string `json:"inf_refmsgid"`
  21975. Infcode int64 `json:"infcode"`
  21976. Output string `json:"output"`
  21977. RefmsgTime string `json:"refmsg_time"`
  21978. RespondTime string `json:"respond_time"`
  21979. Signtype interface{} `json:"signtype"`
  21980. WarnMsg interface{} `json:"warn_msg"`
  21981. }
  21982. type ResultSix10265 struct {
  21983. Cainfo interface{} `json:"cainfo"`
  21984. ErrMsg string `json:"err_msg"`
  21985. InfRefmsgid string `json:"inf_refmsgid"`
  21986. Infcode string `json:"infcode"`
  21987. Output struct {
  21988. } `json:"output"`
  21989. RefmsgTime string `json:"refmsg_time"`
  21990. RespondTime string `json:"respond_time"`
  21991. Signtype interface{} `json:"signtype"`
  21992. WarnMsg interface{} `json:"warn_msg"`
  21993. }
  21994. type ResultSeven struct {
  21995. Cainfo string `json:"cainfo"`
  21996. ErrMsg string `json:"err_msg"`
  21997. InfRefmsgid string `json:"inf_refmsgid"`
  21998. Infcode int64 `json:"infcode"`
  21999. Output struct {
  22000. Setlinfo struct {
  22001. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22002. AcctPay float64 `json:"acct_pay"`
  22003. ActPayDedc float64 `json:"act_pay_dedc"`
  22004. Age float64 `json:"age"`
  22005. Balc float64 `json:"balc"`
  22006. Certno string `json:"certno"`
  22007. ClrOptins string `json:"clr_optins"`
  22008. ClrType string `json:"clr_type"`
  22009. ClrWay string `json:"clr_way"`
  22010. CvlservFlag string `json:"cvlserv_flag"`
  22011. CvlservPay float64 `json:"cvlserv_pay"`
  22012. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22013. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22014. Gend string `json:"gend"`
  22015. HifesPay float64 `json:"hifes_pay"`
  22016. HifmiPay float64 `json:"hifmi_pay"`
  22017. HifpPay float64 `json:"hifp_pay"`
  22018. HospPartAmt float64 `json:"hosp_part_amt"`
  22019. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22020. Insutype string `json:"insutype"`
  22021. MafPay float64 `json:"maf_pay"`
  22022. MdtrtCertType string `json:"mdtrt_cert_type"`
  22023. HifobPay float64 `json:"hifob_pay"`
  22024. MdtrtID string `json:"mdtrt_id"`
  22025. MedType string `json:"med_type"`
  22026. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22027. MedinsSetlID string `json:"medins_setl_id"`
  22028. Naty string `json:"naty"`
  22029. OthPay float64 `json:"oth_pay"`
  22030. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22031. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22032. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22033. PsnCashPay float64 `json:"psn_cash_pay"`
  22034. PsnCertType string `json:"psn_cert_type"`
  22035. PsnName string `json:"psn_name"`
  22036. PsnNo string `json:"psn_no"`
  22037. PsnPartAmt float64 `json:"psn_part_amt"`
  22038. PsnType string `json:"psn_type"`
  22039. SetlID string `json:"setl_id"`
  22040. SetlTime string `json:"setl_time"`
  22041. } `json:"setlinfo"`
  22042. Setldetail interface{} `json:"setldetail"`
  22043. } `json:"output"`
  22044. RefmsgTime string `json:"refmsg_time"`
  22045. RespondTime string `json:"respond_time"`
  22046. Signtype interface{} `json:"signtype"`
  22047. WarnMsg interface{} `json:"warn_msg"`
  22048. }
  22049. type ResultSevenAH struct {
  22050. Cainfo string `json:"cainfo"`
  22051. ErrMsg string `json:"err_msg"`
  22052. InfRefmsgid string `json:"inf_refmsgid"`
  22053. Infcode int64 `json:"infcode"`
  22054. Output struct {
  22055. Setlinfo struct {
  22056. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22057. AcctPay float64 `json:"acct_pay"`
  22058. ActPayDedc float64 `json:"act_pay_dedc"`
  22059. Age float64 `json:"age"`
  22060. Balc float64 `json:"balc"`
  22061. Certno string `json:"certno"`
  22062. ClrOptins string `json:"clr_optins"`
  22063. ClrType string `json:"clr_type"`
  22064. ClrWay string `json:"clr_way"`
  22065. CvlservFlag string `json:"cvlserv_flag"`
  22066. CvlservPay float64 `json:"cvlserv_pay"`
  22067. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22068. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22069. Gend string `json:"gend"`
  22070. HifesPay float64 `json:"hifes_pay"`
  22071. HifmiPay float64 `json:"hifmi_pay"`
  22072. HifpPay float64 `json:"hifp_pay"`
  22073. HospPartAmt float64 `json:"hosp_part_amt"`
  22074. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22075. Insutype string `json:"insutype"`
  22076. MafPay float64 `json:"maf_pay"`
  22077. MdtrtCertType string `json:"mdtrt_cert_type"`
  22078. HifobPay float64 `json:"hifob_pay"`
  22079. MdtrtID string `json:"mdtrt_id"`
  22080. MedType string `json:"med_type"`
  22081. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22082. MedinsSetlID string `json:"medins_setl_id"`
  22083. Naty string `json:"naty"`
  22084. OthPay float64 `json:"oth_pay"`
  22085. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22086. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22087. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22088. PsnCashPay float64 `json:"psn_cash_pay"`
  22089. PsnCertType string `json:"psn_cert_type"`
  22090. PsnName string `json:"psn_name"`
  22091. PsnNo string `json:"psn_no"`
  22092. PsnPartAmt float64 `json:"psn_part_amt"`
  22093. PsnType string `json:"psn_type"`
  22094. SetlID string `json:"setl_id"`
  22095. SetlTime int64 `json:"setl_time"`
  22096. } `json:"setlinfo"`
  22097. Setldetail interface{} `json:"setldetail"`
  22098. } `json:"output"`
  22099. RefmsgTime string `json:"refmsg_time"`
  22100. RespondTime string `json:"respond_time"`
  22101. Signtype interface{} `json:"signtype"`
  22102. WarnMsg interface{} `json:"warn_msg"`
  22103. }
  22104. type ResultSeven10265 struct {
  22105. Cainfo string `json:"cainfo"`
  22106. ErrMsg string `json:"err_msg"`
  22107. InfRefmsgid string `json:"inf_refmsgid"`
  22108. Infcode string `json:"infcode"`
  22109. Output struct {
  22110. Setlinfo struct {
  22111. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22112. AcctPay float64 `json:"acct_pay"`
  22113. ActPayDedc float64 `json:"act_pay_dedc"`
  22114. Age float64 `json:"age"`
  22115. Balc float64 `json:"balc"`
  22116. Certno string `json:"certno"`
  22117. ClrOptins string `json:"clr_optins"`
  22118. ClrType string `json:"clr_type"`
  22119. ClrWay string `json:"clr_way"`
  22120. CvlservFlag string `json:"cvlserv_flag"`
  22121. CvlservPay float64 `json:"cvlserv_pay"`
  22122. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22123. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22124. Gend string `json:"gend"`
  22125. HifesPay float64 `json:"hifes_pay"`
  22126. HifmiPay float64 `json:"hifmi_pay"`
  22127. HifpPay float64 `json:"hifp_pay"`
  22128. HospPartAmt float64 `json:"hosp_part_amt"`
  22129. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22130. Insutype string `json:"insutype"`
  22131. MafPay float64 `json:"maf_pay"`
  22132. MdtrtCertType string `json:"mdtrt_cert_type"`
  22133. HifobPay float64 `json:"hifob_pay"`
  22134. MdtrtID string `json:"mdtrt_id"`
  22135. MedType string `json:"med_type"`
  22136. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22137. MedinsSetlID string `json:"medins_setl_id"`
  22138. Naty string `json:"naty"`
  22139. OthPay float64 `json:"oth_pay"`
  22140. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22141. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22142. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22143. PsnCashPay float64 `json:"psn_cash_pay"`
  22144. PsnCertType string `json:"psn_cert_type"`
  22145. PsnName string `json:"psn_name"`
  22146. PsnNo string `json:"psn_no"`
  22147. PsnPartAmt float64 `json:"psn_part_amt"`
  22148. PsnType string `json:"psn_type"`
  22149. SetlID string `json:"setl_id"`
  22150. SetlTime string `json:"setl_time"`
  22151. } `json:"setlinfo"`
  22152. Setldetail interface{} `json:"setldetail"`
  22153. } `json:"output"`
  22154. RefmsgTime string `json:"refmsg_time"`
  22155. RespondTime string `json:"respond_time"`
  22156. Signtype interface{} `json:"signtype"`
  22157. WarnMsg interface{} `json:"warn_msg"`
  22158. }
  22159. type ResultSeven10265Two struct {
  22160. Cainfo string `json:"cainfo"`
  22161. ErrMsg string `json:"err_msg"`
  22162. InfRefmsgid string `json:"inf_refmsgid"`
  22163. Infcode string `json:"infcode"`
  22164. Output struct {
  22165. Setlinfo struct {
  22166. AcctMulaidPay string `json:"acct_mulaid_pay"`
  22167. AcctPay float64 `json:"acct_pay"`
  22168. ActPayDedc float64 `json:"act_pay_dedc"`
  22169. Age float64 `json:"age"`
  22170. Balc float64 `json:"balc"`
  22171. Certno string `json:"certno"`
  22172. ClrOptins string `json:"clr_optins"`
  22173. ClrType string `json:"clr_type"`
  22174. ClrWay string `json:"clr_way"`
  22175. CvlservFlag string `json:"cvlserv_flag"`
  22176. CvlservPay float64 `json:"cvlserv_pay"`
  22177. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22178. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22179. Gend string `json:"gend"`
  22180. HifesPay float64 `json:"hifes_pay"`
  22181. HifmiPay float64 `json:"hifmi_pay"`
  22182. HifpPay float64 `json:"hifp_pay"`
  22183. HospPartAmt string `json:"hosp_part_amt"`
  22184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22185. Insutype string `json:"insutype"`
  22186. MafPay float64 `json:"maf_pay"`
  22187. MdtrtCertType string `json:"mdtrt_cert_type"`
  22188. HifobPay float64 `json:"hifob_pay"`
  22189. MdtrtID string `json:"mdtrt_id"`
  22190. MedType string `json:"med_type"`
  22191. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22192. MedinsSetlID string `json:"medins_setl_id"`
  22193. Naty string `json:"naty"`
  22194. OthPay float64 `json:"oth_pay"`
  22195. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22196. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22197. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22198. PsnCashPay float64 `json:"psn_cash_pay"`
  22199. PsnCertType string `json:"psn_cert_type"`
  22200. PsnName string `json:"psn_name"`
  22201. PsnNo string `json:"psn_no"`
  22202. PsnPartAmt float64 `json:"psn_part_amt"`
  22203. PsnType string `json:"psn_type"`
  22204. SetlID string `json:"setl_id"`
  22205. SetlTime string `json:"setl_time"`
  22206. } `json:"setlinfo"`
  22207. Setldetail interface{} `json:"setldetail"`
  22208. } `json:"output"`
  22209. RefmsgTime string `json:"refmsg_time"`
  22210. RespondTime string `json:"respond_time"`
  22211. Signtype interface{} `json:"signtype"`
  22212. WarnMsg interface{} `json:"warn_msg"`
  22213. }
  22214. type GZResultSeven10265Two struct {
  22215. Cainfo string `json:"cainfo"`
  22216. ErrMsg string `json:"err_msg"`
  22217. InfRefmsgid string `json:"inf_refmsgid"`
  22218. Infcode int64 `json:"infcode"`
  22219. Output struct {
  22220. Setlinfo struct {
  22221. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22222. AcctPay float64 `json:"acct_pay"`
  22223. ActPayDedc float64 `json:"act_pay_dedc"`
  22224. Age float64 `json:"age"`
  22225. Balc float64 `json:"balc"`
  22226. Certno string `json:"certno"`
  22227. ClrOptins string `json:"clr_optins"`
  22228. ClrType string `json:"clr_type"`
  22229. ClrWay string `json:"clr_way"`
  22230. CvlservFlag string `json:"cvlserv_flag"`
  22231. CvlservPay float64 `json:"cvlserv_pay"`
  22232. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22233. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22234. Gend string `json:"gend"`
  22235. HifesPay float64 `json:"hifes_pay"`
  22236. HifmiPay float64 `json:"hifmi_pay"`
  22237. HifpPay float64 `json:"hifp_pay"`
  22238. HospPartAmt float64 `json:"hosp_part_amt"`
  22239. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22240. Insutype string `json:"insutype"`
  22241. MafPay float64 `json:"maf_pay"`
  22242. MdtrtCertType string `json:"mdtrt_cert_type"`
  22243. HifobPay float64 `json:"hifob_pay"`
  22244. MdtrtID string `json:"mdtrt_id"`
  22245. MedType string `json:"med_type"`
  22246. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22247. MedinsSetlID string `json:"medins_setl_id"`
  22248. Naty string `json:"naty"`
  22249. OthPay float64 `json:"oth_pay"`
  22250. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22251. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22252. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22253. PsnCashPay float64 `json:"psn_cash_pay"`
  22254. PsnCertType string `json:"psn_cert_type"`
  22255. PsnName string `json:"psn_name"`
  22256. PsnNo string `json:"psn_no"`
  22257. PsnPartAmt float64 `json:"psn_part_amt"`
  22258. PsnType string `json:"psn_type"`
  22259. SetlID string `json:"setl_id"`
  22260. SetlTime string `json:"setl_time"`
  22261. } `json:"setlinfo"`
  22262. Setldetail interface{} `json:"setldetail"`
  22263. } `json:"output"`
  22264. RefmsgTime string `json:"refmsg_time"`
  22265. RespondTime string `json:"respond_time"`
  22266. Signtype interface{} `json:"signtype"`
  22267. WarnMsg interface{} `json:"warn_msg"`
  22268. }
  22269. type ResultEight struct {
  22270. Cainfo string `json:"cainfo"`
  22271. ErrMsg string `json:"err_msg"`
  22272. InfRefmsgid string `json:"inf_refmsgid"`
  22273. Infcode int64 `json:"infcode"`
  22274. Output struct {
  22275. Stmtinfo struct {
  22276. SetlOptins string `json:"setl_optins"`
  22277. StmtRslt string `json:"stmt_rslt"`
  22278. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22279. } `json:"stmtinfo"`
  22280. } `json:"output"`
  22281. RefmsgTime string `json:"refmsg_time"`
  22282. RespondTime string `json:"respond_time"`
  22283. Signtype interface{} `json:"signtype"`
  22284. WarnMsg interface{} `json:"warn_msg"`
  22285. }
  22286. type ResultEightFor10188 struct {
  22287. Cainfo string `json:"cainfo"`
  22288. ErrMsg string `json:"err_msg"`
  22289. InfRefmsgid string `json:"inf_refmsgid"`
  22290. Infcode string `json:"infcode"`
  22291. Output struct {
  22292. Stmtinfo struct {
  22293. SetlOptins string `json:"setl_optins"`
  22294. StmtRslt string `json:"stmt_rslt"`
  22295. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22296. } `json:"stmtinfo"`
  22297. } `json:"output"`
  22298. RefmsgTime string `json:"refmsg_time"`
  22299. RespondTime string `json:"respond_time"`
  22300. Signtype interface{} `json:"signtype"`
  22301. WarnMsg interface{} `json:"warn_msg"`
  22302. }
  22303. type ResultNine struct {
  22304. Cainfo string `json:"cainfo"`
  22305. ErrMsg string `json:"err_msg"`
  22306. InfRefmsgid string `json:"inf_refmsgid"`
  22307. Infcode int64 `json:"infcode"`
  22308. Output struct {
  22309. FileQuryNo string `json:"file_qury_no"`
  22310. } `json:"output"`
  22311. RefmsgTime string `json:"refmsg_time"`
  22312. RespondTime string `json:"respond_time"`
  22313. Signtype interface{} `json:"signtype"`
  22314. WarnMsg interface{} `json:"warn_msg"`
  22315. }
  22316. type ResultTen struct {
  22317. Cainfo string `json:"cainfo"`
  22318. ErrMsg string `json:"err_msg"`
  22319. InfRefmsgid string `json:"inf_refmsgid"`
  22320. Infcode int64 `json:"infcode"`
  22321. Output struct {
  22322. Fileinfo struct {
  22323. DldEndtime string `json:"dld_endtime"`
  22324. FileQuryNo string `json:"file_qury_no"`
  22325. Filename string `json:"filename"`
  22326. } `json:"fileinfo"`
  22327. } `json:"output"`
  22328. RefmsgTime string `json:"refmsg_time"`
  22329. RespondTime string `json:"respond_time"`
  22330. Signtype interface{} `json:"signtype"`
  22331. WarnMsg interface{} `json:"warn_msg"`
  22332. }
  22333. type Result5262 struct {
  22334. ErrMsg string `json:"err_msg"`
  22335. InfRefmsgid string `json:"inf_refmsgid"`
  22336. Infcode int64 `json:"infcode"`
  22337. Output struct {
  22338. PageInfo struct {
  22339. Size int `json:"size"`
  22340. RecordCounts int `json:"record_counts"`
  22341. } `json:"page_info"`
  22342. Idetinfo []interface{} `json:"idetinfo"`
  22343. Result []struct {
  22344. SetlID string `json:"setl_id"`
  22345. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22346. MdtrtID string `json:"mdtrt_id"`
  22347. InitSetlID string `json:"init_setl_id,omitempty"`
  22348. PsnNo string `json:"psn_no"`
  22349. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22350. PsnName string `json:"psn_name"`
  22351. PsnCertType string `json:"psn_cert_type"`
  22352. Certno string `json:"certno"`
  22353. Gend string `json:"gend,omitempty"`
  22354. Naty string `json:"naty,omitempty"`
  22355. Brdy string `json:"brdy,omitempty"`
  22356. Age float64 `json:"age,omitempty"`
  22357. Insutype string `json:"insutype,omitempty"`
  22358. PsnType string `json:"psn_type"`
  22359. CvlservFlag string `json:"cvlserv_flag"`
  22360. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22361. SpPsnType string `json:"sp_psn_type,omitempty"`
  22362. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22363. ClctGrde string `json:"clct_grde,omitempty"`
  22364. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22365. NwbFlag string `json:"nwb_flag,omitempty"`
  22366. InsuAdmdvs string `json:"insu_admdvs"`
  22367. EmpNo string `json:"emp_no,omitempty"`
  22368. EmpName string `json:"emp_name,omitempty"`
  22369. EmpType string `json:"emp_type,omitempty"`
  22370. EconType string `json:"econ_type,omitempty"`
  22371. AfilIndu string `json:"afil_indu,omitempty"`
  22372. AfilRlts string `json:"afil_rlts,omitempty"`
  22373. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22374. PayLoc string `json:"pay_loc,omitempty"`
  22375. FixmedinsCode string `json:"fixmedins_code"`
  22376. FixmedinsName string `json:"fixmedins_name"`
  22377. HospLv string `json:"hosp_lv,omitempty"`
  22378. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22379. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22380. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22381. Begndate string `json:"begndate"`
  22382. Enddate string `json:"enddate"`
  22383. SetlTime string `json:"setl_time"`
  22384. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22385. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22386. MedType string `json:"med_type"`
  22387. SetlType string `json:"setl_type,omitempty"`
  22388. ClrType string `json:"clr_type,omitempty"`
  22389. ClrWay string `json:"clr_way,omitempty"`
  22390. PsnSetlway string `json:"psn_setlway,omitempty"`
  22391. ClrOptins string `json:"clr_optins,omitempty"`
  22392. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22393. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22394. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22395. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22396. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22397. DedcStd float64 `json:"dedc_std,omitempty"`
  22398. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22399. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22400. HifpPay float64 `json:"hifp_pay,omitempty"`
  22401. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22402. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22403. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22404. HifesPay float64 `json:"hifes_pay,omitempty"`
  22405. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22406. HifobPay float64 `json:"hifob_pay,omitempty"`
  22407. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22408. MafPay float64 `json:"maf_pay,omitempty"`
  22409. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22410. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22411. PsnPay float64 `json:"psn_pay,omitempty"`
  22412. AcctPay float64 `json:"acct_pay,omitempty"`
  22413. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22414. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22415. Balc float64 `json:"balc,omitempty"`
  22416. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22417. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22418. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22419. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22420. Year string `json:"year,omitempty"`
  22421. DiseNo string `json:"dise_no,omitempty"`
  22422. DiseName string `json:"dise_name,omitempty"`
  22423. Invono string `json:"invono,omitempty"`
  22424. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22425. ValiFlag string `json:"vali_flag,omitempty"`
  22426. Memo string `json:"memo,omitempty"`
  22427. Rid string `json:"rid"`
  22428. UpdtTime string `json:"updt_time,omitempty"`
  22429. CrterID string `json:"crter_id,omitempty"`
  22430. CrterName string `json:"crter_name,omitempty"`
  22431. CrteTime string `json:"crte_time,omitempty"`
  22432. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22433. OpterID string `json:"opter_id,omitempty"`
  22434. OpterName string `json:"opter_name,omitempty"`
  22435. OptTime string `json:"opt_time,omitempty"`
  22436. OptinsNo string `json:"optins_no,omitempty"`
  22437. PoolareaNo string `json:"poolarea_no,omitempty"`
  22438. } `json:"result"`
  22439. } `json:"output"`
  22440. RefmsgTime string `json:"refmsg_time"`
  22441. RespondTime string `json:"respond_time"`
  22442. Signtype interface{} `json:"signtype"`
  22443. WarnInfo interface{} `json:"warn_info"`
  22444. }
  22445. type Result5267 struct {
  22446. ErrMsg string `json:"err_msg"`
  22447. InfRefmsgid string `json:"inf_refmsgid"`
  22448. Infcode int64 `json:"infcode"`
  22449. Output struct {
  22450. PageInfo struct {
  22451. Size int `json:"size"`
  22452. RecordCounts int `json:"record_counts"`
  22453. } `json:"pageinfo"`
  22454. Result []struct {
  22455. SetlID string `json:"setl_id"`
  22456. ClrOptins string `json:"clr_optins"`
  22457. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22458. MdtrtID string `json:"mdtrt_id"`
  22459. InitSetlID string `json:"init_setl_id,omitempty"`
  22460. PsnNo string `json:"psn_no"`
  22461. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22462. PsnName string `json:"psn_name"`
  22463. PsnCertType string `json:"psn_cert_type"`
  22464. Certno string `json:"certno"`
  22465. Gend string `json:"gend,omitempty"`
  22466. Naty string `json:"naty,omitempty"`
  22467. Brdy string `json:"brdy,omitempty"`
  22468. Age float64 `json:"age,omitempty"`
  22469. Insutype string `json:"insutype,omitempty"`
  22470. PsnType string `json:"psn_type"`
  22471. CvlservFlag string `json:"cvlserv_flag"`
  22472. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22473. SpPsnType string `json:"sp_psn_type,omitempty"`
  22474. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22475. ClctGrde string `json:"clct_grde,omitempty"`
  22476. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22477. NwbFlag string `json:"nwb_flag,omitempty"`
  22478. InsuAdmdvs string `json:"insu_admdvs"`
  22479. EmpNo string `json:"emp_no,omitempty"`
  22480. EmpName string `json:"emp_name,omitempty"`
  22481. EmpType string `json:"emp_type,omitempty"`
  22482. EconType string `json:"econ_type,omitempty"`
  22483. AfilIndu string `json:"afil_indu,omitempty"`
  22484. AfilRlts string `json:"afil_rlts,omitempty"`
  22485. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22486. PayLoc string `json:"pay_loc,omitempty"`
  22487. FixmedinsCode string `json:"fixmedins_code"`
  22488. FixmedinsName string `json:"fixmedins_name"`
  22489. HospLv string `json:"hosp_lv,omitempty"`
  22490. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22491. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22492. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22493. Begndate string `json:"begndate,omitempty"`
  22494. Enddate string `json:"enddate,omitempty"`
  22495. SetlTime string `json:"setl_time,omitempty"`
  22496. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22497. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22498. MedType string `json:"med_type"`
  22499. SetlType string `json:"setl_type,omitempty"`
  22500. ClrType string `json:"clr_type,omitempty"`
  22501. ClrWay string `json:"clr_way,omitempty"`
  22502. PsnSetlway string `json:"psn_setlway,omitempty"`
  22503. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22504. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22505. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22506. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22507. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22508. DedcStd float64 `json:"dedc_std,omitempty"`
  22509. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22510. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22511. HifpPay float64 `json:"hifp_pay,omitempty"`
  22512. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22513. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22514. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22515. HifesPay float64 `json:"hifes_pay,omitempty"`
  22516. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22517. HifobPay float64 `json:"hifob_pay,omitempty"`
  22518. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22519. MafPay float64 `json:"maf_pay,omitempty"`
  22520. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22521. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22522. PsnPay float64 `json:"psn_pay,omitempty"`
  22523. AcctPay float64 `json:"acct_pay,omitempty"`
  22524. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22525. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22526. Balc float64 `json:"balc,omitempty"`
  22527. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22528. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22529. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22530. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22531. Year string `json:"year,omitempty"`
  22532. DiseNo string `json:"dise_no,omitempty"`
  22533. DiseName string `json:"dise_name,omitempty"`
  22534. Invono string `json:"invono,omitempty"`
  22535. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22536. Memo string `json:"memo,omitempty"`
  22537. UpdtTime string `json:"updt_time,omitempty"`
  22538. OpterID string `json:"opter_id,omitempty"`
  22539. OpterName string `json:"opter_name,omitempty"`
  22540. OptTime string `json:"opt_time,omitempty"`
  22541. OptinsNo string `json:"optins_no,omitempty"`
  22542. PoolareaNo string `json:"poolarea_no,omitempty"`
  22543. } `json:"result"`
  22544. } `json:"output"`
  22545. RefmsgTime string `json:"refmsg_time"`
  22546. RespondTime string `json:"respond_time"`
  22547. Signtype interface{} `json:"signtype"`
  22548. WarnInfo interface{} `json:"warn_info"`
  22549. }
  22550. // type Autogenerated struct {
  22551. // Output struct {
  22552. // Setlinfo struct {
  22553. // SetlTime string `json:"setl_time"`
  22554. // CvlservPay float64 `json:"cvlserv_pay"`
  22555. // Year string `json:"year"`
  22556. // MedType string `json:"med_type"`
  22557. // PsnPay float64 `json:"psn_pay"`
  22558. // OpterID string `json:"opter_id"`
  22559. // Begndate string `json:"begndate"`
  22560. // FlxempeFlag string `json:"flxempe_flag"`
  22561. // HifmiPay float64 `json:"hifmi_pay"`
  22562. // PsnNo string `json:"psn_no"`
  22563. // ActPayDedc float64 `json:"act_pay_dedc"`
  22564. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22565. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22566. // ClrWay string `json:"clr_way"`
  22567. // OthPay float64 `json:"oth_pay"`
  22568. // Gend string `json:"gend"`
  22569. // MdtrtID string `json:"mdtrt_id"`
  22570. // AcctPay float64 `json:"acct_pay"`
  22571. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22572. // Insutype string `json:"insutype"`
  22573. // Invono interface{} `json:"invono"`
  22574. // Enddate string `json:"enddate"`
  22575. // CashPayamt float64 `json:"cash_payamt"`
  22576. // PsnType string `json:"psn_type"`
  22577. // FixmedinsName string `json:"fixmedins_name"`
  22578. // HifpPay float64 `json:"hifp_pay"`
  22579. // NewFlag interface{} `json:"new_flag"`
  22580. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22581. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22582. // PayLoc string `json:"pay_loc"`
  22583. // ClrType string `json:"clr_type"`
  22584. // RefdSetlFlag string `json:"refd_setl_flag"`
  22585. // CvlservFlag string `json:"cvlserv_flag"`
  22586. // EmpName string `json:"emp_name"`
  22587. // Brdy string `json:"brdy"`
  22588. // Naty string `json:"naty"`
  22589. // Certno string `json:"certno"`
  22590. // DiseCode string `json:"dise_code"`
  22591. // FixmedinsCode string `json:"fixmedins_code"`
  22592. // DedcHospLv string `json:"dedc_hosp_lv"`
  22593. // OpterName string `json:"opter_name"`
  22594. // Balc float64 `json:"balc"`
  22595. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22596. // PsnCertType string `json:"psn_cert_type"`
  22597. // HifobPay float64 `json:"hifob_pay"`
  22598. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22599. // HifesPay float64 `json:"hifes_pay"`
  22600. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22601. // OptTime string `json:"opt_time"`
  22602. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22603. // SetlID string `json:"setl_id"`
  22604. // MafPay float64 `json:"maf_pay"`
  22605. // PsnName string `json:"psn_name"`
  22606. // InsuOptins interface{} `json:"insu_optins"`
  22607. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22608. // ClrOptins string `json:"clr_optins"`
  22609. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22610. // DiseName string `json:"dise_name"`
  22611. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22612. // Age float64 `json:"age"`
  22613. // DtrtCertType string `json:"dtrt_cert_type"`
  22614. // HospLv string `json:"hosp_lv"`
  22615. // } `json:"setlinfo"`
  22616. // Setldetail []struct {
  22617. // FundPayType string `json:"fund_pay_type"`
  22618. // FundPayamt float64 `json:"fund_payamt"`
  22619. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22620. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22621. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22622. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22623. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22624. // } `json:"setldetail"`
  22625. // } `json:"output"`
  22626. // Infcode int `json:"infcode"`
  22627. // WarnMsg interface{} `json:"warn_msg"`
  22628. // Cainfo interface{} `json:"cainfo"`
  22629. // ErrMsg interface{} `json:"err_msg"`
  22630. // RefmsgTime string `json:"refmsg_time"`
  22631. // Signtype interface{} `json:"signtype"`
  22632. // RespondTime string `json:"respond_time"`
  22633. // InfRefmsgid string `json:"inf_refmsgid"`
  22634. // }
  22635. type Result002 struct {
  22636. Cainfo interface{} `json:"cainfo"`
  22637. ErrMsg string `json:"err_msg"`
  22638. InfRefmsgid string `json:"inf_refmsgid"`
  22639. Infcode int64 `json:"infcode"`
  22640. Output struct {
  22641. RxFile string `json:"rx_file"`
  22642. SignDigest string `json:"sign_digest"`
  22643. SignCertSn string `json:"sign_cert_sn"`
  22644. SignCertDn string `json:"sign_cert_dn"`
  22645. } `json:"output"`
  22646. RefmsgTime string `json:"refmsg_time"`
  22647. RespondTime string `json:"respond_time"`
  22648. Signtype interface{} `json:"signtype"`
  22649. WarnMsg interface{} `json:"warn_msg"`
  22650. }
  22651. type Result003 struct {
  22652. Cainfo interface{} `json:"cainfo"`
  22653. ErrMsg string `json:"err_msg"`
  22654. InfRefmsgid string `json:"inf_refmsgid"`
  22655. Infcode int64 `json:"infcode"`
  22656. Output struct {
  22657. HiRxno string `json:"hi_rxno"`
  22658. RxStasCodg string `json:"rx_stas_codg"`
  22659. RxStasName string `json:"rx_stas_name"`
  22660. } `json:"output"`
  22661. RefmsgTime string `json:"refmsg_time"`
  22662. RespondTime string `json:"respond_time"`
  22663. Signtype interface{} `json:"signtype"`
  22664. WarnMsg interface{} `json:"warn_msg"`
  22665. }
  22666. type ResultEleven struct {
  22667. Cainfo string `json:"cainfo"`
  22668. ErrMsg string `json:"err_msg"`
  22669. InfRefmsgid string `json:"inf_refmsgid"`
  22670. Infcode int64 `json:"infcode"`
  22671. Output struct {
  22672. Setlinfo struct {
  22673. SetlTime string `json:"setl_time"`
  22674. CvlservPay float64 `json:"cvlserv_pay"`
  22675. Year string `json:"year"`
  22676. MedType string `json:"med_type"`
  22677. PsnPay float64 `json:"psn_pay"`
  22678. OpterID string `json:"opter_id"`
  22679. Begndate string `json:"begndate"`
  22680. FlxempeFlag string `json:"flxempe_flag"`
  22681. HifmiPay float64 `json:"hifmi_pay"`
  22682. PsnNo string `json:"psn_no"`
  22683. ActPayDedc float64 `json:"act_pay_dedc"`
  22684. MedinsSetlID interface{} `json:"medins_setl_id"`
  22685. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22686. ClrWay string `json:"clr_way"`
  22687. OthPay float64 `json:"oth_pay"`
  22688. Gend string `json:"gend"`
  22689. MdtrtID string `json:"mdtrt_id"`
  22690. AcctPay float64 `json:"acct_pay"`
  22691. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22692. Insutype string `json:"insutype"`
  22693. Invono interface{} `json:"invono"`
  22694. Enddate string `json:"enddate"`
  22695. CashPayamt float64 `json:"cash_payamt"`
  22696. PsnType string `json:"psn_type"`
  22697. FixmedinsName string `json:"fixmedins_name"`
  22698. HifpPay float64 `json:"hifp_pay"`
  22699. NewFlag interface{} `json:"new_flag"`
  22700. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22701. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22702. PayLoc string `json:"pay_loc"`
  22703. ClrType string `json:"clr_type"`
  22704. RefdSetlFlag string `json:"refd_setl_flag"`
  22705. CvlservFlag string `json:"cvlserv_flag"`
  22706. EmpName string `json:"emp_name"`
  22707. Brdy string `json:"brdy"`
  22708. Naty string `json:"naty"`
  22709. Certno string `json:"certno"`
  22710. DiseCode string `json:"dise_code"`
  22711. FixmedinsCode string `json:"fixmedins_code"`
  22712. DedcHospLv string `json:"dedc_hosp_lv"`
  22713. OpterName string `json:"opter_name"`
  22714. Balc float64 `json:"balc"`
  22715. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22716. PsnCertType string `json:"psn_cert_type"`
  22717. HifobPay float64 `json:"hifob_pay"`
  22718. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22719. HifesPay float64 `json:"hifes_pay"`
  22720. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22721. OptTime string `json:"opt_time"`
  22722. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22723. SetlID string `json:"setl_id"`
  22724. MafPay float64 `json:"maf_pay"`
  22725. PsnName string `json:"psn_name"`
  22726. InsuOptins interface{} `json:"insu_optins"`
  22727. PrefFundPay interface{} `json:"pref_fund_pay"`
  22728. ClrOptins string `json:"clr_optins"`
  22729. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22730. DiseName string `json:"dise_name"`
  22731. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22732. Age float64 `json:"age"`
  22733. DtrtCertType string `json:"dtrt_cert_type"`
  22734. HospLv string `json:"hosp_lv"`
  22735. PsnCashPay float64 `json:"psn_cash_pay"`
  22736. } `json:"setlinfo"`
  22737. } `json:"output"`
  22738. RefmsgTime string `json:"refmsg_time"`
  22739. RespondTime string `json:"respond_time"`
  22740. Signtype interface{} `json:"signtype"`
  22741. WarnMsg interface{} `json:"warn_msg"`
  22742. }
  22743. type ResultElevenah struct {
  22744. Cainfo string `json:"cainfo"`
  22745. ErrMsg string `json:"err_msg"`
  22746. InfRefmsgid string `json:"inf_refmsgid"`
  22747. Infcode int64 `json:"infcode"`
  22748. Output struct {
  22749. Setlinfo struct {
  22750. SetlTime int64 `json:"setl_time"`
  22751. CvlservPay float64 `json:"cvlserv_pay"`
  22752. Year string `json:"year"`
  22753. MedType string `json:"med_type"`
  22754. PsnPay float64 `json:"psn_pay"`
  22755. OpterID string `json:"opter_id"`
  22756. Begndate int64 `json:"begndate"`
  22757. FlxempeFlag string `json:"flxempe_flag"`
  22758. HifmiPay float64 `json:"hifmi_pay"`
  22759. PsnNo string `json:"psn_no"`
  22760. ActPayDedc float64 `json:"act_pay_dedc"`
  22761. MedinsSetlID interface{} `json:"medins_setl_id"`
  22762. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22763. ClrWay string `json:"clr_way"`
  22764. OthPay float64 `json:"oth_pay"`
  22765. Gend string `json:"gend"`
  22766. MdtrtID string `json:"mdtrt_id"`
  22767. AcctPay float64 `json:"acct_pay"`
  22768. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22769. Insutype string `json:"insutype"`
  22770. Invono interface{} `json:"invono"`
  22771. Enddate int64 `json:"enddate"`
  22772. CashPayamt float64 `json:"cash_payamt"`
  22773. PsnType string `json:"psn_type"`
  22774. FixmedinsName string `json:"fixmedins_name"`
  22775. HifpPay float64 `json:"hifp_pay"`
  22776. NewFlag interface{} `json:"new_flag"`
  22777. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22778. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22779. PayLoc string `json:"pay_loc"`
  22780. ClrType string `json:"clr_type"`
  22781. RefdSetlFlag string `json:"refd_setl_flag"`
  22782. CvlservFlag string `json:"cvlserv_flag"`
  22783. EmpName string `json:"emp_name"`
  22784. Brdy int64 `json:"brdy"`
  22785. Naty string `json:"naty"`
  22786. Certno string `json:"certno"`
  22787. DiseCode string `json:"dise_code"`
  22788. FixmedinsCode string `json:"fixmedins_code"`
  22789. DedcHospLv string `json:"dedc_hosp_lv"`
  22790. OpterName string `json:"opter_name"`
  22791. Balc float64 `json:"balc"`
  22792. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22793. PsnCertType string `json:"psn_cert_type"`
  22794. HifobPay float64 `json:"hifob_pay"`
  22795. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22796. HifesPay float64 `json:"hifes_pay"`
  22797. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22798. OptTime int64 `json:"opt_time"`
  22799. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22800. SetlID string `json:"setl_id"`
  22801. MafPay float64 `json:"maf_pay"`
  22802. PsnName string `json:"psn_name"`
  22803. InsuOptins interface{} `json:"insu_optins"`
  22804. PrefFundPay interface{} `json:"pref_fund_pay"`
  22805. ClrOptins string `json:"clr_optins"`
  22806. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22807. DiseName string `json:"dise_name"`
  22808. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22809. Age float64 `json:"age"`
  22810. DtrtCertType string `json:"dtrt_cert_type"`
  22811. HospLv string `json:"hosp_lv"`
  22812. PsnCashPay float64 `json:"psn_cash_pay"`
  22813. } `json:"setlinfo"`
  22814. } `json:"output"`
  22815. RefmsgTime string `json:"refmsg_time"`
  22816. RespondTime string `json:"respond_time"`
  22817. Signtype interface{} `json:"signtype"`
  22818. WarnMsg interface{} `json:"warn_msg"`
  22819. }
  22820. type ResultEleven10265 struct {
  22821. Cainfo string `json:"cainfo"`
  22822. ErrMsg string `json:"err_msg"`
  22823. InfRefmsgid string `json:"inf_refmsgid"`
  22824. Infcode string `json:"infcode"`
  22825. Output struct {
  22826. Setlinfo struct {
  22827. SetlTime string `json:"setl_time"`
  22828. CvlservPay float64 `json:"cvlserv_pay"`
  22829. Year string `json:"year"`
  22830. MedType string `json:"med_type"`
  22831. PsnPay float64 `json:"psn_pay"`
  22832. OpterID string `json:"opter_id"`
  22833. Begndate string `json:"begndate"`
  22834. FlxempeFlag string `json:"flxempe_flag"`
  22835. HifmiPay float64 `json:"hifmi_pay"`
  22836. PsnNo string `json:"psn_no"`
  22837. ActPayDedc float64 `json:"act_pay_dedc"`
  22838. MedinsSetlID interface{} `json:"medins_setl_id"`
  22839. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22840. ClrWay string `json:"clr_way"`
  22841. OthPay float64 `json:"oth_pay"`
  22842. Gend string `json:"gend"`
  22843. MdtrtID string `json:"mdtrt_id"`
  22844. AcctPay float64 `json:"acct_pay"`
  22845. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22846. Insutype string `json:"insutype"`
  22847. Invono interface{} `json:"invono"`
  22848. Enddate string `json:"enddate"`
  22849. CashPayamt float64 `json:"cash_payamt"`
  22850. PsnType string `json:"psn_type"`
  22851. FixmedinsName string `json:"fixmedins_name"`
  22852. HifpPay float64 `json:"hifp_pay"`
  22853. NewFlag interface{} `json:"new_flag"`
  22854. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22855. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22856. PayLoc string `json:"pay_loc"`
  22857. ClrType string `json:"clr_type"`
  22858. RefdSetlFlag string `json:"refd_setl_flag"`
  22859. CvlservFlag string `json:"cvlserv_flag"`
  22860. EmpName string `json:"emp_name"`
  22861. Brdy string `json:"brdy"`
  22862. Naty string `json:"naty"`
  22863. Certno string `json:"certno"`
  22864. DiseCode string `json:"dise_code"`
  22865. FixmedinsCode string `json:"fixmedins_code"`
  22866. DedcHospLv string `json:"dedc_hosp_lv"`
  22867. OpterName string `json:"opter_name"`
  22868. Balc float64 `json:"balc"`
  22869. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22870. PsnCertType string `json:"psn_cert_type"`
  22871. HifobPay float64 `json:"hifob_pay"`
  22872. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22873. HifesPay float64 `json:"hifes_pay"`
  22874. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22875. OptTime string `json:"opt_time"`
  22876. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22877. SetlID string `json:"setl_id"`
  22878. MafPay float64 `json:"maf_pay"`
  22879. PsnName string `json:"psn_name"`
  22880. InsuOptins interface{} `json:"insu_optins"`
  22881. PrefFundPay interface{} `json:"pref_fund_pay"`
  22882. ClrOptins string `json:"clr_optins"`
  22883. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22884. DiseName string `json:"dise_name"`
  22885. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22886. Age float64 `json:"age"`
  22887. DtrtCertType string `json:"dtrt_cert_type"`
  22888. HospLv string `json:"hosp_lv"`
  22889. PsnCashPay float64 `json:"psn_cash_pay"`
  22890. } `json:"setlinfo"`
  22891. } `json:"output"`
  22892. RefmsgTime string `json:"refmsg_time"`
  22893. RespondTime string `json:"respond_time"`
  22894. Signtype interface{} `json:"signtype"`
  22895. WarnMsg interface{} `json:"warn_msg"`
  22896. }
  22897. type ResultTwelve struct {
  22898. Cainfo string `json:"cainfo"`
  22899. ErrMsg string `json:"err_msg"`
  22900. InfRefmsgid string `json:"inf_refmsgid"`
  22901. Infcode int64 `json:"infcode"`
  22902. Output struct {
  22903. MdtrtId string `json:"mdtrt_id"`
  22904. ChrgBchno string `json:"chrg_bchno"`
  22905. PsnNo string `json:"psn_no"`
  22906. } `json:"output"`
  22907. RefmsgTime string `json:"refmsg_time"`
  22908. RespondTime string `json:"respond_time"`
  22909. Signtype interface{} `json:"signtype"`
  22910. WarnMsg interface{} `json:"warn_msg"`
  22911. }
  22912. type ResultThirteen struct {
  22913. ErrMsg string `json:"err_msg"`
  22914. InfRefmsgid string `json:"inf_refmsgid"`
  22915. Infcode int64 `json:"infcode"`
  22916. Output struct {
  22917. Result struct {
  22918. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22919. } `json:"result"`
  22920. } `json:"output"`
  22921. RefmsgTime string `json:"refmsg_time"`
  22922. RespondTime string `json:"respond_time"`
  22923. Signtype interface{} `json:"signtype"`
  22924. WarnInfo interface{} `json:"warn_info"`
  22925. }
  22926. type ResultThirteen10265 struct {
  22927. ErrMsg string `json:"err_msg"`
  22928. InfRefmsgid string `json:"inf_refmsgid"`
  22929. Infcode string `json:"infcode"`
  22930. Output struct {
  22931. Result struct {
  22932. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22933. } `json:"result"`
  22934. } `json:"output"`
  22935. RefmsgTime string `json:"refmsg_time"`
  22936. RespondTime string `json:"respond_time"`
  22937. Signtype interface{} `json:"signtype"`
  22938. WarnInfo interface{} `json:"warn_info"`
  22939. }
  22940. type ResultFourteen struct {
  22941. ErrMsg string `json:"err_msg"`
  22942. InfRefmsgid string `json:"inf_refmsgid"`
  22943. Infcode int64 `json:"infcode"`
  22944. Output struct {
  22945. } `json:"output"`
  22946. RefmsgTime string `json:"refmsg_time"`
  22947. RespondTime string `json:"respond_time"`
  22948. Signtype interface{} `json:"signtype"`
  22949. WarnInfo interface{} `json:"warn_info"`
  22950. }
  22951. type ResultCFYLJG001 struct {
  22952. ErrMsg string `json:"err_msg"`
  22953. InfRefmsgid string `json:"inf_refmsgid"`
  22954. Infcode int64 `json:"infcode"`
  22955. Output struct {
  22956. RxTraceCode string `json:"rx_trace_code"`
  22957. HiRxno string `json:"hi_rxno"`
  22958. } `json:"output"`
  22959. RefmsgTime string `json:"refmsg_time"`
  22960. RespondTime string `json:"respond_time"`
  22961. Signtype interface{} `json:"signtype"`
  22962. WarnInfo interface{} `json:"warn_info"`
  22963. }
  22964. type ResultCFYLJG007 struct {
  22965. ErrMsg string `json:"err_msg"`
  22966. InfRefmsgid string `json:"inf_refmsgid"`
  22967. Infcode int64 `json:"infcode"`
  22968. Output struct {
  22969. HiRxno string `json:"hi_rxno"`
  22970. RxStasName string `json:"rx_stas_name"`
  22971. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22972. Seltdelts []interface{} `json:"seltdelts"`
  22973. RxUsedStasName string `json:"rx_used_stas_name"`
  22974. RxStasCodg string `json:"rx_stas_codg"`
  22975. } `json:"output"`
  22976. RefmsgTime string `json:"refmsg_time"`
  22977. RespondTime string `json:"respond_time"`
  22978. Signtype interface{} `json:"signtype"`
  22979. WarnInfo interface{} `json:"warn_info"`
  22980. }
  22981. type ResultCFYLJG002 struct {
  22982. ErrMsg string `json:"err_msg"`
  22983. InfRefmsgid string `json:"inf_refmsgid"`
  22984. Infcode int64 `json:"infcode"`
  22985. Output struct {
  22986. RxFile string `json:"rx_file"`
  22987. SignDigest string `json:"sign_digest"`
  22988. SignCertSn string `json:"sign_cert_sn"`
  22989. SignCertDn string `json:"sign_cert_dn"`
  22990. } `json:"output"`
  22991. RefmsgTime string `json:"refmsg_time"`
  22992. RespondTime string `json:"respond_time"`
  22993. Signtype interface{} `json:"signtype"`
  22994. WarnInfo interface{} `json:"warn_info"`
  22995. }
  22996. type ResultCFYLJG003 struct {
  22997. ErrMsg string `json:"err_msg"`
  22998. InfRefmsgid string `json:"inf_refmsgid"`
  22999. Infcode int64 `json:"infcode"`
  23000. Output struct {
  23001. HiRxno string `json:"hi_rxno"`
  23002. RxStasCodg string `json:"rx_stas_codg"`
  23003. RxStasName string `json:"rx_stas_name"`
  23004. } `json:"output"`
  23005. RefmsgTime string `json:"refmsg_time"`
  23006. RespondTime string `json:"respond_time"`
  23007. Signtype interface{} `json:"signtype"`
  23008. WarnInfo interface{} `json:"warn_info"`
  23009. }
  23010. type ResultCFYLJG004 struct {
  23011. ErrMsg string `json:"err_msg"`
  23012. InfRefmsgid string `json:"inf_refmsgid"`
  23013. Infcode int64 `json:"infcode"`
  23014. Output struct {
  23015. HiRxno string `json:"hi_rxno"`
  23016. RxStasCodg string `json:"rx_stas_codg"`
  23017. RxStasName string `json:"rx_stas_name"`
  23018. } `json:"output"`
  23019. RefmsgTime string `json:"refmsg_time"`
  23020. RespondTime string `json:"respond_time"`
  23021. Signtype interface{} `json:"signtype"`
  23022. WarnInfo interface{} `json:"warn_info"`
  23023. }
  23024. type ResultCFYLJG008 struct {
  23025. ErrMsg string `json:"err_msg"`
  23026. InfRefmsgid string `json:"inf_refmsgid"`
  23027. Infcode int64 `json:"infcode"`
  23028. Output struct {
  23029. PoolareaNo string `json:"poolareaNo"`
  23030. AdmdvsName string `json:"admdvsName"`
  23031. Count string `json:"count"`
  23032. } `json:"output"`
  23033. RefmsgTime string `json:"refmsg_time"`
  23034. RespondTime string `json:"respond_time"`
  23035. Signtype interface{} `json:"signtype"`
  23036. WarnInfo interface{} `json:"warn_info"`
  23037. }
  23038. type ResultCFYLJG005 struct {
  23039. ErrMsg string `json:"err_msg"`
  23040. InfRefmsgid string `json:"inf_refmsgid"`
  23041. Infcode int64 `json:"infcode"`
  23042. Output struct {
  23043. HiRxNo string `json:"hi_rxno"`
  23044. FixMedinsCode string `json:"fixmedins_code"`
  23045. FixMedinsName string `json:"fixmedins_name"`
  23046. RxStasCodg string `json:"rx_stas_codg"`
  23047. RxStasName string `json:"rx_stas_name"`
  23048. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23049. RxUserdStasName string `json:"rx_userd_stas_name"`
  23050. PrscTime string `json:"prsc_time"`
  23051. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23052. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23053. RxUsedWayName string `json:"rx_used_way_name"`
  23054. RxFrquCodg string `json:"rx_frqu_codg"`
  23055. RxFrquName string `json:"rx_frqu_name"`
  23056. RxDosunt string `json:"rx_dosunt"`
  23057. RxDoscnt float64 `json:"rx_doscnt"`
  23058. RxDrordDscr string `json:"rx_drord_dscr"`
  23059. ValiDays int64 `json:"vali_days"`
  23060. ValiEndTime string `json:"vali_end_time"`
  23061. ReptFlag string `json:"rept_flag"`
  23062. MaxReptCnt int64 `json:"max_rept_cnt"`
  23063. ReptdCnt int64 `json:"reptd_cnt"`
  23064. MinInrvDays int64 `json:"min_inrv_days"`
  23065. RxTypeCode string `json:"rx_type_code"`
  23066. RxTypeName string `json:"rx_type_name"`
  23067. LongRxFlag string `json:"long_rx_flag"`
  23068. RxDetlList []struct {
  23069. MedListCodg string `json:"med_list_codg"`
  23070. MedinsListCodg string `json:"medins_list_codg"`
  23071. HospPrepFlag string `json:"hosp_prep_flag"`
  23072. RxItemTypeCode string `json:"rx_item_type_code"`
  23073. RxItemTypeName string `json:"rx_item_type_name"`
  23074. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23075. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23076. TcmHerbFoote string `json:"tcmherb_foote"`
  23077. MednTypeCode string `json:"medn_type_code"`
  23078. MednTypeName string `json:"medn_type_name"`
  23079. MainMedcFlag string `json:"main_medc_flag"`
  23080. UrgtFlag string `json:"urgt_flag"`
  23081. BasMednFlag string `json:"bas_medn_flag"`
  23082. ImpDrugFlag string `json:"imp_drug_flag"`
  23083. ProdBarc string `json:"prod_barc"`
  23084. DrugProdname string `json:"drug_prodname"`
  23085. GennameCodg string `json:"genname_codg"`
  23086. DrugGenname string `json:"drug_genname"`
  23087. DrugDosform string `json:"drug_dosform"`
  23088. DrugSpec string `json:"drug_spec"`
  23089. PrdrName string `json:"prdr_name"`
  23090. MedcWayCodg string `json:"medc_way_codg"`
  23091. MedcWayDscr string `json:"medc_way_dscr"`
  23092. MedcBegntime string `json:"medc_begntime"`
  23093. MedcEndtime string `json:"medc_endtime"`
  23094. MedcDays float64 `json:"medc_days"`
  23095. DrugPric float64 `json:"drug_pric"`
  23096. DrugSumamt float64 `json:"drug_sumamt"`
  23097. DrugCnt float64 `json:"drug_cnt"`
  23098. DrugDosunt string `json:"drug_dosunt"`
  23099. SinDoscnt float64 `json:"sin_doscnt"`
  23100. SinDosunt string `json:"sin_dosunt"`
  23101. UsedFrquCodg string `json:"used_frqu_codg"`
  23102. UsedFrquName string `json:"used_frqu_name"`
  23103. DrugTotlcnt string `json:"drug_totlcnt"`
  23104. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  23105. DiseCodg string `json:"dise_codg"`
  23106. HospApprFlag string `json:"hosp_appr_flag"`
  23107. } `json:"rx_detl_list"`
  23108. RxOtpinfo struct {
  23109. MedType string `json:"med_type"`
  23110. IptOtpNo string `json:"ipt_otp_no"`
  23111. OtpIptFlag string `json:"otp_ipt_flag"`
  23112. PatnName string `json:"patn_name"`
  23113. PatnAge float64 `json:"patn_age"`
  23114. PatnHgt float64 `json:"patn_hgt"`
  23115. PatnWt float64 `json:"patn_wt"`
  23116. Gend string `json:"gend"`
  23117. GesoVal float64 `json:"geso_val"`
  23118. NwbFlag string `json:"nwb_flag"`
  23119. NwbAge string `json:"nwb_age"`
  23120. SuckPrdFlag string `json:"suck_prd_flag"`
  23121. AlgsHis string `json:"algs_his"`
  23122. Insutype string `json:"insutype"`
  23123. PrscDeptName string `json:"prsc_dept_name"`
  23124. PrscDrName string `json:"prsc_dr_name"`
  23125. PharName string `json:"phar_name"`
  23126. PharChkTime string `json:"phar_chk_time"`
  23127. MdtrtTime string `json:"mdtrt_time"`
  23128. DiseCodg string `json:"dise_codg"`
  23129. DiseName string `json:"dise_name"`
  23130. SpDiseFlag string `json:"sp_dise_flag"`
  23131. MaindiagCode string `json:"maindiag_code"`
  23132. MaindiagName string `json:"maindiag_name"`
  23133. DiseCondDscr string `json:"dise_cond_dscr"`
  23134. FstdiagFlag string `json:"fstdiag_flag"`
  23135. } `json:"rx_otpinfo"`
  23136. RxDiseList []struct {
  23137. DiagType string `json:"diag_type"`
  23138. MaindiagFlag string `json:"maindiag_flag"`
  23139. DiagSrtNo string `json:"diag_srt_no"`
  23140. DiagCode string `json:"diag_code"`
  23141. DiagName string `json:"diag_name"`
  23142. DiagDept string `json:"diag_dept"`
  23143. DiagDrNo string `json:"diag_dr_no"`
  23144. DiagDrName string `json:"diag_dr_name"`
  23145. DiagTime string `json:"diag_time"`
  23146. TcmDiseCode string `json:"tcm_dise_code"`
  23147. TcmDiseName string `json:"tcm_dise_name"`
  23148. TcmSympCode string `json:"tcmsymp_code"`
  23149. TcmSymp string `json:"tcmsymp"`
  23150. } `json:"rx_dise_list"`
  23151. } `json:"output"`
  23152. RefmsgTime string `json:"refmsg_time"`
  23153. RespondTime string `json:"respond_time"`
  23154. Signtype interface{} `json:"signtype"`
  23155. WarnInfo interface{} `json:"warn_info"`
  23156. }
  23157. type ResultCFYLJG006 struct {
  23158. ErrMsg string `json:"err_msg"`
  23159. InfRefmsgid string `json:"inf_refmsgid"`
  23160. Infcode int64 `json:"infcode"`
  23161. Output struct {
  23162. HiRxNo string `json:"hi_rxno"`
  23163. PharCode string `json:"phar_code"`
  23164. PharName string `json:"phar_name"`
  23165. RxChkOpnn string `json:"rx_chk_opnn"`
  23166. RxChkTime string `json:"rx_chk_time"`
  23167. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  23168. RxChkStasName string `json:"rx_chk_stas_name"`
  23169. RxStasCodg string `json:"rx_stas_codg"`
  23170. RxStasName string `json:"rx_stas_name"`
  23171. } `json:"output"`
  23172. RefmsgTime string `json:"refmsg_time"`
  23173. RespondTime string `json:"respond_time"`
  23174. Signtype interface{} `json:"signtype"`
  23175. WarnInfo interface{} `json:"warn_info"`
  23176. }
  23177. type ResultFourteen10265 struct {
  23178. ErrMsg string `json:"err_msg"`
  23179. InfRefmsgid string `json:"inf_refmsgid"`
  23180. Infcode string `json:"infcode"`
  23181. Output struct {
  23182. } `json:"output"`
  23183. RefmsgTime string `json:"refmsg_time"`
  23184. RespondTime string `json:"respond_time"`
  23185. Signtype interface{} `json:"signtype"`
  23186. WarnInfo interface{} `json:"warn_info"`
  23187. }
  23188. type ResultSixteen struct {
  23189. Cainfo string `json:"cainfo"`
  23190. ErrMsg string `json:"err_msg"`
  23191. InfRefmsgid string `json:"inf_refmsgid"`
  23192. Infcode int64 `json:"infcode"`
  23193. Output struct {
  23194. Setlinfo struct {
  23195. MdtrtID string `json:"mdtrt_id"`
  23196. SetlID string `json:"setl_id"`
  23197. ClrOptins string `json:"clr_optins"`
  23198. SetlTime string `json:"setl_time"`
  23199. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23200. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23201. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23202. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23203. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23204. ActPayDedc float64 `json:"act_pay_dedc"`
  23205. HifpPay float64 `json:"hifp_pay"`
  23206. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23207. Lfpay float64 `json:"selfpay"`
  23208. CvlservPay float64 `json:"cvlserv_pay"`
  23209. HifesPay float64 `json:"hifes_pay"`
  23210. HifmiPay float64 `json:"hifmi_pay"`
  23211. HifobPay float64 `json:"hifob_pay"`
  23212. MafPay float64 `json:"maf_pay"`
  23213. OthPay float64 `json:"oth_pay"`
  23214. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23215. PsnPartAmt float64 `json:"psn_part_amt"`
  23216. AcctPay float64 `json:"acct_pay"`
  23217. Balc float64 `json:"balc"`
  23218. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23219. HospPartAmt float64 `json:"hosp_part_amt"`
  23220. MedinsSetlID string `json:"medins_setl_id"`
  23221. PdnCashPay string `json:"pdn_cash_pay"`
  23222. } `json:"setlinfo"`
  23223. } `json:"output"`
  23224. RefmsgTime string `json:"refmsg_time"`
  23225. RespondTime string `json:"respond_time"`
  23226. Signtype interface{} `json:"signtype"`
  23227. WarnMsg interface{} `json:"warn_msg"`
  23228. }
  23229. type ResultSixteen10265 struct {
  23230. Cainfo string `json:"cainfo"`
  23231. ErrMsg string `json:"err_msg"`
  23232. InfRefmsgid string `json:"inf_refmsgid"`
  23233. Infcode string `json:"infcode"`
  23234. Output struct {
  23235. Setlinfo struct {
  23236. MdtrtID string `json:"mdtrt_id"`
  23237. SetlID string `json:"setl_id"`
  23238. ClrOptins string `json:"clr_optins"`
  23239. SetlTime string `json:"setl_time"`
  23240. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23241. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23242. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23243. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23244. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23245. ActPayDedc float64 `json:"act_pay_dedc"`
  23246. HifpPay float64 `json:"hifp_pay"`
  23247. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23248. Lfpay float64 `json:"selfpay"`
  23249. CvlservPay float64 `json:"cvlserv_pay"`
  23250. HifesPay float64 `json:"hifes_pay"`
  23251. HifmiPay float64 `json:"hifmi_pay"`
  23252. HifobPay float64 `json:"hifob_pay"`
  23253. MafPay float64 `json:"maf_pay"`
  23254. OthPay float64 `json:"oth_pay"`
  23255. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23256. PsnPartAmt float64 `json:"psn_part_amt"`
  23257. AcctPay float64 `json:"acct_pay"`
  23258. Balc float64 `json:"balc"`
  23259. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23260. HospPartAmt float64 `json:"hosp_part_amt"`
  23261. MedinsSetlID string `json:"medins_setl_id"`
  23262. PdnCashPay string `json:"pdn_cash_pay"`
  23263. } `json:"setlinfo"`
  23264. } `json:"output"`
  23265. RefmsgTime string `json:"refmsg_time"`
  23266. RespondTime string `json:"respond_time"`
  23267. Signtype interface{} `json:"signtype"`
  23268. WarnMsg interface{} `json:"warn_msg"`
  23269. }
  23270. type ResultSixteen10265Two struct {
  23271. Cainfo string `json:"cainfo"`
  23272. ErrMsg string `json:"err_msg"`
  23273. InfRefmsgid string `json:"inf_refmsgid"`
  23274. Infcode string `json:"infcode"`
  23275. Output struct {
  23276. Setlinfo interface{} `json:"setlinfo"`
  23277. } `json:"output"`
  23278. RefmsgTime string `json:"refmsg_time"`
  23279. RespondTime string `json:"respond_time"`
  23280. Signtype interface{} `json:"signtype"`
  23281. WarnMsg interface{} `json:"warn_msg"`
  23282. }
  23283. type ResultgzSixteen10265Two struct {
  23284. Cainfo string `json:"cainfo"`
  23285. ErrMsg string `json:"err_msg"`
  23286. InfRefmsgid string `json:"inf_refmsgid"`
  23287. Infcode int64 `json:"infcode"`
  23288. Output struct {
  23289. Setlinfo interface{} `json:"setlinfo"`
  23290. } `json:"output"`
  23291. RefmsgTime string `json:"refmsg_time"`
  23292. RespondTime string `json:"respond_time"`
  23293. Signtype interface{} `json:"signtype"`
  23294. WarnMsg interface{} `json:"warn_msg"`
  23295. }
  23296. type ResultSeventeen struct {
  23297. ErrMsg string `json:"err_msg"`
  23298. InfRefmsgid string `json:"inf_refmsgid"`
  23299. Infcode int64 `json:"infcode"`
  23300. Output struct {
  23301. SetlListId string `json:"setl_list_id"`
  23302. } `json:"output"`
  23303. RefmsgTime string `json:"refmsg_time"`
  23304. RespondTime string `json:"respond_time"`
  23305. Signtype string `json:"signtype"`
  23306. WarnInfo string `json:"warn_info"`
  23307. }
  23308. type ResultSeventeenOther struct {
  23309. ErrMsg string `json:"err_msg"`
  23310. InfRefmsgid string `json:"inf_refmsgid"`
  23311. Infcode string `json:"infcode"`
  23312. Output struct {
  23313. SetlListId string `json:"setl_list_id"`
  23314. } `json:"output"`
  23315. RefmsgTime string `json:"refmsg_time"`
  23316. RespondTime string `json:"respond_time"`
  23317. Signtype string `json:"signtype"`
  23318. WarnInfo string `json:"warn_info"`
  23319. }
  23320. type Result90991 struct {
  23321. ErrMsg string `json:"err_msg"`
  23322. InfRefmsgid string `json:"inf_refmsgid"`
  23323. Infcode int64 `json:"infcode"`
  23324. Output struct {
  23325. Result struct {
  23326. PsnNo string `json:"psn_no"`
  23327. CardStat string `json:"card_stat"`
  23328. Certno string `json:"certno"`
  23329. PsnName string `json:"psn_name"`
  23330. CheckStat string `json:"check_stat"`
  23331. SscnoCheckStat string `json:"sscno_check_stat"`
  23332. } `json:"result"`
  23333. } `json:"output"`
  23334. RefmsgTime string `json:"refmsg_time"`
  23335. RespondTime string `json:"respond_time"`
  23336. Signtype interface{} `json:"signtype"`
  23337. WarnInfo interface{} `json:"warn_info"`
  23338. }
  23339. type Result90100 struct {
  23340. ErrMsg string `json:"err_msg"`
  23341. InfRefmsgid string `json:"inf_refmsgid"`
  23342. Infcode int64 `json:"infcode"`
  23343. Output struct {
  23344. PoolareaNo string `json:"poolarea_no"`
  23345. PoolareaNoName string `json:"poolarea_no_name"`
  23346. Insutype string `json:"insutype"`
  23347. InsutypeName string `json:"insutype_name"`
  23348. ClctType string `json:"clct_type"`
  23349. ClctTypeName string `json:"clct_type_name"`
  23350. ClctFlag string `json:"clct_flag"`
  23351. ClctFlagName string `json:"clct_flag_name"`
  23352. AccrymBegn string `json:"accrym_begn"`
  23353. AccrymEnd string `json:"accrym_end"`
  23354. ClctTime string `json:"clct_time"`
  23355. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23356. } `json:"output"`
  23357. RefmsgTime string `json:"refmsg_time"`
  23358. RespondTime string `json:"respond_time"`
  23359. Signtype interface{} `json:"signtype"`
  23360. WarnInfo interface{} `json:"warn_info"`
  23361. }
  23362. type Custom struct {
  23363. DetItemFeeSumamt string
  23364. Cut string
  23365. FeedetlSn string
  23366. Price string
  23367. MedListCodg string
  23368. Type int64
  23369. AdviceId int64
  23370. ProjectId int64
  23371. ItemId int64
  23372. }
  23373. type Result5301 struct {
  23374. ErrMsg string `json:"err_msg"`
  23375. InfRefmsgid string `json:"inf_refmsgid"`
  23376. Infcode int64 `json:"infcode"`
  23377. Output struct {
  23378. Result []struct {
  23379. OpspDiseCode string `json:"opsp_dise_code"`
  23380. OpspDiseName string `json:"opsp_dise_name"`
  23381. Begndate string `json:"begndate"`
  23382. Enddate string `json:"enddate"`
  23383. } `json:"feedetail"`
  23384. } `json:"output"`
  23385. RefmsgTime string `json:"refmsg_time"`
  23386. RespondTime string `json:"respond_time"`
  23387. Signtype interface{} `json:"signtype"`
  23388. WarnInfo interface{} `json:"warn_info"`
  23389. }
  23390. type Result5301For10265 struct {
  23391. ErrMsg string `json:"err_msg"`
  23392. InfRefmsgid string `json:"inf_refmsgid"`
  23393. Infcode string `json:"infcode"`
  23394. Output struct {
  23395. Result []struct {
  23396. OpspDiseCode string `json:"opsp_dise_code"`
  23397. OpspDiseName string `json:"opsp_dise_name"`
  23398. Begndate string `json:"begndate"`
  23399. Enddate string `json:"enddate"`
  23400. } `json:"feedetail"`
  23401. } `json:"output"`
  23402. RefmsgTime string `json:"refmsg_time"`
  23403. RespondTime string `json:"respond_time"`
  23404. Signtype interface{} `json:"signtype"`
  23405. WarnInfo interface{} `json:"warn_info"`
  23406. }
  23407. //获取个人信息----挂号-----上传就诊信息
  23408. func (c *HisApiController) GetRegisterInfo() {
  23409. id, _ := c.GetInt64("id")
  23410. record_time := c.GetString("record_time")
  23411. settlementValue, _ := c.GetInt64("settlement_value")
  23412. medical_insurance_card := c.GetString("medical_insurance_card")
  23413. name := c.GetString("name")
  23414. id_card_type, _ := c.GetInt64("id_card_type")
  23415. certificates, _ := c.GetInt64("certificates")
  23416. medical_care, _ := c.GetInt64("medical_care")
  23417. birthday := c.GetString("birthday")
  23418. id_card := c.GetString("id_card")
  23419. register_type, _ := c.GetInt64("register")
  23420. doctor, _ := c.GetInt64("doctor")
  23421. department, _ := c.GetInt64("department")
  23422. gender, _ := c.GetInt64("sex")
  23423. registration_fee, _ := c.GetFloat("registration_fee")
  23424. medical_expenses, _ := c.GetFloat("medical_expenses")
  23425. social_type, _ := c.GetInt64("social_type")
  23426. admin_user_id, _ := c.GetInt64("admin_user_id")
  23427. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23428. mdtrt_type := c.GetString("mdtrt_type")
  23429. if id_card_type == 5 {
  23430. id_card_type = 4
  23431. }
  23432. timeLayout := "2006-01-02"
  23433. loc, _ := time.LoadLocation("Local")
  23434. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23435. birthUnix := birthdays.Unix()
  23436. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23437. if err != nil {
  23438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23439. return
  23440. }
  23441. recordDateTime := theTime.Unix()
  23442. adminInfo := c.GetAdminUserInfo()
  23443. var patient service.Patients
  23444. if id == 0 {
  23445. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23446. } else {
  23447. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23448. }
  23449. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23450. if patientPrescription.ID == 0 {
  23451. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23452. }
  23453. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23454. if patient.ID == 0 {
  23455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23456. return
  23457. }
  23458. if len(patient.IdCardNo) == 0 {
  23459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23460. return
  23461. }
  23462. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23463. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23464. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23465. //就诊结算未完成,不能进行二次挂号
  23466. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23467. if len(his) >= 1 {
  23468. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23469. if len(his) >= 1 && order.ID == 0 {
  23470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23471. return
  23472. }
  23473. }
  23474. //var register_log string
  23475. if config.IsOpen == 1 {
  23476. var res ResultTwo
  23477. var res10265 ResultTwo10265
  23478. var PsnNo string
  23479. var PsnCertType string
  23480. var Certno string
  23481. var PsnName string
  23482. var Gend string
  23483. var Naty string
  23484. var Brdy string
  23485. var Age float64
  23486. var infoStr string
  23487. var idetinfoStr string
  23488. var infocode int64
  23489. var verify_number string
  23490. fmt.Println(verify_number)
  23491. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23492. psn_info, _ := service.GetPsnByPatientId(id)
  23493. PsnNo = psn_info.PsnNo
  23494. PsnCertType = psn_info.PsnCertType
  23495. Certno = psn_info.Certno
  23496. PsnName = psn_info.PsnName
  23497. Gend = psn_info.Gend
  23498. Naty = psn_info.Naty
  23499. Brdy = psn_info.Brdy
  23500. Age = psn_info.Age
  23501. infoStr = psn_info.Insuinfo
  23502. idetinfoStr = psn_info.Idetinfo
  23503. infocode = 0
  23504. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23505. psn_info, _ := service.GetPsnByPatientId(id)
  23506. PsnNo = psn_info.PsnNo
  23507. PsnCertType = psn_info.PsnCertType
  23508. Certno = psn_info.Certno
  23509. PsnName = psn_info.PsnName
  23510. Gend = psn_info.Gend
  23511. Naty = psn_info.Naty
  23512. Brdy = psn_info.Brdy
  23513. Age = psn_info.Age
  23514. infoStr = psn_info.Insuinfo
  23515. idetinfoStr = psn_info.Idetinfo
  23516. infocode = 0
  23517. verify_number = psn_info.VerifyNumber
  23518. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23519. if id_card_type == 2 {
  23520. //请求内网数据
  23521. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23522. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23523. "&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
  23524. resp, requestErr := http.Get(api)
  23525. if requestErr != nil {
  23526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23527. return
  23528. }
  23529. body, ioErr := ioutil.ReadAll(resp.Body)
  23530. if ioErr != nil {
  23531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23533. return
  23534. }
  23535. var respJSON map[string]interface{}
  23536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23539. return
  23540. }
  23541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23542. result_byte, _ := json.Marshal(respJSON)
  23543. result := string(result_byte)
  23544. var dat map[string]interface{}
  23545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23546. fmt.Println(dat)
  23547. } else {
  23548. fmt.Println(err)
  23549. }
  23550. userJSONBytes, _ := json.Marshal(dat)
  23551. var res ResultTwo
  23552. var resTwo10265 ResultTwo10265
  23553. if miConfig.Code == "H15049901371" {
  23554. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23555. utils.ErrorLog("解析失败:%v", err)
  23556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23557. return
  23558. }
  23559. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23560. res.Infcode = Infcode
  23561. res.ErrMsg = resTwo10265.ErrMsg
  23562. res.Output = resTwo10265.Output
  23563. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23564. res.RespondTime = resTwo10265.RespondTime
  23565. res.WarnInfo = resTwo10265.WarnInfo
  23566. } else {
  23567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23568. utils.ErrorLog("解析失败:%v", err)
  23569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23570. return
  23571. }
  23572. }
  23573. //var insutypes []string
  23574. //var insutype string
  23575. //var is390 int = 0
  23576. //var is310 int = 0
  23577. //for _, item := range res.Output.Iinfo {
  23578. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23579. // insutypes = append(insutypes, item.Insutype)
  23580. // }
  23581. //}
  23582. //if len(insutypes) == 1 {
  23583. // insutype = insutypes[0]
  23584. //} else {
  23585. // for _, i := range insutypes {
  23586. // if i == "390" {
  23587. // is390 = 1
  23588. // }
  23589. //
  23590. // if i == "310" {
  23591. // is310 = 1
  23592. // }
  23593. // }
  23594. //}
  23595. //if is390 == 1 {
  23596. // insutype = "390"
  23597. //}
  23598. //if is310 == 1 {
  23599. // insutype = "310"
  23600. //}
  23601. //if len(insutypes) == 0 {
  23602. // insutype = "310"
  23603. //}
  23604. PsnNo = res.Output.Baseinfo.PsnNo
  23605. PsnCertType = res.Output.Baseinfo.PsnCertType
  23606. Certno = res.Output.Baseinfo.Certno
  23607. PsnName = res.Output.Baseinfo.PsnName
  23608. Gend = res.Output.Baseinfo.Gend
  23609. Naty = res.Output.Baseinfo.Naty
  23610. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23611. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23612. infoStr = string(Iinfos)
  23613. idetinfoStr = string(Idetinfos)
  23614. infocode = res.Infcode
  23615. //infocode = 0
  23616. //verify_number = psn_info.VerifyNumber
  23617. } else {
  23618. psn_info, _ := service.GetPsnByPatientId(id)
  23619. PsnNo = psn_info.PsnNo
  23620. PsnCertType = psn_info.PsnCertType
  23621. Certno = psn_info.Certno
  23622. PsnName = psn_info.PsnName
  23623. Gend = psn_info.Gend
  23624. Naty = psn_info.Naty
  23625. Brdy = psn_info.Brdy
  23626. Age = psn_info.Age
  23627. infoStr = psn_info.Insuinfo
  23628. idetinfoStr = psn_info.Idetinfo
  23629. infocode = 0
  23630. verify_number = psn_info.VerifyNumber
  23631. }
  23632. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23633. if id_card_type == 1 {
  23634. psn_info, _ := service.GetPsnByPatientId(id)
  23635. PsnNo = psn_info.PsnNo
  23636. PsnCertType = psn_info.PsnCertType
  23637. Certno = psn_info.Certno
  23638. PsnName = psn_info.PsnName
  23639. Gend = psn_info.Gend
  23640. Naty = psn_info.Naty
  23641. Brdy = psn_info.Brdy
  23642. Age = psn_info.Age
  23643. infoStr = psn_info.Insuinfo
  23644. idetinfoStr = psn_info.Idetinfo
  23645. infocode = 0
  23646. verify_number = psn_info.VerifyNumber
  23647. } else if id_card_type == 2 {
  23648. 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)
  23649. fmt.Println(errMsgLog)
  23650. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23651. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23652. utils.ErrorLog("解析失败:%v", err)
  23653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23654. return
  23655. }
  23656. PsnNo = res.Output.Baseinfo.PsnNo
  23657. PsnCertType = res.Output.Baseinfo.PsnCertType
  23658. Certno = res.Output.Baseinfo.Certno
  23659. PsnName = res.Output.Baseinfo.PsnName
  23660. Gend = res.Output.Baseinfo.Gend
  23661. Naty = res.Output.Baseinfo.Naty
  23662. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23663. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23664. infoStr = string(Iinfos)
  23665. idetinfoStr = string(Idetinfos)
  23666. infocode = res.Infcode
  23667. }
  23668. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23669. if id_card_type == 1 {
  23670. psn_info, _ := service.GetPsnByPatientId(id)
  23671. PsnNo = psn_info.PsnNo
  23672. PsnCertType = psn_info.PsnCertType
  23673. Certno = psn_info.Certno
  23674. PsnName = psn_info.PsnName
  23675. Gend = psn_info.Gend
  23676. Naty = psn_info.Naty
  23677. Brdy = psn_info.Brdy
  23678. Age = psn_info.Age
  23679. infoStr = psn_info.Insuinfo
  23680. idetinfoStr = psn_info.Idetinfo
  23681. infocode = 0
  23682. verify_number = psn_info.VerifyNumber
  23683. } else if id_card_type == 2 {
  23684. 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, "")
  23685. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23686. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23687. utils.ErrorLog("解析失败:%v", err)
  23688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23689. return
  23690. }
  23691. PsnNo = res.Output.Baseinfo.PsnNo
  23692. PsnCertType = res.Output.Baseinfo.PsnCertType
  23693. Certno = res.Output.Baseinfo.Certno
  23694. PsnName = res.Output.Baseinfo.PsnName
  23695. Gend = res.Output.Baseinfo.Gend
  23696. Naty = res.Output.Baseinfo.Naty
  23697. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23698. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23699. infoStr = string(Iinfos)
  23700. idetinfoStr = string(Idetinfos)
  23701. infocode = res.Infcode
  23702. } else {
  23703. psn_info, _ := service.GetPsnByPatientId(id)
  23704. PsnNo = psn_info.PsnNo
  23705. PsnCertType = psn_info.PsnCertType
  23706. Certno = psn_info.Certno
  23707. PsnName = psn_info.PsnName
  23708. Gend = psn_info.Gend
  23709. Naty = psn_info.Naty
  23710. Brdy = psn_info.Brdy
  23711. Age = psn_info.Age
  23712. infoStr = psn_info.Insuinfo
  23713. idetinfoStr = psn_info.Idetinfo
  23714. infocode = 0
  23715. verify_number = psn_info.VerifyNumber
  23716. }
  23717. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23718. if id_card_type == 1 {
  23719. psn_info, _ := service.GetPsnByPatientId(id)
  23720. PsnNo = psn_info.PsnNo
  23721. PsnCertType = psn_info.PsnCertType
  23722. Certno = psn_info.Certno
  23723. PsnName = psn_info.PsnName
  23724. Gend = psn_info.Gend
  23725. Naty = psn_info.Naty
  23726. Brdy = psn_info.Brdy
  23727. Age = psn_info.Age
  23728. infoStr = psn_info.Insuinfo
  23729. idetinfoStr = psn_info.Idetinfo
  23730. infocode = 0
  23731. verify_number = psn_info.VerifyNumber
  23732. } else if id_card_type == 2 {
  23733. psn_info, _ := service.GetPsnByPatientId(id)
  23734. PsnNo = psn_info.PsnNo
  23735. PsnCertType = psn_info.PsnCertType
  23736. Certno = psn_info.Certno
  23737. PsnName = psn_info.PsnName
  23738. Gend = psn_info.Gend
  23739. Naty = psn_info.Naty
  23740. Brdy = psn_info.Brdy
  23741. Age = psn_info.Age
  23742. infoStr = psn_info.Insuinfo
  23743. idetinfoStr = psn_info.Idetinfo
  23744. infocode = 0
  23745. verify_number = psn_info.VerifyNumber
  23746. } else {
  23747. psn_info, _ := service.GetPsnByPatientId(id)
  23748. PsnNo = psn_info.PsnNo
  23749. PsnCertType = psn_info.PsnCertType
  23750. Certno = psn_info.Certno
  23751. PsnName = psn_info.PsnName
  23752. Gend = psn_info.Gend
  23753. Naty = psn_info.Naty
  23754. Brdy = psn_info.Brdy
  23755. Age = psn_info.Age
  23756. infoStr = psn_info.Insuinfo
  23757. idetinfoStr = psn_info.Idetinfo
  23758. infocode = 0
  23759. verify_number = psn_info.VerifyNumber
  23760. }
  23761. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23762. psn_info, _ := service.GetPsnByPatientId(id)
  23763. PsnNo = psn_info.PsnNo
  23764. PsnCertType = psn_info.PsnCertType
  23765. Certno = psn_info.Certno
  23766. PsnName = psn_info.PsnName
  23767. Gend = psn_info.Gend
  23768. Naty = psn_info.Naty
  23769. Brdy = psn_info.Brdy
  23770. Age = psn_info.Age
  23771. infoStr = psn_info.Insuinfo
  23772. idetinfoStr = psn_info.Idetinfo
  23773. infocode = 0
  23774. verify_number = psn_info.VerifyNumber
  23775. idetinfoStr = psn_info.Idetinfo
  23776. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23777. if id_card_type == 1 {
  23778. psn_info, _ := service.GetPsnByPatientId(id)
  23779. PsnNo = psn_info.PsnNo
  23780. PsnCertType = psn_info.PsnCertType
  23781. Certno = psn_info.Certno
  23782. PsnName = psn_info.PsnName
  23783. Gend = psn_info.Gend
  23784. Naty = psn_info.Naty
  23785. Brdy = psn_info.Brdy
  23786. Age = psn_info.Age
  23787. infoStr = psn_info.Insuinfo
  23788. idetinfoStr = psn_info.Idetinfo
  23789. infocode = 0
  23790. verify_number = psn_info.VerifyNumber
  23791. } else if id_card_type == 2 {
  23792. 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)
  23793. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23794. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23795. utils.ErrorLog("解析失败:%v", err)
  23796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23797. return
  23798. }
  23799. PsnNo = res.Output.Baseinfo.PsnNo
  23800. PsnCertType = res.Output.Baseinfo.PsnCertType
  23801. Certno = res.Output.Baseinfo.Certno
  23802. PsnName = res.Output.Baseinfo.PsnName
  23803. Gend = res.Output.Baseinfo.Gend
  23804. Naty = res.Output.Baseinfo.Naty
  23805. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23806. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23807. infoStr = string(Iinfos)
  23808. idetinfoStr = string(Idetinfos)
  23809. infocode = res.Infcode
  23810. } else if id_card_type == 4 {
  23811. psn_info, _ := service.GetPsnByPatientId(id)
  23812. PsnNo = psn_info.PsnNo
  23813. PsnCertType = psn_info.PsnCertType
  23814. Certno = psn_info.Certno
  23815. PsnName = psn_info.PsnName
  23816. Gend = psn_info.Gend
  23817. Naty = psn_info.Naty
  23818. Brdy = psn_info.Brdy
  23819. Age = psn_info.Age
  23820. infoStr = psn_info.Insuinfo
  23821. idetinfoStr = psn_info.Idetinfo
  23822. infocode = 0
  23823. verify_number = psn_info.VerifyNumber
  23824. }
  23825. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23826. var result string
  23827. var requestLog string
  23828. 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), "")
  23829. if id_card_type == 4 {
  23830. psn_info, _ := service.GetPsnByPatientId(id)
  23831. PsnNo = psn_info.PsnNo
  23832. PsnCertType = psn_info.PsnCertType
  23833. Certno = psn_info.Certno
  23834. PsnName = psn_info.PsnName
  23835. Gend = psn_info.Gend
  23836. Naty = psn_info.Naty
  23837. Brdy = psn_info.Brdy
  23838. Age = psn_info.Age
  23839. infoStr = psn_info.Insuinfo
  23840. idetinfoStr = psn_info.Idetinfo
  23841. infocode = 0
  23842. verify_number = psn_info.VerifyNumber
  23843. } else {
  23844. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23845. if miConfig.Code == "H15049901371" {
  23846. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23847. utils.ErrorLog("解析失败:%v", err)
  23848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23849. return
  23850. }
  23851. res.ErrMsg = res10265.ErrMsg
  23852. res.Output = res10265.Output
  23853. res.InfRefmsgid = res10265.InfRefmsgid
  23854. } else {
  23855. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23856. utils.ErrorLog("解析失败:%v", err)
  23857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23858. return
  23859. }
  23860. }
  23861. PsnNo = res.Output.Baseinfo.PsnNo
  23862. PsnCertType = res.Output.Baseinfo.PsnCertType
  23863. Certno = res.Output.Baseinfo.Certno
  23864. PsnName = res.Output.Baseinfo.PsnName
  23865. Gend = res.Output.Baseinfo.Gend
  23866. Naty = res.Output.Baseinfo.Naty
  23867. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23868. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23869. infoStr = string(Iinfos)
  23870. idetinfoStr = string(Idetinfos)
  23871. if miConfig.Code == "H15049901371" {
  23872. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23873. } else {
  23874. infocode = res.Infcode
  23875. }
  23876. }
  23877. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23878. psn_info, _ := service.GetPsnByPatientId(id)
  23879. PsnNo = psn_info.PsnNo
  23880. PsnCertType = psn_info.PsnCertType
  23881. Certno = psn_info.Certno
  23882. PsnName = psn_info.PsnName
  23883. Gend = psn_info.Gend
  23884. Naty = psn_info.Naty
  23885. Brdy = psn_info.Brdy
  23886. Age = psn_info.Age
  23887. infoStr = psn_info.Insuinfo
  23888. idetinfoStr = psn_info.Idetinfo
  23889. infocode = 0
  23890. verify_number = psn_info.VerifyNumber
  23891. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23892. psn_info, _ := service.GetPsnByPatientId(id)
  23893. PsnNo = psn_info.PsnNo
  23894. PsnCertType = psn_info.PsnCertType
  23895. Certno = psn_info.Certno
  23896. PsnName = psn_info.PsnName
  23897. Gend = psn_info.Gend
  23898. Naty = psn_info.Naty
  23899. Brdy = psn_info.Brdy
  23900. Age = psn_info.Age
  23901. infoStr = psn_info.Insuinfo
  23902. idetinfoStr = psn_info.Idetinfo
  23903. infocode = 0
  23904. verify_number = psn_info.VerifyNumber
  23905. } else {
  23906. var result string
  23907. var requestLog string
  23908. //if miConfig.UserOrgId == 10138 {
  23909. if id_card_type != 4 || id_card_type != 1 {
  23910. var insa string
  23911. if len(patient.InsuplcAdmdvs) > 0 {
  23912. insa = patient.InsuplcAdmdvs
  23913. } else {
  23914. insa = miConfig.InsuplcAdmdvs
  23915. }
  23916. //psn_info, _ := service.GetPsnByPatientId(id)
  23917. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23918. 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)
  23919. }
  23920. //}
  23921. //else {
  23922. // var insa string
  23923. // if len(patient.InsuplcAdmdvs) > 0 {
  23924. // insa = patient.InsuplcAdmdvs
  23925. // } else {
  23926. // insa = miConfig.InsuplcAdmdvs
  23927. // }
  23928. // 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)
  23929. //}
  23930. if id_card_type == 4 || id_card_type == 1 {
  23931. psn_info, _ := service.GetPsnByPatientId(id)
  23932. PsnNo = psn_info.PsnNo
  23933. PsnCertType = psn_info.PsnCertType
  23934. Certno = psn_info.Certno
  23935. PsnName = psn_info.PsnName
  23936. Gend = psn_info.Gend
  23937. Naty = psn_info.Naty
  23938. Brdy = psn_info.Brdy
  23939. Age = psn_info.Age
  23940. infoStr = psn_info.Insuinfo
  23941. idetinfoStr = psn_info.Idetinfo
  23942. infocode = 0
  23943. verify_number = psn_info.VerifyNumber
  23944. } else {
  23945. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23946. if miConfig.Code == "H15049901371" {
  23947. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23948. utils.ErrorLog("解析失败:%v", err)
  23949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23950. return
  23951. }
  23952. res.ErrMsg = res10265.ErrMsg
  23953. res.Output = res10265.Output
  23954. res.InfRefmsgid = res10265.InfRefmsgid
  23955. } else {
  23956. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23957. utils.ErrorLog("解析失败:%v", err)
  23958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23959. return
  23960. }
  23961. }
  23962. PsnNo = res.Output.Baseinfo.PsnNo
  23963. PsnCertType = res.Output.Baseinfo.PsnCertType
  23964. Certno = res.Output.Baseinfo.Certno
  23965. PsnName = res.Output.Baseinfo.PsnName
  23966. Gend = res.Output.Baseinfo.Gend
  23967. Naty = res.Output.Baseinfo.Naty
  23968. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23969. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23970. infoStr = string(Iinfos)
  23971. idetinfoStr = string(Idetinfos)
  23972. if miConfig.Code == "H15049901371" {
  23973. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23974. } else {
  23975. infocode = res.Infcode
  23976. }
  23977. }
  23978. }
  23979. if infocode == 0 {
  23980. his := models.VMHisPatient{
  23981. Name: name,
  23982. Gender: gender,
  23983. Birthday: birthUnix,
  23984. MedicalTreatmentType: medical_care,
  23985. IdType: certificates,
  23986. IdCardNo: id_card,
  23987. BalanceAccountsType: settlementValue,
  23988. SocialType: social_type,
  23989. MedicalInsuranceNumber: medical_insurance_card,
  23990. RegisterType: register_type,
  23991. RegisterCost: registration_fee,
  23992. TreatmentCost: medical_expenses,
  23993. Status: 1,
  23994. Ctime: time.Now().Unix(),
  23995. Mtime: time.Now().Unix(),
  23996. PsnNo: PsnNo,
  23997. PsnCertType: PsnCertType,
  23998. Certno: Certno,
  23999. PsnName: PsnName,
  24000. Gend: Gend,
  24001. Naty: Naty,
  24002. Brdy: Brdy,
  24003. Age: Age,
  24004. Iinfo: infoStr,
  24005. Idetinfo: idetinfoStr,
  24006. PatientId: patient.ID,
  24007. RecordDate: theTime.Unix(),
  24008. UserOrgId: adminInfo.CurrentOrgId,
  24009. AdminUserId: admin_user_id,
  24010. IsReturn: 1,
  24011. IdCardType: id_card_type,
  24012. Doctor: doctor,
  24013. Departments: department,
  24014. MdtrtGrpType: mdtrt_type,
  24015. }
  24016. timestamp := time.Now().Unix()
  24017. tempTime := time.Unix(timestamp, 0)
  24018. timeFormat := tempTime.Format("20060102150405")
  24019. chrgBchno := rand.Intn(100000) + 10000
  24020. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24021. his.Number = ipt_otp_no
  24022. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24023. department, _ := service.GetDepartMentDetail(department)
  24024. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24025. IdCardNo := ""
  24026. if id_card_type == 1 {
  24027. // IdCardNo = medical_insurance_card
  24028. IdCardNo = patient.IdCardNo
  24029. } else {
  24030. IdCardNo = patient.IdCardNo
  24031. }
  24032. var rf []*ResultFive
  24033. json.Unmarshal([]byte(his.Iinfo), &rf)
  24034. var insutypes []*ResultFive
  24035. var insutype string
  24036. var insuplc_admdvs_temp string
  24037. var is390 int = 0
  24038. var is310 int = 0
  24039. for _, item := range rf {
  24040. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24041. insutypes = append(insutypes, item)
  24042. }
  24043. }
  24044. if len(insutypes) == 1 {
  24045. insutype = insutypes[0].Insutype
  24046. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24047. if insutype == "390" {
  24048. is390 = 1
  24049. }
  24050. if insutype == "310" {
  24051. is310 = 1
  24052. }
  24053. } else {
  24054. for _, i := range insutypes {
  24055. if i.Insutype == "390" {
  24056. is390 = 1
  24057. }
  24058. if i.Insutype == "310" {
  24059. is310 = 1
  24060. }
  24061. }
  24062. }
  24063. if is390 == 1 {
  24064. insutype = "390"
  24065. }
  24066. if is310 == 1 {
  24067. insutype = "310"
  24068. }
  24069. fmt.Println(social_type)
  24070. if social_type > 0 {
  24071. insutype = strconv.FormatInt(social_type, 10)
  24072. }
  24073. var infocode int64
  24074. var resThree ResultThree
  24075. var resThree10265 ResultThree10265
  24076. if len(insuplc_admdvs) == 0 {
  24077. psn_info, _ := service.GetPsnByPatientId(id)
  24078. //if len(psn_info.InsuplcAdmdvs) > 0 {
  24079. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24080. //}
  24081. } else {
  24082. insuplc_admdvs_temp = insuplc_admdvs
  24083. }
  24084. if miConfig.MdtrtareaAdmvs == "421300" {
  24085. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24086. psn_info, _ := service.GetPsnByPatientId(id)
  24087. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24088. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24089. "&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
  24090. resp, requestErr := http.Get(api)
  24091. if requestErr != nil {
  24092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24093. return
  24094. }
  24095. body, ioErr := ioutil.ReadAll(resp.Body)
  24096. if ioErr != nil {
  24097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24099. return
  24100. }
  24101. var respJSON map[string]interface{}
  24102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24105. return
  24106. }
  24107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24108. result, _ := json.Marshal(respJSON)
  24109. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24110. utils.ErrorLog("解析失败:%v", err)
  24111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24112. return
  24113. }
  24114. infocode = resThree.Infcode
  24115. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24116. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24117. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24118. // insuplc_admdvs_temp =
  24119. //}
  24120. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24121. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24122. //}
  24123. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24124. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24125. "&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
  24126. resp, requestErr := http.Get(api)
  24127. if requestErr != nil {
  24128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24129. return
  24130. }
  24131. body, ioErr := ioutil.ReadAll(resp.Body)
  24132. if ioErr != nil {
  24133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24135. return
  24136. }
  24137. var respJSON map[string]interface{}
  24138. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24141. return
  24142. }
  24143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24144. result, _ := json.Marshal(respJSON)
  24145. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24146. utils.ErrorLog("解析失败:%v", err)
  24147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24148. return
  24149. }
  24150. infocode = resThree.Infcode
  24151. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24152. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24153. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24154. // insuplc_admdvs_temp =
  24155. //}
  24156. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24157. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24158. //}
  24159. utils.ErrorLog("解析失败:%v", insutype)
  24160. utils.ErrorLog("解析失败:%v", PsnNo)
  24161. utils.ErrorLog("解析失败:%v", Certno)
  24162. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  24163. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  24164. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24165. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  24166. utils.ErrorLog("解析失败:%v", PsnNo)
  24167. utils.ErrorLog("解析失败:%v", department.Number)
  24168. utils.ErrorLog("解析失败:%v", department.Name)
  24169. utils.ErrorLog("解析失败:%v", roles.UserName)
  24170. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24171. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24172. "&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
  24173. resp, requestErr := http.Get(api)
  24174. if requestErr != nil {
  24175. utils.ErrorLog("解析失败:%v", requestErr)
  24176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24177. return
  24178. }
  24179. body, ioErr := ioutil.ReadAll(resp.Body)
  24180. if ioErr != nil {
  24181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24183. return
  24184. }
  24185. var respJSON map[string]interface{}
  24186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24189. return
  24190. }
  24191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24192. result, _ := json.Marshal(respJSON)
  24193. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24194. utils.ErrorLog("解析失败:%v", err)
  24195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24196. return
  24197. }
  24198. infocode = resThree.Infcode
  24199. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24200. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24201. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24202. // insuplc_admdvs_temp =
  24203. //}
  24204. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24205. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24206. //}
  24207. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24208. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24209. "&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
  24210. resp, requestErr := http.Get(api)
  24211. if requestErr != nil {
  24212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24213. return
  24214. }
  24215. body, ioErr := ioutil.ReadAll(resp.Body)
  24216. if ioErr != nil {
  24217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24219. return
  24220. }
  24221. var respJSON map[string]interface{}
  24222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24225. return
  24226. }
  24227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24228. result, _ := json.Marshal(respJSON)
  24229. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24230. utils.ErrorLog("解析失败:%v", err)
  24231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24232. return
  24233. }
  24234. infocode = resThree.Infcode
  24235. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24236. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24237. psn_info, _ := service.GetPsnByPatientId(id)
  24238. var verify_number string
  24239. if id_card_type == 4 {
  24240. verify_number = psn_info.VerifyNumber
  24241. } else if id_card_type == 1 {
  24242. bas := strings.Split(psn_info.CardInfo, "|")
  24243. cardNumber := bas[2]
  24244. verify_number = cardNumber
  24245. }
  24246. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24247. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24248. "&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
  24249. resp, requestErr := http.Get(api)
  24250. if requestErr != nil {
  24251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24252. return
  24253. }
  24254. body, ioErr := ioutil.ReadAll(resp.Body)
  24255. if ioErr != nil {
  24256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24258. return
  24259. }
  24260. var respJSON map[string]interface{}
  24261. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24264. return
  24265. }
  24266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24267. result, _ := json.Marshal(respJSON)
  24268. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24269. // utils.ErrorLog("解析失败:%v", err)
  24270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24271. // return
  24272. //}
  24273. //infocode = resThree.Infcode
  24274. //result, _ := json.Marshal(respJSON)
  24275. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24276. utils.ErrorLog("解析失败:%v", err)
  24277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24278. return
  24279. }
  24280. resThree.ErrMsg = resThree10265.ErrMsg
  24281. resThree.Output = resThree10265.Output
  24282. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24283. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24284. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24285. psn_info, _ := service.GetPsnByPatientId(id)
  24286. his.PsnNo = psn_info.PsnNo
  24287. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24288. var cert_no string
  24289. if id_card_type == 3 {
  24290. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24291. cert_no = IdCardNo
  24292. } else if id_card_type == 4 {
  24293. cert_no = IdCardNo
  24294. psn_info.VerifyNumber = psn_info.VerifyNumber
  24295. } else {
  24296. bas := strings.Split(psn_info.CardInfo, "|")
  24297. cert_no = bas[2]
  24298. }
  24299. var hisPrescription []*models.HisPrescription
  24300. for _, item := range rf {
  24301. if item.Insutype == insutype {
  24302. //insuplc_admdvs = item.InsuplcAdmdvs
  24303. his.InsuplcAdmdvs = insuplc_admdvs
  24304. }
  24305. }
  24306. his.Insutype = insutype
  24307. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24308. fmt.Println(res3101)
  24309. fmt.Println(res3101.Infcode)
  24310. if res3101.Infcode == "0" {
  24311. fmt.Println("33333333")
  24312. if len(res3101.Output.Result) > 0 {
  24313. fmt.Println("222222")
  24314. for _, item := range res3101.Output.Result {
  24315. if len(res3101.ErrMsg) == 0 {
  24316. res3101.ErrMsg = item.VolaCont
  24317. } else {
  24318. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24319. }
  24320. }
  24321. c.ServeSuccessJSON(map[string]interface{}{
  24322. "failed_code": -10,
  24323. "msg": res3101.ErrMsg,
  24324. })
  24325. return
  24326. } else {
  24327. fmt.Println("11111")
  24328. var api string
  24329. if miConfig.MdtrtareaAdmvs == "320921" {
  24330. ipt_otp_no = timeFormat
  24331. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24332. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24333. "&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
  24334. } else {
  24335. ipt_otp_no = timeFormat
  24336. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24337. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24338. "&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
  24339. }
  24340. resp, requestErr := http.Get(api)
  24341. if requestErr != nil {
  24342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24343. return
  24344. }
  24345. body, ioErr := ioutil.ReadAll(resp.Body)
  24346. if ioErr != nil {
  24347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24349. return
  24350. }
  24351. var respJSON map[string]interface{}
  24352. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24355. return
  24356. }
  24357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24358. result, _ := json.Marshal(respJSON)
  24359. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24360. utils.ErrorLog("解析失败:%v", err)
  24361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24362. return
  24363. }
  24364. resThree.ErrMsg = resThree10265.ErrMsg
  24365. resThree.Output = resThree10265.Output
  24366. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24367. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24368. }
  24369. } else if res3101.Infcode != "0" {
  24370. c.ServeSuccessJSON(map[string]interface{}{
  24371. "failed_code": -10,
  24372. "msg": res3101.ErrMsg,
  24373. })
  24374. return
  24375. }
  24376. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24377. psn_info, _ := service.GetPsnByPatientId(id)
  24378. var cert_no string
  24379. if id_card_type == 1 {
  24380. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24381. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24382. } else if id_card_type == 4 {
  24383. cert_no = psn_info.VerifyNumber
  24384. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24385. } else {
  24386. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24387. cert_no = psn_info.VerifyNumber
  24388. }
  24389. 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)
  24390. saveLog(result, requestLog, "2201", "挂号")
  24391. if miConfig.Code == "H15049901371" {
  24392. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24393. utils.ErrorLog("解析失败:%v", err)
  24394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24395. return
  24396. }
  24397. resThree.ErrMsg = resThree10265.ErrMsg
  24398. resThree.Output = resThree10265.Output
  24399. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24400. } else {
  24401. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24402. utils.ErrorLog("解析失败:%v", err)
  24403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24404. return
  24405. }
  24406. }
  24407. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24408. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24409. psn_info, _ := service.GetPsnByPatientId(id)
  24410. var result string
  24411. var requestLog string
  24412. if id_card_type == 1 {
  24413. bas := strings.Split(psn_info.CardInfo, "|")
  24414. basNumber := bas[2]
  24415. card_sn := bas[3]
  24416. 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)
  24417. saveLog(result, requestLog, "2201A", "挂号")
  24418. } else if id_card_type == 2 {
  24419. 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, "", "", "", "", "", "")
  24420. saveLog(result, requestLog, "2201A", "挂号")
  24421. } else {
  24422. 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)
  24423. saveLog(result, requestLog, "2201A", "挂号")
  24424. }
  24425. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24426. utils.ErrorLog("解析失败:%v", err)
  24427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24428. return
  24429. }
  24430. infocode = resThree.Infcode
  24431. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24432. psn_info, _ := service.GetPsnByPatientId(id)
  24433. var result string
  24434. var requestLog string
  24435. if id_card_type == 1 {
  24436. bas := strings.Split(psn_info.CardInfo, "|")
  24437. basNumber := bas[2]
  24438. card_sn := ""
  24439. 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)
  24440. saveLog(result, requestLog, "2201A", "挂号")
  24441. } else if id_card_type == 2 {
  24442. 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, "", "", "", "", "", "")
  24443. saveLog(result, requestLog, "2201A", "挂号")
  24444. } else {
  24445. 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)
  24446. saveLog(result, requestLog, "2201A", "挂号")
  24447. }
  24448. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24449. utils.ErrorLog("解析失败:%v", err)
  24450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24451. return
  24452. }
  24453. infocode = resThree.Infcode
  24454. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24455. psn_info, _ := service.GetPsnByPatientId(id)
  24456. his.PsnNo = psn_info.PsnNo
  24457. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24458. var cert_no string
  24459. if id_card_type == 1 {
  24460. bas := strings.Split(psn_info.CardInfo, "|")
  24461. cert_no = bas[2]
  24462. } else if id_card_type == 4 {
  24463. cert_no = psn_info.VerifyNumber
  24464. psn_info.VerifyNumber = psn_info.VerifyNumber
  24465. IdCardNo = psn_info.VerifyNumber
  24466. } else {
  24467. cert_no = IdCardNo
  24468. psn_info.VerifyNumber = cert_no
  24469. }
  24470. for _, item := range rf {
  24471. if item.Insutype == insutype {
  24472. his.InsuplcAdmdvs = insuplc_admdvs
  24473. }
  24474. }
  24475. his.Insutype = insutype
  24476. var api string
  24477. ipt_otp_no = timeFormat
  24478. 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 +
  24479. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24480. "&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
  24481. resp, requestErr := http.Get(api)
  24482. if requestErr != nil {
  24483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24484. return
  24485. }
  24486. body, ioErr := ioutil.ReadAll(resp.Body)
  24487. if ioErr != nil {
  24488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24490. return
  24491. }
  24492. var respJSON map[string]interface{}
  24493. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24496. return
  24497. }
  24498. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24499. if status == "0" {
  24500. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24501. c.ServeSuccessJSON(map[string]interface{}{
  24502. "failed_code": -10,
  24503. "msg": err_msg,
  24504. })
  24505. return
  24506. }
  24507. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24508. result, _ := json.Marshal(respJSON)
  24509. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24510. utils.ErrorLog("解析失败:%v", err)
  24511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24512. return
  24513. }
  24514. infocode = resThree.Infcode
  24515. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24516. psn_info, _ := service.GetPsnByPatientId(id)
  24517. his.PsnNo = psn_info.PsnNo
  24518. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24519. var cert_no string
  24520. if id_card_type == 1 {
  24521. bas := strings.Split(psn_info.CardInfo, "|")
  24522. cert_no = bas[2]
  24523. } else if id_card_type == 4 {
  24524. cert_no = psn_info.VerifyNumber
  24525. psn_info.VerifyNumber = psn_info.VerifyNumber
  24526. IdCardNo = psn_info.VerifyNumber
  24527. } else {
  24528. cert_no = IdCardNo
  24529. psn_info.VerifyNumber = cert_no
  24530. }
  24531. for _, item := range rf {
  24532. if item.Insutype == insutype {
  24533. his.InsuplcAdmdvs = insuplc_admdvs
  24534. patient.InsuplcAdmdvs = insuplc_admdvs
  24535. }
  24536. }
  24537. his.Insutype = insutype
  24538. var api string
  24539. ipt_otp_no = timeFormat
  24540. 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 +
  24541. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24542. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  24543. resp, requestErr := http.Get(api)
  24544. if requestErr != nil {
  24545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24546. return
  24547. }
  24548. body, ioErr := ioutil.ReadAll(resp.Body)
  24549. if ioErr != nil {
  24550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24552. return
  24553. }
  24554. var respJSON map[string]interface{}
  24555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24558. return
  24559. }
  24560. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24561. if status == "0" {
  24562. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24563. c.ServeSuccessJSON(map[string]interface{}{
  24564. "failed_code": -10,
  24565. "msg": err_msg,
  24566. })
  24567. return
  24568. }
  24569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24570. result, _ := json.Marshal(respJSON)
  24571. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24572. utils.ErrorLog("解析失败:%v", err)
  24573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24574. return
  24575. }
  24576. infocode = resThree.Infcode
  24577. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24578. psn_info, _ := service.GetPsnByPatientId(id)
  24579. var result string
  24580. var requestLog string
  24581. if id_card_type == 1 {
  24582. bas := strings.Split(psn_info.CardInfo, "|")
  24583. basNumber := bas[2]
  24584. card_sn := bas[3]
  24585. 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)
  24586. saveLog(result, requestLog, "2201A", "挂号")
  24587. } else if id_card_type == 2 {
  24588. 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, "", "")
  24589. saveLog(result, requestLog, "2201A", "挂号")
  24590. } else {
  24591. 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, "", "")
  24592. saveLog(result, requestLog, "2201A", "挂号")
  24593. }
  24594. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24595. utils.ErrorLog("解析失败:%v", err)
  24596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24597. return
  24598. }
  24599. infocode = resThree.Infcode
  24600. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24601. psn_info, _ := service.GetPsnByPatientId(id)
  24602. 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)
  24603. saveLog(result, requestLog, "2201A", "挂号")
  24604. if miConfig.Code == "H15049901371" {
  24605. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24606. utils.ErrorLog("解析失败:%v", err)
  24607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24608. return
  24609. }
  24610. resThree.ErrMsg = resThree10265.ErrMsg
  24611. resThree.Output = resThree10265.Output
  24612. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24613. } else {
  24614. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24615. utils.ErrorLog("解析失败:%v", err)
  24616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24617. return
  24618. }
  24619. }
  24620. if miConfig.Code == "H15049901371" {
  24621. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24622. } else {
  24623. infocode = resThree.Infcode
  24624. }
  24625. } else {
  24626. psn_info, _ := service.GetPsnByPatientId(id)
  24627. if id_card_type == 4 || id_card_type == 1 {
  24628. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24629. }
  24630. var rf []*ResultFive
  24631. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24632. var insutypes []*ResultFive
  24633. var insutype string
  24634. var is390 int = 0
  24635. var is310 int = 0
  24636. for _, item := range rf {
  24637. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24638. insutypes = append(insutypes, item)
  24639. }
  24640. }
  24641. if len(insutypes) == 1 {
  24642. insutype = insutypes[0].Insutype
  24643. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24644. } else {
  24645. for _, i := range insutypes {
  24646. if i.Insutype == "390" {
  24647. is390 = 1
  24648. }
  24649. if i.Insutype == "310" {
  24650. is310 = 1
  24651. }
  24652. }
  24653. }
  24654. if is390 == 1 {
  24655. insutype = "390"
  24656. }
  24657. if is310 == 1 {
  24658. insutype = "310"
  24659. }
  24660. fmt.Println(len(insutypes))
  24661. if len(insutypes) == 0 {
  24662. for index, item := range rf {
  24663. if index == 0 {
  24664. insutype = item.Insutype
  24665. insuplc_admdvs = item.InsuplcAdmdvs
  24666. }
  24667. }
  24668. fmt.Println(insutype)
  24669. fmt.Println(insuplc_admdvs)
  24670. }
  24671. if social_type > 0 {
  24672. insutype = strconv.FormatInt(social_type, 10)
  24673. }
  24674. fmt.Println("--------")
  24675. fmt.Println(psn_info)
  24676. fmt.Println(psn_info.PsnNo)
  24677. if miConfig.MdtrtareaAdmvs == "441202" {
  24678. var hisPrescription []*models.HisPrescription
  24679. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24680. if res3101.Infcode == 0 {
  24681. fmt.Println("33333333")
  24682. if len(res3101.Output.Result) > 0 {
  24683. fmt.Println("222222")
  24684. for _, item := range res3101.Output.Result {
  24685. if len(res3101.ErrMsg) == 0 {
  24686. res3101.ErrMsg = item.VolaCont
  24687. } else {
  24688. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24689. }
  24690. }
  24691. c.ServeSuccessJSON(map[string]interface{}{
  24692. "failed_code": -10,
  24693. "msg": res3101.ErrMsg,
  24694. })
  24695. return
  24696. } else {
  24697. hour := time.Now().Format("15")
  24698. min := time.Now().Format("04")
  24699. sec := time.Now().Format("05")
  24700. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24701. fmt.Println(record_time_two)
  24702. 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)
  24703. saveLog(result, requestLog, "2201A", "挂号")
  24704. if miConfig.Code == "H15049901371" {
  24705. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24706. utils.ErrorLog("解析失败:%v", err)
  24707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24708. return
  24709. }
  24710. resThree.ErrMsg = resThree10265.ErrMsg
  24711. resThree.Output = resThree10265.Output
  24712. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24713. } else {
  24714. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24715. utils.ErrorLog("解析失败:%v", err)
  24716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24717. return
  24718. }
  24719. }
  24720. if miConfig.Code == "H15049901371" {
  24721. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24722. } else {
  24723. infocode = resThree.Infcode
  24724. }
  24725. }
  24726. } else if res3101.Infcode != 0 {
  24727. c.ServeSuccessJSON(map[string]interface{}{
  24728. "failed_code": -10,
  24729. "msg": res3101.ErrMsg,
  24730. })
  24731. return
  24732. }
  24733. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24734. var hisPrescription []*models.HisPrescription
  24735. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24736. if res3101.Infcode == 0 {
  24737. fmt.Println("33333333")
  24738. if len(res3101.Output.Result) > 0 {
  24739. fmt.Println("222222")
  24740. for _, item := range res3101.Output.Result {
  24741. if len(res3101.ErrMsg) == 0 {
  24742. res3101.ErrMsg = item.VolaCont
  24743. } else {
  24744. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24745. }
  24746. }
  24747. c.ServeSuccessJSON(map[string]interface{}{
  24748. "failed_code": -10,
  24749. "msg": res3101.ErrMsg,
  24750. })
  24751. return
  24752. } else {
  24753. hour := time.Now().Format("15")
  24754. min := time.Now().Format("04")
  24755. sec := time.Now().Format("05")
  24756. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24757. fmt.Println(record_time_two)
  24758. 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)
  24759. saveLog(result, requestLog, "2201A", "挂号")
  24760. if miConfig.Code == "H15049901371" {
  24761. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24762. utils.ErrorLog("解析失败:%v", err)
  24763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24764. return
  24765. }
  24766. resThree.ErrMsg = resThree10265.ErrMsg
  24767. resThree.Output = resThree10265.Output
  24768. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24769. } else {
  24770. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24771. utils.ErrorLog("解析失败:%v", err)
  24772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24773. return
  24774. }
  24775. }
  24776. if miConfig.Code == "H15049901371" {
  24777. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24778. } else {
  24779. infocode = resThree.Infcode
  24780. }
  24781. }
  24782. } else if res3101.Infcode != 0 {
  24783. c.ServeSuccessJSON(map[string]interface{}{
  24784. "failed_code": -10,
  24785. "msg": res3101.ErrMsg,
  24786. })
  24787. return
  24788. }
  24789. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24790. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24791. psn_info, _ := service.GetPsnByPatientId(id)
  24792. var verify_number string
  24793. if id_card_type == 4 {
  24794. verify_number = psn_info.VerifyNumber
  24795. } else if id_card_type == 1 {
  24796. bas := strings.Split(psn_info.CardInfo, "|")
  24797. cardNumber := bas[2]
  24798. verify_number = cardNumber
  24799. } else {
  24800. verify_number = psn_info.Certno
  24801. }
  24802. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24803. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24804. "&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
  24805. resp, requestErr := http.Get(api)
  24806. if requestErr != nil {
  24807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24808. return
  24809. }
  24810. body, ioErr := ioutil.ReadAll(resp.Body)
  24811. if ioErr != nil {
  24812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24814. return
  24815. }
  24816. var respJSON map[string]interface{}
  24817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24820. return
  24821. }
  24822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24823. result, _ := json.Marshal(respJSON)
  24824. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24825. utils.ErrorLog("解析失败:%v", err)
  24826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24827. return
  24828. }
  24829. infocode = resThree.Infcode
  24830. } else {
  24831. hour := time.Now().Format("15")
  24832. min := time.Now().Format("04")
  24833. sec := time.Now().Format("05")
  24834. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24835. if id_card_type == 1 {
  24836. for _, item := range rf {
  24837. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24838. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24839. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24840. } else if strconv.FormatInt(social_type, 10) == "390" {
  24841. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24842. } else {
  24843. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24844. }
  24845. }
  24846. }
  24847. }
  24848. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24849. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24850. }
  24851. if id_card_type == 1 {
  24852. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24853. bas := strings.Split(psn_info.CardInfo, "|")
  24854. basNumber := bas[1]
  24855. IdCardNo = basNumber
  24856. }
  24857. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24858. IdCardNo = psn_info.VerifyNumber
  24859. }
  24860. if len(insuplc_admdvs_temp) == 0 {
  24861. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24862. }
  24863. 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)
  24864. saveLog(result, requestLog, "2201A", "挂号")
  24865. if miConfig.Code == "H15049901371" {
  24866. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24867. utils.ErrorLog("解析失败:%v", err)
  24868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24869. return
  24870. }
  24871. resThree.ErrMsg = resThree10265.ErrMsg
  24872. resThree.Output = resThree10265.Output
  24873. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24874. } else {
  24875. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24876. utils.ErrorLog("解析失败:%v", err)
  24877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24878. return
  24879. }
  24880. }
  24881. if miConfig.Code == "H15049901371" {
  24882. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24883. } else {
  24884. infocode = resThree.Infcode
  24885. }
  24886. }
  24887. }
  24888. if infocode == -1 {
  24889. adminUser := c.GetAdminUserInfo()
  24890. errlog := &models.HisOrderError{
  24891. UserOrgId: adminUser.CurrentOrgId,
  24892. Ctime: time.Now().Unix(),
  24893. Mtime: time.Now().Unix(),
  24894. ErrMsg: resThree.ErrMsg,
  24895. Status: 1,
  24896. PatientId: id,
  24897. RecordTime: recordDateTime,
  24898. Stage: 2,
  24899. }
  24900. service.CreateErrMsgLog(errlog)
  24901. c.ServeSuccessJSON(map[string]interface{}{
  24902. "failed_code": -10,
  24903. "msg": resThree.ErrMsg,
  24904. })
  24905. return
  24906. }
  24907. his.Number = resThree.Output.Data.MdtrtID
  24908. his.PsnNo = resThree.Output.Data.PsnNo
  24909. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24910. his.IdCardNo = patient.IdCardNo
  24911. his.PhoneNumber = patient.Phone
  24912. his.UserOrgId = adminInfo.CurrentOrgId
  24913. his.Insutype = insutype
  24914. his.Ctime = time.Now().Unix()
  24915. his.Mtime = time.Now().Unix()
  24916. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24917. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24918. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24919. }
  24920. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24921. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24922. }
  24923. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24924. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24925. }
  24926. his.Status = 1
  24927. his.MdtrtGrpType = mdtrt_type
  24928. service.UpdateHisPatientStatus(&his)
  24929. service.UpdateHisPatient123(&patient)
  24930. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24931. c.ServeSuccessJSON(map[string]interface{}{
  24932. "his_info": his,
  24933. })
  24934. } else {
  24935. adminUser := c.GetAdminUserInfo()
  24936. errlog := &models.HisOrderError{
  24937. UserOrgId: adminUser.CurrentOrgId,
  24938. Ctime: time.Now().Unix(),
  24939. Mtime: time.Now().Unix(),
  24940. ErrMsg: res.ErrMsg,
  24941. Status: 1,
  24942. PatientId: id,
  24943. RecordTime: recordDateTime,
  24944. Stage: 1,
  24945. }
  24946. service.CreateErrMsgLog(errlog)
  24947. c.ServeSuccessJSON(map[string]interface{}{
  24948. "failed_code": -10,
  24949. "msg": res.ErrMsg,
  24950. })
  24951. return
  24952. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24953. }
  24954. }
  24955. }
  24956. func (c *HisApiController) GetUploadInfo() {
  24957. id, _ := c.GetInt64("id")
  24958. record_time := c.GetString("record_time")
  24959. his_patient_id, _ := c.GetInt64("his_patient_id")
  24960. order_id, _ := c.GetInt64("order_id")
  24961. pay_way, _ := c.GetInt64("pay_way")
  24962. pay_ways := c.GetString("pay_ways")
  24963. oth_desc := c.GetString("oth_desc")
  24964. pay_price, _ := c.GetFloat("pay_price")
  24965. pay_card_no := c.GetString("pay_card_no")
  24966. discount_price, _ := c.GetFloat("discount_price")
  24967. preferential_price, _ := c.GetFloat("preferential_price")
  24968. reality_price, _ := c.GetFloat("reality_price")
  24969. found_price, _ := c.GetFloat("found_price")
  24970. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24971. private_price, _ := c.GetFloat("private_price")
  24972. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24973. admin_user_id, _ := c.GetInt64("admin_user_id")
  24974. fapiao_code := c.GetString("fapiao_code")
  24975. fapiao_number := c.GetString("fapiao_number")
  24976. diagnosis_id := c.GetString("diagnosis")
  24977. sick_type, _ := c.GetInt64("sick_type")
  24978. reg_type, _ := c.GetInt64("p_type")
  24979. begin_time := c.GetString("begin_time")
  24980. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24981. cash_pay := c.GetString("cash_pay")
  24982. band_card_pay := c.GetString("band_card_pay")
  24983. wechat_pay := c.GetString("wechat_pay")
  24984. ali_pay := c.GetString("ali_pay")
  24985. jifen_pay := c.GetString("jifen_pay")
  24986. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24987. fmt.Println(acct_used_flag)
  24988. id_str := c.GetString("ids")
  24989. ids_arr := strings.Split(id_str, ",")
  24990. timeLayout := "2006-01-02"
  24991. loc, _ := time.LoadLocation("Local")
  24992. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24993. if err != nil {
  24994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24995. return
  24996. }
  24997. recordDateTime := theTime.Unix()
  24998. adminUser := c.GetAdminUserInfo()
  24999. var tempOrder models.HisOrder
  25000. tempOrder, _ = service.GetHisOrderByID(order_id)
  25001. var prescriptions []*models.HisPrescription
  25002. var start_time int64
  25003. var end_time int64
  25004. //押金模块
  25005. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  25006. tmp_decimal := c.GetString("tmp_decimal")
  25007. var decimal float64 //本次使用的押金
  25008. var errmsg error
  25009. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  25010. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  25011. return
  25012. }
  25013. if len(tmp_decimal) > 0 {
  25014. if tmp_decimal[0] == 45 {
  25015. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  25016. return
  25017. }
  25018. }
  25019. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  25020. fmt.Println(errs)
  25021. decimal = tt
  25022. //if adminUser.CurrentOrgId == 10106{
  25023. // if len(fapiao_code) == 0{
  25024. // fapiao_code = "144072080589"
  25025. // }
  25026. // if len(fapiao_number) == 0{
  25027. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  25028. // if order.ID == 0{
  25029. // fapiao_number = "00001520"
  25030. // }else{
  25031. // //fapiao_code = "00001520"
  25032. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  25033. // var zero string
  25034. // if fpNumber >= 1000{
  25035. // zero = "0000" + strconv.Itoa(fpNumber)
  25036. // }else if fpNumber >= 10000{
  25037. // zero = "000" + strconv.Itoa(fpNumber)
  25038. // } else if fpNumber >= 100000{
  25039. // zero = "00" + strconv.Itoa(fpNumber)
  25040. // } else if fpNumber >= 1000000{
  25041. // zero = "0" + strconv.Itoa(fpNumber)
  25042. // }else {
  25043. // zero = strconv.Itoa(fpNumber)
  25044. // }
  25045. // fapiao_number = zero
  25046. // }
  25047. // }
  25048. //}
  25049. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25050. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25051. var patientPrescription models.HisPrescriptionInfo
  25052. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25053. if patientPrescription.ID == 0 {
  25054. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25055. }
  25056. //if patientPrescription.Do
  25057. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25058. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25059. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25060. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25061. var config []*models.HisXtDiagnoseConfig
  25062. for _, item := range diagnosis_ids {
  25063. id, _ := strconv.ParseInt(item, 10, 64)
  25064. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25065. config = append(config, &diagnosisConfig)
  25066. }
  25067. sickConfig, _ := service.FindSickById(sick_type)
  25068. //if tempOrder.ID == 0 {
  25069. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  25070. //}
  25071. if tempOrder.ID == 0 {
  25072. var result string
  25073. var requestLog string
  25074. var res2 ResultSix
  25075. var res3 GZResultSix
  25076. var ressix10265 ResultSix10265
  25077. if miConfig.MdtrtareaAdmvs == "421300" {
  25078. data := make(map[string]interface{})
  25079. client := &http.Client{}
  25080. data["psn_no"] = his.PsnNo
  25081. data["mdtrt_id"] = his.Number
  25082. data["opter"] = roles.UserName
  25083. data["org_name"] = miConfig.OrgName
  25084. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25085. data["doctor_id"] = doctor_info.DoctorNumber
  25086. data["doctor_name"] = doctor_info.UserName
  25087. data["department"] = department.Name
  25088. data["fixmedins_code"] = miConfig.Code
  25089. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25090. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25091. data["secret_key"] = miConfig.SecretKey
  25092. data["sick_code"] = sickConfig.CountryCode
  25093. data["sick_name"] = sickConfig.ClassName
  25094. data["dept"] = strconv.FormatInt(department.ID, 10)
  25095. data["config"] = config
  25096. data["begin_time"] = begin_time
  25097. bytesData, _ := json.Marshal(data)
  25098. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25099. resp, _ := client.Do(req)
  25100. defer resp.Body.Close()
  25101. body, ioErr := ioutil.ReadAll(resp.Body)
  25102. if ioErr != nil {
  25103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25105. return
  25106. }
  25107. var respJSON map[string]interface{}
  25108. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25111. return
  25112. }
  25113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25114. userJSONBytes, _ := json.Marshal(respJSON)
  25115. fmt.Println("log")
  25116. fmt.Println(string(userJSONBytes))
  25117. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25118. utils.ErrorLog("解析失败:%v", err)
  25119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25120. return
  25121. }
  25122. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25123. data := make(map[string]interface{})
  25124. client := &http.Client{}
  25125. data["psn_no"] = his.PsnNo
  25126. data["mdtrt_id"] = his.Number
  25127. data["opter"] = roles.UserName
  25128. data["org_name"] = miConfig.OrgName
  25129. if reg_type == 11 && his.Insutype == "390" {
  25130. data["med_type"] = "110104"
  25131. } else {
  25132. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25133. }
  25134. data["doctor_id"] = doctor_info.DoctorNumber
  25135. data["doctor_name"] = doctor_info.UserName
  25136. data["department"] = department.Name
  25137. data["fixmedins_code"] = miConfig.Code
  25138. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25139. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25140. data["secret_key"] = miConfig.SecretKey
  25141. data["sick_code"] = sickConfig.CountryCode
  25142. data["sick_name"] = sickConfig.ClassName
  25143. data["dept"] = strconv.FormatInt(department.ID, 10)
  25144. data["config"] = config
  25145. data["begin_time"] = begin_time
  25146. bytesData, _ := json.Marshal(data)
  25147. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25148. resp, _ := client.Do(req)
  25149. defer resp.Body.Close()
  25150. body, ioErr := ioutil.ReadAll(resp.Body)
  25151. if ioErr != nil {
  25152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25154. return
  25155. }
  25156. var respJSON map[string]interface{}
  25157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25160. return
  25161. }
  25162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25163. userJSONBytes, _ := json.Marshal(respJSON)
  25164. fmt.Println("log")
  25165. fmt.Println(string(userJSONBytes))
  25166. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25167. utils.ErrorLog("解析失败:%v", err)
  25168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25169. return
  25170. }
  25171. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25172. data := make(map[string]interface{})
  25173. client := &http.Client{}
  25174. data["psn_no"] = his.PsnNo
  25175. data["mdtrt_id"] = his.Number
  25176. data["opter"] = roles.UserName
  25177. data["org_name"] = miConfig.OrgName
  25178. if reg_type == 11 && his.Insutype == "390" {
  25179. data["med_type"] = "110104"
  25180. } else {
  25181. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25182. }
  25183. data["doctor_id"] = doctor_info.DoctorNumber
  25184. data["doctor_name"] = doctor_info.UserName
  25185. data["department"] = department.Name
  25186. data["fixmedins_code"] = miConfig.Code
  25187. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25188. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25189. data["secret_key"] = miConfig.SecretKey
  25190. data["sick_code"] = sickConfig.CountryCode
  25191. data["sick_name"] = sickConfig.ClassName
  25192. data["dept"] = strconv.FormatInt(department.ID, 10)
  25193. data["config"] = config
  25194. data["begin_time"] = begin_time
  25195. bytesData, _ := json.Marshal(data)
  25196. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25197. resp, _ := client.Do(req)
  25198. defer resp.Body.Close()
  25199. body, ioErr := ioutil.ReadAll(resp.Body)
  25200. if ioErr != nil {
  25201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25203. return
  25204. }
  25205. var respJSON map[string]interface{}
  25206. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25209. return
  25210. }
  25211. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25212. userJSONBytes, _ := json.Marshal(respJSON)
  25213. fmt.Println("log")
  25214. fmt.Println(string(userJSONBytes))
  25215. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25216. utils.ErrorLog("解析失败:%v", err)
  25217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25218. return
  25219. }
  25220. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25221. data := make(map[string]interface{})
  25222. client := &http.Client{}
  25223. data["psn_no"] = his.PsnNo
  25224. data["mdtrt_id"] = his.Number
  25225. data["opter"] = roles.UserName
  25226. data["org_name"] = miConfig.OrgName
  25227. if reg_type == 11 && his.Insutype == "390" {
  25228. data["med_type"] = "110104"
  25229. } else {
  25230. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25231. }
  25232. data["doctor_id"] = doctor_info.DoctorNumber
  25233. data["doctor_name"] = doctor_info.UserName
  25234. data["department"] = department.Name
  25235. data["fixmedins_code"] = miConfig.Code
  25236. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25237. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25238. data["secret_key"] = miConfig.SecretKey
  25239. data["sick_code"] = sickConfig.CountryCode
  25240. data["sick_name"] = sickConfig.ClassName
  25241. data["dept"] = strconv.FormatInt(department.ID, 10)
  25242. data["config"] = config
  25243. data["begin_time"] = begin_time
  25244. bytesData, _ := json.Marshal(data)
  25245. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25246. resp, _ := client.Do(req)
  25247. defer resp.Body.Close()
  25248. body, ioErr := ioutil.ReadAll(resp.Body)
  25249. if ioErr != nil {
  25250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25252. return
  25253. }
  25254. var respJSON map[string]interface{}
  25255. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25258. return
  25259. }
  25260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25261. userJSONBytes, _ := json.Marshal(respJSON)
  25262. fmt.Println("log")
  25263. fmt.Println(string(userJSONBytes))
  25264. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25265. utils.ErrorLog("解析失败:%v", err)
  25266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25267. return
  25268. }
  25269. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25270. data := make(map[string]interface{})
  25271. client := &http.Client{}
  25272. data["psn_no"] = his.PsnNo
  25273. data["mdtrt_id"] = his.Number
  25274. data["doctor"] = roles.UserName
  25275. data["department"] = department.Name
  25276. data["org_name"] = miConfig.OrgName
  25277. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25278. data["doctor_id"] = doctor_info.DoctorNumber
  25279. data["new_doctor_name"] = doctor_info.UserName
  25280. data["fixmedins_code"] = miConfig.Code
  25281. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25282. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25283. data["secret_key"] = miConfig.SecretKey
  25284. data["sick_code"] = sickConfig.CountryCode
  25285. data["sick_name"] = sickConfig.ClassName
  25286. data["url"] = miConfig.Url
  25287. data["ak"] = miConfig.AccessKey
  25288. data["begin_time"] = begin_time
  25289. data["cainfo"] = miConfig.Cainfo
  25290. data["dept"] = strconv.FormatInt(department.ID, 10)
  25291. data["config"] = config
  25292. bytesData, _ := json.Marshal(data)
  25293. var req *http.Request
  25294. if miConfig.MdtrtareaAdmvs == "320921" {
  25295. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25296. //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 +
  25297. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25298. } else {
  25299. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25300. }
  25301. resp, _ := client.Do(req)
  25302. defer resp.Body.Close()
  25303. body, ioErr := ioutil.ReadAll(resp.Body)
  25304. if ioErr != nil {
  25305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25307. return
  25308. }
  25309. var respJSON map[string]interface{}
  25310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25313. return
  25314. }
  25315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25316. userJSONBytes, _ := json.Marshal(respJSON)
  25317. fmt.Println("log")
  25318. fmt.Println(string(userJSONBytes))
  25319. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25320. utils.ErrorLog("解析失败:%v", err)
  25321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25322. return
  25323. }
  25324. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25325. res2.Output = ressix10265.Output
  25326. res2.ErrMsg = ressix10265.ErrMsg
  25327. res2.Cainfo = ressix10265.Cainfo
  25328. res2.WarnMsg = ressix10265.WarnMsg
  25329. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25330. res2.Infcode = infocode
  25331. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25332. data := make(map[string]interface{})
  25333. client := &http.Client{}
  25334. data["psn_no"] = his.PsnNo
  25335. data["mdtrt_id"] = his.Number
  25336. data["doctor"] = roles.UserName
  25337. data["department"] = department.Name
  25338. data["org_name"] = miConfig.OrgName
  25339. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25340. data["doctor_id"] = doctor_info.DoctorNumber
  25341. data["new_doctor_name"] = doctor_info.UserName
  25342. data["fixmedins_code"] = miConfig.Code
  25343. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25344. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25345. data["secret_key"] = miConfig.SecretKey
  25346. data["sick_code"] = sickConfig.CountryCode
  25347. data["sick_name"] = sickConfig.ClassName
  25348. data["url"] = miConfig.Url
  25349. data["ak"] = miConfig.AccessKey
  25350. data["begin_time"] = begin_time
  25351. data["cainfo"] = miConfig.Cainfo
  25352. data["dept"] = strconv.FormatInt(department.ID, 10)
  25353. data["config"] = config
  25354. bytesData, _ := json.Marshal(data)
  25355. var req *http.Request
  25356. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25357. resp, _ := client.Do(req)
  25358. defer resp.Body.Close()
  25359. body, ioErr := ioutil.ReadAll(resp.Body)
  25360. if ioErr != nil {
  25361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25363. return
  25364. }
  25365. var respJSON map[string]interface{}
  25366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25369. return
  25370. }
  25371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25372. userJSONBytes, _ := json.Marshal(respJSON)
  25373. fmt.Println("log")
  25374. fmt.Println(string(userJSONBytes))
  25375. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25376. utils.ErrorLog("解析失败:%v", err)
  25377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25378. return
  25379. }
  25380. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25381. res2.Output = ressix10265.Output
  25382. res2.ErrMsg = ressix10265.ErrMsg
  25383. res2.Cainfo = ressix10265.Cainfo
  25384. res2.WarnMsg = ressix10265.WarnMsg
  25385. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25386. res2.Infcode = infocode
  25387. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25388. 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)
  25389. saveLog(result, requestLog, "2203", "上传就诊信息")
  25390. var respJSON2 map[string]interface{}
  25391. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25394. return
  25395. }
  25396. userJSONBytes2, _ := json.Marshal(respJSON2)
  25397. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25398. utils.ErrorLog("解析失败:%v", err)
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25400. return
  25401. }
  25402. 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)
  25403. fmt.Println(result2)
  25404. fmt.Println(src_request)
  25405. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25406. data := make(map[string]interface{})
  25407. client := &http.Client{}
  25408. data["psn_no"] = his.PsnNo
  25409. data["mdtrt_id"] = his.Number
  25410. data["doctor"] = roles.UserName
  25411. data["department"] = department.Name
  25412. data["org_name"] = miConfig.OrgName
  25413. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25414. data["doctor_id"] = doctor_info.DoctorNumber
  25415. data["new_doctor_name"] = doctor_info.UserName
  25416. data["fixmedins_code"] = miConfig.Code
  25417. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25418. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25419. data["secret_key"] = miConfig.SecretKey
  25420. data["sick_code"] = sickConfig.CountryCode
  25421. data["sick_name"] = sickConfig.ClassName
  25422. data["url"] = miConfig.Url
  25423. data["ak"] = miConfig.AccessKey
  25424. data["begin_time"] = begin_time
  25425. data["cainfo"] = miConfig.Cainfo
  25426. data["dept"] = strconv.FormatInt(department.ID, 10)
  25427. data["config"] = config
  25428. bytesData, _ := json.Marshal(data)
  25429. var req *http.Request
  25430. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25431. resp, _ := client.Do(req)
  25432. defer resp.Body.Close()
  25433. body, ioErr := ioutil.ReadAll(resp.Body)
  25434. if ioErr != nil {
  25435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25437. return
  25438. }
  25439. var respJSON map[string]interface{}
  25440. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25443. return
  25444. }
  25445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25446. userJSONBytes, _ := json.Marshal(respJSON)
  25447. fmt.Println("log")
  25448. fmt.Println(string(userJSONBytes))
  25449. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25450. utils.ErrorLog("解析失败:%v", err)
  25451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25452. return
  25453. }
  25454. } else {
  25455. if miConfig.MdtrtareaAdmvs == "440781" { //
  25456. 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)
  25457. } else {
  25458. if miConfig.Code == "H15049901371" {
  25459. //赤峰地区国家医保医疗类别
  25460. //职工透析:医疗类别选特殊情况门诊990502
  25461. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25462. var med_type string
  25463. if his.Insutype == "390" {
  25464. if reg_type == 14 {
  25465. med_type = "9933"
  25466. } else if reg_type == 11 {
  25467. med_type = "11"
  25468. }
  25469. } else if his.Insutype == "310" {
  25470. if reg_type == 14 {
  25471. med_type = "990502"
  25472. } else if reg_type == 11 {
  25473. med_type = "11"
  25474. }
  25475. }
  25476. 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)
  25477. } else {
  25478. 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)
  25479. }
  25480. }
  25481. saveLog(result, requestLog, "2203", "上传就诊信息")
  25482. var respJSON2 map[string]interface{}
  25483. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25486. return
  25487. }
  25488. userJSONBytes2, _ := json.Marshal(respJSON2)
  25489. if miConfig.Code == "H15049901371" {
  25490. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25491. utils.ErrorLog("解析失败:%v", err)
  25492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25493. return
  25494. }
  25495. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25496. res2.Output = ressix10265.Output
  25497. res2.ErrMsg = ressix10265.ErrMsg
  25498. res2.Cainfo = ressix10265.Cainfo
  25499. res2.WarnMsg = ressix10265.WarnMsg
  25500. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25501. res2.Infcode = infocode
  25502. } else {
  25503. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25504. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25505. utils.ErrorLog("解析失败:%v", err)
  25506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25507. return
  25508. }
  25509. res2.Infcode = res3.Infcode
  25510. } else {
  25511. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25512. utils.ErrorLog("解析失败:%v", err)
  25513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25514. return
  25515. }
  25516. }
  25517. }
  25518. }
  25519. if res2.Infcode == -1 {
  25520. adminUser := c.GetAdminUserInfo()
  25521. errlog := &models.HisOrderError{
  25522. UserOrgId: adminUser.CurrentOrgId,
  25523. Ctime: time.Now().Unix(),
  25524. Mtime: time.Now().Unix(),
  25525. ErrMsg: res2.ErrMsg,
  25526. Status: 1,
  25527. PatientId: id,
  25528. RecordTime: recordDateTime,
  25529. Stage: 3,
  25530. }
  25531. service.CreateErrMsgLog(errlog)
  25532. c.ServeSuccessJSON(map[string]interface{}{
  25533. "failed_code": -10,
  25534. "msg": res2.ErrMsg,
  25535. })
  25536. return
  25537. } else {
  25538. his.Diagnosis = diagnosis_id
  25539. his.SickType = sickConfig.ID
  25540. //var p_type int64
  25541. //if reg_type == 1111 || reg_type == 1112 {
  25542. // p_type = 11
  25543. //
  25544. //}
  25545. his.PType = fmt.Sprintf("%d", reg_type)
  25546. service.UpdateHisPatientThree(&his)
  25547. data := make(map[string]interface{})
  25548. if settle_accounts_type == 1 { //日结
  25549. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25550. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25551. } else {
  25552. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25553. }
  25554. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25555. data["pre"] = prescriptions
  25556. } else { //月结
  25557. start_time_str := c.GetString("start_time")
  25558. end_time_str := c.GetString("end_time")
  25559. timeLayout := "2006-01-02"
  25560. loc, _ := time.LoadLocation("Local")
  25561. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25562. if err != nil {
  25563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25564. return
  25565. }
  25566. recordStartTime := theStartTime.Unix()
  25567. start_time = recordStartTime
  25568. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25569. if err != nil {
  25570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25571. return
  25572. }
  25573. recordEndTime := theEndTime.Unix()
  25574. end_time = recordEndTime
  25575. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25576. data["pre"] = prescriptions
  25577. }
  25578. timestamp := time.Now().Unix()
  25579. tempTime := time.Unix(timestamp, 0)
  25580. timeFormat := tempTime.Format("20060102150405")
  25581. chrgBchno := rand.Intn(100000) + 10000
  25582. new_chrg_bchno := ""
  25583. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25584. new_chrg_bchno = chrg_bchno
  25585. strconv.FormatInt(his.PatientId, 10)
  25586. client := &http.Client{}
  25587. if adminUser.CurrentOrgId == 10265 {
  25588. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25589. new_chrg_bchno = "0000"
  25590. }
  25591. }
  25592. data["psn_no"] = his.PsnNo
  25593. data["mdtrt_id"] = his.Number
  25594. data["chrg_bchno"] = new_chrg_bchno
  25595. data["org_name"] = miConfig.OrgName
  25596. data["doctor"] = doctor_info.UserName
  25597. data["doctor_id"] = doctor_info.DoctorNumber
  25598. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25599. data["fixmedins_code"] = miConfig.Code
  25600. data["dept_code"] = department.Number
  25601. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25602. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25603. data["secret_key"] = miConfig.SecretKey
  25604. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25605. data["url"] = miConfig.Url
  25606. data["ak"] = miConfig.AccessKey
  25607. data["new_doctor_name"] = patientPrescription.Doctor
  25608. data["diag_code"] = sickConfig.CountryCode
  25609. data["cainfo"] = miConfig.Cainfo
  25610. data["opter"] = roles.UserName
  25611. var ids []int64
  25612. for _, item := range prescriptions {
  25613. ids = append(ids, item.ID)
  25614. }
  25615. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25616. if config.IsOpen == 1 { //对接了医保,走医保流程
  25617. var res ResultFour
  25618. var resFour10265 ResultFour10265
  25619. if miConfig.MdtrtareaAdmvs == "421300" {
  25620. bytesData, _ := json.Marshal(data)
  25621. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25622. resp, _ := client.Do(req)
  25623. defer resp.Body.Close()
  25624. body, ioErr := ioutil.ReadAll(resp.Body)
  25625. if ioErr != nil {
  25626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25628. return
  25629. }
  25630. var respJSON map[string]interface{}
  25631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25634. return
  25635. }
  25636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25637. userJSONBytes, _ := json.Marshal(respJSON)
  25638. fmt.Println("log")
  25639. fmt.Println(string(userJSONBytes))
  25640. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25641. utils.ErrorLog("解析失败:%v", err)
  25642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25643. return
  25644. }
  25645. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25646. bytesData, _ := json.Marshal(data)
  25647. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25648. resp, _ := client.Do(req)
  25649. defer resp.Body.Close()
  25650. body, ioErr := ioutil.ReadAll(resp.Body)
  25651. if ioErr != nil {
  25652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25654. return
  25655. }
  25656. var respJSON map[string]interface{}
  25657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25660. return
  25661. }
  25662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25663. userJSONBytes, _ := json.Marshal(respJSON)
  25664. fmt.Println("log")
  25665. fmt.Println(string(userJSONBytes))
  25666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25667. utils.ErrorLog("解析失败:%v", err)
  25668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25669. return
  25670. }
  25671. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25672. bytesData, _ := json.Marshal(data)
  25673. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25674. resp, _ := client.Do(req)
  25675. defer resp.Body.Close()
  25676. body, ioErr := ioutil.ReadAll(resp.Body)
  25677. if ioErr != nil {
  25678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25680. return
  25681. }
  25682. var respJSON map[string]interface{}
  25683. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25686. return
  25687. }
  25688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25689. userJSONBytes, _ := json.Marshal(respJSON)
  25690. fmt.Println("log")
  25691. fmt.Println(string(userJSONBytes))
  25692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25693. utils.ErrorLog("解析失败:%v", err)
  25694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25695. return
  25696. }
  25697. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25698. bytesData, _ := json.Marshal(data)
  25699. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25700. resp, _ := client.Do(req)
  25701. defer resp.Body.Close()
  25702. body, ioErr := ioutil.ReadAll(resp.Body)
  25703. if ioErr != nil {
  25704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25706. return
  25707. }
  25708. var respJSON map[string]interface{}
  25709. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25712. return
  25713. }
  25714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25715. userJSONBytes, _ := json.Marshal(respJSON)
  25716. fmt.Println("log")
  25717. fmt.Println(string(userJSONBytes))
  25718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25719. utils.ErrorLog("解析失败:%v", err)
  25720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25721. return
  25722. }
  25723. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25724. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25725. if result3101.Infcode == "0" {
  25726. if len(result3101.Output.Result) > 0 {
  25727. var errMsgs []string
  25728. for _, item := range result3101.Output.Result {
  25729. errMsgs = append(errMsgs, item.VolaCont)
  25730. }
  25731. c.ServeSuccessJSON(map[string]interface{}{
  25732. "failed_code": -10,
  25733. "msg": errMsgs,
  25734. })
  25735. return
  25736. }
  25737. }
  25738. bytesData, _ := json.Marshal(data)
  25739. var req *http.Request
  25740. if miConfig.MdtrtareaAdmvs == "320921" {
  25741. data["diag_code"] = sickConfig.CountryCode
  25742. fmt.Println(data)
  25743. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25744. } else {
  25745. data["diag_code"] = sickConfig.CountryCode
  25746. fmt.Println(data)
  25747. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25748. }
  25749. resp, _ := client.Do(req)
  25750. defer resp.Body.Close()
  25751. body, ioErr := ioutil.ReadAll(resp.Body)
  25752. if ioErr != nil {
  25753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25755. return
  25756. }
  25757. var respJSON map[string]interface{}
  25758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25764. userJSONBytes, _ := json.Marshal(respJSON)
  25765. fmt.Println("log")
  25766. fmt.Println(string(userJSONBytes))
  25767. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25768. utils.ErrorLog("解析失败:%v", err)
  25769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25770. return
  25771. }
  25772. res.InfRefmsgid = resFour10265.InfRefmsgid
  25773. res.Output = resFour10265.Output
  25774. res.ErrMsg = resFour10265.ErrMsg
  25775. res.Cainfo = resFour10265.Cainfo
  25776. res.WarnMsg = resFour10265.WarnMsg
  25777. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25778. res.Infcode = infocode
  25779. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25780. var pagesize int = 2
  25781. var start int = 1
  25782. var stop int
  25783. var pagecount int
  25784. var curpage int
  25785. var isSuccess bool = true
  25786. data["doctor_id"] = doctor_info.DoctorNumber
  25787. //总页数,向上取整,注意除之前要先转换类型为float64
  25788. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25789. for curpage = 1; curpage <= pagecount; curpage++ {
  25790. if curpage == 1 {
  25791. start = 1
  25792. } else {
  25793. start = (curpage-1)*pagesize + 1
  25794. }
  25795. stop = curpage * pagesize
  25796. if stop > len(prescriptions) {
  25797. stop = len(prescriptions)
  25798. }
  25799. //var requestLog string
  25800. data["pre"] = prescriptions[start-1 : stop]
  25801. fmt.Println(data["pre"])
  25802. bytesData, _ := json.Marshal(data)
  25803. var req *http.Request
  25804. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25805. resp, _ := client.Do(req)
  25806. defer resp.Body.Close()
  25807. body, ioErr := ioutil.ReadAll(resp.Body)
  25808. if ioErr != nil {
  25809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25811. return
  25812. }
  25813. var respJSON map[string]interface{}
  25814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25817. return
  25818. }
  25819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25820. userJSONBytes, _ := json.Marshal(respJSON)
  25821. fmt.Println("log")
  25822. fmt.Println(string(userJSONBytes))
  25823. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25824. utils.ErrorLog("解析失败:%v", err)
  25825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25826. return
  25827. }
  25828. res.InfRefmsgid = resFour10265.InfRefmsgid
  25829. res.Output = resFour10265.Output
  25830. res.ErrMsg = resFour10265.ErrMsg
  25831. res.Cainfo = resFour10265.Cainfo
  25832. res.WarnMsg = resFour10265.WarnMsg
  25833. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25834. res.Infcode = infocode
  25835. if infocode == 0 {
  25836. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25837. } else {
  25838. isSuccess = false
  25839. errlog := &models.HisOrderError{
  25840. UserOrgId: adminUser.CurrentOrgId,
  25841. Ctime: time.Now().Unix(),
  25842. Mtime: time.Now().Unix(),
  25843. Number: chrg_bchno,
  25844. ErrMsg: "",
  25845. Status: 1,
  25846. PatientId: id,
  25847. RecordTime: recordDateTime,
  25848. Stage: 4,
  25849. }
  25850. service.CreateErrMsgLog(errlog)
  25851. c.ServeSuccessJSON(map[string]interface{}{
  25852. "failed_code": -10,
  25853. "msg": res.ErrMsg,
  25854. })
  25855. return
  25856. }
  25857. }
  25858. if isSuccess {
  25859. res.Infcode = 0
  25860. }
  25861. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25862. 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)
  25863. var dat map[string]interface{}
  25864. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25865. fmt.Println(dat)
  25866. } else {
  25867. fmt.Println(err)
  25868. }
  25869. saveLog(result, request_log, "2204", "上传费用明细")
  25870. userJSONBytes, _ := json.Marshal(dat)
  25871. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25872. utils.ErrorLog("解析失败:%v", err)
  25873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25874. return
  25875. }
  25876. res.InfRefmsgid = resFour10265.InfRefmsgid
  25877. res.Output = resFour10265.Output
  25878. res.ErrMsg = resFour10265.ErrMsg
  25879. res.Cainfo = resFour10265.Cainfo
  25880. res.WarnMsg = resFour10265.WarnMsg
  25881. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25882. res.Infcode = infocode
  25883. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25884. bytesData, _ := json.Marshal(data)
  25885. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25886. resp, _ := client.Do(req)
  25887. defer resp.Body.Close()
  25888. body, ioErr := ioutil.ReadAll(resp.Body)
  25889. if ioErr != nil {
  25890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25892. return
  25893. }
  25894. var respJSON map[string]interface{}
  25895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25898. return
  25899. }
  25900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25901. userJSONBytes, _ := json.Marshal(respJSON)
  25902. fmt.Println("log")
  25903. fmt.Println(string(userJSONBytes))
  25904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25905. utils.ErrorLog("解析失败:%v", err)
  25906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25907. return
  25908. }
  25909. } else {
  25910. if miConfig.Code == "H15049901371" {
  25911. 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)
  25912. var dat map[string]interface{}
  25913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25914. fmt.Println(dat)
  25915. } else {
  25916. fmt.Println(err)
  25917. }
  25918. saveLog(result, request_log, "2204", "上传费用明细")
  25919. userJSONBytes, _ := json.Marshal(dat)
  25920. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25921. utils.ErrorLog("解析失败:%v", err)
  25922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25923. return
  25924. }
  25925. res.InfRefmsgid = resFour10265.InfRefmsgid
  25926. res.Output = resFour10265.Output
  25927. res.ErrMsg = resFour10265.ErrMsg
  25928. res.Cainfo = resFour10265.Cainfo
  25929. res.WarnMsg = resFour10265.WarnMsg
  25930. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25931. res.Infcode = infocode
  25932. } else {
  25933. 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)
  25934. var dat map[string]interface{}
  25935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25936. fmt.Println(dat)
  25937. } else {
  25938. fmt.Println(err)
  25939. }
  25940. saveLog(result, request_log, "2204", "上传费用明细")
  25941. userJSONBytes, _ := json.Marshal(dat)
  25942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25943. utils.ErrorLog("解析失败:%v", err)
  25944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25945. return
  25946. }
  25947. }
  25948. }
  25949. if res.Infcode == 0 {
  25950. order := &models.HisOrder{
  25951. UserOrgId: adminUser.CurrentOrgId,
  25952. HisPatientId: his.ID,
  25953. PatientId: his.PatientId,
  25954. SettleAccountsDate: recordDateTime,
  25955. MdtrtId: his.Number,
  25956. PsnNo: his.PsnNo,
  25957. MedType: strconv.FormatInt(reg_type, 10),
  25958. Ctime: time.Now().Unix(),
  25959. Mtime: time.Now().Unix(),
  25960. Status: 1,
  25961. Number: chrg_bchno,
  25962. Infcode: res.Infcode,
  25963. WarnMsg: res.WarnMsg,
  25964. Cainfo: res.Cainfo,
  25965. ErrMsg: res.ErrMsg,
  25966. RespondTime: res.RefmsgTime,
  25967. InfRefmsgid: res.InfRefmsgid,
  25968. OrderStatus: 1,
  25969. PayWay: pay_way,
  25970. PayWays: pay_ways,
  25971. OthDesc: oth_desc,
  25972. PayPrice: pay_price,
  25973. PayCardNo: pay_card_no,
  25974. DiscountPrice: discount_price,
  25975. PreferentialPrice: preferential_price,
  25976. RealityPrice: reality_price,
  25977. FoundPrice: found_price,
  25978. MedicalInsurancePrice: medical_insurance_price,
  25979. PrivatePrice: private_price,
  25980. IsMedicineInsurance: 1,
  25981. SettleType: settle_accounts_type,
  25982. SettleStartTime: start_time,
  25983. SettleEndTime: end_time,
  25984. Creator: roles.AdminUserId,
  25985. Modify: roles.AdminUserId,
  25986. FaPiaoNumber: fapiao_number,
  25987. FaPiaoCode: fapiao_code,
  25988. PType: 2,
  25989. Diagnosis: diagnosis_id,
  25990. CashPay: cash_pay,
  25991. WechatPay: wechat_pay,
  25992. AliPay: ali_pay,
  25993. JifenPay: jifen_pay,
  25994. BandCardPay: band_card_pay,
  25995. }
  25996. err = service.CreateOrder(order)
  25997. if err != nil {
  25998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25999. return
  26000. }
  26001. for _, item := range res.Output.Result {
  26002. temp := strings.Split(item.FeedetlSn, "-")
  26003. var advice_id int64 = 0
  26004. var project_id int64 = 0
  26005. var types int64 = 0
  26006. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26007. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26008. if temp[1] == "1" {
  26009. advice_id = id
  26010. project_id = 0
  26011. } else if temp[1] == "2" {
  26012. advice_id = 0
  26013. project_id = id
  26014. }
  26015. if item.MedChrgitmType == "9" {
  26016. item.MedChrgitmType = "09"
  26017. }
  26018. info := &models.HisOrderInfo{
  26019. OrderNumber: order.Number,
  26020. FeedetlSn: item.FeedetlSn,
  26021. UploadDate: time.Now().Unix(),
  26022. AdviceId: advice_id,
  26023. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26024. Cnt: item.Cnt,
  26025. Pric: float64(item.Pric),
  26026. PatientId: his.PatientId,
  26027. PricUplmtAmt: item.PricUplmtAmt,
  26028. SelfpayProp: item.SelfpayProp,
  26029. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26030. OverlmtAmt: item.OverlmtAmt,
  26031. PreselfpayAmt: item.PreselfpayAmt,
  26032. BasMednFlag: item.BasMednFlag,
  26033. MedChrgitmType: item.MedChrgitmType,
  26034. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26035. Status: 1,
  26036. Memo: item.Memo,
  26037. Mtime: time.Now().Unix(),
  26038. InscpScpAmt: item.InscpScpAmt,
  26039. DrtReimFlag: item.DrtReimFlag,
  26040. Ctime: time.Now().Unix(),
  26041. ListSpItemFlag: item.ListSpItemFlag,
  26042. ChldMedcFlag: item.ChldMedcFlag,
  26043. LmtUsedFlag: item.LmtUsedFlag,
  26044. ChrgitmLv: item.ChrgitmLv,
  26045. UserOrgId: adminUser.CurrentOrgId,
  26046. HisPatientId: his.ID,
  26047. OrderId: order.ID,
  26048. ProjectId: project_id,
  26049. Type: types,
  26050. }
  26051. service.CreateOrderInfo(info)
  26052. }
  26053. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  26054. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  26055. var total float64
  26056. for _, item := range prescriptions {
  26057. if item.Type == 1 { //药品
  26058. for _, subItem := range item.HisDoctorAdviceInfo {
  26059. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26060. total_one := price * subItem.PrescribingNumber
  26061. total = total + total_one
  26062. }
  26063. }
  26064. if item.Type == 2 { //项目
  26065. for _, subItem := range item.HisPrescriptionProject {
  26066. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  26067. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26068. total_one := price * cnt
  26069. total = total + total_one
  26070. }
  26071. }
  26072. }
  26073. allTotal := fmt.Sprintf("%.2f", total)
  26074. //if adminUser.CurrentOrgId == 9919 {
  26075. //
  26076. // allTotal = fmt.Sprintf("%.2f", total)
  26077. //
  26078. //} else {
  26079. //
  26080. // allTotal = fmt.Sprintf("%.2f", total)
  26081. //
  26082. //}
  26083. if res.Infcode == 0 {
  26084. var rf []*ResultFive
  26085. json.Unmarshal([]byte(his.Iinfo), &rf)
  26086. chrg_bchno := chrg_bchno
  26087. cert_no := his.Certno
  26088. var insutypes []string
  26089. var insutype string
  26090. var is390 int = 0
  26091. var is310 int = 0
  26092. for _, item := range rf {
  26093. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26094. insutypes = append(insutypes, item.Insutype)
  26095. }
  26096. }
  26097. if len(insutypes) == 1 {
  26098. insutype = insutypes[0]
  26099. } else {
  26100. for _, i := range insutypes {
  26101. if i == "390" {
  26102. is390 = 1
  26103. }
  26104. if i == "310" {
  26105. is310 = 1
  26106. }
  26107. }
  26108. }
  26109. if is390 == 1 {
  26110. insutype = "390"
  26111. }
  26112. if is310 == 1 {
  26113. insutype = "310"
  26114. }
  26115. if len(insutypes) == 0 {
  26116. insutype = "310"
  26117. }
  26118. if len(insutypes) == 2 {
  26119. insutype = strconv.FormatInt(his.SocialType, 10)
  26120. }
  26121. insutype = strconv.FormatInt(his.SocialType, 10)
  26122. //insutype = "390"
  26123. if his.IdCardType == 1 {
  26124. // cert_no = his.MedicalInsuranceNumber
  26125. cert_no = his.Certno
  26126. } else {
  26127. cert_no = his.Certno
  26128. }
  26129. var res ResultSeven
  26130. var resSeven10265 ResultSeven10265
  26131. var gzresSeven10265Two GZResultSeven10265Two
  26132. var src_resquest string
  26133. var result2 string
  26134. if miConfig.MdtrtareaAdmvs == "421300" {
  26135. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26141. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26142. resp, requestErr := http.Get(api)
  26143. if requestErr != nil {
  26144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26145. return
  26146. }
  26147. body, ioErr := ioutil.ReadAll(resp.Body)
  26148. if ioErr != nil {
  26149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26151. return
  26152. }
  26153. var respJSON map[string]interface{}
  26154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26157. return
  26158. }
  26159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26160. result, _ := json.Marshal(respJSON)
  26161. if miConfig.Code == "H15049901371" {
  26162. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26163. utils.ErrorLog("解析失败:%v", err)
  26164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26165. return
  26166. }
  26167. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26168. res.Output = resSeven10265.Output
  26169. res.ErrMsg = resSeven10265.ErrMsg
  26170. res.Cainfo = resSeven10265.Cainfo
  26171. res.WarnMsg = resSeven10265.WarnMsg
  26172. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26173. res.Infcode = infocode
  26174. } else {
  26175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26176. utils.ErrorLog("解析失败:%v", err)
  26177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26178. return
  26179. }
  26180. }
  26181. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26182. if reg_type == 11 && his.Insutype == "390" {
  26183. reg_type = 110104
  26184. }
  26185. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26186. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26187. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26189. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26190. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26191. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26192. resp, requestErr := http.Get(api)
  26193. if requestErr != nil {
  26194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26195. return
  26196. }
  26197. body, ioErr := ioutil.ReadAll(resp.Body)
  26198. if ioErr != nil {
  26199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26201. return
  26202. }
  26203. var respJSON map[string]interface{}
  26204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26207. return
  26208. }
  26209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26210. result, _ := json.Marshal(respJSON)
  26211. if miConfig.Code == "H15049901371" {
  26212. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26213. utils.ErrorLog("解析失败:%v", err)
  26214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26215. return
  26216. }
  26217. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26218. res.Output = resSeven10265.Output
  26219. res.ErrMsg = resSeven10265.ErrMsg
  26220. res.Cainfo = resSeven10265.Cainfo
  26221. res.WarnMsg = resSeven10265.WarnMsg
  26222. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26223. res.Infcode = infocode
  26224. } else {
  26225. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26226. utils.ErrorLog("解析失败:%v", err)
  26227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26228. return
  26229. }
  26230. }
  26231. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26232. if reg_type == 11 && his.Insutype == "390" {
  26233. reg_type = 110104
  26234. }
  26235. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26236. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26237. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26239. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26240. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26241. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26242. resp, requestErr := http.Get(api)
  26243. if requestErr != nil {
  26244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26245. return
  26246. }
  26247. body, ioErr := ioutil.ReadAll(resp.Body)
  26248. if ioErr != nil {
  26249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26251. return
  26252. }
  26253. var respJSON map[string]interface{}
  26254. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26257. return
  26258. }
  26259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26260. result, _ := json.Marshal(respJSON)
  26261. if miConfig.Code == "H15049901371" {
  26262. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26263. utils.ErrorLog("解析失败:%v", err)
  26264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26265. return
  26266. }
  26267. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26268. res.Output = resSeven10265.Output
  26269. res.ErrMsg = resSeven10265.ErrMsg
  26270. res.Cainfo = resSeven10265.Cainfo
  26271. res.WarnMsg = resSeven10265.WarnMsg
  26272. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26273. res.Infcode = infocode
  26274. } else {
  26275. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26276. utils.ErrorLog("解析失败:%v", err)
  26277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26278. return
  26279. }
  26280. }
  26281. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26282. if reg_type == 11 && his.Insutype == "390" {
  26283. reg_type = 110104
  26284. }
  26285. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26286. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26287. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26288. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26289. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26290. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26291. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26292. resp, requestErr := http.Get(api)
  26293. if requestErr != nil {
  26294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26295. return
  26296. }
  26297. body, ioErr := ioutil.ReadAll(resp.Body)
  26298. if ioErr != nil {
  26299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26301. return
  26302. }
  26303. var respJSON map[string]interface{}
  26304. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26307. return
  26308. }
  26309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26310. result, _ := json.Marshal(respJSON)
  26311. if miConfig.Code == "H15049901371" {
  26312. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26313. utils.ErrorLog("解析失败:%v", err)
  26314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26315. return
  26316. }
  26317. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26318. res.Output = resSeven10265.Output
  26319. res.ErrMsg = resSeven10265.ErrMsg
  26320. res.Cainfo = resSeven10265.Cainfo
  26321. res.WarnMsg = resSeven10265.WarnMsg
  26322. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26323. res.Infcode = infocode
  26324. } else {
  26325. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26326. utils.ErrorLog("解析失败:%v", err)
  26327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26328. return
  26329. }
  26330. }
  26331. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26332. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26333. if result3101.Infcode == "0" {
  26334. if len(result3101.Output.Result) > 0 {
  26335. var errMsgs []string
  26336. for _, item := range result3101.Output.Result {
  26337. errMsgs = append(errMsgs, item.VolaCont)
  26338. }
  26339. c.ServeSuccessJSON(map[string]interface{}{
  26340. "failed_code": -10,
  26341. "msg": errMsgs,
  26342. })
  26343. return
  26344. } else {
  26345. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26346. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26347. bas := strings.Split(psn_info.CardInfo, "|")
  26348. if his.IdCardType == 1 {
  26349. cert_no = bas[2]
  26350. } else if his.IdCardType == 3 {
  26351. cert_no = his.Certno
  26352. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26353. } else if his.IdCardType == 4 {
  26354. cert_no = his.Certno
  26355. psn_info.VerifyNumber = psn_info.VerifyNumber
  26356. }
  26357. var api string
  26358. if miConfig.MdtrtareaAdmvs == "320921" {
  26359. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26360. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26361. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26362. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26363. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26364. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26365. "&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
  26366. } else {
  26367. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26368. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26369. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26370. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26371. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26372. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26373. "&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
  26374. }
  26375. resp, requestErr := http.Get(api)
  26376. if requestErr != nil {
  26377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26378. return
  26379. }
  26380. body, ioErr := ioutil.ReadAll(resp.Body)
  26381. if ioErr != nil {
  26382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26384. return
  26385. }
  26386. var respJSON map[string]interface{}
  26387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26390. return
  26391. }
  26392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26393. result, _ := json.Marshal(respJSON)
  26394. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26395. utils.ErrorLog("解析失败:%v", err)
  26396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26397. return
  26398. }
  26399. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26400. res.Output = resSeven10265.Output
  26401. res.ErrMsg = resSeven10265.ErrMsg
  26402. res.Cainfo = resSeven10265.Cainfo
  26403. res.WarnMsg = resSeven10265.WarnMsg
  26404. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26405. res.Infcode = infocode
  26406. }
  26407. }
  26408. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26409. psn_info, _ := service.GetPsnByPatientId(id)
  26410. var verify_number string
  26411. if psn_info.IdCardType == 4 {
  26412. verify_number = psn_info.VerifyNumber
  26413. } else if psn_info.IdCardType == 1 {
  26414. bas := strings.Split(psn_info.CardInfo, "|")
  26415. cardNumber := bas[2]
  26416. verify_number = cardNumber
  26417. } else {
  26418. psn_info.IdCardType = 2
  26419. verify_number = psn_info.Certno
  26420. }
  26421. var api string
  26422. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26423. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26424. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26425. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26426. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26427. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26428. "&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
  26429. resp, requestErr := http.Get(api)
  26430. if requestErr != nil {
  26431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26432. return
  26433. }
  26434. body, ioErr := ioutil.ReadAll(resp.Body)
  26435. if ioErr != nil {
  26436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26438. return
  26439. }
  26440. var respJSON map[string]interface{}
  26441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26444. return
  26445. }
  26446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26447. result, _ := json.Marshal(respJSON)
  26448. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26449. utils.ErrorLog("解析失败:%v", err)
  26450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26451. return
  26452. }
  26453. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26454. res.Output = resSeven10265.Output
  26455. res.ErrMsg = resSeven10265.ErrMsg
  26456. res.Cainfo = resSeven10265.Cainfo
  26457. res.WarnMsg = resSeven10265.WarnMsg
  26458. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26459. res.Infcode = infocode
  26460. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26461. var cert_no string
  26462. if his.IdCardType == 4 {
  26463. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26464. cert_no = psn_info.VerifyNumber
  26465. 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)
  26466. } else if his.IdCardType == 1 {
  26467. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26468. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26469. 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)
  26470. }
  26471. //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)
  26472. var dat map[string]interface{}
  26473. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26474. fmt.Println(dat)
  26475. } else {
  26476. fmt.Println(err)
  26477. }
  26478. saveLog(result2, src_resquest, "2207", "结算")
  26479. userJSONBytes, _ := json.Marshal(dat)
  26480. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26481. utils.ErrorLog("解析失败:%v", err)
  26482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26483. return
  26484. }
  26485. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26486. res.Output = resSeven10265.Output
  26487. res.ErrMsg = resSeven10265.ErrMsg
  26488. res.Cainfo = resSeven10265.Cainfo
  26489. res.WarnMsg = resSeven10265.WarnMsg
  26490. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26491. res.Infcode = infocode
  26492. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26493. res2 := c.GetoleInfo()
  26494. if res2.Infcode == 0 {
  26495. var result string
  26496. var request_log string
  26497. var result_log string
  26498. if res2.Output.MdtrtCertType == "02" {
  26499. 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)
  26500. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26501. } else if res2.Output.MdtrtCertType == "01" {
  26502. 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)
  26503. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26504. } else {
  26505. 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)
  26506. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26507. }
  26508. var dat map[string]interface{}
  26509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26510. fmt.Println(dat)
  26511. } else {
  26512. fmt.Println(err)
  26513. }
  26514. userJSONBytes, _ := json.Marshal(dat)
  26515. var res5 ResultTwo
  26516. //var resTwo10265 ResultTwo10265
  26517. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26518. utils.ErrorLog("解析失败:%v", err)
  26519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26520. return
  26521. }
  26522. if res5.Infcode == -1 {
  26523. c.ServeSuccessJSON(map[string]interface{}{
  26524. "failed_code": -10,
  26525. "msg": res5.ErrMsg,
  26526. })
  26527. return
  26528. }
  26529. var insutypes []string
  26530. var insutype string
  26531. var is390 int = 0
  26532. var is310 int = 0
  26533. for _, item := range res5.Output.Iinfo {
  26534. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26535. insutypes = append(insutypes, item.Insutype)
  26536. }
  26537. }
  26538. if len(insutypes) == 1 {
  26539. insutype = insutypes[0]
  26540. } else {
  26541. for _, i := range insutypes {
  26542. if i == "390" {
  26543. is390 = 1
  26544. }
  26545. if i == "310" {
  26546. is310 = 1
  26547. }
  26548. }
  26549. }
  26550. if is390 == 1 {
  26551. insutype = "390"
  26552. }
  26553. if is310 == 1 {
  26554. insutype = "310"
  26555. }
  26556. if len(insutypes) == 0 {
  26557. insutype = "310"
  26558. }
  26559. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26560. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26561. infoStr := string(Iinfos)
  26562. idetinfoStr := string(Idetinfos)
  26563. psn := &models.HisPsn{
  26564. PsnNo: res5.Output.Baseinfo.PsnNo,
  26565. PatientId: id,
  26566. Certno: res5.Output.Baseinfo.Certno,
  26567. Gend: res5.Output.Baseinfo.Gend,
  26568. Naty: res5.Output.Baseinfo.Naty,
  26569. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26570. PsnName: res5.Output.Baseinfo.PsnName,
  26571. Idetinfo: idetinfoStr,
  26572. Insuinfo: infoStr,
  26573. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26574. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26575. VerifyNumber: res2.Output.EcToken,
  26576. }
  26577. if res2.Output.MdtrtCertType == "01" {
  26578. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26579. psn.VerifyNumber = res2.Output.EcToken
  26580. } else if res2.Output.MdtrtCertType == "02" {
  26581. psn.VerifyNumber = res2.Output.CardNo
  26582. } else {
  26583. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26584. }
  26585. service.CreateHisPsn(psn)
  26586. if res2.Output.MdtrtCertType == "01" {
  26587. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26588. token := res2.Output.EcToken
  26589. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  26590. } else if res2.Output.MdtrtCertType == "02" {
  26591. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  26592. } else {
  26593. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  26594. }
  26595. var dat2 map[string]interface{}
  26596. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26597. fmt.Println(dat2)
  26598. } else {
  26599. fmt.Println(err)
  26600. }
  26601. userJSONBytes3, _ := json.Marshal(dat2)
  26602. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26603. utils.ErrorLog("解析失败:%v", err)
  26604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26605. return
  26606. }
  26607. saveLog(result2, src_resquest, "2207", "结算")
  26608. } else {
  26609. c.ServeSuccessJSON(map[string]interface{}{
  26610. "failed_code": -10,
  26611. "msg": res2.ErrMsg,
  26612. })
  26613. return
  26614. }
  26615. } else {
  26616. if miConfig.Code == "H15049901371" {
  26617. //赤峰地区国家医保医疗类别
  26618. //职工透析:医疗类别选特殊情况门诊990502
  26619. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26620. var med_type string
  26621. if his.Insutype == "390" {
  26622. if reg_type == 14 {
  26623. med_type = "9933"
  26624. } else if reg_type == 11 {
  26625. med_type = "11"
  26626. }
  26627. } else if his.Insutype == "310" {
  26628. if reg_type == 14 {
  26629. med_type = "990502"
  26630. } else if reg_type == 11 {
  26631. med_type = "11"
  26632. }
  26633. }
  26634. 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)
  26635. } else {
  26636. if his.IdCardType == 4 {
  26637. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26638. var token string
  26639. token = psn_info.VerifyNumber
  26640. 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)
  26641. } else {
  26642. if his.IdCardType == 1 {
  26643. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26644. bas := strings.Split(psn_info.CardInfo, "|")
  26645. basNumber := bas[2]
  26646. cert_no = basNumber
  26647. }
  26648. 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)
  26649. }
  26650. }
  26651. //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)
  26652. var dat map[string]interface{}
  26653. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26654. fmt.Println(dat)
  26655. } else {
  26656. fmt.Println(err)
  26657. }
  26658. saveLog(result2, src_resquest, "2207", "结算")
  26659. userJSONBytes, _ := json.Marshal(dat)
  26660. if miConfig.Code == "H15049901371" {
  26661. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26662. utils.ErrorLog("解析失败:%v", err)
  26663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26664. return
  26665. }
  26666. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26667. res.Output = resSeven10265.Output
  26668. res.ErrMsg = resSeven10265.ErrMsg
  26669. res.Cainfo = resSeven10265.Cainfo
  26670. res.WarnMsg = resSeven10265.WarnMsg
  26671. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26672. res.Infcode = infocode
  26673. } else {
  26674. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26675. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26676. utils.ErrorLog("解析失败:%v", err)
  26677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26678. return
  26679. }
  26680. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26681. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26682. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26683. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26684. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26685. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26686. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26687. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26688. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26689. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26690. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26691. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26692. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26693. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26694. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26695. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26696. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26697. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26698. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26699. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26700. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26701. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26702. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26703. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26704. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26705. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26706. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26707. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26708. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26709. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26710. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26711. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26712. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26713. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26714. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26715. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26716. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26717. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26718. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26719. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26720. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26721. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26722. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26723. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26724. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26725. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26726. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26727. res.Cainfo = gzresSeven10265Two.Cainfo
  26728. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26729. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26730. //res.Infcode = infocode
  26731. } else {
  26732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26733. utils.ErrorLog("解析失败:%v", err)
  26734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26735. return
  26736. }
  26737. }
  26738. }
  26739. }
  26740. if res.Infcode == -1 {
  26741. errlog := &models.HisOrderError{
  26742. UserOrgId: adminUser.CurrentOrgId,
  26743. Ctime: time.Now().Unix(),
  26744. Mtime: time.Now().Unix(),
  26745. Number: chrg_bchno,
  26746. ErrMsg: res.ErrMsg,
  26747. Status: 1,
  26748. PatientId: id,
  26749. RecordTime: recordDateTime,
  26750. Stage: 6,
  26751. }
  26752. service.CreateErrMsgLog(errlog)
  26753. c.ServeSuccessJSON(map[string]interface{}{
  26754. "failed_code": -10,
  26755. "msg": res.ErrMsg,
  26756. })
  26757. return
  26758. } else {
  26759. sickConfig, _ := service.FindSickById(his.SickType)
  26760. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26761. order.OrderStatus = 2
  26762. order.Status = 1
  26763. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26764. order.SetlId = res.Output.Setlinfo.SetlID
  26765. order.PsnNo = res.Output.Setlinfo.PsnNo
  26766. order.PsnName = res.Output.Setlinfo.PsnName
  26767. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26768. order.Certno = res.Output.Setlinfo.Certno
  26769. order.Gend = res.Output.Setlinfo.Gend
  26770. order.Naty = res.Output.Setlinfo.Naty
  26771. order.Age = res.Output.Setlinfo.Age
  26772. order.Insutype = res.Output.Setlinfo.Insutype
  26773. order.PsnType = res.Output.Setlinfo.PsnType
  26774. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26775. order.SetlTime = res.Output.Setlinfo.SetlTime
  26776. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26777. if res.Output.Setlinfo.MedType == "140101" {
  26778. order.MedType = "14"
  26779. } else {
  26780. if res.Output.Setlinfo.MedType == "110104" {
  26781. order.MedType = "11"
  26782. } else {
  26783. order.MedType = res.Output.Setlinfo.MedType
  26784. }
  26785. }
  26786. if reg_type == 1112 {
  26787. order.MedType = "1112"
  26788. }
  26789. if reg_type == 1111 {
  26790. order.MedType = "1111"
  26791. }
  26792. order.ClrType = res.Output.Setlinfo.ClrType
  26793. if adminUser.CurrentOrgId == 10480 {
  26794. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26795. order.ClrType = "11"
  26796. } else {
  26797. order.ClrType = "9903"
  26798. }
  26799. }
  26800. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26801. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26802. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26803. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26804. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26805. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26806. order.HifpPay = res.Output.Setlinfo.HifpPay
  26807. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26808. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26809. order.HifesPay = res.Output.Setlinfo.HifesPay
  26810. order.HifobPay = res.Output.Setlinfo.HifobPay
  26811. order.MafPay = res.Output.Setlinfo.MafPay
  26812. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26813. order.OthPay = res.Output.Setlinfo.OthPay
  26814. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26815. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26816. order.AcctPay = res.Output.Setlinfo.AcctPay
  26817. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26818. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26819. order.Balc = res.Output.Setlinfo.Balc
  26820. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26821. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26822. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26823. //order.ClrType = res.Output.Setlinfo.ClrType
  26824. order.ClrWay = res.Output.Setlinfo.ClrWay
  26825. order.Creator = order.Creator
  26826. order.Modify = roles.AdminUserId
  26827. order.RequestLog = src_resquest
  26828. order.FaPiaoNumber = fapiao_number
  26829. order.FaPiaoCode = fapiao_code
  26830. order.SickName = sickConfig.ClassName
  26831. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26832. //detailStr := string(setlDetail)
  26833. //order.SetlDetail = detailStr
  26834. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26835. err = service.UpDateOrder(order)
  26836. if err == nil {
  26837. //判断是否使用了押金
  26838. if dec_way == "true" {
  26839. tmpstring := strconv.FormatInt(order.ID, 10)
  26840. order.Decimal = decimal
  26841. service.UpDateOrder(order)
  26842. //扣押金
  26843. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26844. if errmsg != nil {
  26845. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26846. return
  26847. }
  26848. }
  26849. c.ServeSuccessJSON(map[string]interface{}{
  26850. "msg": "结算成功",
  26851. })
  26852. } else {
  26853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26854. return
  26855. }
  26856. }
  26857. } else {
  26858. adminUser := c.GetAdminUserInfo()
  26859. errlog := &models.HisOrderError{
  26860. UserOrgId: adminUser.CurrentOrgId,
  26861. Ctime: time.Now().Unix(),
  26862. Mtime: time.Now().Unix(),
  26863. ErrMsg: res.ErrMsg,
  26864. Status: 1,
  26865. PatientId: id,
  26866. RecordTime: recordDateTime,
  26867. Stage: 4,
  26868. }
  26869. service.CreateErrMsgLog(errlog)
  26870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26871. return
  26872. }
  26873. } else {
  26874. adminUser := c.GetAdminUserInfo()
  26875. errlog := &models.HisOrderError{
  26876. UserOrgId: adminUser.CurrentOrgId,
  26877. Ctime: time.Now().Unix(),
  26878. Mtime: time.Now().Unix(),
  26879. ErrMsg: res.ErrMsg,
  26880. Status: 1,
  26881. PatientId: id,
  26882. RecordTime: recordDateTime,
  26883. Stage: 4,
  26884. }
  26885. service.CreateErrMsgLog(errlog)
  26886. c.ServeSuccessJSON(map[string]interface{}{
  26887. "failed_code": -10,
  26888. "msg": res.ErrMsg,
  26889. })
  26890. return
  26891. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26892. //return
  26893. }
  26894. }
  26895. }
  26896. } else if tempOrder.ID > 0 {
  26897. if tempOrder.IsPre == 1 {
  26898. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26899. var rf []*ResultFive
  26900. json.Unmarshal([]byte(his.Iinfo), &rf)
  26901. chrg_bchno := tempOrder.Number
  26902. cert_no := his.Certno
  26903. var insutypes []string
  26904. var insutype string
  26905. var is390 int = 0
  26906. var is310 int = 0
  26907. for _, item := range rf {
  26908. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26909. insutypes = append(insutypes, item.Insutype)
  26910. }
  26911. }
  26912. if len(insutypes) == 1 {
  26913. insutype = insutypes[0]
  26914. } else {
  26915. for _, i := range insutypes {
  26916. if i == "390" {
  26917. is390 = 1
  26918. }
  26919. if i == "310" {
  26920. is310 = 1
  26921. }
  26922. }
  26923. }
  26924. if is390 == 1 {
  26925. insutype = "390"
  26926. }
  26927. if is310 == 1 {
  26928. insutype = "310"
  26929. }
  26930. if len(insutypes) == 0 {
  26931. insutype = "310"
  26932. }
  26933. if len(insutypes) == 2 {
  26934. insutype = strconv.FormatInt(his.SocialType, 10)
  26935. }
  26936. //insutype = "390"
  26937. if his.IdCardType == 1 {
  26938. // cert_no = his.MedicalInsuranceNumber
  26939. cert_no = his.Certno
  26940. } else {
  26941. cert_no = his.Certno
  26942. }
  26943. var res ResultSeven
  26944. var ahres ResultSevenAH
  26945. var resSeven10265 ResultSeven10265
  26946. var gzresSeven10265Two GZResultSeven10265Two
  26947. var src_resquest string
  26948. var result2 string
  26949. if miConfig.MdtrtareaAdmvs == "450721" {
  26950. res2 := c.GetoleInfo()
  26951. if res2.Infcode == 0 {
  26952. var result string
  26953. var request_log string
  26954. var result_log string
  26955. if res2.Output.MdtrtCertType == "02" {
  26956. 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)
  26957. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26958. } else if res2.Output.MdtrtCertType == "01" {
  26959. 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)
  26960. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26961. } else {
  26962. 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)
  26963. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26964. }
  26965. var dat map[string]interface{}
  26966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26967. fmt.Println(dat)
  26968. } else {
  26969. fmt.Println(err)
  26970. }
  26971. userJSONBytes, _ := json.Marshal(dat)
  26972. var res5 ResultTwo
  26973. //var resTwo10265 ResultTwo10265
  26974. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26975. utils.ErrorLog("解析失败:%v", err)
  26976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26977. return
  26978. }
  26979. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26980. if res5.Infcode == -1 {
  26981. c.ServeSuccessJSON(map[string]interface{}{
  26982. "failed_code": -10,
  26983. "msg": res5.ErrMsg,
  26984. })
  26985. return
  26986. }
  26987. var insutypes []string
  26988. var insutype string
  26989. var is390 int = 0
  26990. var is310 int = 0
  26991. for _, item := range res5.Output.Iinfo {
  26992. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26993. insutypes = append(insutypes, item.Insutype)
  26994. }
  26995. }
  26996. if len(insutypes) == 1 {
  26997. insutype = insutypes[0]
  26998. } else {
  26999. for _, i := range insutypes {
  27000. if i == "390" {
  27001. is390 = 1
  27002. }
  27003. if i == "310" {
  27004. is310 = 1
  27005. }
  27006. }
  27007. }
  27008. if is390 == 1 {
  27009. insutype = "390"
  27010. }
  27011. if is310 == 1 {
  27012. insutype = "310"
  27013. }
  27014. if len(insutypes) == 0 {
  27015. insutype = "310"
  27016. }
  27017. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27018. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27019. infoStr := string(Iinfos)
  27020. idetinfoStr := string(Idetinfos)
  27021. psn := &models.HisPsn{
  27022. PsnNo: res5.Output.Baseinfo.PsnNo,
  27023. PatientId: id,
  27024. Certno: res5.Output.Baseinfo.Certno,
  27025. Gend: res5.Output.Baseinfo.Gend,
  27026. Naty: res5.Output.Baseinfo.Naty,
  27027. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27028. PsnName: res5.Output.Baseinfo.PsnName,
  27029. Idetinfo: idetinfoStr,
  27030. Insuinfo: infoStr,
  27031. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27032. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27033. VerifyNumber: res2.Output.EcToken,
  27034. }
  27035. service.CreateHisPsn(psn)
  27036. if res2.Output.MdtrtCertType == "01" {
  27037. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27038. token := res2.Output.EcToken
  27039. 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)
  27040. } else if res2.Output.MdtrtCertType == "02" {
  27041. 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)
  27042. } else {
  27043. 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)
  27044. }
  27045. var dat2 map[string]interface{}
  27046. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27047. fmt.Println(dat2)
  27048. } else {
  27049. fmt.Println(err)
  27050. }
  27051. userJSONBytes3, _ := json.Marshal(dat2)
  27052. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27053. utils.ErrorLog("解析失败:%v", err)
  27054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27055. return
  27056. }
  27057. saveLog(result2, src_resquest, "2207", "结算")
  27058. } else {
  27059. c.ServeSuccessJSON(map[string]interface{}{
  27060. "failed_code": -10,
  27061. "msg": res2.ErrMsg,
  27062. })
  27063. return
  27064. }
  27065. } else if miConfig.MdtrtareaAdmvs == "421300" {
  27066. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27067. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27068. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27069. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27070. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27071. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27072. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27073. resp, requestErr := http.Get(api)
  27074. if requestErr != nil {
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27076. return
  27077. }
  27078. body, ioErr := ioutil.ReadAll(resp.Body)
  27079. if ioErr != nil {
  27080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27082. return
  27083. }
  27084. var respJSON map[string]interface{}
  27085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27088. return
  27089. }
  27090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27091. result, _ := json.Marshal(respJSON)
  27092. fmt.Println("log")
  27093. fmt.Println(string(result))
  27094. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27095. utils.ErrorLog("解析失败:%v", err)
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27100. if reg_type == 11 && his.Insutype == "390" {
  27101. reg_type = 110104
  27102. }
  27103. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27104. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27105. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27106. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27107. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27108. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27109. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27110. resp, requestErr := http.Get(api)
  27111. if requestErr != nil {
  27112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27113. return
  27114. }
  27115. body, ioErr := ioutil.ReadAll(resp.Body)
  27116. if ioErr != nil {
  27117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27119. return
  27120. }
  27121. var respJSON map[string]interface{}
  27122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27125. return
  27126. }
  27127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27128. result, _ := json.Marshal(respJSON)
  27129. fmt.Println("log")
  27130. fmt.Println(string(result))
  27131. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27132. utils.ErrorLog("解析失败:%v", err)
  27133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27134. return
  27135. }
  27136. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27137. if reg_type == 11 && his.Insutype == "390" {
  27138. reg_type = 110104
  27139. }
  27140. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27141. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27142. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27143. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27144. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27145. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27146. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27147. resp, requestErr := http.Get(api)
  27148. if requestErr != nil {
  27149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27150. return
  27151. }
  27152. body, ioErr := ioutil.ReadAll(resp.Body)
  27153. if ioErr != nil {
  27154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27156. return
  27157. }
  27158. var respJSON map[string]interface{}
  27159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27162. return
  27163. }
  27164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27165. result, _ := json.Marshal(respJSON)
  27166. fmt.Println("log")
  27167. fmt.Println(string(result))
  27168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27169. utils.ErrorLog("解析失败:%v", err)
  27170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27171. return
  27172. }
  27173. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27174. if reg_type == 11 && his.Insutype == "390" {
  27175. reg_type = 110104
  27176. }
  27177. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27178. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27179. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27180. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27181. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27182. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27183. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27184. resp, requestErr := http.Get(api)
  27185. if requestErr != nil {
  27186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27187. return
  27188. }
  27189. body, ioErr := ioutil.ReadAll(resp.Body)
  27190. if ioErr != nil {
  27191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27193. return
  27194. }
  27195. var respJSON map[string]interface{}
  27196. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27199. return
  27200. }
  27201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27202. result, _ := json.Marshal(respJSON)
  27203. fmt.Println("log")
  27204. fmt.Println(string(result))
  27205. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27206. utils.ErrorLog("解析失败:%v", err)
  27207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27208. return
  27209. }
  27210. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27211. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27212. if result3101.Infcode == "0" {
  27213. if len(result3101.Output.Result) > 0 {
  27214. var errMsgs []string
  27215. for _, item := range result3101.Output.Result {
  27216. errMsgs = append(errMsgs, item.VolaCont)
  27217. }
  27218. c.ServeSuccessJSON(map[string]interface{}{
  27219. "failed_code": -10,
  27220. "msg": errMsgs,
  27221. })
  27222. return
  27223. } else {
  27224. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27225. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27226. bas := strings.Split(psn_info.CardInfo, "|")
  27227. if his.IdCardType == 1 {
  27228. cert_no = bas[2]
  27229. } else if his.IdCardType == 3 {
  27230. cert_no = his.Certno
  27231. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27232. } else if his.IdCardType == 4 {
  27233. cert_no = his.Certno
  27234. psn_info.VerifyNumber = psn_info.VerifyNumber
  27235. }
  27236. //江苏地区国家医保医疗类别
  27237. //职工透析:医疗类别选特殊情况门诊9933
  27238. //居民血透门慢: 医疗类别选门诊慢病1402
  27239. //var med_type string
  27240. //if his.Insutype == "310" {
  27241. // if reg_type == 14 {
  27242. // med_type = "9933"
  27243. // } else if reg_type == 11 {
  27244. // med_type = "11"
  27245. //
  27246. // }
  27247. //} else if his.Insutype == "390" {
  27248. // if reg_type == 14 {
  27249. // med_type = "1402"
  27250. // } else if reg_type == 11 {
  27251. // med_type = "11"
  27252. // }
  27253. //}
  27254. var api string
  27255. if miConfig.MdtrtareaAdmvs == "320921" {
  27256. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27257. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27258. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27260. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27261. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27262. "&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
  27263. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27264. } else {
  27265. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27266. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27267. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27268. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27269. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27270. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27271. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27272. "&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
  27273. }
  27274. resp, requestErr := http.Get(api)
  27275. if requestErr != nil {
  27276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27277. return
  27278. }
  27279. body, ioErr := ioutil.ReadAll(resp.Body)
  27280. if ioErr != nil {
  27281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27283. return
  27284. }
  27285. var respJSON map[string]interface{}
  27286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27289. return
  27290. }
  27291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27292. result, _ := json.Marshal(respJSON)
  27293. fmt.Println("log")
  27294. fmt.Println(string(result))
  27295. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27296. utils.ErrorLog("解析失败:%v", err)
  27297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27298. return
  27299. }
  27300. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27301. res.Output = resSeven10265.Output
  27302. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27303. res.ErrMsg = resSeven10265.ErrMsg
  27304. res.Cainfo = resSeven10265.Cainfo
  27305. res.WarnMsg = resSeven10265.WarnMsg
  27306. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27307. res.Infcode = infocode
  27308. }
  27309. }
  27310. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27311. psn_info, _ := service.GetPsnByPatientId(id)
  27312. var verify_number string
  27313. if psn_info.IdCardType == 4 {
  27314. verify_number = psn_info.VerifyNumber
  27315. } else if psn_info.IdCardType == 1 {
  27316. bas := strings.Split(psn_info.CardInfo, "|")
  27317. cardNumber := bas[2]
  27318. verify_number = cardNumber
  27319. } else {
  27320. verify_number = psn_info.Certno
  27321. psn_info.IdCardType = 2
  27322. }
  27323. var api string
  27324. new_chrg_bchno := chrg_bchno
  27325. if adminUser.CurrentOrgId == 10265 {
  27326. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27327. new_chrg_bchno = "0000"
  27328. }
  27329. }
  27330. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27331. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27332. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27333. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27334. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27335. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27336. "&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
  27337. resp, requestErr := http.Get(api)
  27338. if requestErr != nil {
  27339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27340. return
  27341. }
  27342. body, ioErr := ioutil.ReadAll(resp.Body)
  27343. if ioErr != nil {
  27344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27346. return
  27347. }
  27348. var respJSON map[string]interface{}
  27349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27352. return
  27353. }
  27354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27355. result, _ := json.Marshal(respJSON)
  27356. fmt.Println("log")
  27357. fmt.Println(string(result))
  27358. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27359. utils.ErrorLog("解析失败:%v", err)
  27360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27361. return
  27362. }
  27363. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27364. res.Output = resSeven10265.Output
  27365. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27366. res.ErrMsg = resSeven10265.ErrMsg
  27367. res.Cainfo = resSeven10265.Cainfo
  27368. res.WarnMsg = resSeven10265.WarnMsg
  27369. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27370. res.Infcode = infocode
  27371. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27372. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27373. var cert_no string
  27374. if his.IdCardType == 1 {
  27375. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27376. } else {
  27377. cert_no = psn_info.VerifyNumber
  27378. }
  27379. 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)
  27380. var dat map[string]interface{}
  27381. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27382. fmt.Println(dat)
  27383. } else {
  27384. fmt.Println(err)
  27385. }
  27386. saveLog(result2, src_resquest, "2207", "结算")
  27387. userJSONBytes, _ := json.Marshal(dat)
  27388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27389. utils.ErrorLog("解析失败:%v", err)
  27390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27391. return
  27392. }
  27393. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27394. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27395. var cert_no string
  27396. var card_sn string
  27397. if his.IdCardType == 1 {
  27398. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27399. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27400. bas := strings.Split(psn_info.CardInfo, "|")
  27401. card_sn = bas[3]
  27402. } else if his.IdCardType == 2 {
  27403. cert_no = his.IdCardNo
  27404. } else {
  27405. cert_no = psn_info.VerifyNumber
  27406. }
  27407. var rf []*ResultFive
  27408. json.Unmarshal([]byte(his.Iinfo), &rf)
  27409. var psn_type string
  27410. for _, item := range rf {
  27411. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27412. psn_type = item.PsnType
  27413. }
  27414. }
  27415. 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)
  27416. var dat map[string]interface{}
  27417. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27418. fmt.Println(dat)
  27419. } else {
  27420. fmt.Println(err)
  27421. }
  27422. saveLog(result2, src_resquest, "2207", "结算")
  27423. userJSONBytes, _ := json.Marshal(dat)
  27424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27425. utils.ErrorLog("解析失败:%v", err)
  27426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27427. return
  27428. }
  27429. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27430. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27431. var cert_no string
  27432. var card_sn string
  27433. if his.IdCardType == 1 {
  27434. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27435. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27436. //bas := strings.Split(psn_info.CardInfo, "|")
  27437. card_sn = ""
  27438. } else if his.IdCardType == 2 {
  27439. cert_no = his.IdCardNo
  27440. } else {
  27441. cert_no = psn_info.VerifyNumber
  27442. }
  27443. var rf []*ResultFive
  27444. json.Unmarshal([]byte(his.Iinfo), &rf)
  27445. var psn_type string
  27446. for _, item := range rf {
  27447. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27448. psn_type = item.PsnType
  27449. }
  27450. }
  27451. 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)
  27452. var dat map[string]interface{}
  27453. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27454. fmt.Println(dat)
  27455. } else {
  27456. fmt.Println(err)
  27457. }
  27458. saveLog(result2, src_resquest, "2207", "结算")
  27459. userJSONBytes, _ := json.Marshal(dat)
  27460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27461. utils.ErrorLog("解析失败:%v", err)
  27462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27463. return
  27464. }
  27465. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27466. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27467. if his.IdCardType == 1 {
  27468. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27469. bas := strings.Split(psn_info.CardInfo, "|")
  27470. cert_no = bas[2]
  27471. } else if his.IdCardType == 3 {
  27472. cert_no = his.Certno
  27473. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27474. } else if his.IdCardType == 4 {
  27475. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27476. cert_no =psn_info.VerifyNumber
  27477. psn_info.VerifyNumber = psn_info.VerifyNumber
  27478. } else {
  27479. cert_no = his.Certno
  27480. psn_info.VerifyNumber = his.Certno
  27481. }
  27482. var api string
  27483. var med_type string
  27484. if his.Insutype == "390" {
  27485. if reg_type == 992102 {
  27486. med_type = "992102"
  27487. }
  27488. if reg_type == 140104 {
  27489. med_type = "140104"
  27490. }
  27491. if reg_type == 140201 {
  27492. med_type = "140201"
  27493. }
  27494. if reg_type == 14 {
  27495. med_type = "14"
  27496. }
  27497. } else if his.Insutype == "310" {
  27498. if reg_type == 992102 {
  27499. med_type = "992102"
  27500. }
  27501. if reg_type == 140104 {
  27502. med_type = "140104"
  27503. }
  27504. if reg_type == 140201 {
  27505. med_type = "140201"
  27506. }
  27507. if reg_type == 14 {
  27508. med_type = "14"
  27509. }
  27510. }
  27511. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27517. "&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
  27518. resp, requestErr := http.Get(api)
  27519. if requestErr != nil {
  27520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27521. return
  27522. }
  27523. body, ioErr := ioutil.ReadAll(resp.Body)
  27524. if ioErr != nil {
  27525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27527. return
  27528. }
  27529. var respJSON map[string]interface{}
  27530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27533. return
  27534. }
  27535. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27536. if status == "0" {
  27537. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27538. c.ServeSuccessJSON(map[string]interface{}{
  27539. "failed_code": -10,
  27540. "msg": err_msg,
  27541. })
  27542. return
  27543. }
  27544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27545. result, _ := json.Marshal(respJSON)
  27546. fmt.Println("log")
  27547. fmt.Println(string(result))
  27548. if err := json.Unmarshal(result, &ahres); err != nil {
  27549. utils.ErrorLog("解析失败:%v", err)
  27550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27551. return
  27552. }
  27553. res.InfRefmsgid = ahres.InfRefmsgid
  27554. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27555. // 创建对应的Time类型
  27556. t := time.UnixMilli(timestamp)
  27557. // 格式化成指定的日期字符串
  27558. str := t.Format("2006-01-02 15:04:05")
  27559. res.Output.Setlinfo.SetlTime = str
  27560. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27561. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27562. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27563. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27564. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27565. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27566. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27567. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27568. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27569. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27570. res.Output.Setlinfo.ClrType = "11"
  27571. } else {
  27572. res.Output.Setlinfo.ClrType = "9903"
  27573. }
  27574. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27575. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27576. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27577. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27578. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27579. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27580. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27581. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27582. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27583. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27584. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27585. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27586. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27587. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27588. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27589. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27590. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27591. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27592. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27593. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27594. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27595. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27596. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27597. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27598. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27599. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27600. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27601. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27602. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27603. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27604. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27605. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27606. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27607. res.Output.Setldetail = ahres.Output.Setldetail
  27608. res.ErrMsg = ahres.ErrMsg
  27609. res.Cainfo = ahres.Cainfo
  27610. res.WarnMsg = ahres.WarnMsg
  27611. res.Infcode = ahres.Infcode
  27612. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27613. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27614. if his.IdCardType == 1 {
  27615. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27616. bas := strings.Split(psn_info.CardInfo, "|")
  27617. cert_no = bas[2]
  27618. } else if his.IdCardType == 3 {
  27619. cert_no = his.Certno
  27620. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27621. } else if his.IdCardType == 4 {
  27622. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27623. cert_no = his.Certno
  27624. psn_info.VerifyNumber = psn_info.VerifyNumber
  27625. } else {
  27626. cert_no = his.Certno
  27627. psn_info.VerifyNumber = his.Certno
  27628. }
  27629. var api string
  27630. var med_type string
  27631. if his.Insutype == "390" {
  27632. if reg_type == 992102 {
  27633. med_type = "992102"
  27634. }
  27635. if reg_type == 140104 {
  27636. med_type = "140104"
  27637. }
  27638. if reg_type == 14 {
  27639. med_type = "14"
  27640. }
  27641. if reg_type == 140201 {
  27642. med_type = "140201"
  27643. }
  27644. } else if his.Insutype == "310" {
  27645. if reg_type == 992102 {
  27646. med_type = "992102"
  27647. }
  27648. if reg_type == 14 {
  27649. med_type = "14"
  27650. }
  27651. if reg_type == 140104 {
  27652. med_type = "140104"
  27653. }
  27654. if reg_type == 140201 {
  27655. med_type = "140201"
  27656. }
  27657. }
  27658. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27659. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27660. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27661. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27662. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27663. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27664. "&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
  27665. resp, requestErr := http.Get(api)
  27666. if requestErr != nil {
  27667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27668. return
  27669. }
  27670. body, ioErr := ioutil.ReadAll(resp.Body)
  27671. if ioErr != nil {
  27672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27674. return
  27675. }
  27676. var respJSON map[string]interface{}
  27677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27680. return
  27681. }
  27682. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27683. if status == "0" {
  27684. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27685. c.ServeSuccessJSON(map[string]interface{}{
  27686. "failed_code": -10,
  27687. "msg": err_msg,
  27688. })
  27689. return
  27690. }
  27691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27692. result, _ := json.Marshal(respJSON)
  27693. fmt.Println("log")
  27694. fmt.Println(string(result))
  27695. if err := json.Unmarshal(result, &ahres); err != nil {
  27696. utils.ErrorLog("解析失败:%v", err)
  27697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27698. return
  27699. }
  27700. res.InfRefmsgid = ahres.InfRefmsgid
  27701. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27702. // 创建对应的Time类型
  27703. t := time.UnixMilli(timestamp)
  27704. // 格式化成指定的日期字符串
  27705. str := t.Format("2006-01-02 15:04:05")
  27706. res.Output.Setlinfo.SetlTime = str
  27707. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27708. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27709. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27710. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27711. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27712. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27713. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27714. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27715. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27716. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27717. res.Output.Setlinfo.ClrType = "11"
  27718. } else {
  27719. res.Output.Setlinfo.ClrType = "9903"
  27720. }
  27721. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27722. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27723. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27724. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27725. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27726. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27727. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27728. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27729. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27730. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27731. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27732. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27733. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27734. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27735. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27736. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27737. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27738. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27739. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27740. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27741. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27742. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27743. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27744. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27745. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27746. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27747. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27748. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27749. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27750. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27751. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27752. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27753. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27754. res.Output.Setldetail = ahres.Output.Setldetail
  27755. res.ErrMsg = ahres.ErrMsg
  27756. res.Cainfo = ahres.Cainfo
  27757. res.WarnMsg = ahres.WarnMsg
  27758. res.Infcode = ahres.Infcode
  27759. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27760. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27761. var cert_no string
  27762. if his.IdCardType == 1 {
  27763. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27764. } else if his.IdCardType == 2 {
  27765. cert_no = his.IdCardNo
  27766. } else {
  27767. cert_no = psn_info.VerifyNumber
  27768. }
  27769. 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, "")
  27770. var dat map[string]interface{}
  27771. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27772. fmt.Println(dat)
  27773. } else {
  27774. fmt.Println(err)
  27775. }
  27776. saveLog(result2, src_resquest, "2207", "结算")
  27777. userJSONBytes, _ := json.Marshal(dat)
  27778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27779. utils.ErrorLog("解析失败:%v", err)
  27780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27781. return
  27782. }
  27783. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27784. psn_info, _ := service.GetPsnByPatientId(id)
  27785. var verify_number string
  27786. if psn_info.IdCardType == 4 {
  27787. verify_number = psn_info.VerifyNumber
  27788. } else if psn_info.IdCardType == 1 {
  27789. bas := strings.Split(psn_info.CardInfo, "|")
  27790. cardNumber := bas[2]
  27791. verify_number = cardNumber
  27792. } else {
  27793. verify_number = psn_info.Certno
  27794. psn_info.IdCardType = 2
  27795. }
  27796. var api string
  27797. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27798. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27799. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27801. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27802. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27803. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27804. resp, requestErr := http.Get(api)
  27805. if requestErr != nil {
  27806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27807. return
  27808. }
  27809. body, ioErr := ioutil.ReadAll(resp.Body)
  27810. if ioErr != nil {
  27811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27813. return
  27814. }
  27815. var respJSON map[string]interface{}
  27816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27819. return
  27820. }
  27821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27822. result, _ := json.Marshal(respJSON)
  27823. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27824. utils.ErrorLog("解析失败:%v", err)
  27825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27826. return
  27827. }
  27828. } else {
  27829. var src_resquest string
  27830. if miConfig.Code == "H15049901371" {
  27831. //赤峰地区国家医保医疗类别
  27832. //职工透析:医疗类别选特殊情况门诊990502
  27833. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27834. var med_type string
  27835. if his.Insutype == "390" {
  27836. if reg_type == 14 {
  27837. med_type = "9933"
  27838. } else if reg_type == 11 {
  27839. med_type = "11"
  27840. }
  27841. } else if his.Insutype == "310" {
  27842. if reg_type == 14 {
  27843. med_type = "990502"
  27844. } else if reg_type == 11 {
  27845. med_type = "11"
  27846. }
  27847. }
  27848. 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)
  27849. } else {
  27850. if his.IdCardType == 4 {
  27851. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27852. token := psn_info.VerifyNumber
  27853. 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)
  27854. } else {
  27855. 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)
  27856. }
  27857. }
  27858. var dat map[string]interface{}
  27859. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27860. fmt.Println(dat)
  27861. } else {
  27862. fmt.Println(err)
  27863. }
  27864. saveLog(result2, src_resquest, "2207", "结算")
  27865. userJSONBytes, _ := json.Marshal(dat)
  27866. if miConfig.Code == "H15049901371" {
  27867. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27868. utils.ErrorLog("解析失败:%v", err)
  27869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27870. return
  27871. }
  27872. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27873. res.Output = resSeven10265.Output
  27874. res.ErrMsg = resSeven10265.ErrMsg
  27875. res.Cainfo = resSeven10265.Cainfo
  27876. res.WarnMsg = resSeven10265.WarnMsg
  27877. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27878. res.Infcode = infocode
  27879. } else {
  27880. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27881. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27882. utils.ErrorLog("解析失败:%v", err)
  27883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27884. return
  27885. }
  27886. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27887. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27888. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27889. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27890. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27891. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27892. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27893. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27894. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27895. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27896. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27897. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27898. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27899. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27900. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27901. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27902. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27903. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27904. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27905. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27906. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27907. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27908. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27909. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27910. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27911. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27912. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27913. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27914. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27915. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27916. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27917. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27918. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27919. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27920. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27921. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27922. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27923. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27924. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27925. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27926. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27927. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27928. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27929. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27930. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27931. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27932. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27933. res.Cainfo = gzresSeven10265Two.Cainfo
  27934. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27935. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27936. //res.Infcode = infocode
  27937. } else {
  27938. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27939. utils.ErrorLog("解析失败:%v", err)
  27940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27941. return
  27942. }
  27943. }
  27944. }
  27945. }
  27946. if res.Infcode == -1 {
  27947. errlog := &models.HisOrderError{
  27948. UserOrgId: adminUser.CurrentOrgId,
  27949. Ctime: time.Now().Unix(),
  27950. Mtime: time.Now().Unix(),
  27951. Number: chrg_bchno,
  27952. ErrMsg: res.ErrMsg,
  27953. Status: 1,
  27954. PatientId: id,
  27955. RecordTime: recordDateTime,
  27956. Stage: 6,
  27957. }
  27958. service.CreateErrMsgLog(errlog)
  27959. c.ServeSuccessJSON(map[string]interface{}{
  27960. "failed_code": -10,
  27961. "msg": res.ErrMsg,
  27962. })
  27963. return
  27964. } else {
  27965. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27966. order.OrderStatus = 2
  27967. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27968. order.SetlId = res.Output.Setlinfo.SetlID
  27969. order.PsnNo = res.Output.Setlinfo.PsnNo
  27970. order.PsnName = res.Output.Setlinfo.PsnName
  27971. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27972. order.Certno = res.Output.Setlinfo.Certno
  27973. order.Gend = res.Output.Setlinfo.Gend
  27974. order.Naty = res.Output.Setlinfo.Naty
  27975. order.Age = res.Output.Setlinfo.Age
  27976. order.Insutype = res.Output.Setlinfo.Insutype
  27977. order.PsnType = res.Output.Setlinfo.PsnType
  27978. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27979. order.SetlTime = res.Output.Setlinfo.SetlTime
  27980. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27981. order.PayWays = pay_ways
  27982. order.AcctUsedFlag = acct_used_flag
  27983. order.WechatPay = wechat_pay
  27984. order.AliPay = ali_pay
  27985. order.JifenPay = jifen_pay
  27986. order.BandCardPay = band_card_pay
  27987. order.CashPay = cash_pay
  27988. order.OthDesc = oth_desc
  27989. //order.MedType = res.Output.Setlinfo.MedType
  27990. if reg_type == 1112 {
  27991. order.MedType = "1112"
  27992. }
  27993. if reg_type == 1111 {
  27994. order.MedType = "1111"
  27995. }
  27996. order.ClrType = res.Output.Setlinfo.ClrType
  27997. if adminUser.CurrentOrgId == 10480 {
  27998. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27999. order.ClrType = "11"
  28000. } else {
  28001. order.ClrType = "9903"
  28002. }
  28003. }
  28004. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28005. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28006. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28007. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28008. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28009. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28010. order.HifpPay = res.Output.Setlinfo.HifpPay
  28011. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28012. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28013. order.HifesPay = res.Output.Setlinfo.HifesPay
  28014. order.HifobPay = res.Output.Setlinfo.HifobPay
  28015. order.MafPay = res.Output.Setlinfo.MafPay
  28016. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28017. order.OthPay = res.Output.Setlinfo.OthPay
  28018. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28019. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28020. order.AcctPay = res.Output.Setlinfo.AcctPay
  28021. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28022. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28023. order.Balc = res.Output.Setlinfo.Balc
  28024. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28025. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28026. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28027. order.ClrWay = res.Output.Setlinfo.ClrWay
  28028. order.Creator = order.Creator
  28029. order.Modify = roles.AdminUserId
  28030. order.RequestLog = src_resquest
  28031. order.Diagnosis = diagnosis_id
  28032. order.FaPiaoNumber = fapiao_number
  28033. order.FaPiaoCode = fapiao_code
  28034. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28035. detailStr := string(setlDetail)
  28036. order.SetlDetail = detailStr
  28037. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28038. err = service.UpDateOrder(order)
  28039. if err == nil {
  28040. //判断是否使用了押金
  28041. if dec_way == "true" {
  28042. tmpstring := strconv.FormatInt(order.ID, 10)
  28043. //扣押金
  28044. order.Decimal = decimal
  28045. service.UpDateOrder(order)
  28046. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28047. if errmsg != nil {
  28048. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28049. return
  28050. }
  28051. }
  28052. c.ServeSuccessJSON(map[string]interface{}{
  28053. "msg": "结算成功",
  28054. })
  28055. } else {
  28056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28057. return
  28058. }
  28059. }
  28060. }
  28061. }
  28062. }
  28063. // 上传明细-预结算-
  28064. func (c *HisApiController) GetPreUploadInfo() {
  28065. id, _ := c.GetInt64("id")
  28066. record_time := c.GetString("record_time")
  28067. his_patient_id, _ := c.GetInt64("his_patient_id")
  28068. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  28069. admin_user_id, _ := c.GetInt64("admin_user_id")
  28070. diagnosis_id := c.GetString("diagnosis")
  28071. sick_type, _ := c.GetInt64("sick_type")
  28072. reg_type, _ := c.GetInt64("p_type")
  28073. begin_time := c.GetString("begin_time")
  28074. acct_used_flag := c.GetString("acct_used_flag")
  28075. id_str := c.GetString("ids")
  28076. ids_arr := strings.Split(id_str, ",")
  28077. timeLayout := "2006-01-02"
  28078. loc, _ := time.LoadLocation("Local")
  28079. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28080. if err != nil {
  28081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28082. return
  28083. }
  28084. recordDateTime := theTime.Unix()
  28085. adminUser := c.GetAdminUserInfo()
  28086. diagnosis_ids := strings.Split(diagnosis_id, ",")
  28087. var config []*models.HisXtDiagnoseConfig
  28088. for _, item := range diagnosis_ids {
  28089. id, _ := strconv.ParseInt(item, 10, 64)
  28090. if id > 0 {
  28091. diagnosisConfig, _ := service.FindDiagnoseById(id)
  28092. config = append(config, &diagnosisConfig)
  28093. }
  28094. }
  28095. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28096. sickConfig, _ := service.FindSickById(sick_type)
  28097. var prescriptions []*models.HisPrescription
  28098. var start_time int64
  28099. var end_time int64
  28100. var isSuccess bool = true
  28101. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28102. fmt.Println(his_patient_id)
  28103. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28104. timestamp := time.Now().Unix()
  28105. tempTime := time.Unix(timestamp, 0)
  28106. timeFormat := tempTime.Format("20060102150405")
  28107. chrgBchno := rand.Intn(100000) + 10000
  28108. new_chrg_bchno := ""
  28109. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  28110. new_chrg_bchno = chrg_bchno
  28111. if adminUser.CurrentOrgId == 10265 {
  28112. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28113. new_chrg_bchno = "0000"
  28114. }
  28115. }
  28116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28117. var patientPrescription models.HisPrescriptionInfo
  28118. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28119. if patientPrescription.ID == 0 {
  28120. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  28121. }
  28122. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28123. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28124. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28125. strconv.FormatInt(his.PatientId, 10)
  28126. var res2406 Result2406
  28127. //安徽单病种处理
  28128. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  28129. data := make(map[string]interface{})
  28130. client := &http.Client{}
  28131. data["psn_no"] = his.PsnNo
  28132. data["mdtrt_id"] = his.Number
  28133. data["operator"] = roles.UserName
  28134. data["cert_no"] = his.IdCardNo
  28135. data["org_name"] = miConfig.OrgName
  28136. data["psn_name"] = his.Name
  28137. data["ipt_otp_no"] = his.IptOtpNo
  28138. data["ipt_psn_sp_flag_type"] = "0901"
  28139. data["ipt_psn_sp_flag"] = "1"
  28140. data["fixmedins_code"] = miConfig.Code
  28141. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28142. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28143. data["url"] = miConfig.Url
  28144. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28145. bytesData, _ := json.Marshal(data)
  28146. var req *http.Request
  28147. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28148. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28149. resp, _ := client.Do(req)
  28150. defer resp.Body.Close()
  28151. body, ioErr := ioutil.ReadAll(resp.Body)
  28152. if ioErr != nil {
  28153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28155. return
  28156. }
  28157. var respJSON map[string]interface{}
  28158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28161. return
  28162. }
  28163. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28164. if status == "0" {
  28165. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28166. c.ServeSuccessJSON(map[string]interface{}{
  28167. "failed_code": -10,
  28168. "msg": err_msg,
  28169. })
  28170. return
  28171. }
  28172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28173. userJSONBytes, _ := json.Marshal(respJSON)
  28174. fmt.Println("log")
  28175. fmt.Println(string(userJSONBytes))
  28176. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28177. utils.ErrorLog("解析失败:%v", err)
  28178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28179. return
  28180. }
  28181. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28182. data := make(map[string]interface{})
  28183. client := &http.Client{}
  28184. data["psn_no"] = his.PsnNo
  28185. data["mdtrt_id"] = his.Number
  28186. data["operator"] = roles.UserName
  28187. data["cert_no"] = his.IdCardNo
  28188. data["org_name"] = miConfig.OrgName
  28189. data["psn_name"] = his.Name
  28190. data["ipt_otp_no"] = his.IptOtpNo
  28191. data["ipt_psn_sp_flag_type"] = "0901"
  28192. data["ipt_psn_sp_flag"] = "1"
  28193. data["fixmedins_code"] = miConfig.Code
  28194. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28195. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28196. data["url"] = miConfig.Url
  28197. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28198. bytesData, _ := json.Marshal(data)
  28199. var req *http.Request
  28200. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28201. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28202. resp, _ := client.Do(req)
  28203. defer resp.Body.Close()
  28204. body, ioErr := ioutil.ReadAll(resp.Body)
  28205. if ioErr != nil {
  28206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28208. return
  28209. }
  28210. var respJSON map[string]interface{}
  28211. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28214. return
  28215. }
  28216. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28217. if status == "0" {
  28218. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28219. c.ServeSuccessJSON(map[string]interface{}{
  28220. "failed_code": -10,
  28221. "msg": err_msg,
  28222. })
  28223. return
  28224. }
  28225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28226. userJSONBytes, _ := json.Marshal(respJSON)
  28227. fmt.Println("log")
  28228. fmt.Println(string(userJSONBytes))
  28229. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28230. utils.ErrorLog("解析失败:%v", err)
  28231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28232. return
  28233. }
  28234. }
  28235. if res2406.Infcode != 0 {
  28236. adminUser := c.GetAdminUserInfo()
  28237. errlog := &models.HisOrderError{
  28238. UserOrgId: adminUser.CurrentOrgId,
  28239. Ctime: time.Now().Unix(),
  28240. Mtime: time.Now().Unix(),
  28241. ErrMsg: res2406.ErrMsg,
  28242. Status: 1,
  28243. PatientId: id,
  28244. RecordTime: recordDateTime,
  28245. Stage: 3,
  28246. }
  28247. service.CreateErrMsgLog(errlog)
  28248. c.ServeSuccessJSON(map[string]interface{}{
  28249. "failed_code": -10,
  28250. "msg": res2406.ErrMsg,
  28251. })
  28252. return
  28253. }
  28254. var res2 ResultSix
  28255. var res3 GZResultSix
  28256. var resSix10265 ResultSix10265
  28257. //var time_stamp string
  28258. if miConfig.MdtrtareaAdmvs == "421300" {
  28259. data := make(map[string]interface{})
  28260. client := &http.Client{}
  28261. data["psn_no"] = his.PsnNo
  28262. data["mdtrt_id"] = his.Number
  28263. data["department"] = department.Name
  28264. data["org_name"] = miConfig.OrgName
  28265. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28266. data["doctor_id"] = doctor_info.DoctorNumber
  28267. data["doctor_name"] = roles.UserName
  28268. data["fixmedins_code"] = miConfig.Code
  28269. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28270. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28271. data["secret_key"] = miConfig.SecretKey
  28272. data["sick_code"] = sickConfig.CountryCode
  28273. data["sick_name"] = sickConfig.ClassName
  28274. data["begin_time"] = begin_time
  28275. data["dept"] = strconv.FormatInt(department.ID, 10)
  28276. data["config"] = config
  28277. data["opter"] = roles.UserName
  28278. fmt.Println(data)
  28279. bytesData, _ := json.Marshal(data)
  28280. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28281. resp, _ := client.Do(req)
  28282. defer resp.Body.Close()
  28283. body, ioErr := ioutil.ReadAll(resp.Body)
  28284. if ioErr != nil {
  28285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28287. return
  28288. }
  28289. var respJSON map[string]interface{}
  28290. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28293. return
  28294. }
  28295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28296. userJSONBytes, _ := json.Marshal(respJSON)
  28297. fmt.Println("log")
  28298. fmt.Println(string(userJSONBytes))
  28299. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28300. utils.ErrorLog("解析失败:%v", err)
  28301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28302. return
  28303. }
  28304. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28305. data := make(map[string]interface{})
  28306. client := &http.Client{}
  28307. data["psn_no"] = his.PsnNo
  28308. data["mdtrt_id"] = his.Number
  28309. data["department"] = department.Name
  28310. data["org_name"] = miConfig.OrgName
  28311. if reg_type == 11 && his.Insutype == "390" {
  28312. data["med_type"] = "110104"
  28313. } else {
  28314. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28315. }
  28316. data["doctor_id"] = doctor_info.DoctorNumber
  28317. data["doctor_name"] = roles.UserName
  28318. data["fixmedins_code"] = miConfig.Code
  28319. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28320. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28321. data["secret_key"] = miConfig.SecretKey
  28322. data["sick_code"] = sickConfig.CountryCode
  28323. data["sick_name"] = sickConfig.ClassName
  28324. data["begin_time"] = begin_time
  28325. data["dept"] = strconv.FormatInt(department.ID, 10)
  28326. data["config"] = config
  28327. data["opter"] = roles.UserName
  28328. fmt.Println(data)
  28329. bytesData, _ := json.Marshal(data)
  28330. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28331. resp, _ := client.Do(req)
  28332. defer resp.Body.Close()
  28333. body, ioErr := ioutil.ReadAll(resp.Body)
  28334. if ioErr != nil {
  28335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28337. return
  28338. }
  28339. var respJSON map[string]interface{}
  28340. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28343. return
  28344. }
  28345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28346. userJSONBytes, _ := json.Marshal(respJSON)
  28347. fmt.Println("log")
  28348. fmt.Println(string(userJSONBytes))
  28349. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28350. utils.ErrorLog("解析失败:%v", err)
  28351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28352. return
  28353. }
  28354. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28355. data := make(map[string]interface{})
  28356. client := &http.Client{}
  28357. data["psn_no"] = his.PsnNo
  28358. data["mdtrt_id"] = his.Number
  28359. data["department"] = department.Name
  28360. data["org_name"] = miConfig.OrgName
  28361. if reg_type == 11 && his.Insutype == "390" {
  28362. data["med_type"] = "110104"
  28363. } else {
  28364. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28365. }
  28366. data["doctor_id"] = doctor_info.DoctorNumber
  28367. data["doctor_name"] = roles.UserName
  28368. data["fixmedins_code"] = miConfig.Code
  28369. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28370. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28371. data["secret_key"] = miConfig.SecretKey
  28372. data["sick_code"] = sickConfig.CountryCode
  28373. data["sick_name"] = sickConfig.ClassName
  28374. data["begin_time"] = begin_time
  28375. data["dept"] = strconv.FormatInt(department.ID, 10)
  28376. data["config"] = config
  28377. data["opter"] = roles.UserName
  28378. fmt.Println(data)
  28379. bytesData, _ := json.Marshal(data)
  28380. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28381. resp, _ := client.Do(req)
  28382. defer resp.Body.Close()
  28383. body, ioErr := ioutil.ReadAll(resp.Body)
  28384. if ioErr != nil {
  28385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28387. return
  28388. }
  28389. var respJSON map[string]interface{}
  28390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28393. return
  28394. }
  28395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28396. userJSONBytes, _ := json.Marshal(respJSON)
  28397. fmt.Println("log")
  28398. fmt.Println(string(userJSONBytes))
  28399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28400. utils.ErrorLog("解析失败:%v", err)
  28401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28402. return
  28403. }
  28404. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28405. data := make(map[string]interface{})
  28406. client := &http.Client{}
  28407. data["psn_no"] = his.PsnNo
  28408. data["mdtrt_id"] = his.Number
  28409. data["department"] = department.Name
  28410. data["org_name"] = miConfig.OrgName
  28411. if reg_type == 11 && his.Insutype == "390" {
  28412. data["med_type"] = "110104"
  28413. } else {
  28414. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28415. }
  28416. data["doctor_id"] = doctor_info.DoctorNumber
  28417. data["doctor_name"] = roles.UserName
  28418. data["fixmedins_code"] = miConfig.Code
  28419. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28420. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28421. data["secret_key"] = miConfig.SecretKey
  28422. data["sick_code"] = sickConfig.CountryCode
  28423. data["sick_name"] = sickConfig.ClassName
  28424. data["begin_time"] = begin_time
  28425. data["dept"] = strconv.FormatInt(department.ID, 10)
  28426. data["config"] = config
  28427. data["opter"] = roles.UserName
  28428. fmt.Println(data)
  28429. bytesData, _ := json.Marshal(data)
  28430. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28431. resp, _ := client.Do(req)
  28432. defer resp.Body.Close()
  28433. body, ioErr := ioutil.ReadAll(resp.Body)
  28434. if ioErr != nil {
  28435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28437. return
  28438. }
  28439. var respJSON map[string]interface{}
  28440. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28443. return
  28444. }
  28445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28446. userJSONBytes, _ := json.Marshal(respJSON)
  28447. fmt.Println("log")
  28448. fmt.Println(string(userJSONBytes))
  28449. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28450. utils.ErrorLog("解析失败:%v", err)
  28451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28452. return
  28453. }
  28454. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28455. data := make(map[string]interface{})
  28456. client := &http.Client{}
  28457. data["psn_no"] = his.PsnNo
  28458. data["mdtrt_id"] = his.Number
  28459. data["doctor"] = roles.UserName
  28460. data["department"] = department.Name
  28461. data["org_name"] = miConfig.OrgName
  28462. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28463. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28464. data["fixmedins_code"] = miConfig.Code
  28465. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28466. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28467. data["secret_key"] = miConfig.SecretKey
  28468. data["sick_code"] = sickConfig.CountryCode
  28469. data["sick_name"] = sickConfig.ClassName
  28470. data["begin_time"] = begin_time
  28471. data["dept"] = strconv.FormatInt(department.ID, 10)
  28472. data["config"] = config
  28473. data["url"] = miConfig.Url
  28474. data["ak"] = miConfig.AccessKey
  28475. data["cainfo"] = miConfig.Cainfo
  28476. bytesData, _ := json.Marshal(data)
  28477. var req *http.Request
  28478. if miConfig.MdtrtareaAdmvs == "320921" {
  28479. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28480. } else {
  28481. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28482. }
  28483. resp, _ := client.Do(req)
  28484. defer resp.Body.Close()
  28485. body, ioErr := ioutil.ReadAll(resp.Body)
  28486. if ioErr != nil {
  28487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28489. return
  28490. }
  28491. var respJSON map[string]interface{}
  28492. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28495. return
  28496. }
  28497. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28498. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28499. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28501. userJSONBytes, _ := json.Marshal(respJSON)
  28502. fmt.Println("log")
  28503. fmt.Println(string(userJSONBytes))
  28504. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28505. utils.ErrorLog("解析失败:%v", err)
  28506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28507. return
  28508. }
  28509. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28510. res2.Output = resSix10265.Output
  28511. res2.ErrMsg = resSix10265.ErrMsg
  28512. res2.Cainfo = resSix10265.Cainfo
  28513. res2.WarnMsg = resSix10265.WarnMsg
  28514. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28515. res2.Infcode = infocode
  28516. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28517. data := make(map[string]interface{})
  28518. client := &http.Client{}
  28519. data["psn_no"] = his.PsnNo
  28520. data["mdtrt_id"] = his.Number
  28521. data["doctor"] = roles.UserName
  28522. data["department"] = department.Name
  28523. data["org_name"] = miConfig.OrgName
  28524. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28525. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28526. data["fixmedins_code"] = miConfig.Code
  28527. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28528. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28529. data["secret_key"] = miConfig.SecretKey
  28530. data["sick_code"] = sickConfig.CountryCode
  28531. data["sick_name"] = sickConfig.ClassName
  28532. data["begin_time"] = begin_time
  28533. data["dept"] = strconv.FormatInt(department.ID, 10)
  28534. data["config"] = config
  28535. //data["url"] = miConfig.Url
  28536. //data["ak"] = miConfig.AccessKey
  28537. data["cainfo"] = miConfig.Cainfo
  28538. fmt.Println(data)
  28539. bytesData, _ := json.Marshal(data)
  28540. var req *http.Request
  28541. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28542. resp, _ := client.Do(req)
  28543. defer resp.Body.Close()
  28544. body, ioErr := ioutil.ReadAll(resp.Body)
  28545. if ioErr != nil {
  28546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28548. return
  28549. }
  28550. var respJSON map[string]interface{}
  28551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28554. return
  28555. }
  28556. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28557. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28558. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28560. userJSONBytes, _ := json.Marshal(respJSON)
  28561. fmt.Println("log")
  28562. fmt.Println(string(userJSONBytes))
  28563. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28564. utils.ErrorLog("解析失败:%v", err)
  28565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28566. return
  28567. }
  28568. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28569. res2.Output = resSix10265.Output
  28570. res2.ErrMsg = resSix10265.ErrMsg
  28571. res2.Cainfo = resSix10265.Cainfo
  28572. res2.WarnMsg = resSix10265.WarnMsg
  28573. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28574. res2.Infcode = infocode
  28575. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28576. 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)
  28577. saveLog(result, requestLog, "2203", "上传就诊信息")
  28578. var respJSON2 map[string]interface{}
  28579. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28582. return
  28583. }
  28584. userJSONBytes2, _ := json.Marshal(respJSON2)
  28585. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28586. utils.ErrorLog("解析失败:%v", err)
  28587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28588. return
  28589. }
  28590. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28591. var result string
  28592. var requestLog string
  28593. 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, "")
  28594. saveLog(result, requestLog, "2203", "上传就诊信息")
  28595. var respJSON2 map[string]interface{}
  28596. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28599. return
  28600. }
  28601. userJSONBytes2, _ := json.Marshal(respJSON2)
  28602. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28603. utils.ErrorLog("解析失败:%v", err)
  28604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28605. return
  28606. }
  28607. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28608. var result string
  28609. var requestLog string
  28610. 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, "")
  28611. saveLog(result, requestLog, "2203", "上传就诊信息")
  28612. var respJSON2 map[string]interface{}
  28613. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28616. return
  28617. }
  28618. userJSONBytes2, _ := json.Marshal(respJSON2)
  28619. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28620. utils.ErrorLog("解析失败:%v", err)
  28621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28622. return
  28623. }
  28624. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28625. data := make(map[string]interface{})
  28626. client := &http.Client{}
  28627. data["psn_no"] = his.PsnNo
  28628. data["mdtrt_id"] = his.Number
  28629. data["operator"] = roles.UserName
  28630. data["department"] = department.Name
  28631. data["org_name"] = miConfig.OrgName
  28632. var med_type string
  28633. if his.Insutype == "390" {
  28634. if reg_type == 992102 {
  28635. med_type = "992102"
  28636. data["sick_code"] = "ZDZ940"
  28637. data["sick_name"] = "慢性肾衰竭"
  28638. }
  28639. if reg_type == 140104 {
  28640. med_type = "140104"
  28641. data["sick_code"] = sickConfig.CountryCode
  28642. data["sick_name"] = sickConfig.ClassName
  28643. }
  28644. if reg_type == 14 {
  28645. med_type = "140104"
  28646. data["sick_code"] = sickConfig.CountryCode
  28647. data["sick_name"] = sickConfig.ClassName
  28648. }
  28649. } else if his.Insutype == "310" {
  28650. if reg_type == 992102 {
  28651. med_type = "992102"
  28652. data["sick_code"] = "ZDZ940"
  28653. data["sick_name"] = "慢性肾衰竭"
  28654. }
  28655. if reg_type == 140104 {
  28656. med_type = "140104"
  28657. data["sick_code"] = sickConfig.CountryCode
  28658. data["sick_name"] = sickConfig.ClassName
  28659. }
  28660. if reg_type == 14 {
  28661. med_type = "14"
  28662. data["sick_code"] = sickConfig.CountryCode
  28663. data["sick_name"] = sickConfig.ClassName
  28664. }
  28665. }
  28666. data["med_type"] = med_type
  28667. data["doctor_number"] = doctor_info.DoctorNumber
  28668. data["doctor_name"] = doctor_info.UserName
  28669. data["fixmedins_code"] = miConfig.Code
  28670. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28671. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28672. data["secret_key"] = miConfig.SecretKey
  28673. data["begin_time"] = begin_time
  28674. data["dept"] = strconv.FormatInt(department.ID, 10)
  28675. data["config"] = config
  28676. data["url"] = miConfig.Url
  28677. data["ak"] = miConfig.AccessKey
  28678. data["cainfo"] = miConfig.Cainfo
  28679. bytesData, _ := json.Marshal(data)
  28680. var req *http.Request
  28681. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28682. resp, _ := client.Do(req)
  28683. defer resp.Body.Close()
  28684. body, ioErr := ioutil.ReadAll(resp.Body)
  28685. if ioErr != nil {
  28686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28688. return
  28689. }
  28690. var respJSON map[string]interface{}
  28691. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28694. return
  28695. }
  28696. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28697. if status == "0" {
  28698. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28699. c.ServeSuccessJSON(map[string]interface{}{
  28700. "failed_code": -10,
  28701. "msg": err_msg,
  28702. })
  28703. return
  28704. }
  28705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28706. userJSONBytes, _ := json.Marshal(respJSON)
  28707. fmt.Println("log")
  28708. fmt.Println(string(userJSONBytes))
  28709. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28710. utils.ErrorLog("解析失败:%v", err)
  28711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28712. return
  28713. }
  28714. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28715. data := make(map[string]interface{})
  28716. client := &http.Client{}
  28717. data["psn_no"] = his.PsnNo
  28718. data["mdtrt_id"] = his.Number
  28719. data["operator"] = roles.UserName
  28720. data["department"] = department.Name
  28721. data["org_name"] = miConfig.OrgName
  28722. var med_type string
  28723. if his.Insutype == "390" {
  28724. if reg_type == 992102 {
  28725. med_type = "992102"
  28726. data["sick_code"] = sickConfig.CountryCode
  28727. data["sick_name"] = sickConfig.ClassName
  28728. }
  28729. if reg_type == 140104 {
  28730. med_type = "140104"
  28731. data["sick_code"] = sickConfig.CountryCode
  28732. data["sick_name"] = sickConfig.ClassName
  28733. }
  28734. if reg_type == 140201 {
  28735. med_type = "140201"
  28736. data["sick_code"] = sickConfig.CountryCode
  28737. data["sick_name"] = sickConfig.ClassName
  28738. }
  28739. if reg_type == 14 {
  28740. med_type = "14"
  28741. data["sick_code"] = sickConfig.CountryCode
  28742. data["sick_name"] = sickConfig.ClassName
  28743. }
  28744. } else if his.Insutype == "310" {
  28745. if reg_type == 992102 {
  28746. med_type = "992102"
  28747. data["sick_code"] = sickConfig.CountryCode
  28748. data["sick_name"] = sickConfig.ClassName
  28749. }
  28750. if reg_type == 140104 {
  28751. med_type = "140104"
  28752. data["sick_code"] = sickConfig.CountryCode
  28753. data["sick_name"] = sickConfig.ClassName
  28754. }
  28755. if reg_type == 140201 {
  28756. med_type = "140201"
  28757. data["sick_code"] = sickConfig.CountryCode
  28758. data["sick_name"] = sickConfig.ClassName
  28759. }
  28760. if reg_type == 14 {
  28761. med_type = "14"
  28762. data["sick_code"] = sickConfig.CountryCode
  28763. data["sick_name"] = sickConfig.ClassName
  28764. }
  28765. }
  28766. data["med_type"] = med_type
  28767. data["doctor_number"] = doctor_info.DoctorNumber
  28768. data["doctor_name"] = doctor_info.UserName
  28769. data["fixmedins_code"] = miConfig.Code
  28770. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28771. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28772. data["secret_key"] = miConfig.SecretKey
  28773. data["begin_time"] = begin_time
  28774. data["dept"] = strconv.FormatInt(department.ID, 10)
  28775. data["config"] = config
  28776. data["url"] = miConfig.Url
  28777. data["ak"] = miConfig.AccessKey
  28778. data["cainfo"] = miConfig.Cainfo
  28779. bytesData, _ := json.Marshal(data)
  28780. var req *http.Request
  28781. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28782. resp, _ := client.Do(req)
  28783. defer resp.Body.Close()
  28784. body, ioErr := ioutil.ReadAll(resp.Body)
  28785. if ioErr != nil {
  28786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28788. return
  28789. }
  28790. var respJSON map[string]interface{}
  28791. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28794. return
  28795. }
  28796. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28797. if status == "0" {
  28798. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28799. c.ServeSuccessJSON(map[string]interface{}{
  28800. "failed_code": -10,
  28801. "msg": err_msg,
  28802. })
  28803. return
  28804. }
  28805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28806. userJSONBytes, _ := json.Marshal(respJSON)
  28807. fmt.Println("log")
  28808. fmt.Println(string(userJSONBytes))
  28809. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28810. utils.ErrorLog("解析失败:%v", err)
  28811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28812. return
  28813. }
  28814. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28815. var result string
  28816. var requestLog string
  28817. 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, "")
  28818. saveLog(result, requestLog, "2203", "上传就诊信息")
  28819. var respJSON2 map[string]interface{}
  28820. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28823. return
  28824. }
  28825. userJSONBytes2, _ := json.Marshal(respJSON2)
  28826. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28827. utils.ErrorLog("解析失败:%v", err)
  28828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28829. return
  28830. }
  28831. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28832. data := make(map[string]interface{})
  28833. client := &http.Client{}
  28834. data["psn_no"] = his.PsnNo
  28835. data["mdtrt_id"] = his.Number
  28836. data["doctor"] = roles.UserName
  28837. data["department"] = department.Name
  28838. data["org_name"] = miConfig.OrgName
  28839. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28840. data["doctor_id"] = doctor_info.DoctorNumber
  28841. data["fixmedins_code"] = miConfig.Code
  28842. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28843. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28844. data["secret_key"] = miConfig.SecretKey
  28845. data["sick_code"] = sickConfig.CountryCode
  28846. data["sick_name"] = sickConfig.ClassName
  28847. data["begin_time"] = begin_time
  28848. data["new_doctor_name"] = doctor_info.UserName
  28849. data["dept"] = strconv.FormatInt(department.ID, 10)
  28850. data["config"] = config
  28851. bytesData, _ := json.Marshal(data)
  28852. var req *http.Request
  28853. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28854. resp, _ := client.Do(req)
  28855. defer resp.Body.Close()
  28856. body, ioErr := ioutil.ReadAll(resp.Body)
  28857. if ioErr != nil {
  28858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28860. return
  28861. }
  28862. var respJSON map[string]interface{}
  28863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28866. return
  28867. }
  28868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28869. userJSONBytes, _ := json.Marshal(respJSON)
  28870. fmt.Println("log")
  28871. fmt.Println(string(userJSONBytes))
  28872. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28873. utils.ErrorLog("解析失败:%v", err)
  28874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28875. return
  28876. }
  28877. } else {
  28878. var result string
  28879. var requestLog string
  28880. if miConfig.MdtrtareaAdmvs == "440781" { //
  28881. 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)
  28882. } else {
  28883. if miConfig.Code == "H15049901371" {
  28884. //赤峰地区国家医保医疗类别
  28885. //职工透析:医疗类别选特殊情况门诊990502
  28886. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28887. var med_type string
  28888. if his.Insutype == "390" {
  28889. if reg_type == 14 {
  28890. med_type = "9933"
  28891. } else if reg_type == 11 {
  28892. med_type = "11"
  28893. }
  28894. } else if his.Insutype == "310" {
  28895. if reg_type == 14 {
  28896. med_type = "990502"
  28897. } else if reg_type == 11 {
  28898. med_type = "11"
  28899. }
  28900. }
  28901. 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)
  28902. } else {
  28903. 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)
  28904. }
  28905. saveLog(result, requestLog, "2203", "上传就诊信息")
  28906. var respJSON2 map[string]interface{}
  28907. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28910. return
  28911. }
  28912. userJSONBytes2, _ := json.Marshal(respJSON2)
  28913. if miConfig.Code == "H15049901371" {
  28914. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28915. utils.ErrorLog("解析失败:%v", err)
  28916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28917. return
  28918. }
  28919. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28920. res2.Output = resSix10265.Output
  28921. res2.ErrMsg = resSix10265.ErrMsg
  28922. res2.Cainfo = resSix10265.Cainfo
  28923. res2.WarnMsg = resSix10265.WarnMsg
  28924. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28925. res2.Infcode = infocode
  28926. } else {
  28927. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28928. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28929. utils.ErrorLog("解析失败:%v", err)
  28930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28931. return
  28932. }
  28933. res2.Infcode = res3.Infcode
  28934. } else {
  28935. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28936. utils.ErrorLog("解析失败:%v", err)
  28937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28938. return
  28939. }
  28940. }
  28941. }
  28942. }
  28943. }
  28944. if res2.Infcode == -1 {
  28945. adminUser := c.GetAdminUserInfo()
  28946. errlog := &models.HisOrderError{
  28947. UserOrgId: adminUser.CurrentOrgId,
  28948. Ctime: time.Now().Unix(),
  28949. Mtime: time.Now().Unix(),
  28950. ErrMsg: res2.ErrMsg,
  28951. Status: 1,
  28952. PatientId: id,
  28953. RecordTime: recordDateTime,
  28954. Stage: 3,
  28955. }
  28956. service.CreateErrMsgLog(errlog)
  28957. c.ServeSuccessJSON(map[string]interface{}{
  28958. "failed_code": -10,
  28959. "msg": res2.ErrMsg,
  28960. })
  28961. return
  28962. }
  28963. if res2.Infcode != 0 {
  28964. adminUser := c.GetAdminUserInfo()
  28965. errlog := &models.HisOrderError{
  28966. UserOrgId: adminUser.CurrentOrgId,
  28967. Ctime: time.Now().Unix(),
  28968. Mtime: time.Now().Unix(),
  28969. ErrMsg: res2.ErrMsg,
  28970. Status: 1,
  28971. PatientId: id,
  28972. RecordTime: recordDateTime,
  28973. Stage: 3,
  28974. }
  28975. service.CreateErrMsgLog(errlog)
  28976. c.ServeSuccessJSON(map[string]interface{}{
  28977. "failed_code": -10,
  28978. "msg": res2.ErrMsg,
  28979. })
  28980. return
  28981. } else {
  28982. his.Diagnosis = diagnosis_id
  28983. his.SickType = sickConfig.ID
  28984. his.PType = fmt.Sprintf("%d", reg_type)
  28985. service.UpdateHisPatientThree(&his)
  28986. data := make(map[string]interface{})
  28987. if settle_accounts_type == 1 { //日结
  28988. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28989. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28990. } else {
  28991. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28992. }
  28993. data["pre"] = prescriptions
  28994. } else { //月结
  28995. start_time_str := c.GetString("start_time")
  28996. end_time_str := c.GetString("end_time")
  28997. timeLayout := "2006-01-02"
  28998. loc, _ := time.LoadLocation("Local")
  28999. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  29000. if err != nil {
  29001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29002. return
  29003. }
  29004. recordStartTime := theStartTime.Unix()
  29005. start_time = recordStartTime
  29006. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  29007. if err != nil {
  29008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29009. return
  29010. }
  29011. recordEndTime := theEndTime.Unix()
  29012. end_time = recordEndTime
  29013. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  29014. data["pre"] = prescriptions
  29015. }
  29016. client := &http.Client{}
  29017. data["psn_no"] = his.PsnNo
  29018. data["mdtrt_id"] = his.Number
  29019. data["chrg_bchno"] = new_chrg_bchno
  29020. data["org_name"] = miConfig.OrgName
  29021. data["doctor"] = doctor_info.UserName
  29022. data["doctor_id"] = doctor_info.DoctorNumber
  29023. data["dept"] = department.Name
  29024. data["fixmedins_code"] = miConfig.Code
  29025. data["opter"] = roles.UserName
  29026. data["dept_code"] = department.Number
  29027. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29028. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29029. data["secret_key"] = miConfig.SecretKey
  29030. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  29031. data["url"] = miConfig.Url
  29032. data["ak"] = miConfig.AccessKey
  29033. data["new_doctor_name"] = patientPrescription.Doctor
  29034. if his.Insutype == "390" {
  29035. if reg_type == 992102 {
  29036. data["diag_code"] = "ZDZ940"
  29037. }
  29038. if reg_type == 140104 {
  29039. data["diag_code"] = sickConfig.CountryCode
  29040. }
  29041. if reg_type == 140201 {
  29042. data["diag_code"] = sickConfig.CountryCode
  29043. }
  29044. if reg_type == 14 {
  29045. data["diag_code"] = sickConfig.CountryCode
  29046. }
  29047. } else if his.Insutype == "310" {
  29048. if miConfig.MdtrtareaAdmvs == "341203"{
  29049. if reg_type == 992102 {
  29050. data["diag_code"] = "ZDZ940"
  29051. }
  29052. if reg_type != 992102 {
  29053. data["diag_code"] = sickConfig.CountryCode
  29054. }
  29055. }else{
  29056. data["diag_code"] = sickConfig.CountryCode
  29057. }
  29058. }
  29059. data["cainfo"] = miConfig.Cainfo
  29060. data["opter"] = roles.UserName
  29061. var ids []int64
  29062. for _, item := range prescriptions {
  29063. ids = append(ids, item.ID)
  29064. }
  29065. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29066. if config.IsOpen == 1 { //对接了医保,走医保流程
  29067. var res ResultFour
  29068. var resFour10265 ResultFour10265
  29069. if miConfig.MdtrtareaAdmvs == "421300" {
  29070. bytesData, _ := json.Marshal(data)
  29071. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29072. resp, _ := client.Do(req)
  29073. defer resp.Body.Close()
  29074. body, ioErr := ioutil.ReadAll(resp.Body)
  29075. if ioErr != nil {
  29076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29078. return
  29079. }
  29080. var respJSON map[string]interface{}
  29081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29084. return
  29085. }
  29086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29087. userJSONBytes, _ := json.Marshal(respJSON)
  29088. fmt.Println("log")
  29089. fmt.Println(string(userJSONBytes))
  29090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29091. utils.ErrorLog("解析失败:%v", err)
  29092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29093. return
  29094. }
  29095. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29096. bytesData, _ := json.Marshal(data)
  29097. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29098. resp, _ := client.Do(req)
  29099. defer resp.Body.Close()
  29100. body, ioErr := ioutil.ReadAll(resp.Body)
  29101. if ioErr != nil {
  29102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29104. return
  29105. }
  29106. var respJSON map[string]interface{}
  29107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29110. return
  29111. }
  29112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29113. userJSONBytes, _ := json.Marshal(respJSON)
  29114. fmt.Println("log")
  29115. fmt.Println(string(userJSONBytes))
  29116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29117. utils.ErrorLog("解析失败:%v", err)
  29118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29119. return
  29120. }
  29121. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29122. bytesData, _ := json.Marshal(data)
  29123. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29124. resp, _ := client.Do(req)
  29125. defer resp.Body.Close()
  29126. body, ioErr := ioutil.ReadAll(resp.Body)
  29127. if ioErr != nil {
  29128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29130. return
  29131. }
  29132. var respJSON map[string]interface{}
  29133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29136. return
  29137. }
  29138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29139. userJSONBytes, _ := json.Marshal(respJSON)
  29140. fmt.Println("log")
  29141. fmt.Println(string(userJSONBytes))
  29142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29143. utils.ErrorLog("解析失败:%v", err)
  29144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29145. return
  29146. }
  29147. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29148. bytesData, _ := json.Marshal(data)
  29149. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29150. resp, _ := client.Do(req)
  29151. defer resp.Body.Close()
  29152. body, ioErr := ioutil.ReadAll(resp.Body)
  29153. if ioErr != nil {
  29154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29156. return
  29157. }
  29158. var respJSON map[string]interface{}
  29159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29162. return
  29163. }
  29164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29165. userJSONBytes, _ := json.Marshal(respJSON)
  29166. fmt.Println("log")
  29167. fmt.Println(string(userJSONBytes))
  29168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29169. utils.ErrorLog("解析失败:%v", err)
  29170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29171. return
  29172. }
  29173. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29174. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29175. if result3101.Infcode == "0" {
  29176. if len(result3101.Output.Result) > 0 {
  29177. var errMsgs []string
  29178. for _, item := range result3101.Output.Result {
  29179. errMsgs = append(errMsgs, item.VolaCont)
  29180. }
  29181. c.ServeSuccessJSON(map[string]interface{}{
  29182. "failed_code": -10,
  29183. "msg": errMsgs,
  29184. })
  29185. return
  29186. } else {
  29187. if miConfig.MdtrtareaAdmvs == "320921" {
  29188. data["doctor_id"] = "D320923012139"
  29189. } else {
  29190. data["doctor_id"] = "D371621008686"
  29191. }
  29192. bytesData, _ := json.Marshal(data)
  29193. var req *http.Request
  29194. if miConfig.MdtrtareaAdmvs == "320921" {
  29195. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29196. } else {
  29197. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29198. }
  29199. resp, _ := client.Do(req)
  29200. defer resp.Body.Close()
  29201. body, ioErr := ioutil.ReadAll(resp.Body)
  29202. if ioErr != nil {
  29203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29205. return
  29206. }
  29207. var respJSON map[string]interface{}
  29208. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29211. return
  29212. }
  29213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29214. userJSONBytes, _ := json.Marshal(respJSON)
  29215. fmt.Println("log")
  29216. fmt.Println(string(userJSONBytes))
  29217. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29218. utils.ErrorLog("解析失败:%v", err)
  29219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29220. return
  29221. }
  29222. res.InfRefmsgid = resFour10265.InfRefmsgid
  29223. res.Output = resFour10265.Output
  29224. res.ErrMsg = resFour10265.ErrMsg
  29225. res.Cainfo = resFour10265.Cainfo
  29226. res.WarnMsg = resFour10265.WarnMsg
  29227. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29228. res.Infcode = infocode
  29229. }
  29230. }
  29231. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29232. var pagesize int = 5
  29233. var start int = 1
  29234. var stop int
  29235. var pagecount int
  29236. var curpage int
  29237. data["doctor_id"] = doctor_info.DoctorNumber
  29238. var res2 ResultFour
  29239. //var result res.
  29240. //总页数,向上取整,注意除之前要先转换类型为float64
  29241. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29242. for curpage = 1; curpage <= pagecount; curpage++ {
  29243. if curpage == 1 {
  29244. start = 1
  29245. } else {
  29246. start = (curpage-1)*pagesize + 1
  29247. }
  29248. stop = curpage * pagesize
  29249. if stop > len(prescriptions) {
  29250. stop = len(prescriptions)
  29251. }
  29252. //var requestLog string
  29253. data["pre"] = prescriptions[start-1 : stop]
  29254. fmt.Println(data["pre"])
  29255. bytesData, _ := json.Marshal(data)
  29256. var req *http.Request
  29257. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29258. resp, _ := client.Do(req)
  29259. defer resp.Body.Close()
  29260. body, ioErr := ioutil.ReadAll(resp.Body)
  29261. if ioErr != nil {
  29262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29264. return
  29265. }
  29266. var respJSON map[string]interface{}
  29267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29270. return
  29271. }
  29272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29273. userJSONBytes, _ := json.Marshal(respJSON)
  29274. fmt.Println("log")
  29275. fmt.Println(string(userJSONBytes))
  29276. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29277. utils.ErrorLog("解析失败:%v", err)
  29278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29279. return
  29280. }
  29281. res.InfRefmsgid = resFour10265.InfRefmsgid
  29282. res.Output = resFour10265.Output
  29283. res.ErrMsg = resFour10265.ErrMsg
  29284. res.Cainfo = resFour10265.Cainfo
  29285. res.WarnMsg = resFour10265.WarnMsg
  29286. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29287. res.Infcode = infocode
  29288. if infocode == 0 {
  29289. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29290. } else {
  29291. isSuccess = false
  29292. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29293. res.Infcode = -1
  29294. res.ErrMsg = resFour10265.ErrMsg
  29295. errlog := &models.HisOrderError{
  29296. UserOrgId: adminUser.CurrentOrgId,
  29297. Ctime: time.Now().Unix(),
  29298. Mtime: time.Now().Unix(),
  29299. Number: chrg_bchno,
  29300. ErrMsg: "",
  29301. Status: 1,
  29302. PatientId: id,
  29303. RecordTime: recordDateTime,
  29304. Stage: 4,
  29305. }
  29306. service.CreateErrMsgLog(errlog)
  29307. }
  29308. }
  29309. if isSuccess {
  29310. res.Infcode = 0
  29311. res.Output.Result = res2.Output.Result
  29312. } else {
  29313. order := &models.HisOrder{
  29314. UserOrgId: adminUser.CurrentOrgId,
  29315. HisPatientId: his.ID,
  29316. PatientId: his.PatientId,
  29317. SettleAccountsDate: recordDateTime,
  29318. Ctime: time.Now().Unix(),
  29319. Mtime: time.Now().Unix(),
  29320. MdtrtId: his.Number,
  29321. PsnNo: his.PsnNo,
  29322. MedType: strconv.FormatInt(reg_type, 10),
  29323. Status: 1,
  29324. Number: chrg_bchno,
  29325. Infcode: res.Infcode,
  29326. WarnMsg: res.WarnMsg,
  29327. Cainfo: res.Cainfo,
  29328. ErrMsg: res.ErrMsg,
  29329. RespondTime: res.RefmsgTime,
  29330. InfRefmsgid: res.InfRefmsgid,
  29331. OrderStatus: 1,
  29332. IsMedicineInsurance: 1,
  29333. SettleType: settle_accounts_type,
  29334. SettleStartTime: start_time,
  29335. SettleEndTime: end_time,
  29336. Creator: roles.AdminUserId,
  29337. Modify: roles.AdminUserId,
  29338. PType: 2,
  29339. Diagnosis: diagnosis_id,
  29340. }
  29341. err = service.CreateOrder(order)
  29342. if err != nil {
  29343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29344. return
  29345. }
  29346. c.ServeSuccessJSON(map[string]interface{}{
  29347. "failed_code": -10,
  29348. "msg": res2.ErrMsg,
  29349. })
  29350. return
  29351. }
  29352. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29353. 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)
  29354. var dat map[string]interface{}
  29355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29356. fmt.Println(dat)
  29357. } else {
  29358. fmt.Println(err)
  29359. }
  29360. saveLog(result, request_log, "2204", "上传费用明细")
  29361. userJSONBytes, _ := json.Marshal(dat)
  29362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29363. utils.ErrorLog("解析失败:%v", err)
  29364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29365. return
  29366. }
  29367. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29368. 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, "", "")
  29369. var dat map[string]interface{}
  29370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29371. fmt.Println(dat)
  29372. } else {
  29373. fmt.Println(err)
  29374. }
  29375. saveLog(result, request_log, "2204", "上传费用明细")
  29376. userJSONBytes, _ := json.Marshal(dat)
  29377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29378. utils.ErrorLog("解析失败:%v", err)
  29379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29380. return
  29381. }
  29382. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29383. 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, "", "")
  29384. var dat map[string]interface{}
  29385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29386. fmt.Println(dat)
  29387. } else {
  29388. fmt.Println(err)
  29389. }
  29390. saveLog(result, request_log, "2204", "上传费用明细")
  29391. userJSONBytes, _ := json.Marshal(dat)
  29392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29393. utils.ErrorLog("解析失败:%v", err)
  29394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29395. return
  29396. }
  29397. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29398. bytesData, _ := json.Marshal(data)
  29399. var req *http.Request
  29400. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", 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, &res); err != nil {
  29429. utils.ErrorLog("解析失败:%v", err)
  29430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29431. return
  29432. }
  29433. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29434. bytesData, _ := json.Marshal(data)
  29435. var req *http.Request
  29436. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29437. resp, _ := client.Do(req)
  29438. defer resp.Body.Close()
  29439. body, ioErr := ioutil.ReadAll(resp.Body)
  29440. if ioErr != nil {
  29441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29443. return
  29444. }
  29445. var respJSON map[string]interface{}
  29446. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29449. return
  29450. }
  29451. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29452. if status == "0" {
  29453. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29454. c.ServeSuccessJSON(map[string]interface{}{
  29455. "failed_code": -10,
  29456. "msg": err_msg,
  29457. })
  29458. return
  29459. }
  29460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29461. userJSONBytes, _ := json.Marshal(respJSON)
  29462. fmt.Println("log")
  29463. fmt.Println(string(userJSONBytes))
  29464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29465. utils.ErrorLog("解析失败:%v", err)
  29466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29467. return
  29468. }
  29469. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29470. 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, "", "")
  29471. var dat map[string]interface{}
  29472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29473. fmt.Println(dat)
  29474. } else {
  29475. fmt.Println(err)
  29476. }
  29477. saveLog(result, request_log, "2204", "上传费用明细")
  29478. userJSONBytes, _ := json.Marshal(dat)
  29479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29480. utils.ErrorLog("解析失败:%v", err)
  29481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29482. return
  29483. }
  29484. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29485. bytesData, _ := json.Marshal(data)
  29486. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29487. resp, _ := client.Do(req)
  29488. defer resp.Body.Close()
  29489. body, ioErr := ioutil.ReadAll(resp.Body)
  29490. if ioErr != nil {
  29491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29493. return
  29494. }
  29495. var respJSON map[string]interface{}
  29496. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29499. return
  29500. }
  29501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29502. userJSONBytes, _ := json.Marshal(respJSON)
  29503. fmt.Println("log")
  29504. fmt.Println(string(userJSONBytes))
  29505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29506. utils.ErrorLog("解析失败:%v", err)
  29507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29508. return
  29509. }
  29510. } else {
  29511. if miConfig.MdtrtareaAdmvs == "441202" {
  29512. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29513. if result3101.Infcode == 0 {
  29514. if len(result3101.Output.Result) > 0 {
  29515. var errMsgs []string
  29516. for _, item := range result3101.Output.Result {
  29517. errMsgs = append(errMsgs, item.VolaCont)
  29518. }
  29519. c.ServeSuccessJSON(map[string]interface{}{
  29520. "failed_code": -10,
  29521. "msg": errMsgs,
  29522. })
  29523. return
  29524. } else {
  29525. 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)
  29526. var dat map[string]interface{}
  29527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29528. fmt.Println(dat)
  29529. } else {
  29530. fmt.Println(err)
  29531. }
  29532. saveLog(result, request_log, "2204", "上传费用明细")
  29533. userJSONBytes, _ := json.Marshal(dat)
  29534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29535. utils.ErrorLog("解析失败:%v", err)
  29536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29537. return
  29538. }
  29539. }
  29540. } else {
  29541. c.ServeSuccessJSON(map[string]interface{}{
  29542. "failed_code": -10,
  29543. "msg": result3101.ErrMsg,
  29544. })
  29545. return
  29546. }
  29547. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29548. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29549. if result3101.Infcode == 0 {
  29550. if len(result3101.Output.Result) > 0 {
  29551. var errMsgs []string
  29552. for _, item := range result3101.Output.Result {
  29553. errMsgs = append(errMsgs, item.VolaCont)
  29554. }
  29555. c.ServeSuccessJSON(map[string]interface{}{
  29556. "failed_code": -10,
  29557. "msg": errMsgs,
  29558. })
  29559. return
  29560. } else {
  29561. 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)
  29562. var dat map[string]interface{}
  29563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29564. fmt.Println(dat)
  29565. } else {
  29566. fmt.Println(err)
  29567. }
  29568. saveLog(result, request_log, "2204", "上传费用明细")
  29569. userJSONBytes, _ := json.Marshal(dat)
  29570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29571. utils.ErrorLog("解析失败:%v", err)
  29572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29573. return
  29574. }
  29575. }
  29576. } else {
  29577. c.ServeSuccessJSON(map[string]interface{}{
  29578. "failed_code": -10,
  29579. "msg": result3101.ErrMsg,
  29580. })
  29581. return
  29582. }
  29583. } else {
  29584. if miConfig.Code == "H15049901371" {
  29585. 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)
  29586. var dat map[string]interface{}
  29587. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29588. fmt.Println(dat)
  29589. } else {
  29590. fmt.Println(err)
  29591. }
  29592. saveLog(result, request_log, "2204", "上传费用明细")
  29593. userJSONBytes, _ := json.Marshal(dat)
  29594. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29595. utils.ErrorLog("解析失败:%v", err)
  29596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29597. return
  29598. }
  29599. res.InfRefmsgid = resFour10265.InfRefmsgid
  29600. res.Output = resFour10265.Output
  29601. res.ErrMsg = resFour10265.ErrMsg
  29602. res.Cainfo = resFour10265.Cainfo
  29603. res.WarnMsg = resFour10265.WarnMsg
  29604. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29605. res.Infcode = infocode
  29606. } else {
  29607. 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)
  29608. var dat map[string]interface{}
  29609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29610. fmt.Println(dat)
  29611. } else {
  29612. fmt.Println(err)
  29613. }
  29614. saveLog(result, request_log, "2204", "上传费用明细")
  29615. userJSONBytes, _ := json.Marshal(dat)
  29616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29617. utils.ErrorLog("解析失败:%v", err)
  29618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29619. return
  29620. }
  29621. }
  29622. }
  29623. }
  29624. var total_two float64
  29625. if res.Infcode == -1 {
  29626. errlog := &models.HisOrderError{
  29627. UserOrgId: adminUser.CurrentOrgId,
  29628. Ctime: time.Now().Unix(),
  29629. Mtime: time.Now().Unix(),
  29630. Number: chrg_bchno,
  29631. ErrMsg: res.ErrMsg,
  29632. Status: 1,
  29633. PatientId: id,
  29634. RecordTime: recordDateTime,
  29635. Stage: 4,
  29636. }
  29637. service.CreateErrMsgLog(errlog)
  29638. c.ServeSuccessJSON(map[string]interface{}{
  29639. "failed_code": -10,
  29640. "msg": res.ErrMsg,
  29641. })
  29642. return
  29643. }
  29644. if res.Infcode == 0 {
  29645. order := &models.HisOrder{
  29646. UserOrgId: adminUser.CurrentOrgId,
  29647. HisPatientId: his.ID,
  29648. PatientId: his.PatientId,
  29649. SettleAccountsDate: recordDateTime,
  29650. Ctime: time.Now().Unix(),
  29651. Mtime: time.Now().Unix(),
  29652. MdtrtId: his.Number,
  29653. PsnNo: his.PsnNo,
  29654. MedType: strconv.FormatInt(reg_type, 10),
  29655. Status: 1,
  29656. Number: chrg_bchno,
  29657. Infcode: res.Infcode,
  29658. WarnMsg: res.WarnMsg,
  29659. Cainfo: res.Cainfo,
  29660. ErrMsg: res.ErrMsg,
  29661. RespondTime: res.RefmsgTime,
  29662. InfRefmsgid: res.InfRefmsgid,
  29663. OrderStatus: 1,
  29664. IsMedicineInsurance: 1,
  29665. SettleType: settle_accounts_type,
  29666. SettleStartTime: start_time,
  29667. SettleEndTime: end_time,
  29668. Creator: roles.AdminUserId,
  29669. Modify: roles.AdminUserId,
  29670. PType: 2,
  29671. Diagnosis: diagnosis_id,
  29672. }
  29673. err = service.CreateOrder(order)
  29674. if err != nil {
  29675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29676. return
  29677. }
  29678. for _, item := range res.Output.Result {
  29679. temp := strings.Split(item.FeedetlSn, "-")
  29680. var advice_id int64 = 0
  29681. var project_id int64 = 0
  29682. var types int64 = 0
  29683. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29684. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29685. if temp[1] == "1" {
  29686. advice_id = id
  29687. project_id = 0
  29688. } else if temp[1] == "2" {
  29689. advice_id = 0
  29690. project_id = id
  29691. }
  29692. total_two = total_two + item.DetItemFeeSumamt
  29693. info := &models.HisOrderInfo{
  29694. OrderNumber: order.Number,
  29695. FeedetlSn: item.FeedetlSn,
  29696. UploadDate: time.Now().Unix(),
  29697. AdviceId: advice_id,
  29698. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29699. Cnt: item.Cnt,
  29700. Pric: float64(item.Pric),
  29701. PatientId: his.PatientId,
  29702. PricUplmtAmt: item.PricUplmtAmt,
  29703. SelfpayProp: item.SelfpayProp,
  29704. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29705. OverlmtAmt: item.OverlmtAmt,
  29706. PreselfpayAmt: item.PreselfpayAmt,
  29707. BasMednFlag: item.BasMednFlag,
  29708. MedChrgitmType: item.MedChrgitmType,
  29709. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29710. Status: 1,
  29711. Memo: item.Memo,
  29712. Mtime: time.Now().Unix(),
  29713. InscpScpAmt: item.InscpScpAmt,
  29714. DrtReimFlag: item.DrtReimFlag,
  29715. Ctime: time.Now().Unix(),
  29716. ListSpItemFlag: item.ListSpItemFlag,
  29717. ChldMedcFlag: item.ChldMedcFlag,
  29718. LmtUsedFlag: item.LmtUsedFlag,
  29719. ChrgitmLv: item.ChrgitmLv,
  29720. UserOrgId: adminUser.CurrentOrgId,
  29721. HisPatientId: his.ID,
  29722. OrderId: order.ID,
  29723. ProjectId: project_id,
  29724. Type: types,
  29725. }
  29726. service.CreateOrderInfo(info)
  29727. }
  29728. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29729. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29730. var total float64
  29731. for _, item := range prescriptions {
  29732. if item.Type == 1 { //药品
  29733. for _, subItem := range item.HisDoctorAdviceInfo {
  29734. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29735. total_one := price * subItem.PrescribingNumber
  29736. fmt.Println("subItem")
  29737. fmt.Println(subItem.Price)
  29738. fmt.Println("price")
  29739. fmt.Println(price)
  29740. fmt.Println("total_one")
  29741. fmt.Println(total_one)
  29742. total = total + total_one
  29743. fmt.Println(total)
  29744. }
  29745. }
  29746. if item.Type == 2 { //项目
  29747. for _, subItem := range item.HisPrescriptionProject {
  29748. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29749. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29750. total_one := price * cnt
  29751. total = total + total_one
  29752. }
  29753. }
  29754. }
  29755. allTotal := fmt.Sprintf("%.2f", total)
  29756. if res.Infcode == 0 {
  29757. var rf []*ResultFive
  29758. json.Unmarshal([]byte(his.Iinfo), &rf)
  29759. chrg_bchno := chrg_bchno
  29760. cert_no := his.Certno
  29761. var insutypes []string
  29762. var insutype string
  29763. var is390 int = 0
  29764. var is310 int = 0
  29765. for _, item := range rf {
  29766. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29767. insutypes = append(insutypes, item.Insutype)
  29768. }
  29769. }
  29770. if len(insutypes) == 1 {
  29771. insutype = insutypes[0]
  29772. } else {
  29773. for _, i := range insutypes {
  29774. if i == "390" {
  29775. is390 = 1
  29776. }
  29777. if i == "310" {
  29778. is310 = 1
  29779. }
  29780. }
  29781. }
  29782. if is390 == 1 {
  29783. insutype = "390"
  29784. }
  29785. if is310 == 1 {
  29786. insutype = "310"
  29787. }
  29788. if len(insutypes) == 0 {
  29789. insutype = "390"
  29790. }
  29791. if len(insutypes) == 2 {
  29792. insutype = strconv.FormatInt(his.SocialType, 10)
  29793. }
  29794. //insutype = "390"
  29795. if his.IdCardType == 1 {
  29796. cert_no = his.MedicalInsuranceNumber
  29797. } else {
  29798. cert_no = his.Certno
  29799. }
  29800. var res ResultSeven
  29801. var ahres ResultSevenAH
  29802. var resSeven10265 ResultSeven10265
  29803. var resSeven10265Two ResultSeven10265Two
  29804. var gzresSeven10265Two GZResultSeven10265Two
  29805. if miConfig.MdtrtareaAdmvs == "421300" {
  29806. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29807. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29808. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29809. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29810. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29811. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29812. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29813. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29814. resp, requestErr := http.Get(api)
  29815. if requestErr != nil {
  29816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29817. return
  29818. }
  29819. body, ioErr := ioutil.ReadAll(resp.Body)
  29820. if ioErr != nil {
  29821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29823. return
  29824. }
  29825. var respJSON map[string]interface{}
  29826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29829. return
  29830. }
  29831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29832. result, _ := json.Marshal(respJSON)
  29833. fmt.Println("log")
  29834. fmt.Println(string(result))
  29835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29836. utils.ErrorLog("解析失败:%v", err)
  29837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29838. return
  29839. }
  29840. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29841. if reg_type == 11 && his.Insutype == "390" {
  29842. reg_type = 110104
  29843. }
  29844. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29845. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29846. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29847. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29848. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29849. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29850. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29851. resp, requestErr := http.Get(api)
  29852. if requestErr != nil {
  29853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29854. return
  29855. }
  29856. body, ioErr := ioutil.ReadAll(resp.Body)
  29857. if ioErr != nil {
  29858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29860. return
  29861. }
  29862. var respJSON map[string]interface{}
  29863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29866. return
  29867. }
  29868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29869. result, _ := json.Marshal(respJSON)
  29870. fmt.Println("log")
  29871. fmt.Println(string(result))
  29872. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29873. utils.ErrorLog("解析失败:%v", err)
  29874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29875. return
  29876. }
  29877. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29878. if reg_type == 11 && his.Insutype == "390" {
  29879. reg_type = 110104
  29880. }
  29881. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29882. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29883. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29885. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29886. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29887. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29888. resp, requestErr := http.Get(api)
  29889. if requestErr != nil {
  29890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29891. return
  29892. }
  29893. body, ioErr := ioutil.ReadAll(resp.Body)
  29894. if ioErr != nil {
  29895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29897. return
  29898. }
  29899. var respJSON map[string]interface{}
  29900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29903. return
  29904. }
  29905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29906. result, _ := json.Marshal(respJSON)
  29907. fmt.Println("log")
  29908. fmt.Println(string(result))
  29909. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29910. utils.ErrorLog("解析失败:%v", err)
  29911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29912. return
  29913. }
  29914. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29915. if reg_type == 11 && his.Insutype == "390" {
  29916. reg_type = 110104
  29917. }
  29918. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29919. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29920. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29921. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29922. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29923. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29924. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29925. resp, requestErr := http.Get(api)
  29926. if requestErr != nil {
  29927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29928. return
  29929. }
  29930. body, ioErr := ioutil.ReadAll(resp.Body)
  29931. if ioErr != nil {
  29932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29934. return
  29935. }
  29936. var respJSON map[string]interface{}
  29937. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29940. return
  29941. }
  29942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29943. result, _ := json.Marshal(respJSON)
  29944. fmt.Println("log")
  29945. fmt.Println(string(result))
  29946. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29947. utils.ErrorLog("解析失败:%v", err)
  29948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29949. return
  29950. }
  29951. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29952. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29953. if result3101.Infcode == "0" {
  29954. if len(result3101.Output.Result) > 0 {
  29955. var errMsgs []string
  29956. for _, item := range result3101.Output.Result {
  29957. errMsgs = append(errMsgs, item.VolaCont)
  29958. }
  29959. c.ServeSuccessJSON(map[string]interface{}{
  29960. "failed_code": -10,
  29961. "msg": errMsgs,
  29962. })
  29963. return
  29964. } else {
  29965. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29966. if his.IdCardType != 4 {
  29967. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29968. bas := strings.Split(psn_info.CardInfo, "|")
  29969. if his.IdCardType == 1 {
  29970. cert_no = bas[2]
  29971. } else {
  29972. cert_no = bas[1]
  29973. }
  29974. } else {
  29975. cert_no = his.Certno
  29976. }
  29977. //江苏地区国家医保医疗类别
  29978. //职工透析:医疗类别选特殊情况门诊9933
  29979. //居民血透门慢: 医疗类别选门诊慢病1402
  29980. //var med_type string
  29981. //if his.Insutype == "310" {
  29982. // if reg_type == 14 {
  29983. // med_type = "9933"
  29984. // } else if reg_type == 11 {
  29985. // med_type = "11"
  29986. //
  29987. // }
  29988. //} else if his.Insutype == "390" {
  29989. // if reg_type == 14 {
  29990. // med_type = "1402"
  29991. // } else if reg_type == 11 {
  29992. // med_type = "11"
  29993. // }
  29994. //}
  29995. var api string
  29996. if miConfig.MdtrtareaAdmvs == "320921" {
  29997. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29998. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29999. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30000. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30001. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30002. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30003. "&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
  30004. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30005. } else {
  30006. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30007. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30008. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30009. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30010. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30011. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30012. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30013. "&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
  30014. }
  30015. resp, requestErr := http.Get(api)
  30016. if requestErr != nil {
  30017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30018. return
  30019. }
  30020. body, ioErr := ioutil.ReadAll(resp.Body)
  30021. if ioErr != nil {
  30022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30024. return
  30025. }
  30026. var respJSON map[string]interface{}
  30027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30030. return
  30031. }
  30032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30033. result, _ := json.Marshal(respJSON)
  30034. fmt.Println("log")
  30035. fmt.Println(string(result))
  30036. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  30037. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30038. utils.ErrorLog("解析失败:%v", err)
  30039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30040. return
  30041. }
  30042. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30043. res.Output = resSeven10265.Output
  30044. res.ErrMsg = resSeven10265.ErrMsg
  30045. res.Cainfo = resSeven10265.Cainfo
  30046. res.WarnMsg = resSeven10265.WarnMsg
  30047. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30048. res.Infcode = infocode
  30049. } else {
  30050. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  30051. utils.ErrorLog("解析失败:%v", err)
  30052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30053. return
  30054. }
  30055. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  30056. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  30057. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  30058. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  30059. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30060. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  30061. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  30062. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  30063. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  30064. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  30065. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  30066. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30067. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  30068. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  30069. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30070. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30071. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  30072. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  30073. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  30074. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  30075. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  30076. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30077. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  30078. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  30079. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  30080. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  30081. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  30082. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  30083. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  30084. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  30085. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30086. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  30087. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  30088. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  30089. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30090. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30091. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30092. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30093. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  30094. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30095. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30096. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30097. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30098. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30099. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30100. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30101. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30102. res.ErrMsg = resSeven10265Two.ErrMsg
  30103. res.Cainfo = resSeven10265Two.Cainfo
  30104. res.WarnMsg = resSeven10265Two.WarnMsg
  30105. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30106. res.Infcode = infocode
  30107. }
  30108. }
  30109. }
  30110. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30111. psn_info, _ := service.GetPsnByPatientId(id)
  30112. var verify_number string
  30113. if psn_info.IdCardType == 4 {
  30114. verify_number = psn_info.VerifyNumber
  30115. } else if psn_info.IdCardType == 1 {
  30116. bas := strings.Split(psn_info.CardInfo, "|")
  30117. cardNumber := bas[2]
  30118. verify_number = cardNumber
  30119. } else {
  30120. psn_info.IdCardType = 2
  30121. verify_number = psn_info.Certno
  30122. }
  30123. var api string
  30124. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30125. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30126. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30127. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30128. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30129. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30130. "&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
  30131. resp, requestErr := http.Get(api)
  30132. if requestErr != nil {
  30133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30134. return
  30135. }
  30136. body, ioErr := ioutil.ReadAll(resp.Body)
  30137. if ioErr != nil {
  30138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30140. return
  30141. }
  30142. var respJSON map[string]interface{}
  30143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30146. return
  30147. }
  30148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30149. result, _ := json.Marshal(respJSON)
  30150. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30151. utils.ErrorLog("解析失败:%v", err)
  30152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30153. return
  30154. }
  30155. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30156. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30157. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30158. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30159. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30160. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30161. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30162. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30163. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30164. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30165. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30166. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30167. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30168. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30169. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30170. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30171. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30172. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30173. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30174. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30175. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30176. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30177. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30178. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30179. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30180. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30181. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30182. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30183. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30184. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30185. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30186. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30187. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30188. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30189. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30190. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30191. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30192. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30193. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30194. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30195. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30196. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30197. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30198. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30199. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30200. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30201. res.ErrMsg = resSeven10265.ErrMsg
  30202. res.Cainfo = resSeven10265.Cainfo
  30203. res.WarnMsg = resSeven10265.WarnMsg
  30204. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30205. res.Infcode = infocode
  30206. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30207. acct_used_flag := "1"
  30208. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30209. var result string
  30210. var request_log string
  30211. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30212. 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)
  30213. } else {
  30214. 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)
  30215. }
  30216. var dat map[string]interface{}
  30217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30218. fmt.Println(dat)
  30219. } else {
  30220. fmt.Println(err)
  30221. }
  30222. saveLog(result, request_log, "2206", "预结算")
  30223. userJSONBytes, _ := json.Marshal(dat)
  30224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30225. utils.ErrorLog("解析失败:%v", err)
  30226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30227. return
  30228. }
  30229. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30230. var result string
  30231. var request_log string
  30232. if his.IdCardType == 2 {
  30233. 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, "")
  30234. } else if his.IdCardType == 1 {
  30235. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30236. bas := strings.Split(psn_info.CardInfo, "|")
  30237. basNumber := bas[2]
  30238. card_sn := bas[3]
  30239. var rf []*ResultFive
  30240. json.Unmarshal([]byte(his.Iinfo), &rf)
  30241. var psn_type string
  30242. for _, item := range rf {
  30243. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30244. psn_type = item.PsnType
  30245. }
  30246. }
  30247. 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)
  30248. } else {
  30249. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30250. //bas := strings.Split(psn_info.CardInfo, "|")
  30251. //basNumber := bas[2]
  30252. //card_sn := bas[3]
  30253. var rf []*ResultFive
  30254. json.Unmarshal([]byte(his.Iinfo), &rf)
  30255. var psn_type string
  30256. for _, item := range rf {
  30257. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30258. psn_type = item.PsnType
  30259. }
  30260. }
  30261. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30262. 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)
  30263. }
  30264. var dat map[string]interface{}
  30265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30266. fmt.Println(dat)
  30267. } else {
  30268. fmt.Println(err)
  30269. }
  30270. saveLog(result, request_log, "2206", "预结算")
  30271. userJSONBytes, _ := json.Marshal(dat)
  30272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30273. utils.ErrorLog("解析失败:%v", err)
  30274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30275. return
  30276. }
  30277. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30278. var result string
  30279. var request_log string
  30280. if his.IdCardType == 2 {
  30281. 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, "")
  30282. } else if his.IdCardType == 1 {
  30283. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30284. bas := strings.Split(psn_info.CardInfo, "|")
  30285. basNumber := bas[0]
  30286. card_sn := ""
  30287. var rf []*ResultFive
  30288. json.Unmarshal([]byte(his.Iinfo), &rf)
  30289. var psn_type string
  30290. for _, item := range rf {
  30291. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30292. psn_type = item.PsnType
  30293. }
  30294. }
  30295. 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)
  30296. } else {
  30297. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30298. //bas := strings.Split(psn_info.CardInfo, "|")
  30299. //basNumber := bas[2]
  30300. //card_sn := bas[3]
  30301. var rf []*ResultFive
  30302. json.Unmarshal([]byte(his.Iinfo), &rf)
  30303. var psn_type string
  30304. for _, item := range rf {
  30305. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30306. psn_type = item.PsnType
  30307. }
  30308. }
  30309. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30310. 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)
  30311. }
  30312. var dat map[string]interface{}
  30313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30314. fmt.Println(dat)
  30315. } else {
  30316. fmt.Println(err)
  30317. }
  30318. saveLog(result, request_log, "2206", "预结算")
  30319. userJSONBytes, _ := json.Marshal(dat)
  30320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30321. utils.ErrorLog("解析失败:%v", err)
  30322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30323. return
  30324. }
  30325. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30326. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30327. if his.IdCardType == 4 {
  30328. psn_info.VerifyNumber = psn_info.VerifyNumber
  30329. cert_no = psn_info.VerifyNumber
  30330. } else if his.IdCardType == 2 {
  30331. cert_no = psn_info.Certno
  30332. psn_info.VerifyNumber = psn_info.Certno
  30333. } else {
  30334. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30335. bas := strings.Split(psn_info.CardInfo, "|")
  30336. if his.IdCardType == 1 {
  30337. cert_no = bas[2]
  30338. } else {
  30339. cert_no = bas[1]
  30340. }
  30341. }
  30342. var api string
  30343. var med_type string
  30344. if his.Insutype == "390" {
  30345. if reg_type == 992102 {
  30346. med_type = "992102"
  30347. }
  30348. if reg_type == 140104 {
  30349. med_type = "140104"
  30350. }
  30351. if reg_type == 140201 {
  30352. med_type = "140201"
  30353. }
  30354. if reg_type == 14 {
  30355. med_type = "140104"
  30356. }
  30357. } else if his.Insutype == "310" {
  30358. if reg_type == 992102 {
  30359. med_type = "992102"
  30360. }
  30361. if reg_type == 140104 {
  30362. med_type = "140104"
  30363. }
  30364. if reg_type == 140201 {
  30365. med_type = "140201"
  30366. }
  30367. if reg_type == 14 {
  30368. med_type = "140104"
  30369. }
  30370. }
  30371. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30372. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30373. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30374. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30375. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30376. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30377. "&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
  30378. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30379. resp, requestErr := http.Get(api)
  30380. if requestErr != nil {
  30381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30382. return
  30383. }
  30384. body, ioErr := ioutil.ReadAll(resp.Body)
  30385. if ioErr != nil {
  30386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30388. return
  30389. }
  30390. var respJSON map[string]interface{}
  30391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30394. return
  30395. }
  30396. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30397. if status == "0" {
  30398. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30399. c.ServeSuccessJSON(map[string]interface{}{
  30400. "failed_code": -10,
  30401. "msg": err_msg,
  30402. })
  30403. return
  30404. }
  30405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30406. result, _ := json.Marshal(respJSON)
  30407. fmt.Println("log")
  30408. fmt.Println(string(result))
  30409. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30410. utils.ErrorLog("解析失败:%v", err)
  30411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30412. return
  30413. }
  30414. res.InfRefmsgid = ahres.InfRefmsgid
  30415. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30416. // 创建对应的Time类型
  30417. t := time.UnixMilli(timestamp)
  30418. // 格式化成指定的日期字符串
  30419. str := t.Format("2006-01-02 15:04:05")
  30420. res.Output.Setlinfo.SetlTime = str
  30421. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30422. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30423. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30424. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30425. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30426. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30427. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30428. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30429. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30430. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30431. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30432. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30433. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30434. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30435. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30436. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30437. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30438. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30439. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30440. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30441. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30442. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30443. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30444. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30445. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30446. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30447. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30448. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30449. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30450. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30451. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30452. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30453. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30454. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30455. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30456. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30457. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30458. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30459. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30460. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30461. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30462. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30463. //res.Output.Setldetail = ahres.Output.Setldetail
  30464. res.ErrMsg = ahres.ErrMsg
  30465. res.Cainfo = ahres.Cainfo
  30466. res.WarnMsg = ahres.WarnMsg
  30467. res.Infcode = ahres.Infcode
  30468. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30469. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30470. if his.IdCardType == 4 {
  30471. psn_info.VerifyNumber = psn_info.VerifyNumber
  30472. cert_no = psn_info.Certno
  30473. } else if his.IdCardType == 2 {
  30474. cert_no = psn_info.Certno
  30475. psn_info.VerifyNumber = psn_info.Certno
  30476. } else {
  30477. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30478. bas := strings.Split(psn_info.CardInfo, "|")
  30479. if his.IdCardType == 1 {
  30480. cert_no = bas[2]
  30481. } else {
  30482. cert_no = bas[1]
  30483. }
  30484. }
  30485. var api string
  30486. var med_type string
  30487. if his.Insutype == "390" {
  30488. if reg_type == 992102 {
  30489. med_type = "992102"
  30490. }
  30491. if reg_type == 140104 {
  30492. med_type = "140104"
  30493. }
  30494. if reg_type == 140201 {
  30495. med_type = "140201"
  30496. }
  30497. if reg_type == 14 {
  30498. med_type = "14"
  30499. }
  30500. } else if his.Insutype == "310" {
  30501. if reg_type == 992102 {
  30502. med_type = "992102"
  30503. }
  30504. if reg_type == 140104 {
  30505. med_type = "140104"
  30506. }
  30507. if reg_type == 140201 {
  30508. med_type = "140201"
  30509. }
  30510. if reg_type == 14 {
  30511. med_type = "14"
  30512. }
  30513. }
  30514. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30515. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30516. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30518. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30519. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30520. "&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
  30521. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30522. resp, requestErr := http.Get(api)
  30523. if requestErr != nil {
  30524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30525. return
  30526. }
  30527. body, ioErr := ioutil.ReadAll(resp.Body)
  30528. if ioErr != nil {
  30529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30531. return
  30532. }
  30533. var respJSON map[string]interface{}
  30534. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30537. return
  30538. }
  30539. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30540. if status == "0" {
  30541. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30542. c.ServeSuccessJSON(map[string]interface{}{
  30543. "failed_code": -10,
  30544. "msg": err_msg,
  30545. })
  30546. return
  30547. }
  30548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30549. result, _ := json.Marshal(respJSON)
  30550. fmt.Println("log")
  30551. fmt.Println(string(result))
  30552. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30553. utils.ErrorLog("解析失败:%v", err)
  30554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30555. return
  30556. }
  30557. res.InfRefmsgid = ahres.InfRefmsgid
  30558. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30559. // 创建对应的Time类型
  30560. t := time.UnixMilli(timestamp)
  30561. // 格式化成指定的日期字符串
  30562. str := t.Format("2006-01-02 15:04:05")
  30563. res.Output.Setlinfo.SetlTime = str
  30564. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30565. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30566. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30567. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30568. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30569. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30570. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30571. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30572. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30573. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30574. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30575. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30576. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30577. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30578. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30579. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30580. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30581. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30582. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30583. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30584. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30585. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30586. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30587. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30588. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30589. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30590. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30591. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30592. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30593. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30594. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30595. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30596. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30597. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30598. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30599. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30600. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30601. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30602. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30603. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30604. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30605. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30606. //res.Output.Setldetail = ahres.Output.Setldetail
  30607. res.ErrMsg = ahres.ErrMsg
  30608. res.Cainfo = ahres.Cainfo
  30609. res.WarnMsg = ahres.WarnMsg
  30610. res.Infcode = ahres.Infcode
  30611. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30612. var result string
  30613. var request_log string
  30614. if his.IdCardType == 2 {
  30615. 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")
  30616. } else if his.IdCardType == 1 {
  30617. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30618. bas := strings.Split(psn_info.CardInfo, "|")
  30619. basNumber := bas[2]
  30620. card_sn := bas[3]
  30621. 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")
  30622. } else {
  30623. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30624. 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")
  30625. }
  30626. var dat map[string]interface{}
  30627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30628. fmt.Println(dat)
  30629. } else {
  30630. fmt.Println(err)
  30631. }
  30632. saveLog(result, request_log, "2206", "预结算")
  30633. userJSONBytes, _ := json.Marshal(dat)
  30634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30635. utils.ErrorLog("解析失败:%v", err)
  30636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30637. return
  30638. }
  30639. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30640. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30641. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30642. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30643. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30644. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30645. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30646. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30647. resp, requestErr := http.Get(api)
  30648. if requestErr != nil {
  30649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30650. return
  30651. }
  30652. body, ioErr := ioutil.ReadAll(resp.Body)
  30653. if ioErr != nil {
  30654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30656. return
  30657. }
  30658. var respJSON map[string]interface{}
  30659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30662. return
  30663. }
  30664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30665. result, _ := json.Marshal(respJSON)
  30666. fmt.Println("log")
  30667. fmt.Println(string(result))
  30668. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30669. utils.ErrorLog("解析失败:%v", err)
  30670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30671. return
  30672. }
  30673. } else {
  30674. if miConfig.MdtrtareaAdmvs == "441202" {
  30675. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30676. if result3101.Infcode == 0 {
  30677. if len(result3101.Output.Result) > 0 {
  30678. var errMsgs []string
  30679. for _, item := range result3101.Output.Result {
  30680. errMsgs = append(errMsgs, item.VolaCont)
  30681. }
  30682. c.ServeSuccessJSON(map[string]interface{}{
  30683. "failed_code": -10,
  30684. "msg": errMsgs,
  30685. })
  30686. return
  30687. } else {
  30688. var result string
  30689. var request_log string
  30690. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30691. allTotal = fmt.Sprintf("%.2f", total_two)
  30692. if his.IdCardType == 4 {
  30693. 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)
  30694. } else {
  30695. 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)
  30696. }
  30697. var dat map[string]interface{}
  30698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30699. fmt.Println(dat)
  30700. } else {
  30701. fmt.Println(err)
  30702. }
  30703. saveLog(result, request_log, "2206", "预结算")
  30704. //userJSONBytes, _ := json.Marshal(dat)
  30705. //
  30706. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30707. // utils.ErrorLog("解析失败:%v", err)
  30708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30709. // return
  30710. //}
  30711. userJSONBytes, _ := json.Marshal(dat)
  30712. if miConfig.Code == "H15049901371" {
  30713. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30714. utils.ErrorLog("解析失败:%v", err)
  30715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30716. return
  30717. }
  30718. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30719. res.Output = resSeven10265.Output
  30720. res.ErrMsg = resSeven10265.ErrMsg
  30721. res.Cainfo = resSeven10265.Cainfo
  30722. res.WarnMsg = resSeven10265.WarnMsg
  30723. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30724. res.Infcode = infocode
  30725. } else {
  30726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30727. utils.ErrorLog("解析失败:%v", err)
  30728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30729. return
  30730. }
  30731. }
  30732. }
  30733. } else {
  30734. c.ServeSuccessJSON(map[string]interface{}{
  30735. "failed_code": -10,
  30736. "msg": result3101.ErrMsg,
  30737. })
  30738. return
  30739. }
  30740. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30741. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30742. if result3101.Infcode == 0 {
  30743. if len(result3101.Output.Result) > 0 {
  30744. var errMsgs []string
  30745. for _, item := range result3101.Output.Result {
  30746. errMsgs = append(errMsgs, item.VolaCont)
  30747. }
  30748. c.ServeSuccessJSON(map[string]interface{}{
  30749. "failed_code": -10,
  30750. "msg": errMsgs,
  30751. })
  30752. return
  30753. } else {
  30754. var result string
  30755. var request_log string
  30756. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30757. allTotal = fmt.Sprintf("%.2f", total_two)
  30758. if his.IdCardType == 4 {
  30759. 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)
  30760. } else {
  30761. 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)
  30762. }
  30763. var dat map[string]interface{}
  30764. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30765. fmt.Println(dat)
  30766. } else {
  30767. fmt.Println(err)
  30768. }
  30769. saveLog(result, request_log, "2206", "预结算")
  30770. //userJSONBytes, _ := json.Marshal(dat)
  30771. //
  30772. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30773. // utils.ErrorLog("解析失败:%v", err)
  30774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30775. // return
  30776. //}
  30777. userJSONBytes, _ := json.Marshal(dat)
  30778. if miConfig.Code == "H15049901371" {
  30779. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30780. utils.ErrorLog("解析失败:%v", err)
  30781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30782. return
  30783. }
  30784. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30785. res.Output = resSeven10265.Output
  30786. res.ErrMsg = resSeven10265.ErrMsg
  30787. res.Cainfo = resSeven10265.Cainfo
  30788. res.WarnMsg = resSeven10265.WarnMsg
  30789. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30790. res.Infcode = infocode
  30791. } else {
  30792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30793. utils.ErrorLog("解析失败:%v", err)
  30794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30795. return
  30796. }
  30797. }
  30798. }
  30799. } else {
  30800. c.ServeSuccessJSON(map[string]interface{}{
  30801. "failed_code": -10,
  30802. "msg": result3101.ErrMsg,
  30803. })
  30804. return
  30805. }
  30806. } else {
  30807. var result string
  30808. var request_log string
  30809. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30810. allTotal = fmt.Sprintf("%.2f", total_two)
  30811. if his.IdCardType == 4 {
  30812. 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)
  30813. } else {
  30814. 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)
  30815. }
  30816. var dat map[string]interface{}
  30817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30818. fmt.Println(dat)
  30819. } else {
  30820. fmt.Println(err)
  30821. }
  30822. saveLog(result, request_log, "2206", "预结算")
  30823. //userJSONBytes, _ := json.Marshal(dat)
  30824. //
  30825. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30826. // utils.ErrorLog("解析失败:%v", err)
  30827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30828. // return
  30829. //}
  30830. userJSONBytes, _ := json.Marshal(dat)
  30831. if miConfig.Code == "H15049901371" {
  30832. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30833. utils.ErrorLog("解析失败:%v", err)
  30834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30835. return
  30836. }
  30837. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30838. res.Output = resSeven10265.Output
  30839. res.ErrMsg = resSeven10265.ErrMsg
  30840. res.Cainfo = resSeven10265.Cainfo
  30841. res.WarnMsg = resSeven10265.WarnMsg
  30842. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30843. res.Infcode = infocode
  30844. } else {
  30845. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30846. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30847. utils.ErrorLog("解析失败:%v", err)
  30848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30849. return
  30850. }
  30851. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30852. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30853. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30854. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30855. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30856. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30857. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30858. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30859. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30860. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30861. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30862. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30863. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30864. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30865. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30866. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30867. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30868. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30869. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30870. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30871. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30872. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30873. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30874. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30875. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30876. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30877. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30878. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30879. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30880. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30881. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30882. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30883. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30884. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30885. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30886. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30887. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30888. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30889. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30890. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30891. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30892. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30893. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30894. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30895. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30896. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30897. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30898. res.Cainfo = gzresSeven10265Two.Cainfo
  30899. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30900. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30901. //res.Infcode = infocode
  30902. } else {
  30903. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30904. utils.ErrorLog("解析失败:%v", err)
  30905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30906. return
  30907. }
  30908. }
  30909. }
  30910. }
  30911. }
  30912. utils.ErrorLog("解析失败:%v", res.Infcode)
  30913. if res.Infcode == -1 {
  30914. errlog := &models.HisOrderError{
  30915. UserOrgId: adminUser.CurrentOrgId,
  30916. Ctime: time.Now().Unix(),
  30917. Mtime: time.Now().Unix(),
  30918. Number: chrg_bchno,
  30919. ErrMsg: res.ErrMsg,
  30920. Status: 1,
  30921. PatientId: id,
  30922. RecordTime: recordDateTime,
  30923. Stage: 20,
  30924. }
  30925. service.CreateErrMsgLog(errlog)
  30926. c.ServeSuccessJSON(map[string]interface{}{
  30927. "failed_code": -10,
  30928. "msg": res.ErrMsg,
  30929. })
  30930. return
  30931. }
  30932. if res.Infcode != 0 {
  30933. errlog := &models.HisOrderError{
  30934. UserOrgId: adminUser.CurrentOrgId,
  30935. Ctime: time.Now().Unix(),
  30936. Mtime: time.Now().Unix(),
  30937. Number: chrg_bchno,
  30938. ErrMsg: res.ErrMsg,
  30939. Status: 1,
  30940. PatientId: id,
  30941. RecordTime: recordDateTime,
  30942. Stage: 20,
  30943. }
  30944. service.CreateErrMsgLog(errlog)
  30945. c.ServeSuccessJSON(map[string]interface{}{
  30946. "failed_code": -10,
  30947. "msg": res.ErrMsg,
  30948. })
  30949. return
  30950. } else {
  30951. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30952. order.OrderStatus = 1
  30953. order.IsPre = 1
  30954. order.Status = 1
  30955. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30956. order.SetlId = res.Output.Setlinfo.SetlID
  30957. order.PsnNo = res.Output.Setlinfo.PsnNo
  30958. order.PsnName = res.Output.Setlinfo.PsnName
  30959. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30960. order.Certno = res.Output.Setlinfo.Certno
  30961. order.Gend = res.Output.Setlinfo.Gend
  30962. order.Naty = res.Output.Setlinfo.Naty
  30963. order.Age = res.Output.Setlinfo.Age
  30964. order.Insutype = res.Output.Setlinfo.Insutype
  30965. order.PsnType = res.Output.Setlinfo.PsnType
  30966. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30967. order.SetlTime = res.Output.Setlinfo.SetlTime
  30968. order.AcctUsedFlag = acct_used_flag
  30969. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30970. if res.Output.Setlinfo.MedType == "140101" {
  30971. order.MedType = "14"
  30972. } else {
  30973. if res.Output.Setlinfo.MedType == "110104" {
  30974. order.MedType = "11"
  30975. } else {
  30976. order.MedType = res.Output.Setlinfo.MedType
  30977. }
  30978. }
  30979. if res.Output.Setlinfo.MedType == "992102" {
  30980. order.MedType = "992102"
  30981. }
  30982. if res.Output.Setlinfo.MedType == "140104" {
  30983. order.MedType = "140104"
  30984. }
  30985. if res.Output.Setlinfo.MedType == "140201" {
  30986. order.MedType = "140201"
  30987. }
  30988. if res.Output.Setlinfo.MedType == "14" {
  30989. order.MedType = "14"
  30990. }
  30991. if reg_type == 1112 {
  30992. order.MedType = "1112"
  30993. }
  30994. if reg_type == 1111 {
  30995. order.MedType = "1111"
  30996. }
  30997. order.ClrType = res.Output.Setlinfo.ClrType
  30998. if adminUser.CurrentOrgId == 10480 {
  30999. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  31000. order.ClrType = "11"
  31001. } else {
  31002. order.ClrType = "9903"
  31003. }
  31004. }
  31005. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  31006. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  31007. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  31008. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  31009. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  31010. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  31011. order.HifpPay = res.Output.Setlinfo.HifpPay
  31012. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  31013. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  31014. order.HifesPay = res.Output.Setlinfo.HifesPay
  31015. order.HifobPay = res.Output.Setlinfo.HifobPay
  31016. order.MafPay = res.Output.Setlinfo.MafPay
  31017. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  31018. order.OthPay = res.Output.Setlinfo.OthPay
  31019. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  31020. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  31021. order.AcctPay = res.Output.Setlinfo.AcctPay
  31022. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  31023. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  31024. order.Balc = res.Output.Setlinfo.Balc
  31025. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  31026. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  31027. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  31028. order.ClrWay = res.Output.Setlinfo.ClrWay
  31029. order.Creator = order.Creator
  31030. order.Modify = roles.AdminUserId
  31031. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  31032. //detailStr := string(setlDetail)
  31033. //order.SetlDetail = detailStr
  31034. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  31035. err = service.UpDateOrder(order)
  31036. if err == nil {
  31037. c.ServeSuccessJSON(map[string]interface{}{
  31038. "msg": "预结算成功",
  31039. })
  31040. } else {
  31041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  31042. return
  31043. }
  31044. }
  31045. } else {
  31046. adminUser := c.GetAdminUserInfo()
  31047. errlog := &models.HisOrderError{
  31048. UserOrgId: adminUser.CurrentOrgId,
  31049. Ctime: time.Now().Unix(),
  31050. Mtime: time.Now().Unix(),
  31051. ErrMsg: res.ErrMsg,
  31052. Status: 1,
  31053. PatientId: id,
  31054. RecordTime: recordDateTime,
  31055. Stage: 4,
  31056. }
  31057. service.CreateErrMsgLog(errlog)
  31058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31059. return
  31060. }
  31061. } else {
  31062. if miConfig.MdtrtareaAdmvs == "150499" {
  31063. order := &models.HisOrder{
  31064. UserOrgId: adminUser.CurrentOrgId,
  31065. HisPatientId: his.ID,
  31066. PatientId: his.PatientId,
  31067. SettleAccountsDate: recordDateTime,
  31068. Ctime: time.Now().Unix(),
  31069. Mtime: time.Now().Unix(),
  31070. MdtrtId: his.Number,
  31071. PsnNo: his.PsnNo,
  31072. MedType: strconv.FormatInt(reg_type, 10),
  31073. Status: 1,
  31074. Number: chrg_bchno,
  31075. Infcode: res.Infcode,
  31076. WarnMsg: res.WarnMsg,
  31077. Cainfo: res.Cainfo,
  31078. ErrMsg: res.ErrMsg,
  31079. RespondTime: res.RefmsgTime,
  31080. InfRefmsgid: res.InfRefmsgid,
  31081. OrderStatus: 1,
  31082. IsMedicineInsurance: 1,
  31083. SettleType: settle_accounts_type,
  31084. SettleStartTime: start_time,
  31085. SettleEndTime: end_time,
  31086. Creator: roles.AdminUserId,
  31087. Modify: roles.AdminUserId,
  31088. PType: 2,
  31089. Diagnosis: diagnosis_id,
  31090. }
  31091. err = service.CreateOrder(order)
  31092. if err != nil {
  31093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31094. return
  31095. }
  31096. }
  31097. adminUser := c.GetAdminUserInfo()
  31098. errlog := &models.HisOrderError{
  31099. UserOrgId: adminUser.CurrentOrgId,
  31100. Ctime: time.Now().Unix(),
  31101. Mtime: time.Now().Unix(),
  31102. ErrMsg: res.ErrMsg,
  31103. Status: 1,
  31104. PatientId: id,
  31105. RecordTime: recordDateTime,
  31106. Stage: 4,
  31107. }
  31108. service.CreateErrMsgLog(errlog)
  31109. c.ServeSuccessJSON(map[string]interface{}{
  31110. "failed_code": -10,
  31111. "msg": res.ErrMsg,
  31112. })
  31113. return
  31114. }
  31115. }
  31116. }
  31117. }
  31118. // 退款
  31119. func (c *HisApiController) Refund() {
  31120. order_id, _ := c.GetInt64("order_id")
  31121. admin_user_id, _ := c.GetInt64("admin_user_id")
  31122. adminUser := c.GetAdminUserInfo()
  31123. var order models.HisOrder
  31124. order, _ = service.GetHisOrderByID(order_id)
  31125. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31126. if fapiao.ID > 0 {
  31127. c.ServeSuccessJSON(map[string]interface{}{
  31128. "failed_code": -10,
  31129. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31130. })
  31131. return
  31132. }
  31133. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31134. if order.ID == 0 {
  31135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31136. return
  31137. }
  31138. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31139. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31140. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31141. if config.IsOpen == 1 { //对接了医保,走医保流程
  31142. var res ResultSixteen
  31143. var ahres ResultSevenAH
  31144. var resSixteen10265 ResultSixteen10265
  31145. var resSixteen10265Two ResultSixteen10265Two
  31146. var gz ResultgzSixteen10265Two
  31147. var src_resquest string
  31148. var result string
  31149. if miConfig.MdtrtareaAdmvs == "421300" {
  31150. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31151. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31152. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31153. resp3, requestErr3 := http.Get(api3)
  31154. if requestErr3 != nil {
  31155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31156. return
  31157. }
  31158. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31159. if ioErr3 != nil {
  31160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31162. return
  31163. }
  31164. var respJSON3 map[string]interface{}
  31165. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31168. return
  31169. }
  31170. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31171. userJSONBytes3, _ := json.Marshal(respJSON3)
  31172. fmt.Println("log")
  31173. fmt.Println(string(userJSONBytes3))
  31174. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31175. utils.ErrorLog("解析失败:%v", err)
  31176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31177. return
  31178. }
  31179. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31180. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31181. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31182. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31183. resp3, requestErr3 := http.Get(api3)
  31184. if requestErr3 != nil {
  31185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31186. return
  31187. }
  31188. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31189. if ioErr3 != nil {
  31190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31192. return
  31193. }
  31194. var respJSON3 map[string]interface{}
  31195. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31198. return
  31199. }
  31200. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31201. userJSONBytes3, _ := json.Marshal(respJSON3)
  31202. fmt.Println("log")
  31203. fmt.Println(string(userJSONBytes3))
  31204. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31205. utils.ErrorLog("解析失败:%v", err)
  31206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31207. return
  31208. }
  31209. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31210. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31211. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31212. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31213. resp3, requestErr3 := http.Get(api3)
  31214. if requestErr3 != nil {
  31215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31216. return
  31217. }
  31218. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31219. if ioErr3 != nil {
  31220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31222. return
  31223. }
  31224. var respJSON3 map[string]interface{}
  31225. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31228. return
  31229. }
  31230. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31231. userJSONBytes3, _ := json.Marshal(respJSON3)
  31232. fmt.Println("log")
  31233. fmt.Println(string(userJSONBytes3))
  31234. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31235. utils.ErrorLog("解析失败:%v", err)
  31236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31237. return
  31238. }
  31239. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31240. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31241. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31242. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31243. resp3, requestErr3 := http.Get(api3)
  31244. if requestErr3 != nil {
  31245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31246. return
  31247. }
  31248. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31249. if ioErr3 != nil {
  31250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31252. return
  31253. }
  31254. var respJSON3 map[string]interface{}
  31255. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31258. return
  31259. }
  31260. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31261. userJSONBytes3, _ := json.Marshal(respJSON3)
  31262. fmt.Println("log")
  31263. fmt.Println(string(userJSONBytes3))
  31264. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31265. utils.ErrorLog("解析失败:%v", err)
  31266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31267. return
  31268. }
  31269. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31270. var api3 string
  31271. if miConfig.MdtrtareaAdmvs == "320921" {
  31272. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31273. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31274. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31275. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31276. } else {
  31277. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31278. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31279. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31280. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31281. }
  31282. resp3, requestErr3 := http.Get(api3)
  31283. if requestErr3 != nil {
  31284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31285. return
  31286. }
  31287. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31288. if ioErr3 != nil {
  31289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31291. return
  31292. }
  31293. var respJSON3 map[string]interface{}
  31294. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31297. return
  31298. }
  31299. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31300. userJSONBytes3, _ := json.Marshal(respJSON3)
  31301. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31302. utils.ErrorLog("解析失败:%v", err)
  31303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31304. return
  31305. }
  31306. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31307. res.Output = resSixteen10265.Output
  31308. res.ErrMsg = resSixteen10265.ErrMsg
  31309. res.Cainfo = resSixteen10265.Cainfo
  31310. res.WarnMsg = resSixteen10265.WarnMsg
  31311. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31312. res.Infcode = infocode
  31313. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31314. var api3 string
  31315. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31316. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31317. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31318. resp3, requestErr3 := http.Get(api3)
  31319. if requestErr3 != nil {
  31320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31321. return
  31322. }
  31323. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31324. if ioErr3 != nil {
  31325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31327. return
  31328. }
  31329. var respJSON3 map[string]interface{}
  31330. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31333. return
  31334. }
  31335. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31336. userJSONBytes3, _ := json.Marshal(respJSON3)
  31337. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31338. utils.ErrorLog("解析失败:%v", err)
  31339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31340. return
  31341. }
  31342. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31343. res.Output = resSixteen10265.Output
  31344. res.ErrMsg = resSixteen10265.ErrMsg
  31345. res.Cainfo = resSixteen10265.Cainfo
  31346. res.WarnMsg = resSixteen10265.WarnMsg
  31347. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31348. res.Infcode = infocode
  31349. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31350. 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)
  31351. var dat map[string]interface{}
  31352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31353. fmt.Println(dat)
  31354. } else {
  31355. fmt.Println(err)
  31356. }
  31357. saveLog(result, src_resquest, "2208", "退费")
  31358. userJSONBytes, _ := json.Marshal(dat)
  31359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31360. utils.ErrorLog("解析失败:%v", err)
  31361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31362. return
  31363. }
  31364. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31365. 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, "")
  31366. var dat map[string]interface{}
  31367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31368. fmt.Println(dat)
  31369. } else {
  31370. fmt.Println(err)
  31371. }
  31372. saveLog(result, src_resquest, "2208", "退费")
  31373. userJSONBytes, _ := json.Marshal(dat)
  31374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31375. utils.ErrorLog("解析失败:%v", err)
  31376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31377. return
  31378. }
  31379. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31380. 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, "")
  31381. var dat map[string]interface{}
  31382. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31383. fmt.Println(dat)
  31384. } else {
  31385. fmt.Println(err)
  31386. }
  31387. saveLog(result, src_resquest, "2208", "退费")
  31388. userJSONBytes, _ := json.Marshal(dat)
  31389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31390. utils.ErrorLog("解析失败:%v", err)
  31391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31392. return
  31393. }
  31394. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31395. var api3 string
  31396. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31397. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31398. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31399. resp3, requestErr3 := http.Get(api3)
  31400. if requestErr3 != nil {
  31401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31402. return
  31403. }
  31404. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31405. if ioErr3 != nil {
  31406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31408. return
  31409. }
  31410. var respJSON3 map[string]interface{}
  31411. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31414. return
  31415. }
  31416. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31417. if status == "0" {
  31418. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31419. c.ServeSuccessJSON(map[string]interface{}{
  31420. "failed_code": -10,
  31421. "msg": err_msg,
  31422. })
  31423. return
  31424. }
  31425. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31426. userJSONBytes3, _ := json.Marshal(respJSON3)
  31427. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31428. // utils.ErrorLog("解析失败:%v", err)
  31429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31430. // return
  31431. //}
  31432. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31433. utils.ErrorLog("解析失败:%v", err)
  31434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31435. return
  31436. }
  31437. res.InfRefmsgid = ahres.InfRefmsgid
  31438. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31439. // 创建对应的Time类型
  31440. t := time.UnixMilli(timestamp)
  31441. // 格式化成指定的日期字符串
  31442. str := t.Format("2006-01-02 15:04:05")
  31443. res.Output.Setlinfo.SetlTime = str
  31444. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31445. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31446. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31447. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31448. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31449. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31450. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31451. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31452. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31453. //
  31454. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31455. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31456. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31457. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31458. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31459. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31460. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31461. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31462. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31463. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31464. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31465. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31466. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31467. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31468. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31469. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31470. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31471. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31472. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31473. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31474. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31475. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31476. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31477. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31478. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31479. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31480. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31481. //res.Output.Setldetail = ahres.Output.Setldetail
  31482. res.ErrMsg = ahres.ErrMsg
  31483. res.Cainfo = ahres.Cainfo
  31484. res.WarnMsg = ahres.WarnMsg
  31485. res.Infcode = ahres.Infcode
  31486. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31487. var api3 string
  31488. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31489. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31490. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31491. resp3, requestErr3 := http.Get(api3)
  31492. if requestErr3 != nil {
  31493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31494. return
  31495. }
  31496. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31497. if ioErr3 != nil {
  31498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31500. return
  31501. }
  31502. var respJSON3 map[string]interface{}
  31503. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31506. return
  31507. }
  31508. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31509. if status == "0" {
  31510. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31511. c.ServeSuccessJSON(map[string]interface{}{
  31512. "failed_code": -10,
  31513. "msg": err_msg,
  31514. })
  31515. return
  31516. }
  31517. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31518. userJSONBytes3, _ := json.Marshal(respJSON3)
  31519. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31520. // utils.ErrorLog("解析失败:%v", err)
  31521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31522. // return
  31523. //}
  31524. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31525. utils.ErrorLog("解析失败:%v", err)
  31526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31527. return
  31528. }
  31529. res.InfRefmsgid = ahres.InfRefmsgid
  31530. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31531. // 创建对应的Time类型
  31532. t := time.UnixMilli(timestamp)
  31533. // 格式化成指定的日期字符串
  31534. str := t.Format("2006-01-02 15:04:05")
  31535. res.Output.Setlinfo.SetlTime = str
  31536. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31537. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31538. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31539. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31540. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31541. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31542. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31543. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31544. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31545. //
  31546. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31547. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31548. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31549. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31550. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31551. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31552. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31553. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31554. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31555. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31556. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31557. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31558. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31559. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31560. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31561. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31562. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31563. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31564. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31565. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31566. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31567. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31568. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31569. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31570. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31571. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31572. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31573. //res.Output.Setldetail = ahres.Output.Setldetail
  31574. res.ErrMsg = ahres.ErrMsg
  31575. res.Cainfo = ahres.Cainfo
  31576. res.WarnMsg = ahres.WarnMsg
  31577. res.Infcode = ahres.Infcode
  31578. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31579. 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, "")
  31580. var dat map[string]interface{}
  31581. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31582. fmt.Println(dat)
  31583. } else {
  31584. fmt.Println(err)
  31585. }
  31586. saveLog(result, src_resquest, "2208", "退费")
  31587. userJSONBytes, _ := json.Marshal(dat)
  31588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31589. utils.ErrorLog("解析失败:%v", err)
  31590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31591. return
  31592. }
  31593. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31594. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31595. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31596. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31597. resp3, requestErr3 := http.Get(api3)
  31598. if requestErr3 != nil {
  31599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31600. return
  31601. }
  31602. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31603. if ioErr3 != nil {
  31604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31606. return
  31607. }
  31608. var respJSON3 map[string]interface{}
  31609. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31612. return
  31613. }
  31614. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31615. userJSONBytes3, _ := json.Marshal(respJSON3)
  31616. fmt.Println("log")
  31617. fmt.Println(string(userJSONBytes3))
  31618. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31619. utils.ErrorLog("解析失败:%v", err)
  31620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31621. return
  31622. }
  31623. } else {
  31624. if miConfig.Code == "H15049901371" {
  31625. 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)
  31626. var dat map[string]interface{}
  31627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31628. fmt.Println(dat)
  31629. } else {
  31630. fmt.Println(err)
  31631. }
  31632. saveLog(result, src_resquest, "2208", "退费")
  31633. if strings.Contains(result, "Post") {
  31634. res.Infcode = -1
  31635. res.ErrMsg = result
  31636. }
  31637. userJSONBytes, _ := json.Marshal(dat)
  31638. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31639. utils.ErrorLog("解析失败:%v", err)
  31640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31641. return
  31642. }
  31643. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31644. res.Output = resSixteen10265.Output
  31645. res.ErrMsg = resSixteen10265.ErrMsg
  31646. res.Cainfo = resSixteen10265.Cainfo
  31647. res.WarnMsg = resSixteen10265.WarnMsg
  31648. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31649. res.Infcode = infocode
  31650. } else {
  31651. 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)
  31652. var dat map[string]interface{}
  31653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31654. fmt.Println(dat)
  31655. } else {
  31656. fmt.Println(err)
  31657. }
  31658. saveLog(result, src_resquest, "2208", "退费")
  31659. userJSONBytes, _ := json.Marshal(dat)
  31660. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31661. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31662. utils.ErrorLog("解析失败:%v", err)
  31663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31664. return
  31665. }
  31666. res.Infcode = gz.Infcode
  31667. } else {
  31668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31669. utils.ErrorLog("解析失败:%v", err)
  31670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31671. return
  31672. }
  31673. }
  31674. if strings.Contains(result, "Post") {
  31675. res.Infcode = -1
  31676. res.ErrMsg = result
  31677. }
  31678. }
  31679. }
  31680. if res.Infcode == -1 {
  31681. c.ServeSuccessJSON(map[string]interface{}{
  31682. "failed_code": -10,
  31683. "msg": res.ErrMsg,
  31684. })
  31685. return
  31686. }
  31687. if res.Infcode != -1 {
  31688. var res2 ResultSix
  31689. var resSix10265 ResultSix10265
  31690. if miConfig.MdtrtareaAdmvs == "421300" {
  31691. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31692. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31694. resp3, requestErr3 := http.Get(api3)
  31695. if requestErr3 != nil {
  31696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31697. return
  31698. }
  31699. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31700. if ioErr3 != nil {
  31701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31703. return
  31704. }
  31705. var respJSON3 map[string]interface{}
  31706. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31709. return
  31710. }
  31711. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31712. userJSONBytes3, _ := json.Marshal(respJSON3)
  31713. fmt.Println("log")
  31714. fmt.Println(string(userJSONBytes3))
  31715. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31716. utils.ErrorLog("解析失败:%v", err)
  31717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31718. return
  31719. }
  31720. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31721. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31722. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31723. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31724. resp3, requestErr3 := http.Get(api3)
  31725. if requestErr3 != nil {
  31726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31727. return
  31728. }
  31729. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31730. if ioErr3 != nil {
  31731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31733. return
  31734. }
  31735. var respJSON3 map[string]interface{}
  31736. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31739. return
  31740. }
  31741. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31742. userJSONBytes3, _ := json.Marshal(respJSON3)
  31743. fmt.Println("log")
  31744. fmt.Println(string(userJSONBytes3))
  31745. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31746. utils.ErrorLog("解析失败:%v", err)
  31747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31748. return
  31749. }
  31750. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31751. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31752. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31753. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31754. resp3, requestErr3 := http.Get(api3)
  31755. if requestErr3 != nil {
  31756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31757. return
  31758. }
  31759. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31760. if ioErr3 != nil {
  31761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31763. return
  31764. }
  31765. var respJSON3 map[string]interface{}
  31766. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31769. return
  31770. }
  31771. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31772. userJSONBytes3, _ := json.Marshal(respJSON3)
  31773. fmt.Println("log")
  31774. fmt.Println(string(userJSONBytes3))
  31775. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31776. utils.ErrorLog("解析失败:%v", err)
  31777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31778. return
  31779. }
  31780. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31781. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31782. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31784. resp3, requestErr3 := http.Get(api3)
  31785. if requestErr3 != nil {
  31786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31787. return
  31788. }
  31789. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31790. if ioErr3 != nil {
  31791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31793. return
  31794. }
  31795. var respJSON3 map[string]interface{}
  31796. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31799. return
  31800. }
  31801. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31802. userJSONBytes3, _ := json.Marshal(respJSON3)
  31803. fmt.Println("log")
  31804. fmt.Println(string(userJSONBytes3))
  31805. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31806. utils.ErrorLog("解析失败:%v", err)
  31807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31808. return
  31809. }
  31810. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31811. var api3 string
  31812. if miConfig.MdtrtareaAdmvs == "320921" {
  31813. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31814. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31815. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31816. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31817. } else {
  31818. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31819. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31820. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31821. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31822. }
  31823. resp3, requestErr3 := http.Get(api3)
  31824. if requestErr3 != nil {
  31825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31826. return
  31827. }
  31828. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31829. if ioErr3 != nil {
  31830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31832. return
  31833. }
  31834. var respJSON3 map[string]interface{}
  31835. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31838. return
  31839. }
  31840. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31841. userJSONBytes3, _ := json.Marshal(respJSON3)
  31842. fmt.Println("log")
  31843. fmt.Println(string(userJSONBytes3))
  31844. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31845. utils.ErrorLog("解析失败:%v", err)
  31846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31847. return
  31848. }
  31849. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31850. res2.Output = resSix10265.Output
  31851. res2.ErrMsg = resSix10265.ErrMsg
  31852. res2.Cainfo = resSix10265.Cainfo
  31853. res2.WarnMsg = resSix10265.WarnMsg
  31854. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31855. res2.Infcode = infocode
  31856. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31857. var api3 string
  31858. new_chrg_bchno := order.Number
  31859. if adminUser.CurrentOrgId == 10265 {
  31860. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31861. new_chrg_bchno = "0000"
  31862. }
  31863. }
  31864. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31865. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31867. resp3, requestErr3 := http.Get(api3)
  31868. if requestErr3 != nil {
  31869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31870. return
  31871. }
  31872. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31873. if ioErr3 != nil {
  31874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31876. return
  31877. }
  31878. var respJSON3 map[string]interface{}
  31879. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31882. return
  31883. }
  31884. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31885. userJSONBytes3, _ := json.Marshal(respJSON3)
  31886. fmt.Println("log")
  31887. fmt.Println(string(userJSONBytes3))
  31888. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31889. utils.ErrorLog("解析失败:%v", err)
  31890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31891. return
  31892. }
  31893. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31894. res2.Output = resSix10265.Output
  31895. res2.ErrMsg = resSix10265.ErrMsg
  31896. res2.Cainfo = resSix10265.Cainfo
  31897. res2.WarnMsg = resSix10265.WarnMsg
  31898. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31899. res2.Infcode = infocode
  31900. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31901. 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)
  31902. var dat map[string]interface{}
  31903. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31904. fmt.Println(dat)
  31905. } else {
  31906. fmt.Println(err)
  31907. }
  31908. saveLog(result2, src_request, "2205", "撤销明细")
  31909. userJSONBytes, _ := json.Marshal(dat)
  31910. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31911. utils.ErrorLog("解析失败:%v", err)
  31912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31913. return
  31914. }
  31915. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31916. 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, "")
  31917. var dat map[string]interface{}
  31918. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31919. fmt.Println(dat)
  31920. } else {
  31921. fmt.Println(err)
  31922. }
  31923. saveLog(result2, src_request, "2205", "撤销明细")
  31924. userJSONBytes, _ := json.Marshal(dat)
  31925. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31926. utils.ErrorLog("解析失败:%v", err)
  31927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31928. return
  31929. }
  31930. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31931. 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, "")
  31932. var dat map[string]interface{}
  31933. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31934. fmt.Println(dat)
  31935. } else {
  31936. fmt.Println(err)
  31937. }
  31938. saveLog(result2, src_request, "2205", "撤销明细")
  31939. userJSONBytes, _ := json.Marshal(dat)
  31940. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31941. utils.ErrorLog("解析失败:%v", err)
  31942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31943. return
  31944. }
  31945. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31946. var api3 string
  31947. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31948. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31950. resp3, requestErr3 := http.Get(api3)
  31951. if requestErr3 != nil {
  31952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31953. return
  31954. }
  31955. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31956. if ioErr3 != nil {
  31957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31959. return
  31960. }
  31961. var respJSON3 map[string]interface{}
  31962. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31965. return
  31966. }
  31967. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31968. if status == "0" {
  31969. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31970. c.ServeSuccessJSON(map[string]interface{}{
  31971. "failed_code": -10,
  31972. "msg": err_msg,
  31973. })
  31974. return
  31975. }
  31976. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31977. userJSONBytes3, _ := json.Marshal(respJSON3)
  31978. fmt.Println("log")
  31979. fmt.Println(string(userJSONBytes3))
  31980. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31981. utils.ErrorLog("解析失败:%v", err)
  31982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31983. return
  31984. }
  31985. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31986. 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, "")
  31987. var dat map[string]interface{}
  31988. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31989. fmt.Println(dat)
  31990. } else {
  31991. fmt.Println(err)
  31992. }
  31993. saveLog(result2, src_request, "2205", "撤销明细")
  31994. userJSONBytes, _ := json.Marshal(dat)
  31995. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31996. utils.ErrorLog("解析失败:%v", err)
  31997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31998. return
  31999. }
  32000. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32001. 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, "")
  32002. var dat map[string]interface{}
  32003. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32004. fmt.Println(dat)
  32005. } else {
  32006. fmt.Println(err)
  32007. }
  32008. saveLog(result2, src_request, "2205", "撤销明细")
  32009. userJSONBytes, _ := json.Marshal(dat)
  32010. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32011. utils.ErrorLog("解析失败:%v", err)
  32012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32013. return
  32014. }
  32015. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32016. var api3 string
  32017. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32018. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32019. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32020. resp3, requestErr3 := http.Get(api3)
  32021. if requestErr3 != nil {
  32022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32023. return
  32024. }
  32025. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32026. if ioErr3 != nil {
  32027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32029. return
  32030. }
  32031. var respJSON3 map[string]interface{}
  32032. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32035. return
  32036. }
  32037. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32038. if status == "0" {
  32039. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32040. c.ServeSuccessJSON(map[string]interface{}{
  32041. "failed_code": -10,
  32042. "msg": err_msg,
  32043. })
  32044. return
  32045. }
  32046. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32047. userJSONBytes3, _ := json.Marshal(respJSON3)
  32048. fmt.Println("log")
  32049. fmt.Println(string(userJSONBytes3))
  32050. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32051. utils.ErrorLog("解析失败:%v", err)
  32052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32053. return
  32054. }
  32055. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32056. 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, "")
  32057. var dat map[string]interface{}
  32058. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32059. fmt.Println(dat)
  32060. } else {
  32061. fmt.Println(err)
  32062. }
  32063. saveLog(result2, src_request, "2205", "撤销明细")
  32064. userJSONBytes, _ := json.Marshal(dat)
  32065. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32066. utils.ErrorLog("解析失败:%v", err)
  32067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32068. return
  32069. }
  32070. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32071. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32072. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32073. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32074. resp3, requestErr3 := http.Get(api3)
  32075. if requestErr3 != nil {
  32076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32077. return
  32078. }
  32079. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32080. if ioErr3 != nil {
  32081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32083. return
  32084. }
  32085. var respJSON3 map[string]interface{}
  32086. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32089. return
  32090. }
  32091. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32092. userJSONBytes3, _ := json.Marshal(respJSON3)
  32093. fmt.Println("log")
  32094. fmt.Println(string(userJSONBytes3))
  32095. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32096. utils.ErrorLog("解析失败:%v", err)
  32097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32098. return
  32099. }
  32100. } else {
  32101. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32102. res2.Infcode = 0
  32103. } else {
  32104. 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)
  32105. var dat map[string]interface{}
  32106. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32107. fmt.Println(dat)
  32108. } else {
  32109. fmt.Println(err)
  32110. }
  32111. saveLog(result2, src_request, "2205", "撤销明细")
  32112. userJSONBytes, _ := json.Marshal(dat)
  32113. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32114. utils.ErrorLog("解析失败:%v", err)
  32115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32116. return
  32117. }
  32118. }
  32119. }
  32120. if res2.Infcode == -1 {
  32121. c.ServeSuccessJSON(map[string]interface{}{
  32122. "failed_code": -10,
  32123. "msg": res2.ErrMsg,
  32124. })
  32125. return
  32126. }
  32127. if res2.Infcode == 0 {
  32128. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32129. if err == nil {
  32130. //当押金不为零时产生退费记录
  32131. if order.Decimal != 0 {
  32132. tmp := strconv.FormatInt(order.ID, 10)
  32133. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32134. if err != nil {
  32135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32136. return
  32137. }
  32138. }
  32139. c.ServeSuccessJSON(map[string]interface{}{
  32140. "msg": "退费成功",
  32141. })
  32142. } else {
  32143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32144. return
  32145. }
  32146. } else {
  32147. c.ServeSuccessJSON(map[string]interface{}{
  32148. "failed_code": -10,
  32149. "msg": res2.ErrMsg,
  32150. })
  32151. }
  32152. } else {
  32153. c.ServeSuccessJSON(map[string]interface{}{
  32154. "failed_code": -10,
  32155. "msg": res.ErrMsg,
  32156. })
  32157. }
  32158. }
  32159. }
  32160. func (c *HisApiController) RefundNumber() {
  32161. record_time := c.GetString("record_time")
  32162. //patient_id, _ := c.GetInt64("patient_id")
  32163. admin_user_id, _ := c.GetInt64("admin_user_id")
  32164. his_patient_id, _ := c.GetInt64("id")
  32165. timeLayout := "2006-01-02"
  32166. loc, _ := time.LoadLocation("Local")
  32167. adminUser := c.GetAdminUserInfo()
  32168. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32169. fmt.Println(err)
  32170. if err != nil {
  32171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32172. return
  32173. }
  32174. recordDateTime := theTime.Unix()
  32175. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32176. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32177. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32178. //order, _ := service.GetHisOrderByID(order_id)
  32179. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32180. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32182. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32183. if count > 0 {
  32184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32185. return
  32186. }
  32187. if config.IsOpen == 1 { //对接了医保,走医保流程
  32188. var res2 ResultSix
  32189. var res3 GZResultSix
  32190. var resSix10265 ResultSix10265
  32191. if miConfig.MdtrtareaAdmvs == "421300" {
  32192. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32193. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32194. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32195. resp3, requestErr3 := http.Get(api3)
  32196. if requestErr3 != nil {
  32197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32198. return
  32199. }
  32200. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32201. if ioErr3 != nil {
  32202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32204. return
  32205. }
  32206. var respJSON3 map[string]interface{}
  32207. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32210. return
  32211. }
  32212. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32213. userJSONBytes3, _ := json.Marshal(respJSON3)
  32214. fmt.Println("log")
  32215. fmt.Println(string(userJSONBytes3))
  32216. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32217. utils.ErrorLog("解析失败:%v", err)
  32218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32219. return
  32220. }
  32221. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32222. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32223. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32224. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32225. resp3, requestErr3 := http.Get(api3)
  32226. if requestErr3 != nil {
  32227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32228. return
  32229. }
  32230. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32231. if ioErr3 != nil {
  32232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32234. return
  32235. }
  32236. var respJSON3 map[string]interface{}
  32237. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32240. return
  32241. }
  32242. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32243. userJSONBytes3, _ := json.Marshal(respJSON3)
  32244. fmt.Println("log")
  32245. fmt.Println(string(userJSONBytes3))
  32246. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32247. utils.ErrorLog("解析失败:%v", err)
  32248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32249. return
  32250. }
  32251. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32252. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32253. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32254. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32255. resp3, requestErr3 := http.Get(api3)
  32256. if requestErr3 != nil {
  32257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32258. return
  32259. }
  32260. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32261. if ioErr3 != nil {
  32262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32264. return
  32265. }
  32266. var respJSON3 map[string]interface{}
  32267. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32270. return
  32271. }
  32272. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32273. userJSONBytes3, _ := json.Marshal(respJSON3)
  32274. fmt.Println("log")
  32275. fmt.Println(string(userJSONBytes3))
  32276. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32277. utils.ErrorLog("解析失败:%v", err)
  32278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32279. return
  32280. }
  32281. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32282. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32283. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32284. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32285. resp3, requestErr3 := http.Get(api3)
  32286. if requestErr3 != nil {
  32287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32288. return
  32289. }
  32290. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32291. if ioErr3 != nil {
  32292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32294. return
  32295. }
  32296. var respJSON3 map[string]interface{}
  32297. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32300. return
  32301. }
  32302. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32303. userJSONBytes3, _ := json.Marshal(respJSON3)
  32304. fmt.Println("log")
  32305. fmt.Println(string(userJSONBytes3))
  32306. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32307. utils.ErrorLog("解析失败:%v", err)
  32308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32309. return
  32310. }
  32311. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32312. var api3 string
  32313. if miConfig.MdtrtareaAdmvs == "320921" {
  32314. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32315. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32316. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32317. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32318. } else {
  32319. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32320. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32321. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32322. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32323. }
  32324. resp3, requestErr3 := http.Get(api3)
  32325. if requestErr3 != nil {
  32326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32327. return
  32328. }
  32329. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32330. if ioErr3 != nil {
  32331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32333. return
  32334. }
  32335. var respJSON3 map[string]interface{}
  32336. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32339. return
  32340. }
  32341. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32342. userJSONBytes3, _ := json.Marshal(respJSON3)
  32343. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32344. utils.ErrorLog("解析失败:%v", err)
  32345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32346. return
  32347. }
  32348. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32349. res2.Output = resSix10265.Output
  32350. res2.ErrMsg = resSix10265.ErrMsg
  32351. res2.Cainfo = resSix10265.Cainfo
  32352. res2.WarnMsg = resSix10265.WarnMsg
  32353. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32354. res2.Infcode = infocode
  32355. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32356. var api3 string
  32357. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32358. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32359. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32360. resp3, requestErr3 := http.Get(api3)
  32361. if requestErr3 != nil {
  32362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32363. return
  32364. }
  32365. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32366. if ioErr3 != nil {
  32367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32369. return
  32370. }
  32371. var respJSON3 map[string]interface{}
  32372. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32375. return
  32376. }
  32377. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32378. userJSONBytes3, _ := json.Marshal(respJSON3)
  32379. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32380. utils.ErrorLog("解析失败:%v", err)
  32381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32382. return
  32383. }
  32384. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32385. res2.Output = resSix10265.Output
  32386. res2.ErrMsg = resSix10265.ErrMsg
  32387. res2.Cainfo = resSix10265.Cainfo
  32388. res2.WarnMsg = resSix10265.WarnMsg
  32389. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32390. res2.Infcode = infocode
  32391. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32392. 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)
  32393. var dat map[string]interface{}
  32394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32395. fmt.Println(dat)
  32396. } else {
  32397. fmt.Println(err)
  32398. }
  32399. saveLog(result, request, "2202", "退号")
  32400. userJSONBytes, _ := json.Marshal(dat)
  32401. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32402. utils.ErrorLog("解析失败:%v", err)
  32403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32404. return
  32405. }
  32406. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32407. 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, "")
  32408. var dat map[string]interface{}
  32409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32410. fmt.Println(dat)
  32411. } else {
  32412. fmt.Println(err)
  32413. }
  32414. saveLog(result, request, "2202", "退号")
  32415. userJSONBytes, _ := json.Marshal(dat)
  32416. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32417. utils.ErrorLog("解析失败:%v", err)
  32418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32419. return
  32420. }
  32421. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32422. 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, "")
  32423. var dat map[string]interface{}
  32424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32425. fmt.Println(dat)
  32426. } else {
  32427. fmt.Println(err)
  32428. }
  32429. saveLog(result, request, "2202", "退号")
  32430. userJSONBytes, _ := json.Marshal(dat)
  32431. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32432. utils.ErrorLog("解析失败:%v", err)
  32433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32434. return
  32435. }
  32436. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32437. var api3 string
  32438. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32439. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32441. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32442. resp3, requestErr3 := http.Get(api3)
  32443. if requestErr3 != nil {
  32444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32445. return
  32446. }
  32447. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32448. if ioErr3 != nil {
  32449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32451. return
  32452. }
  32453. var respJSON3 map[string]interface{}
  32454. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32457. return
  32458. }
  32459. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32460. if status == "0" {
  32461. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32462. c.ServeSuccessJSON(map[string]interface{}{
  32463. "failed_code": -10,
  32464. "msg": err_msg,
  32465. })
  32466. return
  32467. }
  32468. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32469. userJSONBytes3, _ := json.Marshal(respJSON3)
  32470. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32471. utils.ErrorLog("解析失败:%v", err)
  32472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32473. return
  32474. }
  32475. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32476. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32477. var api3 string
  32478. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32479. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32480. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32481. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32482. resp3, requestErr3 := http.Get(api3)
  32483. if requestErr3 != nil {
  32484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32485. return
  32486. }
  32487. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32488. if ioErr3 != nil {
  32489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32491. return
  32492. }
  32493. var respJSON3 map[string]interface{}
  32494. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32497. return
  32498. }
  32499. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32500. if status == "0" {
  32501. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32502. c.ServeSuccessJSON(map[string]interface{}{
  32503. "failed_code": -10,
  32504. "msg": err_msg,
  32505. })
  32506. return
  32507. }
  32508. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32509. userJSONBytes3, _ := json.Marshal(respJSON3)
  32510. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32511. utils.ErrorLog("解析失败:%v", err)
  32512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32513. return
  32514. }
  32515. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32516. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32517. 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, "")
  32518. var dat map[string]interface{}
  32519. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32520. fmt.Println(dat)
  32521. } else {
  32522. fmt.Println(err)
  32523. }
  32524. saveLog(result, request, "2202", "退号")
  32525. userJSONBytes, _ := json.Marshal(dat)
  32526. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32527. utils.ErrorLog("解析失败:%v", err)
  32528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32529. return
  32530. }
  32531. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32532. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32533. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32535. resp3, requestErr3 := http.Get(api3)
  32536. if requestErr3 != nil {
  32537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32538. return
  32539. }
  32540. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32541. if ioErr3 != nil {
  32542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32544. return
  32545. }
  32546. var respJSON3 map[string]interface{}
  32547. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32550. return
  32551. }
  32552. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32553. userJSONBytes3, _ := json.Marshal(respJSON3)
  32554. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32555. utils.ErrorLog("解析失败:%v", err)
  32556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32557. return
  32558. }
  32559. } else {
  32560. var api3 string
  32561. if miConfig.Code == "H15049901371" {
  32562. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32563. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32564. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32565. } else {
  32566. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32567. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32569. }
  32570. resp3, requestErr3 := http.Get(api3)
  32571. if requestErr3 != nil {
  32572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32573. return
  32574. }
  32575. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32576. if ioErr3 != nil {
  32577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32579. return
  32580. }
  32581. var respJSON3 map[string]interface{}
  32582. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32585. return
  32586. }
  32587. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32588. userJSONBytes3, _ := json.Marshal(respJSON3)
  32589. if miConfig.Code == "H15049901371" {
  32590. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32591. utils.ErrorLog("解析失败:%v", err)
  32592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32593. return
  32594. }
  32595. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32596. res2.Output = resSix10265.Output
  32597. res2.ErrMsg = resSix10265.ErrMsg
  32598. res2.Cainfo = resSix10265.Cainfo
  32599. res2.WarnMsg = resSix10265.WarnMsg
  32600. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32601. res2.Infcode = infocode
  32602. } else {
  32603. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32604. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32605. utils.ErrorLog("解析失败:%v", err)
  32606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32607. return
  32608. }
  32609. res2.Infcode = res3.Infcode
  32610. } else {
  32611. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32612. utils.ErrorLog("解析失败:%v", err)
  32613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32614. return
  32615. }
  32616. }
  32617. }
  32618. }
  32619. if res2.Infcode == -1 {
  32620. c.ServeSuccessJSON(map[string]interface{}{
  32621. "failed_code": -10,
  32622. "msg": res2.ErrMsg,
  32623. })
  32624. return
  32625. }
  32626. if res2.Infcode == 0 {
  32627. if err == nil {
  32628. c.ServeSuccessJSON(map[string]interface{}{
  32629. "msg": "退号成功",
  32630. })
  32631. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32632. } else {
  32633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32634. return
  32635. }
  32636. }
  32637. } else {
  32638. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32639. //if err == nil {
  32640. // c.ServeSuccessJSON(map[string]interface{}{
  32641. // "msg": "退费成功",
  32642. // })
  32643. //} else {
  32644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32645. // return
  32646. //}
  32647. }
  32648. }
  32649. func (c *HisApiController) RefundDetail() {
  32650. order_id, _ := c.GetInt64("order_id")
  32651. admin_user_id, _ := c.GetInt64("admin_user_id")
  32652. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32653. number := c.GetString("number")
  32654. record_time := c.GetString("record_time")
  32655. patient_id, _ := c.GetInt64("patient_id")
  32656. //med_type, _ := c.GetInt64("med_type")
  32657. timeLayout := "2006-01-02"
  32658. loc, _ := time.LoadLocation("Local")
  32659. adminUser := c.GetAdminUserInfo()
  32660. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32661. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32662. fmt.Println(err)
  32663. if err != nil {
  32664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32665. return
  32666. }
  32667. recordDateTime := theTime.Unix()
  32668. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32669. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32670. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32671. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32672. var order models.HisOrder
  32673. order, _ = service.GetHisOrderByID(order_id)
  32674. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32675. if config.IsOpen == 1 { //对接了医保,走医保流程
  32676. var res2 ResultSix
  32677. if miConfig.MdtrtareaAdmvs == "421300" {
  32678. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32679. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32681. resp3, requestErr3 := http.Get(api3)
  32682. if requestErr3 != nil {
  32683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32684. return
  32685. }
  32686. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32687. if ioErr3 != nil {
  32688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32690. return
  32691. }
  32692. var respJSON3 map[string]interface{}
  32693. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32696. return
  32697. }
  32698. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32699. userJSONBytes3, _ := json.Marshal(respJSON3)
  32700. fmt.Println("log")
  32701. fmt.Println(string(userJSONBytes3))
  32702. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32703. utils.ErrorLog("解析失败:%v", err)
  32704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32705. return
  32706. }
  32707. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32708. if err == nil {
  32709. c.ServeSuccessJSON(map[string]interface{}{
  32710. "msg": "撤销明细成功",
  32711. })
  32712. return
  32713. } else {
  32714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32715. return
  32716. }
  32717. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32718. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32719. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32720. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32721. resp3, requestErr3 := http.Get(api3)
  32722. if requestErr3 != nil {
  32723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32724. return
  32725. }
  32726. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32727. if ioErr3 != nil {
  32728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32730. return
  32731. }
  32732. var respJSON3 map[string]interface{}
  32733. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32736. return
  32737. }
  32738. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32739. userJSONBytes3, _ := json.Marshal(respJSON3)
  32740. fmt.Println("log")
  32741. fmt.Println(string(userJSONBytes3))
  32742. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32743. utils.ErrorLog("解析失败:%v", err)
  32744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32745. return
  32746. }
  32747. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32748. if err == nil {
  32749. c.ServeSuccessJSON(map[string]interface{}{
  32750. "msg": "撤销明细成功",
  32751. })
  32752. return
  32753. } else {
  32754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32755. return
  32756. }
  32757. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32758. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32759. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32760. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32761. resp3, requestErr3 := http.Get(api3)
  32762. if requestErr3 != nil {
  32763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32764. return
  32765. }
  32766. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32767. if ioErr3 != nil {
  32768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32770. return
  32771. }
  32772. var respJSON3 map[string]interface{}
  32773. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32776. return
  32777. }
  32778. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32779. userJSONBytes3, _ := json.Marshal(respJSON3)
  32780. fmt.Println("log")
  32781. fmt.Println(string(userJSONBytes3))
  32782. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32783. utils.ErrorLog("解析失败:%v", err)
  32784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32785. return
  32786. }
  32787. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32788. if err == nil {
  32789. c.ServeSuccessJSON(map[string]interface{}{
  32790. "msg": "撤销明细成功",
  32791. })
  32792. return
  32793. } else {
  32794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32795. return
  32796. }
  32797. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32798. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32799. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32800. "&insuplc_admdvs=" + his.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, &res2); err != nil {
  32823. utils.ErrorLog("解析失败:%v", err)
  32824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32825. return
  32826. }
  32827. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32828. if err == nil {
  32829. c.ServeSuccessJSON(map[string]interface{}{
  32830. "msg": "撤销明细成功",
  32831. })
  32832. return
  32833. } else {
  32834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32835. return
  32836. }
  32837. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32838. var resSix10265 ResultSix10265
  32839. var api3 string
  32840. if miConfig.MdtrtareaAdmvs == "320921" {
  32841. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32842. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32844. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32845. } else {
  32846. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32847. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32848. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32849. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32850. }
  32851. resp3, requestErr3 := http.Get(api3)
  32852. utils.ErrorLog("接口: %v", requestErr3)
  32853. if requestErr3 != nil {
  32854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32855. return
  32856. }
  32857. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32858. if ioErr3 != nil {
  32859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32861. return
  32862. }
  32863. var respJSON3 map[string]interface{}
  32864. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32867. return
  32868. }
  32869. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32870. userJSONBytes3, _ := json.Marshal(respJSON3)
  32871. fmt.Println("log")
  32872. fmt.Println(string(userJSONBytes3))
  32873. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32874. utils.ErrorLog("解析失败:%v", err)
  32875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32876. return
  32877. }
  32878. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32879. res2.Output = resSix10265.Output
  32880. res2.ErrMsg = resSix10265.ErrMsg
  32881. res2.Cainfo = resSix10265.Cainfo
  32882. res2.WarnMsg = resSix10265.WarnMsg
  32883. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32884. res2.Infcode = infocode
  32885. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32886. if err == nil {
  32887. c.ServeSuccessJSON(map[string]interface{}{
  32888. "msg": "撤销明细成功",
  32889. })
  32890. return
  32891. } else {
  32892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32893. return
  32894. }
  32895. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32896. var api3 string
  32897. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32898. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32899. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32900. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32901. resp3, requestErr3 := http.Get(api3)
  32902. utils.ErrorLog("接口: %v", requestErr3)
  32903. if requestErr3 != nil {
  32904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32905. return
  32906. }
  32907. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32908. if ioErr3 != nil {
  32909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32911. return
  32912. }
  32913. var respJSON3 map[string]interface{}
  32914. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32917. return
  32918. }
  32919. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32920. if status == "0" {
  32921. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32922. c.ServeSuccessJSON(map[string]interface{}{
  32923. "failed_code": -10,
  32924. "msg": err_msg,
  32925. })
  32926. return
  32927. }
  32928. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32929. userJSONBytes3, _ := json.Marshal(respJSON3)
  32930. fmt.Println("log")
  32931. fmt.Println(string(userJSONBytes3))
  32932. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32933. utils.ErrorLog("解析失败:%v", err)
  32934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32935. return
  32936. }
  32937. fmt.Println(res2.Infcode)
  32938. if res2.Infcode == -1 {
  32939. c.ServeSuccessJSON(map[string]interface{}{
  32940. "failed_code": -10,
  32941. "msg": res2.ErrMsg,
  32942. })
  32943. return
  32944. }
  32945. if res2.Infcode == 0 {
  32946. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32947. if err == nil {
  32948. c.ServeSuccessJSON(map[string]interface{}{
  32949. "msg": "撤销明细成功",
  32950. })
  32951. return
  32952. } else {
  32953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32954. return
  32955. }
  32956. } else {
  32957. c.ServeSuccessJSON(map[string]interface{}{
  32958. "failed_code": -10,
  32959. "msg": res2.ErrMsg,
  32960. })
  32961. }
  32962. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32963. if err == nil {
  32964. c.ServeSuccessJSON(map[string]interface{}{
  32965. "msg": "撤销明细成功",
  32966. })
  32967. return
  32968. } else {
  32969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32970. return
  32971. }
  32972. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32973. var api3 string
  32974. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32975. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32976. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32977. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32978. resp3, requestErr3 := http.Get(api3)
  32979. utils.ErrorLog("接口: %v", requestErr3)
  32980. if requestErr3 != nil {
  32981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32982. return
  32983. }
  32984. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32985. if ioErr3 != nil {
  32986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32988. return
  32989. }
  32990. var respJSON3 map[string]interface{}
  32991. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32994. return
  32995. }
  32996. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32997. if status == "0" {
  32998. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32999. c.ServeSuccessJSON(map[string]interface{}{
  33000. "failed_code": -10,
  33001. "msg": err_msg,
  33002. })
  33003. return
  33004. }
  33005. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33006. userJSONBytes3, _ := json.Marshal(respJSON3)
  33007. fmt.Println("log")
  33008. fmt.Println(string(userJSONBytes3))
  33009. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33010. utils.ErrorLog("解析失败:%v", err)
  33011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33012. return
  33013. }
  33014. fmt.Println(res2.Infcode)
  33015. if res2.Infcode == -1 {
  33016. c.ServeSuccessJSON(map[string]interface{}{
  33017. "failed_code": -10,
  33018. "msg": res2.ErrMsg,
  33019. })
  33020. return
  33021. }
  33022. if res2.Infcode == 0 {
  33023. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33024. if err == nil {
  33025. c.ServeSuccessJSON(map[string]interface{}{
  33026. "msg": "撤销明细成功",
  33027. })
  33028. return
  33029. } else {
  33030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33031. return
  33032. }
  33033. } else {
  33034. c.ServeSuccessJSON(map[string]interface{}{
  33035. "failed_code": -10,
  33036. "msg": res2.ErrMsg,
  33037. })
  33038. }
  33039. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33040. if err == nil {
  33041. c.ServeSuccessJSON(map[string]interface{}{
  33042. "msg": "撤销明细成功",
  33043. })
  33044. return
  33045. } else {
  33046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33047. return
  33048. }
  33049. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33050. var resSix10265 ResultSix10265
  33051. new_chrg_bchno := order.Number
  33052. if adminUser.CurrentOrgId == 10265 {
  33053. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33054. new_chrg_bchno = "0000"
  33055. }
  33056. }
  33057. var api3 string
  33058. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33059. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33060. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33061. resp3, requestErr3 := http.Get(api3)
  33062. if requestErr3 != nil {
  33063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33064. return
  33065. }
  33066. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33067. if ioErr3 != nil {
  33068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33070. return
  33071. }
  33072. var respJSON3 map[string]interface{}
  33073. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33076. return
  33077. }
  33078. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33079. userJSONBytes3, _ := json.Marshal(respJSON3)
  33080. fmt.Println("log")
  33081. fmt.Println(string(userJSONBytes3))
  33082. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33083. utils.ErrorLog("解析失败:%v", err)
  33084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33085. return
  33086. }
  33087. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33088. res2.Output = resSix10265.Output
  33089. res2.ErrMsg = resSix10265.ErrMsg
  33090. res2.Cainfo = resSix10265.Cainfo
  33091. res2.WarnMsg = resSix10265.WarnMsg
  33092. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33093. res2.Infcode = infocode
  33094. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33095. if err == nil {
  33096. c.ServeSuccessJSON(map[string]interface{}{
  33097. "msg": "撤销明细成功",
  33098. })
  33099. return
  33100. } else {
  33101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33102. return
  33103. }
  33104. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33105. 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)
  33106. var dat map[string]interface{}
  33107. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33108. fmt.Println(dat)
  33109. } else {
  33110. fmt.Println(err)
  33111. }
  33112. saveLog(result2, src_request, "2205", "撤销明细")
  33113. userJSONBytes, _ := json.Marshal(dat)
  33114. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33115. utils.ErrorLog("解析失败:%v", err)
  33116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33117. return
  33118. }
  33119. if res2.Infcode == 0 {
  33120. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33121. if err == nil {
  33122. c.ServeSuccessJSON(map[string]interface{}{
  33123. "msg": "撤销明细成功",
  33124. })
  33125. return
  33126. } else {
  33127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33128. return
  33129. }
  33130. } else {
  33131. c.ServeSuccessJSON(map[string]interface{}{
  33132. "failed_code": -10,
  33133. "msg": res2.ErrMsg,
  33134. })
  33135. }
  33136. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33137. 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, "")
  33138. var dat map[string]interface{}
  33139. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33140. fmt.Println(dat)
  33141. } else {
  33142. fmt.Println(err)
  33143. }
  33144. saveLog(result2, src_request, "2205", "撤销明细")
  33145. userJSONBytes, _ := json.Marshal(dat)
  33146. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33147. utils.ErrorLog("解析失败:%v", err)
  33148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33149. return
  33150. }
  33151. if res2.Infcode == 0 {
  33152. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33153. if err == nil {
  33154. c.ServeSuccessJSON(map[string]interface{}{
  33155. "msg": "撤销明细成功",
  33156. })
  33157. return
  33158. } else {
  33159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33160. return
  33161. }
  33162. } else {
  33163. c.ServeSuccessJSON(map[string]interface{}{
  33164. "failed_code": -10,
  33165. "msg": res2.ErrMsg,
  33166. })
  33167. }
  33168. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33169. 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, "")
  33170. var dat map[string]interface{}
  33171. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33172. fmt.Println(dat)
  33173. } else {
  33174. fmt.Println(err)
  33175. }
  33176. saveLog(result2, src_request, "2205", "撤销明细")
  33177. userJSONBytes, _ := json.Marshal(dat)
  33178. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33179. utils.ErrorLog("解析失败:%v", err)
  33180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33181. return
  33182. }
  33183. if res2.Infcode == 0 {
  33184. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33185. if err == nil {
  33186. c.ServeSuccessJSON(map[string]interface{}{
  33187. "msg": "撤销明细成功",
  33188. })
  33189. return
  33190. } else {
  33191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33192. return
  33193. }
  33194. } else {
  33195. c.ServeSuccessJSON(map[string]interface{}{
  33196. "failed_code": -10,
  33197. "msg": res2.ErrMsg,
  33198. })
  33199. }
  33200. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33201. 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, "")
  33202. var dat map[string]interface{}
  33203. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33204. fmt.Println(dat)
  33205. } else {
  33206. fmt.Println(err)
  33207. }
  33208. saveLog(result2, src_request, "2205", "撤销明细")
  33209. userJSONBytes, _ := json.Marshal(dat)
  33210. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33211. utils.ErrorLog("解析失败:%v", err)
  33212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33213. return
  33214. }
  33215. if res2.Infcode == 0 {
  33216. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33217. if err == nil {
  33218. c.ServeSuccessJSON(map[string]interface{}{
  33219. "msg": "撤销明细成功",
  33220. })
  33221. return
  33222. } else {
  33223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33224. return
  33225. }
  33226. } else {
  33227. c.ServeSuccessJSON(map[string]interface{}{
  33228. "failed_code": -10,
  33229. "msg": res2.ErrMsg,
  33230. })
  33231. }
  33232. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33233. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33234. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33235. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33236. resp2, requestErr2 := http.Get(api2)
  33237. if requestErr2 != nil {
  33238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33239. return
  33240. }
  33241. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33242. if ioErr2 != nil {
  33243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33245. return
  33246. }
  33247. var respJSON2 map[string]interface{}
  33248. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33251. return
  33252. }
  33253. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33254. userJSONBytes3, _ := json.Marshal(respJSON2)
  33255. fmt.Println("log")
  33256. fmt.Println(string(userJSONBytes3))
  33257. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33258. utils.ErrorLog("解析失败:%v", err)
  33259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33260. return
  33261. }
  33262. if res2.Infcode == 0 {
  33263. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33264. if err == nil {
  33265. c.ServeSuccessJSON(map[string]interface{}{
  33266. "msg": "撤销明细成功",
  33267. })
  33268. return
  33269. } else {
  33270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33271. return
  33272. }
  33273. } else {
  33274. c.ServeSuccessJSON(map[string]interface{}{
  33275. "failed_code": -10,
  33276. "msg": res2.ErrMsg,
  33277. })
  33278. }
  33279. } else {
  33280. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33281. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33282. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33283. resp2, requestErr2 := http.Get(api2)
  33284. if requestErr2 != nil {
  33285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33286. return
  33287. }
  33288. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33289. if ioErr2 != nil {
  33290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33292. return
  33293. }
  33294. var respJSON2 map[string]interface{}
  33295. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33298. return
  33299. }
  33300. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33301. userJSONBytes3, _ := json.Marshal(respJSON2)
  33302. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33303. utils.ErrorLog("解析失败:%v", err)
  33304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33305. return
  33306. }
  33307. if res2.Infcode == -1 {
  33308. c.ServeSuccessJSON(map[string]interface{}{
  33309. "failed_code": -10,
  33310. "msg": res2.ErrMsg,
  33311. })
  33312. return
  33313. } else {
  33314. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33315. if err == nil {
  33316. c.ServeSuccessJSON(map[string]interface{}{
  33317. "msg": "撤销明细成功",
  33318. })
  33319. return
  33320. } else {
  33321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33322. return
  33323. }
  33324. }
  33325. }
  33326. } else {
  33327. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33328. if err == nil {
  33329. c.ServeSuccessJSON(map[string]interface{}{
  33330. "msg": "退费成功",
  33331. })
  33332. } else {
  33333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33334. return
  33335. }
  33336. }
  33337. }
  33338. // 对账
  33339. func (c *HisApiController) GetCheckAccount() {
  33340. start_time := c.GetString("start_time")
  33341. end_time := c.GetString("end_time")
  33342. insutype := c.GetString("insutype")
  33343. clr_type := c.GetString("clr_type")
  33344. clr_org := c.GetString("clr_optins")
  33345. admin_user_id, _ := c.GetInt64("admin_user_id")
  33346. adminUser := c.GetAdminUserInfo()
  33347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33348. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33349. if len(clr_org) == 0 {
  33350. clr_org = miConfig.InsuplcAdmdvs
  33351. }
  33352. timeLayout := "2006-01-02"
  33353. loc, _ := time.LoadLocation("Local")
  33354. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33355. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33356. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33357. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33358. fixmedins_setl_cnt := int64(len(orders))
  33359. var medfee_sumamt float64
  33360. var acct_pay float64
  33361. var fund_pay_sumamt float64
  33362. for _, item := range orders {
  33363. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33364. acct_pay = acct_pay + item.AcctPay
  33365. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33366. }
  33367. var user_name string
  33368. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33369. if role.ID == 0 {
  33370. user_name = "xxx"
  33371. } else {
  33372. user_name = role.UserName
  33373. }
  33374. var res ResultEight
  33375. var res10188 ResultEightFor10188
  33376. if config.IsOpen == 1 {
  33377. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33378. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33379. "insutype=" + insutype +
  33380. "&clr_type=" + clr_type +
  33381. "&setl_optins=" + clr_org +
  33382. "&stmt_begndate=" + start_time +
  33383. "&stm_enddate=" + end_time +
  33384. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33385. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33386. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33387. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33388. "&fixmedins_code=" + miConfig.Code +
  33389. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33390. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33391. "&secret_key=" + miConfig.SecretKey +
  33392. "&org_name=" + miConfig.OrgName +
  33393. "&doctor=" + user_name +
  33394. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33395. fmt.Println(api)
  33396. resp, requestErr := http.Get(api)
  33397. if requestErr != nil {
  33398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33399. return
  33400. }
  33401. body, ioErr := ioutil.ReadAll(resp.Body)
  33402. fmt.Println(body)
  33403. if ioErr != nil {
  33404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33406. return
  33407. }
  33408. var respJSON map[string]interface{}
  33409. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33412. return
  33413. }
  33414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33415. userJSONBytes, _ := json.Marshal(respJSON)
  33416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33417. utils.ErrorLog("解析失败:%v", err)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. res.InfRefmsgid = res10188.InfRefmsgid
  33422. res.Output = res10188.Output
  33423. res.ErrMsg = res10188.ErrMsg
  33424. res.Cainfo = res10188.Cainfo
  33425. res.WarnMsg = res10188.WarnMsg
  33426. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33427. res.Infcode = infocode
  33428. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33429. if clr_type != "9903" {
  33430. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33431. }
  33432. if clr_type == "9903" {
  33433. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33434. }
  33435. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33436. "insutype=" + insutype +
  33437. "&clr_type=" + clr_type +
  33438. "&setl_optins=" + clr_org +
  33439. "&stmt_begndate=" + start_time +
  33440. "&stm_enddate=" + end_time +
  33441. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33442. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33443. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33444. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33445. "&fixmedins_code=" + miConfig.Code +
  33446. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33447. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33448. "&secret_key=" + miConfig.SecretKey +
  33449. "&org_name=" + miConfig.OrgName +
  33450. "&doctor=" + user_name
  33451. resp, requestErr := http.Get(api)
  33452. if requestErr != nil {
  33453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33454. return
  33455. }
  33456. body, ioErr := ioutil.ReadAll(resp.Body)
  33457. if ioErr != nil {
  33458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33460. return
  33461. }
  33462. var respJSON map[string]interface{}
  33463. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33466. return
  33467. }
  33468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33469. result, _ := json.Marshal(respJSON)
  33470. fmt.Println("log")
  33471. fmt.Println(string(result))
  33472. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33473. utils.ErrorLog("解析失败:%v", err)
  33474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33475. return
  33476. }
  33477. res.InfRefmsgid = res10188.InfRefmsgid
  33478. res.Output = res10188.Output
  33479. res.ErrMsg = res10188.ErrMsg
  33480. res.Cainfo = res10188.Cainfo
  33481. res.WarnMsg = res10188.WarnMsg
  33482. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33483. res.Infcode = infocode
  33484. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33485. var baseParams models.BaseParams
  33486. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33487. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33488. baseParams.SecretKey = miConfig.SecretKey
  33489. baseParams.OrgName = miConfig.OrgName
  33490. baseParams.FixmedinsCode = miConfig.Code
  33491. baseParams.EncKey = miConfig.EncKey
  33492. baseParams.AppSecret = miConfig.AppSecret
  33493. baseParams.SignKey = miConfig.SignKey
  33494. baseParams.AppID = miConfig.Code
  33495. baseParams.Doctor = role.UserName
  33496. baseParams.RequestUrl = miConfig.Url
  33497. businessParams := models.BusinessParams{
  33498. Insutype: insutype,
  33499. ClrType: clr_type,
  33500. SetlOptins: clr_org,
  33501. StmtBegndate: start_time,
  33502. StmtEnddate: end_time,
  33503. MedfeeSumamt: medfee_sumamt,
  33504. FundPaySumamt: fund_pay_sumamt,
  33505. AcctPay: acct_pay,
  33506. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33507. }
  33508. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33509. fmt.Println(requestLog)
  33510. fmt.Println(result)
  33511. fmt.Println(err_msg)
  33512. var dat map[string]interface{}
  33513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33514. fmt.Println(dat)
  33515. } else {
  33516. fmt.Println(err)
  33517. }
  33518. userJSONBytes, _ := json.Marshal(dat)
  33519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33520. utils.ErrorLog("解析失败:%v", err)
  33521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33522. return
  33523. }
  33524. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33525. var baseParams models.BaseParams
  33526. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33527. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33528. baseParams.SecretKey = miConfig.SecretKey
  33529. baseParams.OrgName = miConfig.OrgName
  33530. baseParams.FixmedinsCode = miConfig.Code
  33531. baseParams.EncKey = miConfig.EncKey
  33532. baseParams.AppSecret = miConfig.AppSecret
  33533. baseParams.SignKey = miConfig.SignKey
  33534. baseParams.AppID = miConfig.Code
  33535. baseParams.Doctor = role.UserName
  33536. baseParams.RequestUrl = miConfig.Url
  33537. baseParams.AccessKey = miConfig.AccessKey
  33538. businessParams := models.BusinessParams{
  33539. Insutype: insutype,
  33540. ClrType: clr_type,
  33541. SetlOptins: "430822",
  33542. StmtBegndate: start_time,
  33543. StmtEnddate: end_time,
  33544. MedfeeSumamt: medfee_sumamt,
  33545. FundPaySumamt: fund_pay_sumamt,
  33546. AcctPay: acct_pay,
  33547. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33548. }
  33549. 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)
  33550. fmt.Println(requestLog)
  33551. fmt.Println(result)
  33552. var dat map[string]interface{}
  33553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33554. fmt.Println(dat)
  33555. } else {
  33556. fmt.Println(err)
  33557. }
  33558. userJSONBytes, _ := json.Marshal(dat)
  33559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33560. utils.ErrorLog("解析失败:%v", err)
  33561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33562. return
  33563. }
  33564. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33565. var baseParams models.BaseParams
  33566. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33567. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33568. baseParams.SecretKey = miConfig.SecretKey
  33569. baseParams.OrgName = miConfig.OrgName
  33570. baseParams.FixmedinsCode = miConfig.Code
  33571. baseParams.EncKey = miConfig.EncKey
  33572. baseParams.AppSecret = miConfig.AppSecret
  33573. baseParams.SignKey = miConfig.SignKey
  33574. baseParams.AppID = miConfig.Code
  33575. baseParams.Doctor = role.UserName
  33576. baseParams.RequestUrl = miConfig.Url
  33577. businessParams := models.BusinessParams{
  33578. Insutype: insutype,
  33579. ClrType: clr_type,
  33580. SetlOptins: clr_org,
  33581. StmtBegndate: start_time,
  33582. StmtEnddate: end_time,
  33583. MedfeeSumamt: medfee_sumamt,
  33584. FundPaySumamt: fund_pay_sumamt,
  33585. AcctPay: acct_pay,
  33586. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33587. }
  33588. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33589. fmt.Println(requestLog)
  33590. fmt.Println(result)
  33591. fmt.Println(err_msg)
  33592. var dat map[string]interface{}
  33593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33594. fmt.Println(dat)
  33595. } else {
  33596. fmt.Println(err)
  33597. }
  33598. userJSONBytes, _ := json.Marshal(dat)
  33599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33600. utils.ErrorLog("解析失败:%v", err)
  33601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33602. return
  33603. }
  33604. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33605. if len(clr_type) == 0 {
  33606. clr_type = "11"
  33607. }
  33608. api := miConfig.Url + "gdyb/ten?" +
  33609. "insutype=" + insutype +
  33610. "&clr_type=" + clr_type +
  33611. "&setl_optins=" + clr_org +
  33612. "&stmt_begndate=" + start_time +
  33613. "&stm_enddate=" + end_time +
  33614. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33615. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33616. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33617. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33618. "&fixmedins_code=" + miConfig.Code +
  33619. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33620. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33621. "&secret_key=" + miConfig.SecretKey +
  33622. "&org_name=" + miConfig.OrgName +
  33623. "&doctor=" + user_name
  33624. fmt.Println(api)
  33625. resp, requestErr := http.Get(api)
  33626. if requestErr != nil {
  33627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33628. return
  33629. }
  33630. body, ioErr := ioutil.ReadAll(resp.Body)
  33631. fmt.Println(body)
  33632. if ioErr != nil {
  33633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33635. return
  33636. }
  33637. var respJSON map[string]interface{}
  33638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33641. return
  33642. }
  33643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33644. userJSONBytes, _ := json.Marshal(respJSON)
  33645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33646. utils.ErrorLog("解析失败:%v", err)
  33647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33648. return
  33649. }
  33650. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33651. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33652. //fixmedins_setl_cnt := int64(len(orders_two))
  33653. //var medfee_sumamt float64
  33654. //var acct_pay float64
  33655. //var fund_pay_sumamt float64
  33656. //for _, item := range orders_two {
  33657. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33658. // acct_pay = acct_pay + item.AcctPay
  33659. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33660. //}
  33661. var baseParams models.BaseParams
  33662. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33663. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33664. baseParams.SecretKey = miConfig.SecretKey
  33665. baseParams.OrgName = miConfig.OrgName
  33666. baseParams.FixmedinsCode = miConfig.Code
  33667. baseParams.EncKey = miConfig.EncKey
  33668. baseParams.AppSecret = miConfig.AppSecret
  33669. baseParams.SignKey = miConfig.SignKey
  33670. baseParams.AppID = miConfig.Code
  33671. baseParams.Doctor = role.UserName
  33672. baseParams.RequestUrl = miConfig.Url
  33673. if clr_type == "9903" {
  33674. clr_type = "9994"
  33675. }
  33676. businessParams := models.BusinessParams{
  33677. Insutype: insutype,
  33678. ClrType: clr_type,
  33679. SetlOptins: "360302",
  33680. StmtBegndate: start_time,
  33681. StmtEnddate: end_time,
  33682. MedfeeSumamt: 0,
  33683. FundPaySumamt: 0,
  33684. AcctPay: 0,
  33685. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33686. }
  33687. 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))
  33688. fmt.Println(requestLog)
  33689. fmt.Println(result)
  33690. var dat map[string]interface{}
  33691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33692. fmt.Println(dat)
  33693. } else {
  33694. fmt.Println(err)
  33695. }
  33696. userJSONBytes, _ := json.Marshal(dat)
  33697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33698. utils.ErrorLog("解析失败:%v", err)
  33699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33700. return
  33701. }
  33702. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33703. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33704. fixmedins_setl_cnt := int64(len(orders_two))
  33705. var medfee_sumamt float64
  33706. var acct_pay float64
  33707. var fund_pay_sumamt float64
  33708. for _, item := range orders_two {
  33709. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33710. acct_pay = acct_pay + item.AcctPay
  33711. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33712. }
  33713. var baseParams models.BaseParams
  33714. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33715. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33716. baseParams.SecretKey = miConfig.SecretKey
  33717. baseParams.OrgName = miConfig.OrgName
  33718. baseParams.FixmedinsCode = miConfig.Code
  33719. baseParams.EncKey = miConfig.EncKey
  33720. baseParams.AppSecret = miConfig.AppSecret
  33721. baseParams.SignKey = miConfig.SignKey
  33722. baseParams.AppID = miConfig.Code
  33723. baseParams.Doctor = role.UserName
  33724. baseParams.RequestUrl = miConfig.Url
  33725. if clr_type == "9903" {
  33726. clr_type = "9994"
  33727. }
  33728. businessParams := models.BusinessParams{
  33729. Insutype: insutype,
  33730. ClrType: clr_type,
  33731. SetlOptins: "361025",
  33732. StmtBegndate: start_time,
  33733. StmtEnddate: end_time,
  33734. MedfeeSumamt: 0,
  33735. FundPaySumamt: 0,
  33736. AcctPay: 0,
  33737. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33738. }
  33739. 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))
  33740. fmt.Println(requestLog)
  33741. fmt.Println(result)
  33742. var dat map[string]interface{}
  33743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33744. fmt.Println(dat)
  33745. } else {
  33746. fmt.Println(err)
  33747. }
  33748. userJSONBytes, _ := json.Marshal(dat)
  33749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33750. utils.ErrorLog("解析失败:%v", err)
  33751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33752. return
  33753. }
  33754. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33755. var api string
  33756. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33757. "&clr_type=" + clr_type +
  33758. "&setl_optins=" + clr_org +
  33759. "&stmt_begndate=" + start_time +
  33760. "&stm_enddate=" + end_time +
  33761. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33762. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33763. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33764. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33765. "&fixmedins_code=" + miConfig.Code +
  33766. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33767. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33768. "&secret_key=" + miConfig.SecretKey +
  33769. "&org_name=" + miConfig.OrgName +
  33770. "&doctor=" + user_name + "&url=" + miConfig.Url
  33771. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33772. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33773. resp, requestErr := http.Get(api)
  33774. if requestErr != nil {
  33775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33776. return
  33777. }
  33778. body, ioErr := ioutil.ReadAll(resp.Body)
  33779. if ioErr != nil {
  33780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33782. return
  33783. }
  33784. var respJSON map[string]interface{}
  33785. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33788. return
  33789. }
  33790. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33791. if status == "0" {
  33792. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33793. c.ServeSuccessJSON(map[string]interface{}{
  33794. "failed_code": -10,
  33795. "msg": err_msg,
  33796. })
  33797. return
  33798. }
  33799. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33800. userJSONBytes, _ := json.Marshal(respJSON)
  33801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33802. utils.ErrorLog("解析失败:%v", err)
  33803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33804. return
  33805. }
  33806. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33807. var api string
  33808. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33809. "&clr_type=" + clr_type +
  33810. "&setl_optins=" + clr_org +
  33811. "&stmt_begndate=" + start_time +
  33812. "&stm_enddate=" + end_time +
  33813. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33814. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33815. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33816. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33817. "&fixmedins_code=" + miConfig.Code +
  33818. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33819. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33820. "&secret_key=" + miConfig.SecretKey +
  33821. "&org_name=" + miConfig.OrgName +
  33822. "&doctor=" + user_name + "&url=" + miConfig.Url
  33823. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33824. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33825. resp, requestErr := http.Get(api)
  33826. if requestErr != nil {
  33827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33828. return
  33829. }
  33830. body, ioErr := ioutil.ReadAll(resp.Body)
  33831. if ioErr != nil {
  33832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33834. return
  33835. }
  33836. var respJSON map[string]interface{}
  33837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33840. return
  33841. }
  33842. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33843. if status == "0" {
  33844. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33845. c.ServeSuccessJSON(map[string]interface{}{
  33846. "failed_code": -10,
  33847. "msg": err_msg,
  33848. })
  33849. return
  33850. }
  33851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33852. userJSONBytes, _ := json.Marshal(respJSON)
  33853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33854. utils.ErrorLog("解析失败:%v", err)
  33855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33856. return
  33857. }
  33858. } else {
  33859. if len(clr_type) == 0 {
  33860. clr_type = "11"
  33861. }
  33862. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33863. "insutype=" + insutype +
  33864. "&clr_type=" + clr_type +
  33865. "&setl_optins=" + clr_org +
  33866. "&stmt_begndate=" + start_time +
  33867. "&stm_enddate=" + end_time +
  33868. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33869. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33870. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33871. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33872. "&fixmedins_code=" + miConfig.Code +
  33873. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33874. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33875. "&secret_key=" + miConfig.SecretKey +
  33876. "&org_name=" + miConfig.OrgName +
  33877. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33878. fmt.Println(api)
  33879. resp, requestErr := http.Get(api)
  33880. if requestErr != nil {
  33881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33882. return
  33883. }
  33884. body, ioErr := ioutil.ReadAll(resp.Body)
  33885. fmt.Println(body)
  33886. if ioErr != nil {
  33887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33889. return
  33890. }
  33891. var respJSON map[string]interface{}
  33892. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33895. return
  33896. }
  33897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33898. userJSONBytes, _ := json.Marshal(respJSON)
  33899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33900. utils.ErrorLog("解析失败:%v", err)
  33901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33902. return
  33903. }
  33904. }
  33905. if res.Infcode == 0 {
  33906. if res.Output.Stmtinfo.StmtRslt == "0" {
  33907. micc := &models.MedicalInsuranceCostCompare{
  33908. StartTime: startime.Unix(),
  33909. EndTime: endtime.Unix(),
  33910. Insutype: insutype,
  33911. CheckType: 1,
  33912. Num: fixmedins_setl_cnt,
  33913. Mtime: time.Now().Unix(),
  33914. Status: 1,
  33915. UserOrgId: adminUser.CurrentOrgId,
  33916. CostTotal: medfee_sumamt,
  33917. FuncTotal: fund_pay_sumamt,
  33918. PsnPay: acct_pay,
  33919. Creator: admin_user_id,
  33920. Ctime: time.Now().Unix(),
  33921. ClrType: clr_type,
  33922. }
  33923. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33924. if err == nil {
  33925. c.ServeSuccessJSON(map[string]interface{}{
  33926. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33927. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33928. })
  33929. } else {
  33930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33931. }
  33932. } else {
  33933. c.ServeSuccessJSON(map[string]interface{}{
  33934. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33935. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33936. })
  33937. }
  33938. } else {
  33939. c.ServeSuccessJSON(map[string]interface{}{
  33940. "failed_code": -10,
  33941. "msg": res.ErrMsg,
  33942. })
  33943. }
  33944. }
  33945. }
  33946. func (c *HisApiController) Check310() {
  33947. adminUser := c.GetAdminUserInfo()
  33948. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33949. var user_name string
  33950. user_name = "高慧裕"
  33951. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33952. "insutype=" + "310" +
  33953. "&clr_type=" + "" +
  33954. "&setl_optins=" + "441202" +
  33955. "&stmt_begndate=" + "2022-03-01" +
  33956. "&stm_enddate=" + "2022-03-31" +
  33957. "&medfee_sumamt=" + "194930.12" +
  33958. "&fund_pay_sumamt=" + "188741.46" +
  33959. "&acct_pay=" + "0" +
  33960. "&fixmedins_setl_cnt=" + "452" +
  33961. "&fixmedins_code=" + miConfig.Code +
  33962. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33963. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33964. "&secret_key=" + miConfig.SecretKey +
  33965. "&org_name=" + miConfig.OrgName +
  33966. "&doctor=" + user_name
  33967. fmt.Println(api)
  33968. resp, requestErr := http.Get(api)
  33969. if requestErr != nil {
  33970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33971. return
  33972. }
  33973. body, ioErr := ioutil.ReadAll(resp.Body)
  33974. fmt.Println(body)
  33975. if ioErr != nil {
  33976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33978. return
  33979. }
  33980. var respJSON map[string]interface{}
  33981. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33984. return
  33985. }
  33986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33987. userJSONBytes, _ := json.Marshal(respJSON)
  33988. var res ResultEight
  33989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33990. utils.ErrorLog("解析失败:%v", err)
  33991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33992. return
  33993. }
  33994. }
  33995. func (c *HisApiController) Check390() {
  33996. adminUser := c.GetAdminUserInfo()
  33997. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33998. var user_name string
  33999. user_name = "高慧裕"
  34000. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34001. "insutype=" + "390" +
  34002. "&clr_type=" + "" +
  34003. "&setl_optins=" + "441202" +
  34004. "&stmt_begndate=" + "2022-03-01" +
  34005. "&stm_enddate=" + "2022-03-31" +
  34006. "&medfee_sumamt=" + "1068448.89" +
  34007. "&fund_pay_sumamt=" + "1014677.62" +
  34008. "&acct_pay=" + "0" +
  34009. "&fixmedins_setl_cnt=" + "1950" +
  34010. "&fixmedins_code=" + miConfig.Code +
  34011. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34012. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34013. "&secret_key=" + miConfig.SecretKey +
  34014. "&org_name=" + miConfig.OrgName +
  34015. "&doctor=" + user_name
  34016. fmt.Println(api)
  34017. resp, requestErr := http.Get(api)
  34018. if requestErr != nil {
  34019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34020. return
  34021. }
  34022. body, ioErr := ioutil.ReadAll(resp.Body)
  34023. fmt.Println(body)
  34024. if ioErr != nil {
  34025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34027. return
  34028. }
  34029. var respJSON map[string]interface{}
  34030. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34033. return
  34034. }
  34035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34036. userJSONBytes, _ := json.Marshal(respJSON)
  34037. var res ResultEight
  34038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34039. utils.ErrorLog("解析失败:%v", err)
  34040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34041. return
  34042. }
  34043. }
  34044. // 对账明细
  34045. func (c *HisApiController) GetCheckDetailAccount() {
  34046. start_time := c.GetString("start_time")
  34047. end_time := c.GetString("end_time")
  34048. admin_user_id, _ := c.GetInt64("admin_user_id")
  34049. adminUser := c.GetAdminUserInfo()
  34050. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34051. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34052. timeLayout := "2006-01-02"
  34053. loc, _ := time.LoadLocation("Local")
  34054. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34055. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34056. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34057. rand.Seed(time.Now().UnixNano())
  34058. num := rand.Intn(30000)
  34059. Mkdir(miConfig.OrgName)
  34060. file := strconv.FormatInt(int64(num), 10)
  34061. file_name := file + ".txt"
  34062. zip_name := file + ".zip"
  34063. zip_path := miConfig.OrgName + "/" + zip_name
  34064. file_path := miConfig.OrgName + "/" + file_name
  34065. decimal.DivisionPrecision = 2
  34066. var medfee_sumamt float64
  34067. var psn_cash_pay float64
  34068. var fund_pay_sumamt float64
  34069. fixmedins_setl_cnt := int64(len(orders))
  34070. for _, item := range orders {
  34071. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34072. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34073. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34074. }
  34075. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34076. defer f.Close()
  34077. if err != nil {
  34078. fmt.Println(err.Error())
  34079. } else {
  34080. for _, item := range orders {
  34081. var refd_setl_flag string
  34082. if item.OrderStatus == 2 {
  34083. refd_setl_flag = "0"
  34084. var str string
  34085. str = item.SetlId + " " +
  34086. item.MdtrtId + " " +
  34087. item.PsnNo + " " +
  34088. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34089. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34090. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34091. _, err = f.Write([]byte(str))
  34092. }
  34093. if item.OrderStatus == 3 {
  34094. var str string
  34095. str = item.SetlId + " " +
  34096. item.MdtrtId + " " +
  34097. item.PsnNo + " " +
  34098. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34099. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34100. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34101. _, err = f.Write([]byte(str))
  34102. var str2 string
  34103. str2 = item.SetlId + " " +
  34104. item.MdtrtId + " " +
  34105. item.PsnNo + " " +
  34106. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34107. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34108. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34109. _, err = f.Write([]byte(str2))
  34110. }
  34111. }
  34112. }
  34113. Zip(file_path, zip_path)
  34114. fmt.Println(ReadFile(zip_path))
  34115. fmt.Println(string(ReadFile(zip_path)))
  34116. if config.IsOpen == 1 {
  34117. var user_name string
  34118. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34119. if role.ID == 0 {
  34120. user_name = "管理员"
  34121. } else {
  34122. user_name = role.UserName
  34123. }
  34124. baseParams := models.BaseParams{
  34125. SecretKey: miConfig.SecretKey,
  34126. FixmedinsCode: miConfig.Code,
  34127. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34128. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34129. OrgName: miConfig.OrgName,
  34130. Doctor: user_name,
  34131. }
  34132. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34133. var dat map[string]interface{}
  34134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34135. fmt.Println(dat)
  34136. } else {
  34137. fmt.Println(err)
  34138. }
  34139. userJSONBytes, _ := json.Marshal(dat)
  34140. var res ResultNine
  34141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34142. utils.ErrorLog("解析失败:%v", err)
  34143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34144. return
  34145. }
  34146. if res.Infcode == 0 {
  34147. fileNo := res.Output.FileQuryNo
  34148. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34149. "file_qury_no=" + fileNo +
  34150. "&setl_optins=" + "定点医保中心" +
  34151. "&stmt_begndate=" + start_time +
  34152. "&stm_enddate=" + end_time +
  34153. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34154. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34155. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34156. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34157. "&fixmedins_code=" + miConfig.Code +
  34158. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34159. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34160. "&secret_key=" + miConfig.SecretKey +
  34161. "&org_name=" + miConfig.OrgName +
  34162. "&doctor=" + user_name
  34163. resp, requestErr := http.Get(api)
  34164. if requestErr != nil {
  34165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34166. return
  34167. }
  34168. body, ioErr := ioutil.ReadAll(resp.Body)
  34169. if ioErr != nil {
  34170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34172. return
  34173. }
  34174. var respJSON map[string]interface{}
  34175. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34178. return
  34179. }
  34180. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34181. userJSONBytes, _ := json.Marshal(respJSON)
  34182. var res ResultTen
  34183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34184. utils.ErrorLog("解析失败:%v", err)
  34185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34186. return
  34187. }
  34188. if res.Infcode == 0 {
  34189. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34190. micc := &models.MedicalInsuranceCostCompare{
  34191. StartTime: startime.Unix(),
  34192. EndTime: endtime.Unix(),
  34193. Insutype: "0",
  34194. CheckType: 2,
  34195. Num: fixmedins_setl_cnt,
  34196. Mtime: time.Now().Unix(),
  34197. Status: 1,
  34198. UserOrgId: adminUser.CurrentOrgId,
  34199. CostTotal: medfee_sumamt,
  34200. FuncTotal: fund_pay_sumamt,
  34201. PsnPay: psn_cash_pay,
  34202. Creator: admin_user_id,
  34203. Ctime: time.Now().Unix(),
  34204. }
  34205. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34206. c.ServeSuccessJSON(map[string]interface{}{
  34207. "msg": "明细对账成功",
  34208. })
  34209. }
  34210. } else {
  34211. }
  34212. }
  34213. }
  34214. type CustomOrderInfo struct {
  34215. Name string
  34216. Spec string
  34217. Unit string
  34218. Count float64
  34219. Price float64
  34220. Total float64
  34221. }
  34222. func (c *HisApiController) GetBatchSettleAccounts() {
  34223. admin_user_id, _ := c.GetInt64("admin_user_id")
  34224. order_ids := c.GetString("order_ids")
  34225. order_ids_arr := strings.Split(order_ids, ",")
  34226. data3 := []map[string]interface{}{}
  34227. for _, item := range order_ids_arr {
  34228. id, _ := strconv.ParseInt(item, 10, 64)
  34229. order_id := id
  34230. adminUser := c.GetAdminUserInfo()
  34231. order, _ := service.GetHisOrderByID(order_id)
  34232. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34233. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34234. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34235. orderInfos = append(orderInfos, orderInfos_two...)
  34236. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34237. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34238. var diagnosis_ids []string
  34239. if his.ID > 0 {
  34240. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34241. } else {
  34242. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34243. }
  34244. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34245. var dia_config []*models.HisXtDiagnoseConfig
  34246. var name string
  34247. for _, item := range diagnosis_ids {
  34248. id, _ := strconv.ParseInt(item, 10, 64)
  34249. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34250. dia_config = append(dia_config, &diagnosisConfig)
  34251. if len(name) == 0 {
  34252. name = diagnosisConfig.ClassName
  34253. }
  34254. //} else {
  34255. // name = name + "," + diagnosisConfig.ClassName
  34256. //}
  34257. }
  34258. var bedCostTotal float64 = 0 //床位总费
  34259. var bedCostSelfTotal float64 = 0 //床位自费
  34260. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34261. var bedSelfTotal float64 = 0 //床位部分项目自费
  34262. var bedInscpTotal float64 = 0 //床位部分项目自费
  34263. var operationCostTotal float64 = 0 //手术费
  34264. var operationCostSelfTotal float64 = 0 //手术费
  34265. var operationCostPartSelfTotal float64 = 0 //手术费
  34266. var operationSelfTotal float64 = 0 //床位部分项目自费
  34267. var operationInscpTotal float64 = 0 //床位部分项目自费
  34268. var otherCostTotal float64 = 0 //其他费用
  34269. var otherCostSelfTotal float64 = 0 //其他费用
  34270. var otherCostPartSelfTotal float64 = 0 //其他费用
  34271. var otherSelfTotal float64 = 0 //床位部分项目自费
  34272. var otherInscpTotal float64 = 0 //床位部分项目自费
  34273. var materialCostTotal float64 = 0 //材料费
  34274. var materialCostSelfTotal float64 = 0 //材料费
  34275. var materialCostPartSelfTotal float64 = 0 //材料费
  34276. var materialSelfTotal float64 = 0 //床位部分项目自费
  34277. var materialInscpTotal float64 = 0 //床位部分项目自费
  34278. var westernMedicineCostTotal float64 = 0 //西药费
  34279. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34280. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34281. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34282. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34283. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34284. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34285. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34286. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34287. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34288. var checkCostTotal float64 = 0 //检查费
  34289. var checkCostSelfTotal float64 = 0 //检查费
  34290. var checkCostPartSelfTotal float64 = 0 //检查费
  34291. var checkSelfTotal float64 = 0 //床位部分项目自费
  34292. var checkInscpTotal float64 = 0 //床位部分项目自费
  34293. var laboratoryCostTotal float64 = 0 //化验费
  34294. var laboratoryCostSelfTotal float64 = 0 //化验费
  34295. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34296. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34297. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34298. var treatCostTotal float64 = 0 //治疗费用
  34299. var treatCostSelfTotal float64 = 0 //治疗费用
  34300. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34301. var treatSelfTotal float64 = 0 //床位部分项目自费
  34302. var treatInscpTotal float64 = 0 //床位部分项目自费
  34303. decimal.DivisionPrecision = 2
  34304. for _, item := range orderInfos {
  34305. if item.MedChrgitmType == "01" { //床位费
  34306. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34307. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34308. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34309. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34310. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34311. }
  34312. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34313. if item.MedChrgitmType == "03" { //检查费
  34314. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34315. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34316. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34317. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34318. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34319. }
  34320. } else {
  34321. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34322. fmt.Println("------------")
  34323. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34324. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34325. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34326. }
  34327. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34328. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34329. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34330. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34331. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34332. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34333. }
  34334. }
  34335. if item.MedChrgitmType == "04" { //化验费
  34336. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34337. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34338. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34339. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34340. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34341. }
  34342. if item.MedChrgitmType == "05" { //治疗费
  34343. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34344. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34345. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34346. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34347. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34348. }
  34349. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34350. fmt.Println("------------")
  34351. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34352. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34353. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34354. }
  34355. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34356. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34357. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34358. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34359. }
  34360. //if item.MedChrgitmType == "06" { //手术费
  34361. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34362. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34363. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34364. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34365. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34366. //
  34367. //}
  34368. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34369. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34370. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34371. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34372. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34373. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34374. }
  34375. if item.MedChrgitmType == "09" { //西药费
  34376. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34377. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34378. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34379. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34380. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34381. }
  34382. if item.MedChrgitmType == "11" { //中成费
  34383. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34384. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34385. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34386. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34387. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34388. }
  34389. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34390. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34391. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34392. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34393. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34394. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34395. }
  34396. }
  34397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34398. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34399. var user_name string
  34400. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34401. if role.ID == 0 {
  34402. user_name = "管理员"
  34403. } else {
  34404. user_name = role.UserName
  34405. }
  34406. baseParams := models.BaseParams{
  34407. SecretKey: miConfig.SecretKey,
  34408. FixmedinsCode: miConfig.Code,
  34409. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34410. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34411. OrgName: miConfig.OrgName,
  34412. Doctor: user_name,
  34413. RequestUrl: miConfig.Url,
  34414. AccessKey: miConfig.AccessKey,
  34415. }
  34416. businessParams := models.BusinessParams{
  34417. PsnNo: order.PsnNo,
  34418. MdtrtId: order.MdtrtId,
  34419. SetlId: order.SetlId,
  34420. }
  34421. var res ResultEleven
  34422. var resEleven10265 ResultEleven10265
  34423. if config.IsOpen == 1 {
  34424. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34425. result := service.Gdyb5203(baseParams, businessParams)
  34426. service.Gdyb5204(baseParams, businessParams)
  34427. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34428. var dat map[string]interface{}
  34429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34430. fmt.Println(dat)
  34431. } else {
  34432. fmt.Println(err)
  34433. }
  34434. userJSONBytes, _ := json.Marshal(dat)
  34435. if miConfig.Code == "H15049901371" {
  34436. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34437. utils.ErrorLog("解析失败:%v", err)
  34438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34439. return
  34440. }
  34441. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34442. res.Output = resEleven10265.Output
  34443. res.ErrMsg = resEleven10265.ErrMsg
  34444. res.Cainfo = resEleven10265.Cainfo
  34445. res.WarnMsg = resEleven10265.WarnMsg
  34446. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34447. res.Infcode = infocode
  34448. } else {
  34449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34450. utils.ErrorLog("解析失败:%v", err)
  34451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34452. return
  34453. }
  34454. }
  34455. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34456. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34457. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34458. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34459. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34460. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34461. var doctor_name string
  34462. if roles.ID == 0 {
  34463. doctor_name = "管理员"
  34464. } else {
  34465. doctor_name = roles.UserName
  34466. }
  34467. yiliao_leibie := ""
  34468. switch order.MedType {
  34469. case "11":
  34470. yiliao_leibie = "普通门诊"
  34471. break
  34472. case "12":
  34473. yiliao_leibie = "门诊挂号"
  34474. break
  34475. case "13":
  34476. yiliao_leibie = "急诊"
  34477. break
  34478. case "14":
  34479. yiliao_leibie = "门诊特殊病"
  34480. break
  34481. case "15":
  34482. yiliao_leibie = "门诊统筹"
  34483. break
  34484. case "16":
  34485. yiliao_leibie = "门诊慢性病"
  34486. break
  34487. case "21":
  34488. yiliao_leibie = "普通住院"
  34489. break
  34490. }
  34491. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34492. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34493. if res.Infcode == 0 {
  34494. data2 := map[string]interface{}{
  34495. "diagnosis": name,
  34496. "order_infos": orderInfos,
  34497. "number": order.MdtrtId,
  34498. "date": order.SettleAccountsDate,
  34499. "charge_admin": charge_admin,
  34500. "printor_admin": printor_admin,
  34501. "info": res.Output.Setlinfo,
  34502. "order": order,
  34503. "bedCostTotal": bedCostTotal,
  34504. "bedCostSelfTotal": bedCostSelfTotal,
  34505. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34506. "bedSelfTotal": bedSelfTotal,
  34507. "bedInscpTotal": bedInscpTotal,
  34508. "operationCostTotal": operationCostTotal,
  34509. "operationCostSelfTotal": operationCostSelfTotal,
  34510. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34511. "operationSelfTotal": operationSelfTotal,
  34512. "operationInscpTotal": operationInscpTotal,
  34513. "otherCostTotal": otherCostTotal,
  34514. "otherCostSelfTotal": otherCostSelfTotal,
  34515. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34516. "otherSelfTotal": otherSelfTotal,
  34517. "otherInscpTotal": otherInscpTotal,
  34518. "materialCostTotal": materialCostTotal,
  34519. "materialCostSelfTotal": materialCostSelfTotal,
  34520. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34521. "materialSelfTotal": materialSelfTotal,
  34522. "materialInscpTotal": materialInscpTotal,
  34523. "westernMedicineCostTotal": westernMedicineCostTotal,
  34524. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34525. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34526. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34527. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34528. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34529. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34530. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34531. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34532. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34533. "checkCostTotal": checkCostTotal,
  34534. "checkCostSelfTotal": checkCostSelfTotal,
  34535. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34536. "checkSelfTotal": checkSelfTotal,
  34537. "checkInscpTotal": checkInscpTotal,
  34538. "laboratoryCostTotal": laboratoryCostTotal,
  34539. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34540. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34541. "laboratorySelfTotal": laboratorySelfTotal,
  34542. "laboratoryInscpTotal": laboratoryInscpTotal,
  34543. "treatCostTotal": treatCostTotal,
  34544. "treatCostSelfTotal": treatCostSelfTotal,
  34545. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34546. "treatSelfTotal": treatSelfTotal,
  34547. "treatInscpTotal": treatInscpTotal,
  34548. "doctor_info": doctor_info,
  34549. "doctor_code": adminRole_two.DoctorCode,
  34550. "doctor_name": doctor_name,
  34551. "health_card_no": order.PsnNo,
  34552. "department": departments.Name,
  34553. "yiliao_leibie": yiliao_leibie,
  34554. "after_money": order.AccountPrice,
  34555. "patient": patient,
  34556. "org_name": miConfig.OrgName,
  34557. "org_code": miConfig.Code,
  34558. "order_number": order.Number,
  34559. "his_hospital": his_hospital,
  34560. "his": his,
  34561. "dia_config": dia_config,
  34562. "psn_cash_pay": order.PsnCashPay,
  34563. //"check_order_info": cus_slice,
  34564. }
  34565. data3 = append(data3, data2)
  34566. }
  34567. }
  34568. }
  34569. c.ServeSuccessJSON(map[string]interface{}{
  34570. "infos": data3,
  34571. })
  34572. }
  34573. func (c *HisApiController) GetSettleAccounts() {
  34574. //id, _ := c.GetInt64("id")
  34575. //record_time := c.GetString("record_time")
  34576. order_id, _ := c.GetInt64("order_id")
  34577. admin_user_id, _ := c.GetInt64("admin_user_id")
  34578. //timeLayout := "2006-01-02"
  34579. //loc, _ := time.LoadLocation("Local")
  34580. //
  34581. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34582. //if err != nil {
  34583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34584. // return
  34585. //}Hbyb5203
  34586. //recordDateTime := theTime.Unix()
  34587. adminUser := c.GetAdminUserInfo()
  34588. order, _ := service.GetHisOrderByID(order_id)
  34589. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34590. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34591. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34592. orderInfos = append(orderInfos, orderInfos_two...)
  34593. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34594. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34595. var diagnosis_ids []string
  34596. if his.ID > 0 {
  34597. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34598. } else {
  34599. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34600. }
  34601. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34602. var dia_config []*models.HisXtDiagnoseConfig
  34603. var name string
  34604. for _, item := range diagnosis_ids {
  34605. id, _ := strconv.ParseInt(item, 10, 64)
  34606. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34607. dia_config = append(dia_config, &diagnosisConfig)
  34608. if len(name) == 0 {
  34609. name = diagnosisConfig.ClassName
  34610. } else {
  34611. name = name + "," + diagnosisConfig.ClassName
  34612. }
  34613. }
  34614. if patient.UserOrgId == 10215 {
  34615. name = "慢性肾功能不全(血透治疗)"
  34616. }
  34617. var bedCostTotal float64 = 0 //床位总费
  34618. var bedCostSelfTotal float64 = 0 //床位自费
  34619. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34620. var bedSelfTotal float64 = 0 //床位部分项目自费
  34621. var bedInscpTotal float64 = 0 //床位部分项目自费
  34622. var operationCostTotal float64 = 0 //手术费
  34623. var operationCostSelfTotal float64 = 0 //手术费
  34624. var operationCostPartSelfTotal float64 = 0 //手术费
  34625. var operationSelfTotal float64 = 0 //床位部分项目自费
  34626. var operationInscpTotal float64 = 0 //床位部分项目自费
  34627. var otherCostTotal float64 = 0 //其他费用
  34628. var otherCostSelfTotal float64 = 0 //其他费用
  34629. var otherCostPartSelfTotal float64 = 0 //其他费用
  34630. var otherSelfTotal float64 = 0 //床位部分项目自费
  34631. var otherInscpTotal float64 = 0 //床位部分项目自费
  34632. var materialCostTotal float64 = 0 //材料费
  34633. var materialCostSelfTotal float64 = 0 //材料费
  34634. var materialCostPartSelfTotal float64 = 0 //材料费
  34635. var materialSelfTotal float64 = 0 //床位部分项目自费
  34636. var materialInscpTotal float64 = 0 //床位部分项目自费
  34637. var westernMedicineCostTotal float64 = 0 //西药费
  34638. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34639. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34640. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34641. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34642. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34643. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34644. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34645. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34646. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34647. var checkCostTotal float64 = 0 //检查费
  34648. var checkCostSelfTotal float64 = 0 //检查费
  34649. var checkCostPartSelfTotal float64 = 0 //检查费
  34650. var checkSelfTotal float64 = 0 //床位部分项目自费
  34651. var checkInscpTotal float64 = 0 //床位部分项目自费
  34652. var laboratoryCostTotal float64 = 0 //化验费
  34653. var laboratoryCostSelfTotal float64 = 0 //化验费
  34654. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34655. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34656. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34657. var treatCostTotal float64 = 0 //治疗费用
  34658. var treatCostSelfTotal float64 = 0 //治疗费用
  34659. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34660. var treatSelfTotal float64 = 0 //床位部分项目自费
  34661. var treatInscpTotal float64 = 0 //床位部分项目自费
  34662. var zcCostTotal float64 = 0 //治疗费用
  34663. var zcCostSelfTotal float64 = 0 //治疗费用
  34664. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34665. var zcSelfTotal float64 = 0 //床位部分项目自费
  34666. var zcInscpTotal float64 = 0 //床位部分项目自费
  34667. var huliCostTotal float64 = 0 //治疗费用
  34668. var huliCostSelfTotal float64 = 0 //治疗费用
  34669. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34670. var huliSelfTotal float64 = 0 //床位部分项目自费
  34671. var huliInscpTotal float64 = 0 //床位部分项目自费
  34672. decimal.DivisionPrecision = 2
  34673. for _, item := range orderInfos {
  34674. if item.MedChrgitmType == "01" { //床位费
  34675. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34676. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34677. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34678. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34679. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34680. }
  34681. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34682. if item.MedChrgitmType == "03" { //检查费
  34683. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34684. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34685. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34686. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34687. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34688. }
  34689. } else {
  34690. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34691. fmt.Println("------------")
  34692. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34693. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34694. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34695. }
  34696. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34697. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34698. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34699. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34700. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34701. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34702. }
  34703. }
  34704. if item.MedChrgitmType == "04" { //化验费
  34705. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34706. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34707. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34708. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34709. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34710. }
  34711. if item.MedChrgitmType == "05" { //治疗费
  34712. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34713. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34714. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34715. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34716. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34717. }
  34718. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34719. fmt.Println("------------")
  34720. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34721. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34722. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34723. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34724. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34725. }
  34726. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34727. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34728. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34729. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34730. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34731. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34732. }
  34733. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34734. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34735. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34736. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34737. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34738. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34739. }
  34740. if item.MedChrgitmType == "09" { //西药费
  34741. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34742. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34743. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34744. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34745. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34746. }
  34747. if item.MedChrgitmType == "11" { //中成费
  34748. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34749. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34750. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34751. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34752. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34753. }
  34754. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34755. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34756. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34757. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34758. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34759. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34760. }
  34761. if item.MedChrgitmType == "02" { //其他费
  34762. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34763. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34764. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34765. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34766. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34767. }
  34768. if item.MedChrgitmType == "07" { //其他费
  34769. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34770. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34771. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34772. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34773. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34774. }
  34775. }
  34776. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34777. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34778. var user_name string
  34779. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34780. if role.ID == 0 {
  34781. user_name = "管理员"
  34782. } else {
  34783. user_name = role.UserName
  34784. }
  34785. baseParams := models.BaseParams{
  34786. SecretKey: miConfig.SecretKey,
  34787. FixmedinsCode: miConfig.Code,
  34788. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34789. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34790. OrgName: miConfig.OrgName,
  34791. Doctor: user_name,
  34792. RequestUrl: miConfig.Url,
  34793. AccessKey: miConfig.AccessKey,
  34794. }
  34795. businessParams := models.BusinessParams{
  34796. PsnNo: order.PsnNo,
  34797. MdtrtId: order.MdtrtId,
  34798. SetlId: order.SetlId,
  34799. }
  34800. var res ResultEleven
  34801. var resah ResultElevenah
  34802. var resEleven10265 ResultEleven10265
  34803. if config.IsOpen == 1 {
  34804. if miConfig.MdtrtareaAdmvs == "421300" {
  34805. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34806. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34807. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34808. resp, requestErr := http.Get(api)
  34809. if requestErr != nil {
  34810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34811. return
  34812. }
  34813. body, ioErr := ioutil.ReadAll(resp.Body)
  34814. if ioErr != nil {
  34815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34817. return
  34818. }
  34819. var respJSON map[string]interface{}
  34820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34823. return
  34824. }
  34825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34826. result, _ := json.Marshal(respJSON)
  34827. fmt.Println("log")
  34828. fmt.Println(string(result))
  34829. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34830. utils.ErrorLog("解析失败:%v", err)
  34831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34832. return
  34833. }
  34834. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34835. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34836. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34837. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34838. resp, requestErr := http.Get(api)
  34839. if requestErr != nil {
  34840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34841. return
  34842. }
  34843. body, ioErr := ioutil.ReadAll(resp.Body)
  34844. if ioErr != nil {
  34845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34847. return
  34848. }
  34849. var respJSON map[string]interface{}
  34850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34853. return
  34854. }
  34855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34856. result, _ := json.Marshal(respJSON)
  34857. fmt.Println("log")
  34858. fmt.Println(string(result))
  34859. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34860. utils.ErrorLog("解析失败:%v", err)
  34861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34862. return
  34863. }
  34864. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34865. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34866. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34867. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34868. resp, requestErr := http.Get(api)
  34869. if requestErr != nil {
  34870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34871. return
  34872. }
  34873. body, ioErr := ioutil.ReadAll(resp.Body)
  34874. if ioErr != nil {
  34875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34877. return
  34878. }
  34879. var respJSON map[string]interface{}
  34880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34883. return
  34884. }
  34885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34886. result, _ := json.Marshal(respJSON)
  34887. fmt.Println("log")
  34888. fmt.Println(string(result))
  34889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34890. utils.ErrorLog("解析失败:%v", err)
  34891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34892. return
  34893. }
  34894. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34895. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34896. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34897. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34898. resp, requestErr := http.Get(api)
  34899. if requestErr != nil {
  34900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34901. return
  34902. }
  34903. body, ioErr := ioutil.ReadAll(resp.Body)
  34904. if ioErr != nil {
  34905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34907. return
  34908. }
  34909. var respJSON map[string]interface{}
  34910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34913. return
  34914. }
  34915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34916. result, _ := json.Marshal(respJSON)
  34917. fmt.Println("log")
  34918. fmt.Println(string(result))
  34919. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34920. utils.ErrorLog("解析失败:%v", err)
  34921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34922. return
  34923. }
  34924. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34925. var api string
  34926. if miConfig.MdtrtareaAdmvs == "320921" {
  34927. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34928. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34929. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34930. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34931. } else {
  34932. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34933. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34934. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34935. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34936. }
  34937. resp, requestErr := http.Get(api)
  34938. if requestErr != nil {
  34939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34940. return
  34941. }
  34942. body, ioErr := ioutil.ReadAll(resp.Body)
  34943. if ioErr != nil {
  34944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34946. return
  34947. }
  34948. var respJSON map[string]interface{}
  34949. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34952. return
  34953. }
  34954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34955. result, _ := json.Marshal(respJSON)
  34956. fmt.Println("log")
  34957. fmt.Println(string(result))
  34958. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34959. utils.ErrorLog("解析失败:%v", err)
  34960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34961. return
  34962. }
  34963. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34964. res.Output = resEleven10265.Output
  34965. res.ErrMsg = resEleven10265.ErrMsg
  34966. res.Cainfo = resEleven10265.Cainfo
  34967. res.WarnMsg = resEleven10265.WarnMsg
  34968. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34969. res.Infcode = infocode
  34970. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34971. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34972. saveLog(result, requestLog, "5203", "结算单")
  34973. var dat map[string]interface{}
  34974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34975. fmt.Println(dat)
  34976. } else {
  34977. fmt.Println(err)
  34978. }
  34979. userJSONBytes, _ := json.Marshal(dat)
  34980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34981. utils.ErrorLog("解析失败:%v", err)
  34982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34983. return
  34984. }
  34985. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34986. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34987. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34988. saveLog(result, requestLog, "5203", "结算单")
  34989. var dat map[string]interface{}
  34990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34991. fmt.Println(dat)
  34992. } else {
  34993. fmt.Println(err)
  34994. }
  34995. userJSONBytes, _ := json.Marshal(dat)
  34996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34997. utils.ErrorLog("解析失败:%v", err)
  34998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34999. return
  35000. }
  35001. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35002. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35003. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35004. saveLog(result, requestLog, "5203", "结算单")
  35005. var dat map[string]interface{}
  35006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35007. fmt.Println(dat)
  35008. } else {
  35009. fmt.Println(err)
  35010. }
  35011. userJSONBytes, _ := json.Marshal(dat)
  35012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35013. utils.ErrorLog("解析失败:%v", err)
  35014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35015. return
  35016. }
  35017. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35018. var api string
  35019. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35020. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35022. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35023. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35024. resp, requestErr := http.Get(api)
  35025. if requestErr != nil {
  35026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35027. return
  35028. }
  35029. body, ioErr := ioutil.ReadAll(resp.Body)
  35030. if ioErr != nil {
  35031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35033. return
  35034. }
  35035. var respJSON map[string]interface{}
  35036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35039. return
  35040. }
  35041. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35042. if status == "0" {
  35043. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35044. c.ServeSuccessJSON(map[string]interface{}{
  35045. "failed_code": -10,
  35046. "msg": err_msg,
  35047. })
  35048. return
  35049. }
  35050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35051. result, _ := json.Marshal(respJSON)
  35052. fmt.Println("log")
  35053. fmt.Println(string(result))
  35054. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35055. utils.ErrorLog("解析失败:%v", err)
  35056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35057. return
  35058. }
  35059. res.InfRefmsgid = resah.InfRefmsgid
  35060. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35061. // 创建对应的Time类型
  35062. t := time.UnixMilli(timestamp)
  35063. // 格式化成指定的日期字符串
  35064. str := t.Format("2006-01-02 15:04:05")
  35065. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35066. // 创建对应的Time类型
  35067. t3 := time.UnixMilli(timestamp2)
  35068. // 格式化成指定的日期字符串
  35069. str2 := t3.Format("2006-01-02 15:04:05")
  35070. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35071. // 创建对应的Time类型
  35072. t4 := time.UnixMilli(timestamp3)
  35073. // 格式化成指定的日期字符串
  35074. str3 := t4.Format("2006-01-02 15:04:05")
  35075. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35076. // 创建对应的Time类型
  35077. t5 := time.UnixMilli(timestamp4)
  35078. // 格式化成指定的日期字符串
  35079. str5 := t5.Format("2006-01-02 15:04:05")
  35080. res.Output.Setlinfo.Brdy = str2
  35081. res.Output.Setlinfo.SetlTime = str
  35082. res.Output.Setlinfo.Begndate = str3
  35083. res.Output.Setlinfo.Enddate = str5
  35084. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35085. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35086. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35087. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35088. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35089. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35090. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35091. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35092. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35093. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35094. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35095. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35096. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35097. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35098. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35099. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35100. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35101. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35102. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35103. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35104. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35105. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35106. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35107. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35108. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35109. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35110. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35111. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35112. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35113. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35114. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35115. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35116. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35117. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35118. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35119. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35120. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35121. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35122. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35123. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35124. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35125. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35126. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35127. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35128. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35129. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35130. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35131. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35132. //res.Output.Setldetail = resah.Output.Setldetail
  35133. res.ErrMsg = resah.ErrMsg
  35134. res.Cainfo = resah.Cainfo
  35135. res.WarnMsg = resah.WarnMsg
  35136. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35137. var api string
  35138. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35139. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35140. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35141. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35142. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35143. resp, requestErr := http.Get(api)
  35144. if requestErr != nil {
  35145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35146. return
  35147. }
  35148. body, ioErr := ioutil.ReadAll(resp.Body)
  35149. if ioErr != nil {
  35150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35152. return
  35153. }
  35154. var respJSON map[string]interface{}
  35155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35158. return
  35159. }
  35160. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35161. if status == "0" {
  35162. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35163. c.ServeSuccessJSON(map[string]interface{}{
  35164. "failed_code": -10,
  35165. "msg": err_msg,
  35166. })
  35167. return
  35168. }
  35169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35170. result, _ := json.Marshal(respJSON)
  35171. fmt.Println("log")
  35172. fmt.Println(string(result))
  35173. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35174. utils.ErrorLog("解析失败:%v", err)
  35175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35176. return
  35177. }
  35178. res.InfRefmsgid = resah.InfRefmsgid
  35179. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35180. // 创建对应的Time类型
  35181. t := time.UnixMilli(timestamp)
  35182. // 格式化成指定的日期字符串
  35183. str := t.Format("2006-01-02 15:04:05")
  35184. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35185. // 创建对应的Time类型
  35186. t3 := time.UnixMilli(timestamp2)
  35187. // 格式化成指定的日期字符串
  35188. str2 := t3.Format("2006-01-02 15:04:05")
  35189. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35190. // 创建对应的Time类型
  35191. t4 := time.UnixMilli(timestamp3)
  35192. // 格式化成指定的日期字符串
  35193. str3 := t4.Format("2006-01-02 15:04:05")
  35194. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35195. // 创建对应的Time类型
  35196. t5 := time.UnixMilli(timestamp4)
  35197. // 格式化成指定的日期字符串
  35198. str5 := t5.Format("2006-01-02 15:04:05")
  35199. res.Output.Setlinfo.Brdy = str2
  35200. res.Output.Setlinfo.SetlTime = str
  35201. res.Output.Setlinfo.Begndate = str3
  35202. res.Output.Setlinfo.Enddate = str5
  35203. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35204. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35205. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35206. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35207. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35208. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35209. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35210. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35211. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35212. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35213. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35214. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35215. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35216. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35217. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35218. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35219. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35220. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35221. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35222. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35223. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35224. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35225. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35226. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35227. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35228. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35229. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35230. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35231. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35232. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35233. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35234. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35235. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35236. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35237. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35238. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35239. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35240. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35241. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35242. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35243. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35244. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35245. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35246. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35247. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35248. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35249. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35250. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35251. //res.Output.Setldetail = resah.Output.Setldetail
  35252. res.ErrMsg = resah.ErrMsg
  35253. res.Cainfo = resah.Cainfo
  35254. res.WarnMsg = resah.WarnMsg
  35255. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35256. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35257. saveLog(result, requestLog, "5203", "结算单")
  35258. var dat map[string]interface{}
  35259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35260. fmt.Println(dat)
  35261. } else {
  35262. fmt.Println(err)
  35263. }
  35264. userJSONBytes, _ := json.Marshal(dat)
  35265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35266. utils.ErrorLog("解析失败:%v", err)
  35267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35268. return
  35269. }
  35270. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35271. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35272. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35273. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35274. resp, requestErr := http.Get(api)
  35275. if requestErr != nil {
  35276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35277. return
  35278. }
  35279. body, ioErr := ioutil.ReadAll(resp.Body)
  35280. if ioErr != nil {
  35281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35283. return
  35284. }
  35285. var respJSON map[string]interface{}
  35286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35289. return
  35290. }
  35291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35292. result, _ := json.Marshal(respJSON)
  35293. fmt.Println("log")
  35294. fmt.Println(string(result))
  35295. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35296. utils.ErrorLog("解析失败:%v", err)
  35297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35298. return
  35299. }
  35300. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35301. res.Output = resEleven10265.Output
  35302. res.ErrMsg = resEleven10265.ErrMsg
  35303. res.Cainfo = resEleven10265.Cainfo
  35304. res.WarnMsg = resEleven10265.WarnMsg
  35305. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35306. res.Infcode = infocode
  35307. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35308. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35309. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35310. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35311. resp, requestErr := http.Get(api)
  35312. if requestErr != nil {
  35313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35314. return
  35315. }
  35316. body, ioErr := ioutil.ReadAll(resp.Body)
  35317. if ioErr != nil {
  35318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35320. return
  35321. }
  35322. var respJSON map[string]interface{}
  35323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35326. return
  35327. }
  35328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35329. result, _ := json.Marshal(respJSON)
  35330. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35331. utils.ErrorLog("解析失败:%v", err)
  35332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35333. return
  35334. }
  35335. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35336. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35337. //return
  35338. } else {
  35339. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35340. if len(his.InsuplcAdmdvs) == 0 {
  35341. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35342. } else {
  35343. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35344. }
  35345. result := service.Gdyb5203(baseParams, businessParams)
  35346. //service.Gdyb5204(baseParams, businessParams)
  35347. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35348. var dat map[string]interface{}
  35349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35350. fmt.Println(dat)
  35351. } else {
  35352. fmt.Println(err)
  35353. }
  35354. userJSONBytes, _ := json.Marshal(dat)
  35355. if miConfig.Code == "H15049901371" {
  35356. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35357. utils.ErrorLog("解析失败:%v", err)
  35358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35359. return
  35360. }
  35361. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35362. res.Output = resEleven10265.Output
  35363. res.ErrMsg = resEleven10265.ErrMsg
  35364. res.Cainfo = resEleven10265.Cainfo
  35365. res.WarnMsg = resEleven10265.WarnMsg
  35366. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35367. res.Infcode = infocode
  35368. } else {
  35369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35370. utils.ErrorLog("解析失败:%v", err)
  35371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35372. return
  35373. }
  35374. }
  35375. }
  35376. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35377. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35378. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35379. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35380. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35381. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35382. var doctor_name string
  35383. if roles.ID == 0 {
  35384. doctor_name = "管理员"
  35385. } else {
  35386. doctor_name = roles.UserName
  35387. }
  35388. yiliao_leibie := ""
  35389. switch order.MedType {
  35390. case "11":
  35391. yiliao_leibie = "普通门诊"
  35392. break
  35393. case "12":
  35394. yiliao_leibie = "门诊挂号"
  35395. break
  35396. case "13":
  35397. yiliao_leibie = "急诊"
  35398. break
  35399. case "14":
  35400. yiliao_leibie = "门诊特殊病"
  35401. break
  35402. case "15":
  35403. yiliao_leibie = "门诊统筹"
  35404. break
  35405. case "16":
  35406. yiliao_leibie = "门诊慢性病"
  35407. break
  35408. case "21":
  35409. yiliao_leibie = "普通住院"
  35410. break
  35411. }
  35412. //var rf []CustomFundPay
  35413. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35414. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35415. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35416. if res.Infcode == 0 {
  35417. 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{
  35418. c.ServeSuccessJSON(map[string]interface{}{
  35419. "diagnosis": name,
  35420. "order_infos": orderInfos,
  35421. "number": order.MdtrtId,
  35422. "date": order.SettleAccountsDate,
  35423. "charge_admin": charge_admin,
  35424. "printor_admin": printor_admin,
  35425. "info": res.Output.Setlinfo,
  35426. "order": order,
  35427. "bedCostTotal": bedCostTotal,
  35428. "bedCostSelfTotal": bedCostSelfTotal,
  35429. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35430. "bedSelfTotal": bedSelfTotal,
  35431. "bedInscpTotal": bedInscpTotal,
  35432. "operationCostTotal": operationCostTotal,
  35433. "operationCostSelfTotal": operationCostSelfTotal,
  35434. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35435. "operationSelfTotal": operationSelfTotal,
  35436. "operationInscpTotal": operationInscpTotal,
  35437. "otherCostTotal": otherCostTotal,
  35438. "otherCostSelfTotal": otherCostSelfTotal,
  35439. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35440. "otherSelfTotal": otherSelfTotal,
  35441. "otherInscpTotal": otherInscpTotal,
  35442. "materialCostTotal": materialCostTotal,
  35443. "materialCostSelfTotal": materialCostSelfTotal,
  35444. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35445. "materialSelfTotal": materialSelfTotal,
  35446. "materialInscpTotal": materialInscpTotal,
  35447. "westernMedicineCostTotal": westernMedicineCostTotal,
  35448. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35449. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35450. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35451. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35452. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35453. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35454. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35455. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35456. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35457. "checkCostTotal": checkCostTotal,
  35458. "checkCostSelfTotal": checkCostSelfTotal,
  35459. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35460. "checkSelfTotal": checkSelfTotal,
  35461. "checkInscpTotal": checkInscpTotal,
  35462. "laboratoryCostTotal": laboratoryCostTotal,
  35463. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35464. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35465. "laboratorySelfTotal": laboratorySelfTotal,
  35466. "laboratoryInscpTotal": laboratoryInscpTotal,
  35467. "treatCostTotal": treatCostTotal,
  35468. "treatCostSelfTotal": treatCostSelfTotal,
  35469. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35470. "treatSelfTotal": treatSelfTotal,
  35471. "treatInscpTotal": treatInscpTotal,
  35472. "doctor_info": doctor_info,
  35473. "doctor_code": adminRole_two.DoctorCode,
  35474. "doctor_name": doctor_name,
  35475. "health_card_no": order.PsnNo,
  35476. "department": departments.Name,
  35477. "yiliao_leibie": yiliao_leibie,
  35478. "after_money": order.AccountPrice,
  35479. "patient": patient,
  35480. "org_name": miConfig.OrgName,
  35481. "org_code": miConfig.Code,
  35482. "order_number": order.Number,
  35483. "his_hospital": his_hospital,
  35484. "his": his,
  35485. "dia_config": dia_config,
  35486. "psn_cash_pay": order.PsnCashPay,
  35487. "zcCostTotal": zcCostTotal,
  35488. "zcCostSelfTotal": zcCostSelfTotal,
  35489. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35490. "zcSelfTotal": zcSelfTotal,
  35491. "zcInscpTotal": zcInscpTotal,
  35492. "huliCostTotal": huliCostTotal,
  35493. "huliCostSelfTotal": huliCostSelfTotal,
  35494. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35495. "huliSelfTotal": huliSelfTotal,
  35496. "huliInscpTotal": huliInscpTotal,
  35497. //"funds": rf,
  35498. //"check_order_info": cus_slice,
  35499. })
  35500. } else {
  35501. c.ServeSuccessJSON(map[string]interface{}{
  35502. "diagnosis": name,
  35503. "order_infos": orderInfos,
  35504. "number": order.MdtrtId,
  35505. "date": order.SettleAccountsDate,
  35506. "charge_admin": charge_admin,
  35507. "printor_admin": printor_admin,
  35508. "info": order,
  35509. "order": order,
  35510. "bedCostTotal": bedCostTotal,
  35511. "bedCostSelfTotal": bedCostSelfTotal,
  35512. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35513. "bedSelfTotal": bedSelfTotal,
  35514. "bedInscpTotal": bedInscpTotal,
  35515. "operationCostTotal": operationCostTotal,
  35516. "operationCostSelfTotal": operationCostSelfTotal,
  35517. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35518. "operationSelfTotal": operationSelfTotal,
  35519. "operationInscpTotal": operationInscpTotal,
  35520. "otherCostTotal": otherCostTotal,
  35521. "otherCostSelfTotal": otherCostSelfTotal,
  35522. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35523. "otherSelfTotal": otherSelfTotal,
  35524. "otherInscpTotal": otherInscpTotal,
  35525. "materialCostTotal": materialCostTotal,
  35526. "materialCostSelfTotal": materialCostSelfTotal,
  35527. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35528. "materialSelfTotal": materialSelfTotal,
  35529. "materialInscpTotal": materialInscpTotal,
  35530. "westernMedicineCostTotal": westernMedicineCostTotal,
  35531. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35532. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35533. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35534. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35535. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35536. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35537. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35538. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35539. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35540. "checkCostTotal": checkCostTotal,
  35541. "checkCostSelfTotal": checkCostSelfTotal,
  35542. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35543. "checkSelfTotal": checkSelfTotal,
  35544. "checkInscpTotal": checkInscpTotal,
  35545. "laboratoryCostTotal": laboratoryCostTotal,
  35546. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35547. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35548. "laboratorySelfTotal": laboratorySelfTotal,
  35549. "laboratoryInscpTotal": laboratoryInscpTotal,
  35550. "treatCostTotal": treatCostTotal,
  35551. "treatCostSelfTotal": treatCostSelfTotal,
  35552. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35553. "treatSelfTotal": treatSelfTotal,
  35554. "treatInscpTotal": treatInscpTotal,
  35555. "doctor_info": doctor_info,
  35556. "doctor_code": adminRole_two.DoctorCode,
  35557. "doctor_name": doctor_name,
  35558. "health_card_no": order.PsnNo,
  35559. "department": departments.Name,
  35560. "yiliao_leibie": yiliao_leibie,
  35561. "after_money": order.AccountPrice,
  35562. "patient": patient,
  35563. "org_name": miConfig.OrgName,
  35564. "org_code": miConfig.Code,
  35565. "order_number": order.Number,
  35566. "his_hospital": his_hospital,
  35567. "his": his,
  35568. "dia_config": dia_config,
  35569. "psn_cash_pay": order.PsnCashPay,
  35570. "zcCostTotal": zcCostTotal,
  35571. "zcCostSelfTotal": zcCostSelfTotal,
  35572. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35573. "zcSelfTotal": zcSelfTotal,
  35574. "zcInscpTotal": zcInscpTotal,
  35575. "huliCostTotal": huliCostTotal,
  35576. "huliCostSelfTotal": huliCostSelfTotal,
  35577. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35578. "huliSelfTotal": huliSelfTotal,
  35579. "huliInscpTotal": huliInscpTotal,
  35580. //"funds": rf,
  35581. //"check_order_info": cus_slice,
  35582. })
  35583. }
  35584. }
  35585. }
  35586. }
  35587. //func (c *HisApiController) CheckTreatment() {
  35588. // patient_id, _ := c.GetInt64("patient_id")
  35589. // id_card_no := c.GetString("id_card_no")
  35590. // insutype := c.GetString("insutype")
  35591. // med_type := c.GetString("med_type")
  35592. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35593. //
  35594. // adminUser := c.GetAdminUserInfo()
  35595. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35596. //
  35597. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35598. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35599. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35600. //
  35601. // if miConfig.MdtrtareaAdmvs == "421300" {
  35602. // var res ResultTwo
  35603. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35604. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35605. // "&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)
  35606. // resp, requestErr := http.Get(api)
  35607. // if requestErr != nil {
  35608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35609. // return
  35610. // }
  35611. //
  35612. // body, ioErr := ioutil.ReadAll(resp.Body)
  35613. // if ioErr != nil {
  35614. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35616. // return
  35617. // }
  35618. // var respJSON map[string]interface{}
  35619. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35620. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35622. // return
  35623. // }
  35624. //
  35625. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35626. // result, _ := json.Marshal(respJSON)
  35627. //
  35628. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35629. // utils.ErrorLog("解析失败:%v", err)
  35630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35631. // return
  35632. // }
  35633. //
  35634. // if res.Infcode == 0 {
  35635. //
  35636. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35637. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35638. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35639. // resp, requestErr := http.Get(api)
  35640. // if requestErr != nil {
  35641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35642. // return
  35643. // }
  35644. //
  35645. // body, ioErr := ioutil.ReadAll(resp.Body)
  35646. // if ioErr != nil {
  35647. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35649. // return
  35650. // }
  35651. // var respJSON map[string]interface{}
  35652. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35653. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35655. // return
  35656. // }
  35657. // var res Result2001
  35658. //
  35659. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35660. // result2, _ := json.Marshal(respJSON)
  35661. //
  35662. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35663. // utils.ErrorLog("解析失败:%v", err)
  35664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35665. // return
  35666. // }
  35667. //
  35668. // if res.Infcode == 0 {
  35669. // c.ServeSuccessJSON(map[string]interface{}{
  35670. // "msg": res.Output.Trtinfo,
  35671. // })
  35672. // }
  35673. //
  35674. // } else {
  35675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35676. // return
  35677. // }
  35678. //
  35679. // } else {
  35680. //
  35681. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35682. // var dat map[string]interface{}
  35683. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35684. // fmt.Println(dat)
  35685. // } else {
  35686. // fmt.Println(err)
  35687. // }
  35688. // userJSONBytes, _ := json.Marshal(dat)
  35689. // var res ResultTwo
  35690. // var res10265 ResultTwo10265
  35691. // if miConfig.Code == "H15049901371" {
  35692. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35693. // utils.ErrorLog("解析失败:%v", err)
  35694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35695. // return
  35696. // }
  35697. // res.ErrMsg = res10265.ErrMsg
  35698. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35699. // res.Infcode = infocode
  35700. // res.Output = res10265.Output
  35701. // res.InfRefmsgid = res10265.InfRefmsgid
  35702. // } else {
  35703. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35704. // utils.ErrorLog("解析失败:%v", err)
  35705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35706. // return
  35707. // }
  35708. // }
  35709. //
  35710. // var user_name string
  35711. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35712. // if role.ID == 0 {
  35713. // user_name = "xxx"
  35714. // } else {
  35715. // user_name = role.UserName
  35716. // }
  35717. //
  35718. // baseParams := models.BaseParams{
  35719. // SecretKey: miConfig.SecretKey,
  35720. // FixmedinsCode: miConfig.Code,
  35721. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35722. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35723. // OrgName: miConfig.OrgName,
  35724. // Doctor: user_name,
  35725. // }
  35726. //
  35727. // if config.IsOpen == 1 {
  35728. // if miConfig.Code == "H15049901371" {
  35729. // if med_type == "14" {
  35730. // if insutype == "390" {
  35731. // med_type = "9933"
  35732. // } else if insutype == "310" {
  35733. // med_type = "990502"
  35734. // }
  35735. // } else if med_type == "11" {
  35736. // med_type = "11"
  35737. // }
  35738. // }
  35739. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35740. // var dat map[string]interface{}
  35741. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35742. // fmt.Println(dat)
  35743. // } else {
  35744. // fmt.Println(err)
  35745. // }
  35746. // var res Result2001
  35747. // var res10265 Result2001Org10265
  35748. // if miConfig.Code == "H15049901371" {
  35749. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35750. // utils.ErrorLog("解析失败:%v", err)
  35751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35752. // return
  35753. // }
  35754. // res.ErrMsg = res10265.ErrMsg
  35755. // res.Output = res10265.Output
  35756. // res.InfRefmsgid = res10265.InfRefmsgid
  35757. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35758. // res.Infcode = infocode
  35759. // } else {
  35760. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35761. // utils.ErrorLog("解析失败:%v", err)
  35762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35763. // return
  35764. // }
  35765. // }
  35766. // if res.Infcode == 0 {
  35767. // c.ServeSuccessJSON(map[string]interface{}{
  35768. // "msg": res.Output.Trtinfo,
  35769. // })
  35770. // }
  35771. // }
  35772. // }
  35773. //}
  35774. //func (c *HisApiController) PutRecord() {
  35775. // id, _ := c.GetInt64("id")
  35776. // record_time := c.GetString("record_time")
  35777. // timeLayout := "2006-01-02"
  35778. // loc, _ := time.LoadLocation("Local")
  35779. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35780. // if err != nil {
  35781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35782. // return
  35783. // }
  35784. // recordDateTime := theTime.Unix()
  35785. //
  35786. // adminInfo := c.GetAdminUserInfo()
  35787. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35788. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35789. //
  35790. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35791. //
  35792. // fmt.Println(miConfig.SecretKey)
  35793. //
  35794. // if patient == nil {
  35795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35796. // return
  35797. // }
  35798. // if len(patient.IdCardNo) == 0 {
  35799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35800. // return
  35801. // }
  35802. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35803. // if config.IsOpen == 1 {
  35804. // 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
  35805. // resp, requestErr := http.Get(api)
  35806. // if requestErr != nil {
  35807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35808. // return
  35809. // }
  35810. // defer resp.Body.Close()
  35811. // body, ioErr := ioutil.ReadAll(resp.Body)
  35812. // if ioErr != nil {
  35813. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35815. // return
  35816. // }
  35817. // var respJSON map[string]interface{}
  35818. //
  35819. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35820. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35822. // return
  35823. // }
  35824. //
  35825. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35826. // userJSONBytes, _ := json.Marshal(userJSON)
  35827. // var res ResultTwo
  35828. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35829. // utils.ErrorLog("解析失败:%v", err)
  35830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35831. // return
  35832. // }
  35833. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35834. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35835. // infoStr := string(Iinfos)
  35836. // idetinfoStr := string(Idetinfos)
  35837. //
  35838. // if res.Infcode == 0 {
  35839. // his := models.VMHisPatient{
  35840. // Status: 1,
  35841. // Ctime: time.Now().Unix(),
  35842. // Mtime: time.Now().Unix(),
  35843. // PsnNo: res.Output.Baseinfo.PsnNo,
  35844. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35845. // Certno: res.Output.Baseinfo.Certno,
  35846. // PsnName: res.Output.Baseinfo.PsnName,
  35847. // Gend: res.Output.Baseinfo.Gend,
  35848. // Naty: res.Output.Baseinfo.Naty,
  35849. // Brdy: res.Output.Baseinfo.Brdy,
  35850. // Age: res.Output.Baseinfo.Age,
  35851. // Iinfo: infoStr,
  35852. // Idetinfo: idetinfoStr,
  35853. // PatientId: patient.ID,
  35854. // RecordDate: theTime.Unix(),
  35855. // UserOrgId: adminInfo.CurrentOrgId,
  35856. // AdminUserId: adminInfo.AdminUser.Id,
  35857. // IsReturn: 1,
  35858. // }
  35859. //
  35860. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35861. // //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")
  35862. // //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")
  35863. //
  35864. // //var dat map[string]interface{}
  35865. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35866. // // fmt.Println(dat)
  35867. // //} else {
  35868. // // fmt.Println(err)
  35869. // //}
  35870. //
  35871. // var dat2 map[string]interface{}
  35872. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35873. // fmt.Println(dat2)
  35874. // } else {
  35875. // fmt.Println(err)
  35876. // }
  35877. //
  35878. // } else {
  35879. // adminUser := c.GetAdminUserInfo()
  35880. // errlog := &models.HisOrderError{
  35881. // UserOrgId: adminUser.CurrentOrgId,
  35882. // Ctime: time.Now().Unix(),
  35883. // Mtime: time.Now().Unix(),
  35884. // ErrMsg: res.ErrMsg,
  35885. // Status: 1,
  35886. // PatientId: id,
  35887. // RecordTime: recordDateTime,
  35888. // Stage: 1,
  35889. // }
  35890. // service.CreateErrMsgLog(errlog)
  35891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35892. // return
  35893. // }
  35894. // }
  35895. //
  35896. //}
  35897. //func (c *HisApiController) GetUploadDiag() {
  35898. // id, _ := c.GetInt64("id")
  35899. // record_time := c.GetString("record_time")
  35900. //
  35901. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35902. // sick_type, _ := c.GetInt64("sick_type")
  35903. // reg_type, _ := c.GetInt64("reg_type")
  35904. //
  35905. // timeLayout := "2006-01-02"
  35906. // loc, _ := time.LoadLocation("Local")
  35907. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35908. // if err != nil {
  35909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35910. // return
  35911. // }
  35912. //
  35913. // var patientPrescription models.HisPrescriptionInfo
  35914. // recordDateTime := theTime.Unix()
  35915. // adminInfo := c.GetAdminUserInfo()
  35916. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35917. //
  35918. // if patientPrescription.ID == 0 {
  35919. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35920. // }
  35921. //
  35922. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35923. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35924. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35925. // sickConfig, _ := service.FindSickById(sick_type)
  35926. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35927. //
  35928. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35929. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35930. // "&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 +
  35931. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35932. // resp2, requestErr2 := http.Get(api2)
  35933. // if requestErr2 != nil {
  35934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35935. // return
  35936. // }
  35937. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35938. // if ioErr2 != nil {
  35939. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35941. // return
  35942. // }
  35943. // var respJSON2 map[string]interface{}
  35944. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35945. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35947. // return
  35948. // }
  35949. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35950. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35951. //
  35952. // var res2 ResultSix
  35953. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35954. // utils.ErrorLog("解析失败:%v", err)
  35955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35956. // return
  35957. // }
  35958. // if res2.Infcode != 0 {
  35959. // adminUser := c.GetAdminUserInfo()
  35960. // errlog := &models.HisOrderError{
  35961. // UserOrgId: adminUser.CurrentOrgId,
  35962. // Ctime: time.Now().Unix(),
  35963. // Mtime: time.Now().Unix(),
  35964. // ErrMsg: res2.ErrMsg,
  35965. // Status: 1,
  35966. // PatientId: id,
  35967. // RecordTime: recordDateTime,
  35968. // Stage: 3,
  35969. // }
  35970. // service.CreateErrMsgLog(errlog)
  35971. //
  35972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35973. // return
  35974. // }
  35975. //
  35976. // c.ServeSuccessJSON(map[string]interface{}{
  35977. // "msg": "上传成功",
  35978. // })
  35979. //
  35980. //}
  35981. type QueryResult struct {
  35982. ID int64
  35983. Name string
  35984. Code string
  35985. List_type_code string
  35986. }
  35987. func (c *HisApiController) GetCheckCode() {
  35988. ids_str := c.GetString("ids")
  35989. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35990. ids_arr := strings.Split(ids_str, ",")
  35991. var queryResult []QueryResult
  35992. ids := make([]int64, 0)
  35993. for _, item := range ids_arr {
  35994. id, _ := strconv.ParseInt(item, 10, 64)
  35995. ids = append(ids, id)
  35996. }
  35997. if record_type == 1 {
  35998. drugs, _ := service.GetBatchDrugList(ids)
  35999. for _, item := range drugs {
  36000. result := QueryResult{
  36001. ID: item.ID,
  36002. Name: item.DrugName,
  36003. Code: item.MedicalInsuranceNumber,
  36004. List_type_code: "101",
  36005. }
  36006. queryResult = append(queryResult, result)
  36007. }
  36008. } else if record_type == 2 {
  36009. goods, _ := service.GetBatchGoodInformationList(ids)
  36010. fmt.Println(goods)
  36011. for _, item := range goods {
  36012. result := QueryResult{
  36013. ID: item.ID,
  36014. Name: item.GoodName,
  36015. Code: item.SocialSecurityDirectoryCode,
  36016. List_type_code: "301",
  36017. }
  36018. queryResult = append(queryResult, result)
  36019. }
  36020. } else if record_type == 3 {
  36021. projects, _ := service.GetBathchMyPorjecgList(ids)
  36022. for _, item := range projects {
  36023. result := QueryResult{
  36024. ID: item.ID,
  36025. Name: item.ProjectName,
  36026. Code: item.MedicalCode,
  36027. List_type_code: "201",
  36028. }
  36029. queryResult = append(queryResult, result)
  36030. }
  36031. }
  36032. admin_user_id, _ := c.GetInt64("admin_user_id")
  36033. adminUser := c.GetAdminUserInfo()
  36034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36035. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36036. var user_name string
  36037. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36038. if role.ID == 0 {
  36039. user_name = "管理员"
  36040. } else {
  36041. user_name = role.UserName
  36042. }
  36043. baseParams := models.BaseParams{
  36044. SecretKey: miConfig.SecretKey,
  36045. FixmedinsCode: miConfig.Code,
  36046. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36047. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36048. OrgName: miConfig.OrgName,
  36049. Doctor: user_name,
  36050. }
  36051. var result string
  36052. if miConfig.MdtrtareaAdmvs == "430800" {
  36053. for _, item := range queryResult {
  36054. if record_type == 1 {
  36055. 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)
  36056. } else if record_type == 2 {
  36057. fmt.Println(item.Code)
  36058. 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)
  36059. } else if record_type == 3 {
  36060. 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)
  36061. }
  36062. var dat map[string]interface{}
  36063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36064. fmt.Println(dat)
  36065. } else {
  36066. fmt.Println(err)
  36067. }
  36068. userJSONBytes, _ := json.Marshal(dat)
  36069. var res ResultSix
  36070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36071. utils.ErrorLog("解析失败:%v", err)
  36072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36073. return
  36074. }
  36075. if res.Infcode == 0 {
  36076. if record_type == 1 {
  36077. service.UpdateBaseDrugById(item.ID)
  36078. } else if record_type == 2 {
  36079. service.UpdateGoodInformaitonByDetail(item.ID)
  36080. } else if record_type == 3 {
  36081. service.UpdateProjectById(item.ID)
  36082. }
  36083. c.ServeSuccessJSON(map[string]interface{}{
  36084. "failed_code": 0,
  36085. "msg": "目录对照成功",
  36086. })
  36087. } else {
  36088. c.ServeSuccessJSON(map[string]interface{}{
  36089. "failed_code": -10,
  36090. "msg": res.ErrMsg,
  36091. })
  36092. }
  36093. }
  36094. } else {
  36095. for _, item := range queryResult {
  36096. var result string
  36097. if record_type == 1 {
  36098. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36099. } else if record_type == 2 {
  36100. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36101. } else if record_type == 3 {
  36102. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36103. }
  36104. var dat map[string]interface{}
  36105. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36106. fmt.Println(dat)
  36107. } else {
  36108. fmt.Println(err)
  36109. }
  36110. userJSONBytes, _ := json.Marshal(dat)
  36111. var res ResultSix
  36112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36113. utils.ErrorLog("解析失败:%v", err)
  36114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36115. return
  36116. }
  36117. if res.Infcode == 0 {
  36118. if record_type == 1 {
  36119. service.UpdateBaseDrugById(item.ID)
  36120. } else if record_type == 2 {
  36121. service.UpdateGoodInformaitonByDetail(item.ID)
  36122. } else if record_type == 3 {
  36123. service.UpdateProjectById(item.ID)
  36124. }
  36125. c.ServeSuccessJSON(map[string]interface{}{
  36126. "failed_code": 0,
  36127. "msg": "目录对照成功",
  36128. })
  36129. } else {
  36130. c.ServeSuccessJSON(map[string]interface{}{
  36131. "failed_code": -10,
  36132. "msg": res.ErrMsg,
  36133. })
  36134. }
  36135. }
  36136. }
  36137. }
  36138. func (c *HisApiController) UnCheckCode() {
  36139. ids_str := c.GetString("ids")
  36140. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36141. admin_user_id, _ := c.GetInt64("admin_user_id")
  36142. ids_arr := strings.Split(ids_str, ",")
  36143. var queryResult []QueryResult
  36144. ids := make([]int64, 0)
  36145. for _, item := range ids_arr {
  36146. id, _ := strconv.ParseInt(item, 10, 64)
  36147. ids = append(ids, id)
  36148. }
  36149. if record_type == 1 {
  36150. drugs, _ := service.GetBatchDrugList(ids)
  36151. for _, item := range drugs {
  36152. result := QueryResult{
  36153. ID: item.ID,
  36154. Name: item.DrugName,
  36155. Code: item.MedicalInsuranceNumber,
  36156. List_type_code: "101",
  36157. }
  36158. queryResult = append(queryResult, result)
  36159. }
  36160. } else if record_type == 2 {
  36161. goods, _ := service.GetBatchGoodInformationList(ids)
  36162. for _, item := range goods {
  36163. result := QueryResult{
  36164. ID: item.ID,
  36165. Name: item.GoodName,
  36166. Code: item.SocialSecurityDirectoryCode,
  36167. List_type_code: "301",
  36168. }
  36169. queryResult = append(queryResult, result)
  36170. }
  36171. } else if record_type == 3 {
  36172. projects, _ := service.GetBathchMyPorjecgList(ids)
  36173. for _, item := range projects {
  36174. result := QueryResult{
  36175. ID: item.ID,
  36176. Name: item.ProjectName,
  36177. Code: item.MedicalCode,
  36178. List_type_code: "201",
  36179. }
  36180. queryResult = append(queryResult, result)
  36181. }
  36182. }
  36183. adminUser := c.GetAdminUserInfo()
  36184. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36185. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36186. var user_name string
  36187. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36188. if role.ID == 0 {
  36189. user_name = "xxx"
  36190. } else {
  36191. user_name = role.UserName
  36192. }
  36193. baseParams := &models.BaseParams{
  36194. SecretKey: miConfig.SecretKey,
  36195. FixmedinsCode: miConfig.Code,
  36196. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36197. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36198. OrgName: miConfig.OrgName,
  36199. Doctor: user_name,
  36200. }
  36201. if config.IsOpen == 1 {
  36202. if miConfig.MdtrtareaAdmvs == "430800" {
  36203. for _, item := range queryResult {
  36204. var result string
  36205. if record_type == 1 {
  36206. 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)
  36207. } else if record_type == 2 {
  36208. fmt.Println(item.Code)
  36209. 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)
  36210. } else if record_type == 3 {
  36211. 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)
  36212. }
  36213. var dat map[string]interface{}
  36214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36215. fmt.Println(dat)
  36216. } else {
  36217. fmt.Println(err)
  36218. }
  36219. userJSONBytes, _ := json.Marshal(dat)
  36220. var res ResultSix
  36221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36222. utils.ErrorLog("解析失败:%v", err)
  36223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36224. return
  36225. }
  36226. if res.Infcode == 0 {
  36227. if record_type == 1 {
  36228. service.UpdateBaseDrugById(item.ID)
  36229. } else if record_type == 2 {
  36230. service.UpdateGoodInformaitonByDetail(item.ID)
  36231. } else if record_type == 3 {
  36232. service.UpdateProjectById(item.ID)
  36233. }
  36234. c.ServeSuccessJSON(map[string]interface{}{
  36235. "failed_code": 0,
  36236. "msg": "目录对照成功",
  36237. })
  36238. } else {
  36239. c.ServeSuccessJSON(map[string]interface{}{
  36240. "failed_code": -10,
  36241. "msg": res.ErrMsg,
  36242. })
  36243. }
  36244. }
  36245. } else {
  36246. for _, item := range queryResult {
  36247. var result string
  36248. if record_type == 1 {
  36249. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36250. } else if record_type == 2 {
  36251. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36252. } else if record_type == 3 {
  36253. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36254. }
  36255. var dat2 map[string]interface{}
  36256. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36257. fmt.Println(dat2)
  36258. } else {
  36259. fmt.Println(err)
  36260. }
  36261. userJSONBytes, _ := json.Marshal(dat2)
  36262. var res ResultSix
  36263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36264. utils.ErrorLog("解析失败:%v", err)
  36265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36266. return
  36267. }
  36268. if res.Infcode == 0 {
  36269. if record_type == 1 {
  36270. service.UpdateDrugByIdDetail(item.ID)
  36271. } else if record_type == 2 {
  36272. service.UpdateGoodInfoById(item.ID)
  36273. } else if record_type == 3 {
  36274. service.UpdateMyProjectById(item.ID)
  36275. }
  36276. c.ServeSuccessJSON(map[string]interface{}{
  36277. "failed_code": 0,
  36278. "msg": "撤销目录对照成功",
  36279. })
  36280. } else {
  36281. c.ServeSuccessJSON(map[string]interface{}{
  36282. "failed_code": -10,
  36283. "msg": res.ErrMsg,
  36284. })
  36285. }
  36286. }
  36287. }
  36288. }
  36289. }
  36290. func (c *HisApiController) GetPatientInfo() {
  36291. id_card_no := c.GetString("id_card_no")
  36292. admin_user_id, _ := c.GetInt64("admin_user_id")
  36293. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36294. if patient.ID == 0 {
  36295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36296. return
  36297. }
  36298. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36300. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36301. var res ResultTwo
  36302. var res10265 ResultTwo10265
  36303. if config.IsOpen == 1 {
  36304. if miConfig.MdtrtareaAdmvs == "150499" {
  36305. //请求内网数据
  36306. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36307. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36308. "&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
  36309. resp, requestErr := http.Get(api)
  36310. if requestErr != nil {
  36311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36312. return
  36313. }
  36314. body, ioErr := ioutil.ReadAll(resp.Body)
  36315. if ioErr != nil {
  36316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36318. return
  36319. }
  36320. var respJSON map[string]interface{}
  36321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36324. return
  36325. }
  36326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36327. result_byte, _ := json.Marshal(respJSON)
  36328. result := string(result_byte)
  36329. var dat map[string]interface{}
  36330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36331. fmt.Println(dat)
  36332. } else {
  36333. fmt.Println(err)
  36334. }
  36335. userJSONBytes, _ := json.Marshal(dat)
  36336. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36337. utils.ErrorLog("解析失败:%v", err)
  36338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36339. return
  36340. }
  36341. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36342. res.Infcode = Infcode
  36343. res.ErrMsg = res10265.ErrMsg
  36344. res.Output = res10265.Output
  36345. res.InfRefmsgid = res10265.InfRefmsgid
  36346. res.RespondTime = res10265.RespondTime
  36347. res.WarnInfo = res10265.WarnInfo
  36348. } else {
  36349. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36350. var dat map[string]interface{}
  36351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36352. fmt.Println(dat)
  36353. } else {
  36354. fmt.Println(err)
  36355. }
  36356. userJSONBytes, _ := json.Marshal(dat)
  36357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36358. utils.ErrorLog("解析失败:%v", err)
  36359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36360. return
  36361. }
  36362. }
  36363. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36364. // utils.ErrorLog("解析失败:%v", err)
  36365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36366. // return
  36367. //}
  36368. for index, item := range res.Output.Iinfo {
  36369. if item.PsnInsuStas == "2" {
  36370. fmt.Println("--------")
  36371. res.Output.Iinfo[index].Insutype = "300"
  36372. res.Output.Iinfo[index].PsnInsuStas = "1"
  36373. }
  36374. }
  36375. fmt.Println(res.Output.Iinfo)
  36376. if res.Infcode != 0 {
  36377. c.ServeSuccessJSON(map[string]interface{}{
  36378. "failed_code": -10,
  36379. "msg": res.ErrMsg,
  36380. })
  36381. } else {
  36382. c.ServeSuccessJSON(map[string]interface{}{
  36383. "failed_code": 0,
  36384. "info": res,
  36385. })
  36386. }
  36387. }
  36388. }
  36389. func (c *HisApiController) PsnPutOnRecord() {
  36390. record_type, _ := c.GetInt64("type")
  36391. patient_id, _ := c.GetInt64("patient_id")
  36392. admin_user_id, _ := c.GetInt64("admin_user_id")
  36393. start_time := c.GetString("start_time")
  36394. end_time := c.GetString("end_time")
  36395. adminUser := c.GetAdminUserInfo()
  36396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36397. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36398. var patients []*models.Patients
  36399. if record_type == 1 { //全部备案
  36400. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36401. patients = append(patients, patient...)
  36402. } else { //单个备案
  36403. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36404. patients = append(patients, patient)
  36405. }
  36406. var user_name string
  36407. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36408. if role.ID == 0 {
  36409. user_name = "xxx"
  36410. } else {
  36411. user_name = role.UserName
  36412. }
  36413. if config.IsOpen == 1 {
  36414. for _, item := range patients {
  36415. 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
  36416. resp, requestErr := http.Get(api)
  36417. if requestErr != nil {
  36418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36419. return
  36420. }
  36421. defer resp.Body.Close()
  36422. body, ioErr := ioutil.ReadAll(resp.Body)
  36423. if ioErr != nil {
  36424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36426. return
  36427. }
  36428. var respJSON map[string]interface{}
  36429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36432. return
  36433. }
  36434. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36435. userJSONBytes, _ := json.Marshal(userJSON)
  36436. var res ResultTwo
  36437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36438. utils.ErrorLog("解析失败:%v", err)
  36439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36440. return
  36441. }
  36442. if res.Infcode == 0 {
  36443. 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)
  36444. var dat map[string]interface{}
  36445. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36446. fmt.Println(dat)
  36447. } else {
  36448. fmt.Println(err)
  36449. }
  36450. userJSONBytes, _ := json.Marshal(dat)
  36451. var res2 ResultThirteen
  36452. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36453. utils.ErrorLog("解析失败:%v", err)
  36454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36455. return
  36456. }
  36457. if res2.Infcode == 0 {
  36458. psnResult := &models.GdybPsnRecord{
  36459. UserOrgId: adminUser.CurrentOrgId,
  36460. PatientId: item.ID,
  36461. PsnNo: res.Output.Baseinfo.PsnNo,
  36462. Ctime: time.Now().Unix(),
  36463. Mtime: time.Now().Unix(),
  36464. Status: 1,
  36465. IsCancel: 1,
  36466. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36467. }
  36468. service.CreatePsnRecord(psnResult)
  36469. } else {
  36470. c.ServeSuccessJSON(map[string]interface{}{
  36471. "failed_code": -10,
  36472. "msg": res2.ErrMsg,
  36473. })
  36474. return
  36475. }
  36476. }
  36477. }
  36478. }
  36479. }
  36480. func (c *HisApiController) PsnUnPutOnRecord() {
  36481. id, _ := c.GetInt64("id")
  36482. //record_type, _ := c.GetInt64("type")
  36483. admin_user_id, _ := c.GetInt64("admin_user_id")
  36484. adminUser := c.GetAdminUserInfo()
  36485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36486. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36487. var user_name string
  36488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36489. if role.ID == 0 {
  36490. user_name = "xxx"
  36491. } else {
  36492. user_name = role.UserName
  36493. }
  36494. psn_record, _ := service.GetPsnRecordById(id)
  36495. if psn_record.ID == 0 {
  36496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36497. return
  36498. }
  36499. if config.IsOpen == 1 {
  36500. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36501. var dat map[string]interface{}
  36502. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36503. fmt.Println(dat)
  36504. } else {
  36505. fmt.Println(err)
  36506. }
  36507. userJSONBytes, _ := json.Marshal(dat)
  36508. var res ResultFourteen
  36509. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36510. utils.ErrorLog("解析失败:%v", err)
  36511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36512. return
  36513. }
  36514. if res.Infcode == 0 {
  36515. psn_record.IsCancel = 2
  36516. service.CreatePsnRecord(&psn_record)
  36517. } else {
  36518. c.ServeSuccessJSON(map[string]interface{}{
  36519. "failed_code": -10,
  36520. "msg": res.ErrMsg,
  36521. })
  36522. return
  36523. }
  36524. }
  36525. }
  36526. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36527. patient_id, _ := c.GetInt64("patient_id")
  36528. insutype_two := c.GetString("insutype")
  36529. psn_no := c.GetString("psn_no")
  36530. doctor_id, _ := c.GetInt64("doctor_id")
  36531. sick_id, _ := c.GetInt64("sick_id")
  36532. department_id, _ := c.GetInt64("department_id")
  36533. start_time := c.GetString("start_time")
  36534. end_time := c.GetString("end_time")
  36535. check_time := c.GetString("check_time")
  36536. hospital_code := c.GetString("hospital_code")
  36537. hospital_name := c.GetString("hospital_name")
  36538. adminUser := c.GetAdminUserInfo()
  36539. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36540. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36541. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36542. sick, _ := service.FindSickById(sick_id)
  36543. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36544. if len(hospital_code) == 0 {
  36545. hospital_code = miConfig.Code
  36546. }
  36547. if len(hospital_name) == 0 {
  36548. hospital_name = miConfig.OrgName
  36549. }
  36550. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36551. var res ResultTwo
  36552. var res10265 ResultTwo10265
  36553. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36554. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36555. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36556. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36557. "&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
  36558. resp, requestErr := http.Get(api)
  36559. if requestErr != nil {
  36560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36561. return
  36562. }
  36563. body, ioErr := ioutil.ReadAll(resp.Body)
  36564. if ioErr != nil {
  36565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36567. return
  36568. }
  36569. var respJSON map[string]interface{}
  36570. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36573. return
  36574. }
  36575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36576. result, _ := json.Marshal(respJSON)
  36577. fmt.Println("log")
  36578. fmt.Println(string(result))
  36579. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36580. utils.ErrorLog("解析失败:%v", err)
  36581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36582. return
  36583. }
  36584. res.ErrMsg = res10265.ErrMsg
  36585. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36586. res.Infcode = infocode
  36587. res.Output = res10265.Output
  36588. res.InfRefmsgid = res10265.InfRefmsgid
  36589. } else {
  36590. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36591. if miConfig.Code == "H15049901371" {
  36592. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36593. utils.ErrorLog("解析失败:%v", err)
  36594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36595. return
  36596. }
  36597. res.ErrMsg = res10265.ErrMsg
  36598. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36599. res.Infcode = infocode
  36600. res.Output = res10265.Output
  36601. res.InfRefmsgid = res10265.InfRefmsgid
  36602. } else {
  36603. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36604. utils.ErrorLog("解析失败:%v", err)
  36605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36606. return
  36607. }
  36608. }
  36609. }
  36610. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36611. infoStr := string(Iinfos)
  36612. var rf []*ResultFive
  36613. json.Unmarshal([]byte(infoStr), &rf)
  36614. var insuplc_admdvs string
  36615. var insutype string
  36616. var is390 int = 0
  36617. var is310 int = 0
  36618. var insutypes []*ResultFive
  36619. for _, item := range rf {
  36620. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36621. insutypes = append(insutypes, item)
  36622. }
  36623. }
  36624. if len(insutypes) == 1 {
  36625. insutype = insutypes[0].Insutype
  36626. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36627. } else {
  36628. for _, i := range insutypes {
  36629. if i.Insutype == "390" {
  36630. is390 = 1
  36631. }
  36632. if i.Insutype == "310" {
  36633. is310 = 1
  36634. }
  36635. }
  36636. }
  36637. if is390 == 1 {
  36638. insutype = "390"
  36639. }
  36640. if is310 == 1 {
  36641. insutype = "310"
  36642. }
  36643. if len(insutypes) == 2 {
  36644. insutype = insutype_two
  36645. }
  36646. if len(insutypes) == 0 {
  36647. insutype = "310"
  36648. }
  36649. insutype = insutype_two
  36650. fmt.Println(insutype)
  36651. for _, item := range rf {
  36652. fmt.Println(item.Insutype)
  36653. fmt.Println(insutype)
  36654. if item.Insutype == insutype {
  36655. fmt.Println(item.Insutype)
  36656. fmt.Println(insutype)
  36657. insuplc_admdvs = item.InsuplcAdmdvs
  36658. }
  36659. }
  36660. fmt.Println(insuplc_admdvs)
  36661. var res2 ResultThirteen
  36662. var res10265_2 ResultThirteen10265
  36663. if config.IsOpen == 1 {
  36664. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36665. } else {
  36666. if miConfig.MdtrtareaAdmvs == "150499" {
  36667. //
  36668. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36669. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36670. // "&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
  36671. //resp, requestErr := http.Get(api)
  36672. //if requestErr != nil {
  36673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36674. // return
  36675. //}
  36676. //
  36677. //body, ioErr := ioutil.ReadAll(resp.Body)
  36678. //if ioErr != nil {
  36679. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36681. // return
  36682. //}
  36683. //var respJSON map[string]interface{}
  36684. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36685. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36687. // return
  36688. //}
  36689. //
  36690. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36691. //result, _ := json.Marshal(respJSON)
  36692. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36693. // utils.ErrorLog("解析失败:%v", err)
  36694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36695. // return
  36696. //}
  36697. //infocode = resThree.Infcode
  36698. //result, _ := json.Marshal(respJSON)
  36699. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36700. // utils.ErrorLog("解析失败:%v", err)
  36701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36702. // return
  36703. //}
  36704. //
  36705. //resThree.ErrMsg = resThree10265.ErrMsg
  36706. //
  36707. //resThree.Output = resThree10265.Output
  36708. //
  36709. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36710. //
  36711. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36712. //
  36713. } else {
  36714. 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)
  36715. var dat map[string]interface{}
  36716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36717. fmt.Println(dat)
  36718. } else {
  36719. fmt.Println(err)
  36720. }
  36721. userJSONBytes, _ := json.Marshal(dat)
  36722. if miConfig.Code == "H15049901371" {
  36723. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36724. utils.ErrorLog("解析失败:%v", err)
  36725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36726. return
  36727. }
  36728. res2.ErrMsg = res10265_2.ErrMsg
  36729. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36730. res2.Infcode = infocode
  36731. res2.Output = res10265_2.Output
  36732. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36733. } else {
  36734. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36735. utils.ErrorLog("解析失败:%v", err)
  36736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36737. return
  36738. }
  36739. }
  36740. }
  36741. }
  36742. if res2.Infcode == 0 {
  36743. psnResult := &models.GdybPsnNcdsRecord{
  36744. UserOrgId: adminUser.CurrentOrgId,
  36745. PatientId: patient.ID,
  36746. PsnNo: psn_no,
  36747. DoctorId: doctor.AdminUserId,
  36748. DepartmentId: department_id,
  36749. SickType: sick_id,
  36750. Insutype: insutype,
  36751. Ctime: time.Now().Unix(),
  36752. Mtime: time.Now().Unix(),
  36753. Status: 1,
  36754. IsCancel: 1,
  36755. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36756. }
  36757. service.CreatePsnNCDSRecord(psnResult)
  36758. c.ServeSuccessJSON(map[string]interface{}{
  36759. "failed_code": 0,
  36760. "msg": "备案成功",
  36761. "result": psnResult,
  36762. })
  36763. } else {
  36764. c.ServeSuccessJSON(map[string]interface{}{
  36765. "failed_code": -10,
  36766. "msg": res2.ErrMsg,
  36767. })
  36768. return
  36769. }
  36770. }
  36771. }
  36772. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36773. id, _ := c.GetInt64("id")
  36774. admin_user_id, _ := c.GetInt64("admin_user_id")
  36775. adminUser := c.GetAdminUserInfo()
  36776. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36777. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36778. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36779. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36780. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36781. //var user_name string
  36782. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36783. //if role.ID == 0 {
  36784. // user_name = "xxx"
  36785. //} else {
  36786. // user_name = role.UserName
  36787. //}
  36788. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36789. if psn_record.ID == 0 {
  36790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36791. return
  36792. }
  36793. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36794. var res ResultTwo
  36795. var res10265 ResultTwo10265
  36796. if miConfig.Code == "H15049901371" {
  36797. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36798. utils.ErrorLog("解析失败:%v", err)
  36799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36800. return
  36801. }
  36802. res.ErrMsg = res10265.ErrMsg
  36803. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36804. res.Infcode = infocode
  36805. res.Output = res10265.Output
  36806. res.InfRefmsgid = res10265.InfRefmsgid
  36807. } else {
  36808. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36809. utils.ErrorLog("解析失败:%v", err)
  36810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36811. return
  36812. }
  36813. }
  36814. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36815. infoStr := string(Iinfos)
  36816. var rf []*ResultFive
  36817. json.Unmarshal([]byte(infoStr), &rf)
  36818. var insuplc_admdvs string
  36819. var insutype string
  36820. var is390 int = 0
  36821. var is310 int = 0
  36822. var insutypes []*ResultFive
  36823. for _, item := range rf {
  36824. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36825. insutypes = append(insutypes, item)
  36826. }
  36827. }
  36828. if len(insutypes) == 1 {
  36829. insutype = insutypes[0].Insutype
  36830. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36831. } else {
  36832. for _, i := range insutypes {
  36833. if i.Insutype == "390" {
  36834. is390 = 1
  36835. }
  36836. if i.Insutype == "310" {
  36837. is310 = 1
  36838. }
  36839. }
  36840. }
  36841. if is390 == 1 {
  36842. insutype = "390"
  36843. }
  36844. if is310 == 1 {
  36845. insutype = "310"
  36846. }
  36847. if len(insutypes) == 0 {
  36848. insutype = "310"
  36849. }
  36850. insutype = psn_record.Insutype
  36851. for _, item := range rf {
  36852. if item.Insutype == insutype {
  36853. insuplc_admdvs = item.InsuplcAdmdvs
  36854. }
  36855. }
  36856. if config.IsOpen == 1 {
  36857. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36858. var dat map[string]interface{}
  36859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36860. fmt.Println(dat)
  36861. } else {
  36862. fmt.Println(err)
  36863. }
  36864. userJSONBytes, _ := json.Marshal(dat)
  36865. var res ResultFourteen
  36866. var res10265 ResultFourteen10265
  36867. if miConfig.Code == "H15049901371" {
  36868. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36869. utils.ErrorLog("解析失败:%v", err)
  36870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36871. return
  36872. }
  36873. res.ErrMsg = res10265.ErrMsg
  36874. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36875. res.Infcode = infocode
  36876. res.Output = res10265.Output
  36877. res.InfRefmsgid = res10265.InfRefmsgid
  36878. } else {
  36879. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36880. utils.ErrorLog("解析失败:%v", err)
  36881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36882. return
  36883. }
  36884. }
  36885. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36886. // utils.ErrorLog("解析失败:%v", err)
  36887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36888. // return
  36889. //}
  36890. if res.Infcode == 0 {
  36891. psn_record.IsCancel = 2
  36892. service.CreatePsnNCDSRecord(&psn_record)
  36893. c.ServeSuccessJSON(map[string]interface{}{
  36894. "failed_code": 0,
  36895. "msg": "撤销备案成功",
  36896. })
  36897. } else {
  36898. c.ServeSuccessJSON(map[string]interface{}{
  36899. "failed_code": -10,
  36900. "msg": res.ErrMsg,
  36901. })
  36902. return
  36903. }
  36904. }
  36905. }
  36906. func (c *HisApiController) TestTest() {
  36907. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36908. fmt.Println(patient.Iinfo)
  36909. }
  36910. type CustomData struct {
  36911. MsgId string
  36912. PsnNo string
  36913. Info string
  36914. }
  36915. func (c *HisApiController) ReversalData() {
  36916. var customData []*CustomData
  36917. custom := &CustomData{
  36918. MsgId: "H44022900158202103301714472004",
  36919. PsnNo: "44020000001101329945",
  36920. Info: "2207",
  36921. }
  36922. customData = append(customData, custom)
  36923. custom1 := &CustomData{
  36924. MsgId: "H4402290015820210330172057803",
  36925. PsnNo: "44020000001101161813",
  36926. Info: "2207",
  36927. }
  36928. customData = append(customData, custom1)
  36929. custom2 := &CustomData{
  36930. MsgId: "H44022900158202103301705198813",
  36931. PsnNo: "44190000133097375417",
  36932. Info: "2207",
  36933. }
  36934. customData = append(customData, custom2)
  36935. custom3 := &CustomData{
  36936. MsgId: "H44022900158202103301715524756",
  36937. PsnNo: "44020000001100187221",
  36938. Info: "2207",
  36939. }
  36940. customData = append(customData, custom3)
  36941. custom4 := &CustomData{
  36942. MsgId: "H44022900158202103301730376224",
  36943. PsnNo: "44020000001101959155",
  36944. Info: "2207",
  36945. }
  36946. customData = append(customData, custom4)
  36947. custom5 := &CustomData{
  36948. MsgId: "H44022900158202103301748008725",
  36949. PsnNo: "44020000001104246641",
  36950. Info: "2207",
  36951. }
  36952. customData = append(customData, custom5)
  36953. custom6 := &CustomData{
  36954. MsgId: "H44022900158202103301718096755",
  36955. PsnNo: "44020000001102211860",
  36956. Info: "2207",
  36957. }
  36958. customData = append(customData, custom6)
  36959. custom7 := &CustomData{
  36960. MsgId: "H44022900158202103301736551640",
  36961. PsnNo: "44020000001102687718",
  36962. Info: "2207",
  36963. }
  36964. customData = append(customData, custom7)
  36965. custom8 := &CustomData{
  36966. MsgId: "H44022900158202103301743097676",
  36967. PsnNo: "44020000001102127785",
  36968. Info: "2207",
  36969. }
  36970. customData = append(customData, custom8)
  36971. custom9 := &CustomData{
  36972. MsgId: "H44022900158202103301712304203",
  36973. PsnNo: "44020000001101518097",
  36974. Info: "2207",
  36975. }
  36976. customData = append(customData, custom9)
  36977. custom10 := &CustomData{
  36978. MsgId: "H44022900158202103301738448785",
  36979. PsnNo: "44020000001100500813",
  36980. Info: "2207",
  36981. }
  36982. customData = append(customData, custom10)
  36983. custom11 := &CustomData{
  36984. MsgId: "H44022900158202103301732455843",
  36985. PsnNo: "44020000001102690557",
  36986. Info: "2207",
  36987. }
  36988. customData = append(customData, custom11)
  36989. custom12 := &CustomData{
  36990. MsgId: "H44022900158202103301745421708",
  36991. PsnNo: "44020000001102211928",
  36992. Info: "2207",
  36993. }
  36994. customData = append(customData, custom12)
  36995. custom1212 := &CustomData{
  36996. MsgId: "H440229001582021033017351627",
  36997. PsnNo: "44020000001102481733",
  36998. Info: "2207",
  36999. }
  37000. customData = append(customData, custom1212)
  37001. custom13 := &CustomData{
  37002. MsgId: "H44022900158202103301740327951",
  37003. PsnNo: "44020000001103174866",
  37004. Info: "2207",
  37005. }
  37006. customData = append(customData, custom13)
  37007. custom14 := &CustomData{
  37008. MsgId: "H4402290015820210330174922668",
  37009. PsnNo: "44020000001102927272",
  37010. Info: "2207",
  37011. }
  37012. customData = append(customData, custom14)
  37013. custom15 := &CustomData{
  37014. MsgId: "H44022900158202103301752362273",
  37015. PsnNo: "44020000001102942890",
  37016. Info: "2207",
  37017. }
  37018. customData = append(customData, custom15)
  37019. custom16 := &CustomData{
  37020. MsgId: "H44022900158202103301751082917",
  37021. PsnNo: "44020000001101662162",
  37022. Info: "2207",
  37023. }
  37024. customData = append(customData, custom16)
  37025. custom17 := &CustomData{
  37026. MsgId: "H44022900158202103301754147728",
  37027. PsnNo: "44020000000229014511",
  37028. Info: "2207",
  37029. }
  37030. customData = append(customData, custom17)
  37031. adminUser := c.GetAdminUserInfo()
  37032. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37033. for _, item := range customData {
  37034. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37035. fmt.Println(result)
  37036. }
  37037. }
  37038. func (c *HisApiController) GetAllopatry() {
  37039. year := c.GetString("year")
  37040. month := c.GetString("month")
  37041. admin_user_id, _ := c.GetInt64("admin_user_id")
  37042. adminUser := c.GetAdminUserInfo()
  37043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37044. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37045. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37046. var dat map[string]interface{}
  37047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37048. fmt.Println(dat)
  37049. } else {
  37050. fmt.Println(err)
  37051. }
  37052. userJSONBytes, _ := json.Marshal(dat)
  37053. var res models.Result9001
  37054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37055. utils.ErrorLog("解析失败:%v", err)
  37056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37057. return
  37058. }
  37059. fmt.Println(res.Output.Signinoutb)
  37060. fmt.Println(res.Output.Signinoutb.SignNo)
  37061. fmt.Println(string(userJSONBytes))
  37062. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37063. var dat3 map[string]interface{}
  37064. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37065. fmt.Println(dat3)
  37066. } else {
  37067. fmt.Println(err)
  37068. }
  37069. userJSONBytes3, _ := json.Marshal(dat3)
  37070. var res3 models.Result3260
  37071. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37072. utils.ErrorLog("解析失败:%v", err)
  37073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37074. return
  37075. }
  37076. var curpage int
  37077. var pagesize int = 100
  37078. var start int = 1
  37079. //var stop int
  37080. //pagecount := 10
  37081. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37082. var res22 []models.Result3260
  37083. for curpage = 1; curpage <= pagecount; curpage++ {
  37084. if curpage == 1 {
  37085. start = 0
  37086. } else {
  37087. start = (curpage-1)*pagesize + 1
  37088. }
  37089. fmt.Println(start)
  37090. //stop = curpage * pagesize
  37091. //if stop > int(res3.Output.Totalrow) {
  37092. // stop =int(res3.Output.Totalrow)
  37093. //}
  37094. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37095. var dat2 map[string]interface{}
  37096. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37097. fmt.Println(dat)
  37098. } else {
  37099. fmt.Println(err)
  37100. }
  37101. userJSONBytes2, _ := json.Marshal(dat2)
  37102. var res2 models.Result3260
  37103. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37104. utils.ErrorLog("解析失败:%v", err)
  37105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37106. return
  37107. }
  37108. if res2.Infcode == 0 {
  37109. res22 = append(res22, res2)
  37110. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37111. //var dat2 map[string]interface{}
  37112. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37113. // fmt.Println(dat)
  37114. //} else {
  37115. // fmt.Println(err)
  37116. //}
  37117. //c.ServeSuccessJSON(map[string]interface{}{
  37118. // "list": res2.Output.Data,
  37119. //})
  37120. //continue
  37121. }
  37122. }
  37123. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37124. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37125. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37126. //var dat2 map[string]interface{}
  37127. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37128. // fmt.Println(dat)
  37129. //} else {
  37130. // fmt.Println(err)
  37131. //}
  37132. //userJSONBytes2, _ := json.Marshal(dat2)
  37133. //var res2 models.Result3260
  37134. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37135. // utils.ErrorLog("解析失败:%v", err)
  37136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37137. // return
  37138. //}
  37139. //if res2.Infcode == 0 {
  37140. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37141. // var dat2 map[string]interface{}
  37142. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37143. // fmt.Println(dat)
  37144. // } else {
  37145. // fmt.Println(err)
  37146. // }
  37147. // c.ServeSuccessJSON(map[string]interface{}{
  37148. // "list": res2.Output.Data,
  37149. // })
  37150. //}
  37151. }
  37152. func (c *HisApiController) ComfirmAllopatry() {
  37153. year := c.GetString("year")
  37154. month := c.GetString("month")
  37155. admin_user_id, _ := c.GetInt64("admin_user_id")
  37156. adminUser := c.GetAdminUserInfo()
  37157. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37158. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37159. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37160. var dat map[string]interface{}
  37161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37162. fmt.Println(dat)
  37163. } else {
  37164. fmt.Println(err)
  37165. }
  37166. userJSONBytes, _ := json.Marshal(dat)
  37167. var res models.Result9001
  37168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37169. utils.ErrorLog("解析失败:%v", err)
  37170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37171. return
  37172. }
  37173. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37174. var dat2 map[string]interface{}
  37175. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37176. fmt.Println(dat)
  37177. } else {
  37178. fmt.Println(err)
  37179. }
  37180. userJSONBytes2, _ := json.Marshal(dat2)
  37181. var res2 models.Result3260
  37182. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37183. utils.ErrorLog("解析失败:%v", err)
  37184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37185. return
  37186. }
  37187. //if res2.Infcode == 0 {
  37188. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37189. // var dat map[string]interface{}
  37190. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37191. // fmt.Println(dat)
  37192. // } else {
  37193. // fmt.Println(err)
  37194. // }
  37195. // userJSONBytes, _ := json.Marshal(dat)
  37196. // var res3 models.Result3261
  37197. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37198. // utils.ErrorLog("解析失败:%v", err)
  37199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37200. // return
  37201. // }
  37202. //
  37203. // if res3.Infcode == 0 {
  37204. // record := &models.HisYidiClearRecord{
  37205. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37206. // Ctime: time.Now().Unix(),
  37207. // Mtime: time.Now().Unix(),
  37208. // Status: 1,
  37209. // MsgId: msgId,
  37210. // }
  37211. // service.SaveClearRecord(record)
  37212. // c.ServeSuccessJSON(map[string]interface{}{
  37213. // "msg": "提取成功",
  37214. // })
  37215. // }
  37216. //}
  37217. }
  37218. func (c *HisApiController) RefundAllopatry() {
  37219. year := c.GetString("year")
  37220. month := c.GetString("month")
  37221. //id, _ := c.GetInt64("id")
  37222. admin_user_id, _ := c.GetInt64("admin_user_id")
  37223. adminUser := c.GetAdminUserInfo()
  37224. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37225. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37226. //record, _ := service.GetClearRecordById(id)
  37227. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37228. var dat map[string]interface{}
  37229. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37230. fmt.Println(dat)
  37231. } else {
  37232. fmt.Println(err)
  37233. }
  37234. userJSONBytes, _ := json.Marshal(dat)
  37235. var res models.Result9001
  37236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37237. utils.ErrorLog("解析失败:%v", err)
  37238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37239. return
  37240. }
  37241. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37242. var dat2 map[string]interface{}
  37243. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37244. fmt.Println(dat)
  37245. } else {
  37246. fmt.Println(err)
  37247. }
  37248. userJSONBytes2, _ := json.Marshal(dat2)
  37249. var empty ResultFourteen
  37250. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37251. utils.ErrorLog("解析失败:%v", err)
  37252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37253. return
  37254. }
  37255. if empty.Infcode == 0 {
  37256. c.ServeSuccessJSON(map[string]interface{}{
  37257. "msg": "撤销成功",
  37258. })
  37259. return
  37260. }
  37261. }
  37262. func (c *HisApiController) ReversalOtherData() {
  37263. var customData []*CustomData
  37264. custom := &CustomData{
  37265. MsgId: "H44022900158202103301714472004",
  37266. PsnNo: "44020000001101329945",
  37267. Info: "2208",
  37268. }
  37269. customData = append(customData, custom)
  37270. custom1 := &CustomData{
  37271. MsgId: "H4402290015820210330172057803",
  37272. PsnNo: "44020000001101161813",
  37273. Info: "2208",
  37274. }
  37275. customData = append(customData, custom1)
  37276. custom2 := &CustomData{
  37277. MsgId: "H44022900158202103301705198813",
  37278. PsnNo: "44190000133097375417",
  37279. Info: "2208",
  37280. }
  37281. customData = append(customData, custom2)
  37282. custom3 := &CustomData{
  37283. MsgId: "H44022900158202103301715524756",
  37284. PsnNo: "44020000001100187221",
  37285. Info: "2208",
  37286. }
  37287. customData = append(customData, custom3)
  37288. custom4 := &CustomData{
  37289. MsgId: "H44022900158202103301730376224",
  37290. PsnNo: "44020000001101959155",
  37291. Info: "2208",
  37292. }
  37293. customData = append(customData, custom4)
  37294. custom5 := &CustomData{
  37295. MsgId: "H44022900158202103301748008725",
  37296. PsnNo: "44020000001104246641",
  37297. Info: "2208",
  37298. }
  37299. customData = append(customData, custom5)
  37300. custom6 := &CustomData{
  37301. MsgId: "H44022900158202103301718096755",
  37302. PsnNo: "44020000001102211860",
  37303. Info: "2208",
  37304. }
  37305. customData = append(customData, custom6)
  37306. custom7 := &CustomData{
  37307. MsgId: "H44022900158202103301736551640",
  37308. PsnNo: "44020000001102687718",
  37309. Info: "2208",
  37310. }
  37311. customData = append(customData, custom7)
  37312. custom8 := &CustomData{
  37313. MsgId: "H44022900158202103301743097676",
  37314. PsnNo: "44020000001102127785",
  37315. Info: "2208",
  37316. }
  37317. customData = append(customData, custom8)
  37318. custom9 := &CustomData{
  37319. MsgId: "H44022900158202103301712304203",
  37320. PsnNo: "44020000001101518097",
  37321. Info: "2208",
  37322. }
  37323. customData = append(customData, custom9)
  37324. custom10 := &CustomData{
  37325. MsgId: "H44022900158202103301738448785",
  37326. PsnNo: "44020000001100500813",
  37327. Info: "2208",
  37328. }
  37329. customData = append(customData, custom10)
  37330. custom11 := &CustomData{
  37331. MsgId: "H44022900158202103301732455843",
  37332. PsnNo: "44020000001102690557",
  37333. Info: "2208",
  37334. }
  37335. customData = append(customData, custom11)
  37336. custom12 := &CustomData{
  37337. MsgId: "H44022900158202103301745421708",
  37338. PsnNo: "44020000001102211928",
  37339. Info: "2208",
  37340. }
  37341. customData = append(customData, custom12)
  37342. custom1212 := &CustomData{
  37343. MsgId: "H440229001582021033017351627",
  37344. PsnNo: "44020000001102481733",
  37345. Info: "2208",
  37346. }
  37347. customData = append(customData, custom1212)
  37348. custom13 := &CustomData{
  37349. MsgId: "H44022900158202103301740327951",
  37350. PsnNo: "44020000001103174866",
  37351. Info: "2208",
  37352. }
  37353. customData = append(customData, custom13)
  37354. custom14 := &CustomData{
  37355. MsgId: "H4402290015820210330174922668",
  37356. PsnNo: "44020000001102927272",
  37357. Info: "2208",
  37358. }
  37359. customData = append(customData, custom14)
  37360. custom15 := &CustomData{
  37361. MsgId: "H44022900158202103301752362273",
  37362. PsnNo: "44020000001102942890",
  37363. Info: "2208",
  37364. }
  37365. customData = append(customData, custom15)
  37366. custom16 := &CustomData{
  37367. MsgId: "H44022900158202103301751082917",
  37368. PsnNo: "44020000001101662162",
  37369. Info: "2208",
  37370. }
  37371. customData = append(customData, custom16)
  37372. custom17 := &CustomData{
  37373. MsgId: "H44022900158202103301754147728",
  37374. PsnNo: "44020000000229014511",
  37375. Info: "2208",
  37376. }
  37377. customData = append(customData, custom17)
  37378. adminUser := c.GetAdminUserInfo()
  37379. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37380. for _, item := range customData {
  37381. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37382. fmt.Println(result)
  37383. }
  37384. }
  37385. func PathExists(path string) (bool, error) {
  37386. _, err := os.Stat(path)
  37387. if err == nil {
  37388. return true, nil
  37389. }
  37390. if os.IsNotExist(err) {
  37391. return false, nil
  37392. }
  37393. return false, err
  37394. }
  37395. // 创建文件夹
  37396. func Mkdir(dir string) {
  37397. // 创建文件夹
  37398. exist, err := PathExists(dir)
  37399. if err != nil {
  37400. fmt.Println(err.Error())
  37401. } else {
  37402. if exist {
  37403. fmt.Println(dir + "文件夹已存在!")
  37404. } else {
  37405. // 文件夹名称,权限
  37406. err := os.Mkdir(dir, os.ModePerm)
  37407. if err != nil {
  37408. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37409. } else {
  37410. fmt.Println(dir + "文件夹创建成功!")
  37411. }
  37412. }
  37413. }
  37414. }
  37415. // 压缩文件
  37416. func Zip(srcFile string, destZip string) error {
  37417. zipfile, err := os.Create(destZip)
  37418. if err != nil {
  37419. return err
  37420. }
  37421. defer zipfile.Close()
  37422. archive := zip.NewWriter(zipfile)
  37423. defer archive.Close()
  37424. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37425. if err != nil {
  37426. return err
  37427. }
  37428. header, err := zip.FileInfoHeader(info)
  37429. if err != nil {
  37430. return err
  37431. }
  37432. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37433. // header.Name = path
  37434. if info.IsDir() {
  37435. header.Name += "/"
  37436. } else {
  37437. header.Method = zip.Deflate
  37438. }
  37439. writer, err := archive.CreateHeader(header)
  37440. if err != nil {
  37441. return err
  37442. }
  37443. if !info.IsDir() {
  37444. file, err := os.Open(path)
  37445. if err != nil {
  37446. return err
  37447. }
  37448. defer file.Close()
  37449. _, err = io.Copy(writer, file)
  37450. }
  37451. return err
  37452. })
  37453. return err
  37454. }
  37455. func ReadFile(filePath string) []byte {
  37456. f, err := os.Open(filePath)
  37457. if err != nil {
  37458. fmt.Println("read file fail", err)
  37459. return nil
  37460. }
  37461. defer f.Close()
  37462. fd, err := ioutil.ReadAll(f)
  37463. if err != nil {
  37464. fmt.Println("read to fd fail", err)
  37465. return nil
  37466. }
  37467. return fd
  37468. }
  37469. func saveLogq(result string, request string, infno string, desc string) {
  37470. dir := "日志"
  37471. utils.Mkdir(dir)
  37472. month := time.Unix(1557042972, 0).Format("1")
  37473. year := time.Now().Format("2006")
  37474. month = time.Now().Format("01")
  37475. day := time.Now().Format("02")
  37476. hour := time.Now().Format("15")
  37477. min := time.Now().Format("04")
  37478. sec := time.Now().Format("05")
  37479. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37480. file := year + month + day + "_log"
  37481. file_name := file + ".txt"
  37482. file_path := "日志" + "/" + file_name
  37483. exist, _ := utils.PathExists(file_path)
  37484. if exist { //存在
  37485. fmt.Println("存在")
  37486. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37487. if err != nil {
  37488. fmt.Println("read fail")
  37489. }
  37490. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37491. n, _ := f.Seek(0, 2)
  37492. _, err = f.WriteAt([]byte(content), n)
  37493. } else { //不存在
  37494. fmt.Println("文件不存在,创建文件")
  37495. f, err := os.Create("日志" + "/" + file_name)
  37496. defer f.Close()
  37497. if err != nil {
  37498. } else {
  37499. _, err = f.Write([]byte("记录日志"))
  37500. }
  37501. }
  37502. }
  37503. func saveLog(result string, request string, infno string, desc string) {
  37504. org_id, _ := beego.AppConfig.Int64("org_id")
  37505. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37506. dir := miConfig.OrgName + "日志"
  37507. utils.Mkdir(dir)
  37508. month := time.Unix(1557042972, 0).Format("1")
  37509. year := time.Now().Format("2006")
  37510. month = time.Now().Format("01")
  37511. day := time.Now().Format("02")
  37512. hour := time.Now().Format("15")
  37513. min := time.Now().Format("04")
  37514. sec := time.Now().Format("05")
  37515. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37516. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37517. file_name := file + ".txt"
  37518. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37519. exist, _ := utils.PathExists(file_path)
  37520. if exist { //存在
  37521. fmt.Println("存在")
  37522. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37523. if err != nil {
  37524. fmt.Println("read fail")
  37525. }
  37526. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37527. n, _ := f.Seek(0, 2)
  37528. _, err = f.WriteAt([]byte(content), n)
  37529. } else { //不存在
  37530. fmt.Println("文件不存在,创建文件")
  37531. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37532. defer f.Close()
  37533. if err != nil {
  37534. } else {
  37535. _, err = f.Write([]byte("记录日志"))
  37536. }
  37537. }
  37538. }
  37539. type Charset string
  37540. const (
  37541. UTF8 = Charset("UTF-8")
  37542. GB18030 = Charset("GB18030")
  37543. )
  37544. func ConvertToString(src string, srcCode string, tagCode string) string {
  37545. srcCoder := mahonia.NewDecoder(srcCode)
  37546. srcResult := srcCoder.ConvertString(src)
  37547. tagCoder := mahonia.NewDecoder(tagCode)
  37548. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37549. result := string(cdata)
  37550. return result
  37551. }
  37552. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37553. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37554. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37555. var token string
  37556. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37557. var api string
  37558. if miConfig.MdtrtareaAdmvs == "320921" {
  37559. 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 +
  37560. "&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
  37561. fmt.Println(api)
  37562. } else {
  37563. 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 +
  37564. "&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
  37565. }
  37566. resp, requestErr := http.Get(api)
  37567. if requestErr != nil {
  37568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37569. return ""
  37570. }
  37571. body, ioErr := ioutil.ReadAll(resp.Body)
  37572. if ioErr != nil {
  37573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37575. return ""
  37576. }
  37577. var respJSON map[string]interface{}
  37578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37581. return ""
  37582. }
  37583. var status string
  37584. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37585. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37586. var res ResultTwo //1101结果
  37587. var res10265 ResultTwo10265 //1101结果
  37588. if status == "0" { //读卡成功
  37589. var card_info string //卡信息
  37590. var busi_card_info string
  37591. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37592. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37593. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37594. fmt.Println(card_info)
  37595. fmt.Println(busi_card_info)
  37596. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37597. result, _ := json.Marshal(respJSON)
  37598. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37599. utils.ErrorLog("解析失败:%v", err)
  37600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37601. return ""
  37602. }
  37603. res.ErrMsg = res10265.ErrMsg
  37604. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37605. res.Infcode = infocode
  37606. res.Output = res10265.Output
  37607. res.InfRefmsgid = res10265.InfRefmsgid
  37608. if res.Infcode == 0 {
  37609. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37610. if err == gorm.ErrRecordNotFound {
  37611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37612. return ""
  37613. } else if err != nil {
  37614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37615. return ""
  37616. } else {
  37617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37618. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37619. infoStr := string(Iinfos)
  37620. idetinfoStr := string(Idetinfos)
  37621. psn := &models.HisPsn{
  37622. PsnNo: res.Output.Baseinfo.PsnNo,
  37623. PatientId: patient.ID,
  37624. Certno: res.Output.Baseinfo.Certno,
  37625. Gend: res.Output.Baseinfo.Gend,
  37626. Naty: res.Output.Baseinfo.Naty,
  37627. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37628. PsnName: res.Output.Baseinfo.PsnName,
  37629. Idetinfo: idetinfoStr,
  37630. Insuinfo: infoStr,
  37631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37632. CardInfo: card_info,
  37633. VerifyNumber: token,
  37634. }
  37635. service.CreateHisPsn(psn)
  37636. return token
  37637. }
  37638. }
  37639. } else {
  37640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37641. return ""
  37642. }
  37643. } else { //读卡失败
  37644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37645. return ""
  37646. }
  37647. return token
  37648. }
  37649. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37650. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37651. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37652. var token string
  37653. var api string
  37654. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37655. "&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
  37656. fmt.Println(api)
  37657. resp, requestErr := http.Get(api)
  37658. if requestErr != nil {
  37659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37660. return ""
  37661. }
  37662. body, ioErr := ioutil.ReadAll(resp.Body)
  37663. if ioErr != nil {
  37664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37666. return ""
  37667. }
  37668. var respJSON map[string]interface{}
  37669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37672. return ""
  37673. }
  37674. var status string
  37675. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37676. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37677. var res ResultTwo //1101结果
  37678. if status == "1" { //读卡成功
  37679. var card_info string //卡信息
  37680. var busi_card_info string
  37681. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37682. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37683. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37684. fmt.Println(card_info)
  37685. fmt.Println(busi_card_info)
  37686. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37687. result, _ := json.Marshal(respJSON)
  37688. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37689. utils.ErrorLog("解析失败:%v", err)
  37690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37691. return ""
  37692. }
  37693. if res.Infcode == 0 {
  37694. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37695. if err == gorm.ErrRecordNotFound {
  37696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37697. return ""
  37698. } else if err != nil {
  37699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37700. return ""
  37701. } else {
  37702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37704. infoStr := string(Iinfos)
  37705. idetinfoStr := string(Idetinfos)
  37706. psn := &models.HisPsn{
  37707. PsnNo: res.Output.Baseinfo.PsnNo,
  37708. PatientId: patient.ID,
  37709. Certno: res.Output.Baseinfo.Certno,
  37710. Gend: res.Output.Baseinfo.Gend,
  37711. Naty: res.Output.Baseinfo.Naty,
  37712. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37713. PsnName: res.Output.Baseinfo.PsnName,
  37714. Idetinfo: idetinfoStr,
  37715. Insuinfo: infoStr,
  37716. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37717. CardInfo: card_info,
  37718. VerifyNumber: token,
  37719. }
  37720. service.CreateHisPsn(psn)
  37721. return token
  37722. }
  37723. }
  37724. } else {
  37725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37726. return ""
  37727. }
  37728. return token
  37729. }
  37730. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37731. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37732. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37733. var token string
  37734. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37735. var api string
  37736. if miConfig.MdtrtareaAdmvs == "320921" {
  37737. 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 +
  37738. "&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
  37739. fmt.Println(api)
  37740. } else {
  37741. 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 +
  37742. "&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
  37743. }
  37744. resp, requestErr := http.Get(api)
  37745. if requestErr != nil {
  37746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37747. return ""
  37748. }
  37749. body, ioErr := ioutil.ReadAll(resp.Body)
  37750. if ioErr != nil {
  37751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37753. return ""
  37754. }
  37755. var respJSON map[string]interface{}
  37756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37759. return ""
  37760. }
  37761. var status string
  37762. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37763. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37764. var res ResultTwo //1101结果
  37765. var res10265 ResultTwo10265 //1101结果
  37766. if status == "0" { //读卡成功
  37767. var card_info string //卡信息
  37768. var busi_card_info string
  37769. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37770. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37771. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37772. fmt.Println(card_info)
  37773. fmt.Println(busi_card_info)
  37774. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37775. result, _ := json.Marshal(respJSON)
  37776. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37777. utils.ErrorLog("解析失败:%v", err)
  37778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37779. return ""
  37780. }
  37781. res.ErrMsg = res10265.ErrMsg
  37782. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37783. res.Infcode = infocode
  37784. res.Output = res10265.Output
  37785. res.InfRefmsgid = res10265.InfRefmsgid
  37786. if res.Infcode == 0 {
  37787. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37788. if err == gorm.ErrRecordNotFound {
  37789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37790. return ""
  37791. } else if err != nil {
  37792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37793. return ""
  37794. } else {
  37795. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37796. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37797. infoStr := string(Iinfos)
  37798. idetinfoStr := string(Idetinfos)
  37799. psn := &models.HisPsn{
  37800. PsnNo: res.Output.Baseinfo.PsnNo,
  37801. PatientId: patient.ID,
  37802. Certno: res.Output.Baseinfo.Certno,
  37803. Gend: res.Output.Baseinfo.Gend,
  37804. Naty: res.Output.Baseinfo.Naty,
  37805. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37806. PsnName: res.Output.Baseinfo.PsnName,
  37807. Idetinfo: idetinfoStr,
  37808. Insuinfo: infoStr,
  37809. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37810. CardInfo: card_info,
  37811. VerifyNumber: token,
  37812. }
  37813. service.CreateHisPsn(psn)
  37814. return token
  37815. }
  37816. }
  37817. } else {
  37818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37819. return ""
  37820. }
  37821. } else { //读卡失败
  37822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37823. return ""
  37824. }
  37825. return token
  37826. }
  37827. func DeleteExtraSpaceTwo(s string) string {
  37828. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37829. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37830. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37831. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37832. s2 := make([]byte, len(s1)) //定义字符数组切片
  37833. copy(s2, s1) //将字符串复制到切片
  37834. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37835. for len(spc_index) > 0 { //找到适配项
  37836. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37837. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37838. }
  37839. return string(s2)
  37840. }
  37841. func Remove0000(s string) string {
  37842. str := make([]rune, 0, len(s))
  37843. for _, v := range []rune(s) {
  37844. if v == 0 {
  37845. continue
  37846. }
  37847. str = append(str, v)
  37848. }
  37849. return string(str)
  37850. }
  37851. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37852. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37853. readCard := DllDef.MustFindProc("EcQuery")
  37854. pCardInfo := make([]byte, 8192)
  37855. pBusiCardInfo := make([]byte, 8192)
  37856. data := make(map[string]interface{})
  37857. //pData := make(map[string]interface{})
  37858. inputData := make(map[string]interface{})
  37859. inputData["orgId"] = code
  37860. inputData["businessType"] = "01101"
  37861. inputData["operatorId"] = operator_id
  37862. inputData["operatorName"] = operator_name
  37863. inputData["officeId"] = "001"
  37864. inputData["officeName"] = "血透室"
  37865. //
  37866. data["data"] = inputData
  37867. data["transType"] = "ec.query"
  37868. data["orgId"] = code
  37869. bytesData, _ := json.Marshal(data)
  37870. pCardInfo = bytesData
  37871. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37872. fmt.Println(ret2)
  37873. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37874. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37875. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37876. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37877. if ret2 != 0 {
  37878. return "", ""
  37879. }
  37880. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37881. }
  37882. func DeleteExtraSpace(s string) string {
  37883. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37884. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37885. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37886. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37887. s2 := make([]byte, len(s1)) //定义字符数组切片
  37888. copy(s2, s1) //将字符串复制到切片
  37889. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37890. for len(spc_index) > 0 { //找到适配项
  37891. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37892. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37893. }
  37894. return string(s2)
  37895. }
  37896. // 对账
  37897. func (c *HisApiController) Post3202() {
  37898. start_time := c.GetString("start_time")
  37899. end_time := c.GetString("end_time")
  37900. //insutype := c.GetString("insutype")
  37901. clr_type := c.GetString("clr_type")
  37902. clr_org := c.GetString("clr_optins")
  37903. admin_user_id, _ := c.GetInt64("admin_user_id")
  37904. adminUser := c.GetAdminUserInfo()
  37905. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37906. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37907. if len(clr_org) == 0 {
  37908. clr_org = miConfig.MdtrtareaAdmvs
  37909. }
  37910. timeLayout := "2006-01-02"
  37911. loc, _ := time.LoadLocation("Local")
  37912. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37913. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37914. var orders []*models.HisOrder
  37915. if clr_org == "421300" {
  37916. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37917. } else if clr_org == "420902" {
  37918. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37919. } else {
  37920. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37921. }
  37922. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37923. //fixmedins_setl_cnt := int64(len(orders))
  37924. var medfee_sumamt float64
  37925. var acct_pay float64
  37926. var fund_pay_sumamt float64
  37927. for _, item := range orders {
  37928. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37929. acct_pay = acct_pay + item.AcctPay
  37930. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37931. }
  37932. //var medfee_sumamt_two float64
  37933. //var acct_pay_two float64
  37934. //var fund_pay_sumamt_two float64
  37935. //for _, item := range orders_two {
  37936. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37937. // acct_pay_two = acct_pay_two + item.AcctPay
  37938. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37939. //}
  37940. //var user_name string
  37941. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37942. //if role.ID == 0 {
  37943. // user_name = "xxx"
  37944. //} else {
  37945. // user_name = role.UserName
  37946. //}
  37947. var res ResultSix
  37948. if config.IsOpen == 1 {
  37949. var bps []*models.BusinessParamsTwo
  37950. var bp models.BusinessParamsTwo
  37951. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37952. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37953. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37954. bp.MedfeeSumamt = medfee_sumamt_str
  37955. bp.AcctPay = acct_pay_str
  37956. bp.FundPaySumamt = fund_pay_sumamt_str
  37957. bp.Insutype = ""
  37958. bp.StmtBegndate = start_time
  37959. bp.ClrType = clr_type
  37960. bp.SetlOptins = clr_org
  37961. bp.StmtEnddate = end_time
  37962. bps = append(bps, &bp)
  37963. data := make(map[string]interface{})
  37964. data["bps"] = bps
  37965. data["org_name"] = miConfig.OrgName
  37966. data["doctor"] = role.UserName
  37967. data["fixmedins_code"] = miConfig.Code
  37968. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37969. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37970. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37971. if miConfig.MdtrtareaAdmvs == "421300" {
  37972. client := &http.Client{}
  37973. bytesData, _ := json.Marshal(data)
  37974. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37975. resp, _ := client.Do(req)
  37976. defer resp.Body.Close()
  37977. body, ioErr := ioutil.ReadAll(resp.Body)
  37978. if ioErr != nil {
  37979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37981. return
  37982. }
  37983. var respJSON map[string]interface{}
  37984. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37987. return
  37988. }
  37989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37990. userJSONBytes, _ := json.Marshal(respJSON)
  37991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37992. utils.ErrorLog("解析失败:%v", err)
  37993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37994. return
  37995. }
  37996. }
  37997. if miConfig.MdtrtareaAdmvs == "420200" {
  37998. client := &http.Client{}
  37999. bytesData, _ := json.Marshal(data)
  38000. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38001. resp, _ := client.Do(req)
  38002. defer resp.Body.Close()
  38003. body, ioErr := ioutil.ReadAll(resp.Body)
  38004. if ioErr != nil {
  38005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38007. return
  38008. }
  38009. var respJSON map[string]interface{}
  38010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38013. return
  38014. }
  38015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38016. userJSONBytes, _ := json.Marshal(respJSON)
  38017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38018. utils.ErrorLog("解析失败:%v", err)
  38019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38020. return
  38021. }
  38022. }
  38023. if miConfig.MdtrtareaAdmvs == "421182" {
  38024. client := &http.Client{}
  38025. bytesData, _ := json.Marshal(data)
  38026. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38027. resp, _ := client.Do(req)
  38028. defer resp.Body.Close()
  38029. body, ioErr := ioutil.ReadAll(resp.Body)
  38030. if ioErr != nil {
  38031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38033. return
  38034. }
  38035. var respJSON map[string]interface{}
  38036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38039. return
  38040. }
  38041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38042. userJSONBytes, _ := json.Marshal(respJSON)
  38043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38044. utils.ErrorLog("解析失败:%v", err)
  38045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38046. return
  38047. }
  38048. }
  38049. if miConfig.MdtrtareaAdmvs == "420902" {
  38050. client := &http.Client{}
  38051. bytesData, _ := json.Marshal(data)
  38052. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38053. resp, _ := client.Do(req)
  38054. defer resp.Body.Close()
  38055. body, ioErr := ioutil.ReadAll(resp.Body)
  38056. if ioErr != nil {
  38057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38059. return
  38060. }
  38061. var respJSON map[string]interface{}
  38062. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38065. return
  38066. }
  38067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38068. userJSONBytes, _ := json.Marshal(respJSON)
  38069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38070. utils.ErrorLog("解析失败:%v", err)
  38071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38072. return
  38073. }
  38074. }
  38075. if res.Infcode == 0 {
  38076. c.ServeSuccessJSON(map[string]interface{}{
  38077. "msg": "发起成功",
  38078. })
  38079. } else {
  38080. c.ServeSuccessJSON(map[string]interface{}{
  38081. "failed_code": -10,
  38082. "msg": res.ErrMsg,
  38083. })
  38084. }
  38085. }
  38086. }
  38087. func (c *HisApiController) Post3204a() {
  38088. start_time := c.GetString("start_time")
  38089. end_time := c.GetString("end_time")
  38090. //insutype := c.GetString("insutype")
  38091. clr_type := c.GetString("clr_type")
  38092. clr_org := c.GetString("clr_optins")
  38093. admin_user_id, _ := c.GetInt64("admin_user_id")
  38094. adminUser := c.GetAdminUserInfo()
  38095. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38096. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38097. if len(clr_org) == 0 {
  38098. clr_org = miConfig.MdtrtareaAdmvs
  38099. }
  38100. timeLayout := "2006-01-02"
  38101. loc, _ := time.LoadLocation("Local")
  38102. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38103. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38104. var orders []*models.HisOrder
  38105. if clr_org == "421300" {
  38106. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38107. } else if clr_org == "420902" {
  38108. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38109. } else {
  38110. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38111. }
  38112. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38113. //fixmedins_setl_cnt := int64(len(orders))
  38114. var medfee_sumamt float64
  38115. var acct_pay float64
  38116. var fund_pay_sumamt float64
  38117. for _, item := range orders {
  38118. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38119. acct_pay = acct_pay + item.AcctPay
  38120. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38121. }
  38122. //var medfee_sumamt_two float64
  38123. //var acct_pay_two float64
  38124. //var fund_pay_sumamt_two float64
  38125. //for _, item := range orders_two {
  38126. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38127. // acct_pay_two = acct_pay_two + item.AcctPay
  38128. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38129. //}
  38130. //var user_name string
  38131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38132. //if role.ID == 0 {
  38133. // user_name = "xxx"
  38134. //} else {
  38135. // user_name = role.UserName
  38136. //}
  38137. var res ResultSix
  38138. if config.IsOpen == 1 {
  38139. var bps []*models.BusinessParamsTwo
  38140. var bp models.BusinessParamsTwo
  38141. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38142. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38143. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38144. bp.MedfeeSumamt = medfee_sumamt_str
  38145. bp.AcctPay = acct_pay_str
  38146. bp.FundPaySumamt = fund_pay_sumamt_str
  38147. bp.Insutype = ""
  38148. bp.StmtBegndate = start_time
  38149. bp.ClrType = clr_type
  38150. bp.SetlOptins = clr_org
  38151. bp.StmtEnddate = end_time
  38152. bps = append(bps, &bp)
  38153. data := make(map[string]interface{})
  38154. data["bps"] = bps
  38155. data["org_name"] = miConfig.OrgName
  38156. data["doctor"] = role.UserName
  38157. data["fixmedins_code"] = miConfig.Code
  38158. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38159. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38160. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38161. if miConfig.MdtrtareaAdmvs == "421300" {
  38162. client := &http.Client{}
  38163. bytesData, _ := json.Marshal(data)
  38164. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38165. resp, _ := client.Do(req)
  38166. defer resp.Body.Close()
  38167. body, ioErr := ioutil.ReadAll(resp.Body)
  38168. if ioErr != nil {
  38169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38171. return
  38172. }
  38173. var respJSON map[string]interface{}
  38174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38177. return
  38178. }
  38179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38180. userJSONBytes, _ := json.Marshal(respJSON)
  38181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38182. utils.ErrorLog("解析失败:%v", err)
  38183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38184. return
  38185. }
  38186. }
  38187. if miConfig.MdtrtareaAdmvs == "420200" {
  38188. client := &http.Client{}
  38189. bytesData, _ := json.Marshal(data)
  38190. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38191. resp, _ := client.Do(req)
  38192. defer resp.Body.Close()
  38193. body, ioErr := ioutil.ReadAll(resp.Body)
  38194. if ioErr != nil {
  38195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38197. return
  38198. }
  38199. var respJSON map[string]interface{}
  38200. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38203. return
  38204. }
  38205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38206. userJSONBytes, _ := json.Marshal(respJSON)
  38207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38208. utils.ErrorLog("解析失败:%v", err)
  38209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38210. return
  38211. }
  38212. }
  38213. if miConfig.MdtrtareaAdmvs == "421182" {
  38214. client := &http.Client{}
  38215. bytesData, _ := json.Marshal(data)
  38216. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38217. resp, _ := client.Do(req)
  38218. defer resp.Body.Close()
  38219. body, ioErr := ioutil.ReadAll(resp.Body)
  38220. if ioErr != nil {
  38221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38223. return
  38224. }
  38225. var respJSON map[string]interface{}
  38226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38229. return
  38230. }
  38231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38232. userJSONBytes, _ := json.Marshal(respJSON)
  38233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38234. utils.ErrorLog("解析失败:%v", err)
  38235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38236. return
  38237. }
  38238. }
  38239. if miConfig.MdtrtareaAdmvs == "420902" {
  38240. client := &http.Client{}
  38241. bytesData, _ := json.Marshal(data)
  38242. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38243. resp, _ := client.Do(req)
  38244. defer resp.Body.Close()
  38245. body, ioErr := ioutil.ReadAll(resp.Body)
  38246. if ioErr != nil {
  38247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38249. return
  38250. }
  38251. var respJSON map[string]interface{}
  38252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38255. return
  38256. }
  38257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38258. userJSONBytes, _ := json.Marshal(respJSON)
  38259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38260. utils.ErrorLog("解析失败:%v", err)
  38261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38262. return
  38263. }
  38264. }
  38265. if res.Infcode == 0 {
  38266. c.ServeSuccessJSON(map[string]interface{}{
  38267. "msg": "撤销成功",
  38268. })
  38269. } else {
  38270. c.ServeSuccessJSON(map[string]interface{}{
  38271. "failed_code": -10,
  38272. "msg": res.ErrMsg,
  38273. })
  38274. }
  38275. }
  38276. }
  38277. func (c *HisApiController) Post3204() {
  38278. admin_user_id, _ := c.GetInt64("admin_user_id")
  38279. id := c.GetString("id")
  38280. adminUser := c.GetAdminUserInfo()
  38281. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38282. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38283. //clr_org := miConfig.MdtrtareaAdmvs
  38284. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38285. var res ResultSix
  38286. if config.IsOpen == 1 {
  38287. data := make(map[string]interface{})
  38288. data["id"] = id
  38289. data["org_name"] = miConfig.OrgName
  38290. data["doctor"] = role.UserName
  38291. data["fixmedins_code"] = miConfig.Code
  38292. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38293. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38294. client := &http.Client{}
  38295. bytesData, _ := json.Marshal(data)
  38296. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38297. resp, _ := client.Do(req)
  38298. defer resp.Body.Close()
  38299. body, ioErr := ioutil.ReadAll(resp.Body)
  38300. if ioErr != nil {
  38301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38303. return
  38304. }
  38305. var respJSON map[string]interface{}
  38306. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38309. return
  38310. }
  38311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38312. userJSONBytes, _ := json.Marshal(respJSON)
  38313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38314. utils.ErrorLog("解析失败:%v", err)
  38315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38316. return
  38317. }
  38318. if res.Infcode == 0 {
  38319. c.ServeSuccessJSON(map[string]interface{}{
  38320. "msg": "发起成功",
  38321. })
  38322. } else {
  38323. c.ServeSuccessJSON(map[string]interface{}{
  38324. "failed_code": -10,
  38325. "msg": res.ErrMsg,
  38326. })
  38327. }
  38328. }
  38329. }
  38330. func (c *HisApiController) Post8404() {
  38331. admin_user_id, _ := c.GetInt64("admin_user_id")
  38332. month := c.GetString("month")
  38333. adminUser := c.GetAdminUserInfo()
  38334. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38335. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38336. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38337. var res ResultSix
  38338. if config.IsOpen == 1 {
  38339. data := make(map[string]interface{})
  38340. data["month"] = month
  38341. data["org_name"] = miConfig.OrgName
  38342. data["doctor"] = role.UserName
  38343. data["fixmedins_code"] = miConfig.Code
  38344. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38345. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38346. client := &http.Client{}
  38347. bytesData, _ := json.Marshal(data)
  38348. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38349. resp, _ := client.Do(req)
  38350. defer resp.Body.Close()
  38351. body, ioErr := ioutil.ReadAll(resp.Body)
  38352. if ioErr != nil {
  38353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38355. return
  38356. }
  38357. var respJSON map[string]interface{}
  38358. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38361. return
  38362. }
  38363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38364. userJSONBytes, _ := json.Marshal(respJSON)
  38365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38366. utils.ErrorLog("解析失败:%v", err)
  38367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38368. return
  38369. }
  38370. if res.Infcode == 0 {
  38371. c.ServeSuccessJSON(map[string]interface{}{
  38372. "msg": "查询成功",
  38373. })
  38374. } else {
  38375. c.ServeSuccessJSON(map[string]interface{}{
  38376. "failed_code": -10,
  38377. "msg": res.ErrMsg,
  38378. })
  38379. }
  38380. }
  38381. }
  38382. func (c *HisApiController) Post3202b() {
  38383. start_time := c.GetString("start_time")
  38384. end_time := c.GetString("end_time")
  38385. //insutype := c.GetString("insutype")
  38386. clr_type := c.GetString("clr_type")
  38387. clr_org := c.GetString("clr_optins")
  38388. admin_user_id, _ := c.GetInt64("admin_user_id")
  38389. adminUser := c.GetAdminUserInfo()
  38390. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38391. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38392. if len(clr_org) == 0 {
  38393. clr_org = miConfig.MdtrtareaAdmvs
  38394. }
  38395. timeLayout := "2006-01-02"
  38396. loc, _ := time.LoadLocation("Local")
  38397. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38398. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38399. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38400. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38401. //fixmedins_setl_cnt := int64(len(orders))
  38402. var medfee_sumamt float64
  38403. var acct_pay float64
  38404. var fund_pay_sumamt float64
  38405. for _, item := range orders {
  38406. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38407. acct_pay = acct_pay + item.AcctPay
  38408. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38409. }
  38410. //var medfee_sumamt_two float64
  38411. //var acct_pay_two float64
  38412. //var fund_pay_sumamt_two float64
  38413. //for _, item := range orders_two {
  38414. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38415. // acct_pay_two = acct_pay_two + item.AcctPay
  38416. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38417. //}
  38418. //var user_name string
  38419. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38420. //if role.ID == 0 {
  38421. // user_name = "xxx"
  38422. //} else {
  38423. // user_name = role.UserName
  38424. //}
  38425. var res ResultSix
  38426. if config.IsOpen == 1 {
  38427. var bps []*models.BusinessParamsTwo
  38428. var bp models.BusinessParamsTwo
  38429. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38430. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38431. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38432. bp.MedfeeSumamt = medfee_sumamt_str
  38433. bp.AcctPay = acct_pay_str
  38434. bp.FundPaySumamt = fund_pay_sumamt_str
  38435. bp.Insutype = "390"
  38436. bp.StmtBegndate = start_time
  38437. bp.ClrType = clr_type
  38438. bp.SetlOptins = clr_org
  38439. bp.StmtEnddate = end_time
  38440. bps = append(bps, &bp)
  38441. data := make(map[string]interface{})
  38442. data["bps"] = bps
  38443. data["org_name"] = miConfig.OrgName
  38444. data["doctor"] = role.UserName
  38445. data["fixmedins_code"] = miConfig.Code
  38446. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38447. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38448. if miConfig.MdtrtareaAdmvs == "421300" {
  38449. client := &http.Client{}
  38450. bytesData, _ := json.Marshal(data)
  38451. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38452. resp, _ := client.Do(req)
  38453. defer resp.Body.Close()
  38454. body, ioErr := ioutil.ReadAll(resp.Body)
  38455. if ioErr != nil {
  38456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38458. return
  38459. }
  38460. var respJSON map[string]interface{}
  38461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38464. return
  38465. }
  38466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38467. userJSONBytes, _ := json.Marshal(respJSON)
  38468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38469. utils.ErrorLog("解析失败:%v", err)
  38470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38471. return
  38472. }
  38473. }
  38474. if miConfig.MdtrtareaAdmvs == "420200" {
  38475. client := &http.Client{}
  38476. bytesData, _ := json.Marshal(data)
  38477. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38478. resp, _ := client.Do(req)
  38479. defer resp.Body.Close()
  38480. body, ioErr := ioutil.ReadAll(resp.Body)
  38481. if ioErr != nil {
  38482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38484. return
  38485. }
  38486. var respJSON map[string]interface{}
  38487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38490. return
  38491. }
  38492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38493. userJSONBytes, _ := json.Marshal(respJSON)
  38494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38495. utils.ErrorLog("解析失败:%v", err)
  38496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38497. return
  38498. }
  38499. }
  38500. if miConfig.MdtrtareaAdmvs == "421182" {
  38501. client := &http.Client{}
  38502. bytesData, _ := json.Marshal(data)
  38503. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38504. resp, _ := client.Do(req)
  38505. defer resp.Body.Close()
  38506. body, ioErr := ioutil.ReadAll(resp.Body)
  38507. if ioErr != nil {
  38508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38510. return
  38511. }
  38512. var respJSON map[string]interface{}
  38513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38516. return
  38517. }
  38518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38519. userJSONBytes, _ := json.Marshal(respJSON)
  38520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38521. utils.ErrorLog("解析失败:%v", err)
  38522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38523. return
  38524. }
  38525. }
  38526. if res.Infcode == 0 {
  38527. c.ServeSuccessJSON(map[string]interface{}{
  38528. "msg": "发起成功",
  38529. })
  38530. } else {
  38531. c.ServeSuccessJSON(map[string]interface{}{
  38532. "failed_code": -10,
  38533. "msg": res.ErrMsg,
  38534. })
  38535. }
  38536. }
  38537. }
  38538. func (c *HisApiController) Post1608() {
  38539. start_time := c.GetString("start_time")
  38540. end_time := c.GetString("end_time")
  38541. admin_user_id, _ := c.GetInt64("admin_user_id")
  38542. adminUser := c.GetAdminUserInfo()
  38543. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38544. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38545. timeLayout := "2006-01-02"
  38546. loc, _ := time.LoadLocation("Local")
  38547. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38548. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38549. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38550. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38551. fixmedins_setl_cnt := int64(len(orders))
  38552. var medfee_sumamt float64
  38553. var func_smamt float64
  38554. for _, item := range orders {
  38555. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38556. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38557. }
  38558. times := strings.Split(start_time, "-")
  38559. time_tows := strings.Split(end_time, "-")
  38560. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38561. var res ResultSix
  38562. if config.IsOpen == 1 {
  38563. //var bps []*models.BusinessParamsTwo
  38564. //var bp models.BusinessParamsTwo
  38565. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38566. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38567. data := make(map[string]interface{})
  38568. data["org_name"] = miConfig.OrgName
  38569. data["doctor"] = role.UserName
  38570. data["func_smamt"] = func_smamt_str
  38571. data["fixmedins_code"] = miConfig.Code
  38572. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38573. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38574. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38575. data["medfee_sumamt"] = medfee_sumamt_str
  38576. data["start_time"] = times[0] + times[1] + times[2]
  38577. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38578. if miConfig.MdtrtareaAdmvs == "421300" {
  38579. client := &http.Client{}
  38580. bytesData, _ := json.Marshal(data)
  38581. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38582. resp, _ := client.Do(req)
  38583. defer resp.Body.Close()
  38584. body, ioErr := ioutil.ReadAll(resp.Body)
  38585. if ioErr != nil {
  38586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38588. return
  38589. }
  38590. var respJSON map[string]interface{}
  38591. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38594. return
  38595. }
  38596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38597. userJSONBytes, _ := json.Marshal(respJSON)
  38598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38599. utils.ErrorLog("解析失败:%v", err)
  38600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38601. return
  38602. }
  38603. }
  38604. if miConfig.MdtrtareaAdmvs == "420200" {
  38605. client := &http.Client{}
  38606. bytesData, _ := json.Marshal(data)
  38607. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38608. resp, _ := client.Do(req)
  38609. defer resp.Body.Close()
  38610. body, ioErr := ioutil.ReadAll(resp.Body)
  38611. if ioErr != nil {
  38612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38614. return
  38615. }
  38616. var respJSON map[string]interface{}
  38617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38620. return
  38621. }
  38622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38623. userJSONBytes, _ := json.Marshal(respJSON)
  38624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38625. utils.ErrorLog("解析失败:%v", err)
  38626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38627. return
  38628. }
  38629. }
  38630. if miConfig.MdtrtareaAdmvs == "421182" {
  38631. client := &http.Client{}
  38632. bytesData, _ := json.Marshal(data)
  38633. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38634. resp, _ := client.Do(req)
  38635. defer resp.Body.Close()
  38636. body, ioErr := ioutil.ReadAll(resp.Body)
  38637. if ioErr != nil {
  38638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38640. return
  38641. }
  38642. var respJSON map[string]interface{}
  38643. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38646. return
  38647. }
  38648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38649. userJSONBytes, _ := json.Marshal(respJSON)
  38650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38651. utils.ErrorLog("解析失败:%v", err)
  38652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38653. return
  38654. }
  38655. }
  38656. if res.Infcode == 0 {
  38657. c.ServeSuccessJSON(map[string]interface{}{
  38658. "msg": "发起成功",
  38659. })
  38660. } else {
  38661. c.ServeSuccessJSON(map[string]interface{}{
  38662. "failed_code": -10,
  38663. "msg": res.ErrMsg,
  38664. })
  38665. }
  38666. }
  38667. }
  38668. // 5.11.1.1【5262】结算信息按时间段查询
  38669. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38670. admin_user_id, _ := c.GetInt64("admin_user_id")
  38671. adminUser := c.GetAdminUserInfo()
  38672. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38673. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38674. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38675. var res Result5262
  38676. if config.IsOpen == 1 {
  38677. if miConfig.MdtrtareaAdmvs == "421300" {
  38678. data := make(map[string]interface{})
  38679. data["bps"] = bp
  38680. data["org_name"] = miConfig.OrgName
  38681. data["doctor"] = role.UserName
  38682. data["fixmedins_code"] = miConfig.Code
  38683. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38684. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38685. data["page"] = strconv.FormatInt(page, 10)
  38686. data["limit"] = strconv.FormatInt(limit, 10)
  38687. fmt.Println(data)
  38688. client := &http.Client{}
  38689. bytesData, _ := json.Marshal(data)
  38690. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38691. resp, _ := client.Do(req)
  38692. defer resp.Body.Close()
  38693. body, ioErr := ioutil.ReadAll(resp.Body)
  38694. if ioErr != nil {
  38695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38697. return
  38698. }
  38699. var respJSON map[string]interface{}
  38700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38703. return
  38704. }
  38705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38706. userJSONBytes, _ := json.Marshal(respJSON)
  38707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38708. utils.ErrorLog("解析失败:%v", err)
  38709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38710. return
  38711. }
  38712. }
  38713. if miConfig.MdtrtareaAdmvs == "420200" {
  38714. data := make(map[string]interface{})
  38715. data["bps"] = bp
  38716. data["org_name"] = miConfig.OrgName
  38717. data["doctor"] = role.UserName
  38718. data["fixmedins_code"] = miConfig.Code
  38719. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38720. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38721. data["page"] = strconv.FormatInt(page, 10)
  38722. data["limit"] = strconv.FormatInt(limit, 10)
  38723. fmt.Println(data)
  38724. client := &http.Client{}
  38725. bytesData, _ := json.Marshal(data)
  38726. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38727. resp, _ := client.Do(req)
  38728. defer resp.Body.Close()
  38729. body, ioErr := ioutil.ReadAll(resp.Body)
  38730. if ioErr != nil {
  38731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38733. return
  38734. }
  38735. var respJSON map[string]interface{}
  38736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38739. return
  38740. }
  38741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38742. userJSONBytes, _ := json.Marshal(respJSON)
  38743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38744. utils.ErrorLog("解析失败:%v", err)
  38745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38746. return
  38747. }
  38748. }
  38749. if miConfig.MdtrtareaAdmvs == "421182" {
  38750. data := make(map[string]interface{})
  38751. data["bps"] = bp
  38752. data["org_name"] = miConfig.OrgName
  38753. data["doctor"] = role.UserName
  38754. data["fixmedins_code"] = miConfig.Code
  38755. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38756. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38757. data["page"] = strconv.FormatInt(page, 10)
  38758. data["limit"] = strconv.FormatInt(limit, 10)
  38759. fmt.Println(data)
  38760. client := &http.Client{}
  38761. bytesData, _ := json.Marshal(data)
  38762. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38763. resp, _ := client.Do(req)
  38764. defer resp.Body.Close()
  38765. body, ioErr := ioutil.ReadAll(resp.Body)
  38766. if ioErr != nil {
  38767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38769. return
  38770. }
  38771. var respJSON map[string]interface{}
  38772. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38775. return
  38776. }
  38777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38778. userJSONBytes, _ := json.Marshal(respJSON)
  38779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38780. utils.ErrorLog("解析失败:%v", err)
  38781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38782. return
  38783. }
  38784. }
  38785. if miConfig.MdtrtareaAdmvs == "420902" {
  38786. data := make(map[string]interface{})
  38787. data["bps"] = bp
  38788. data["org_name"] = miConfig.OrgName
  38789. data["doctor"] = role.UserName
  38790. data["fixmedins_code"] = miConfig.Code
  38791. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38792. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38793. data["page"] = strconv.FormatInt(page, 10)
  38794. data["limit"] = strconv.FormatInt(limit, 10)
  38795. fmt.Println(data)
  38796. client := &http.Client{}
  38797. bytesData, _ := json.Marshal(data)
  38798. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38799. resp, _ := client.Do(req)
  38800. defer resp.Body.Close()
  38801. body, ioErr := ioutil.ReadAll(resp.Body)
  38802. if ioErr != nil {
  38803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38805. return
  38806. }
  38807. var respJSON map[string]interface{}
  38808. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38811. return
  38812. }
  38813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38814. userJSONBytes, _ := json.Marshal(respJSON)
  38815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38816. utils.ErrorLog("解析失败:%v", err)
  38817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38818. return
  38819. }
  38820. }
  38821. if res.Infcode == 0 {
  38822. c.ServeSuccessJSON(map[string]interface{}{
  38823. "order": res.Output.Result,
  38824. "total": res.Output.PageInfo.RecordCounts,
  38825. })
  38826. } else {
  38827. c.ServeSuccessJSON(map[string]interface{}{
  38828. "failed_code": -10,
  38829. "msg": res.ErrMsg,
  38830. })
  38831. }
  38832. }
  38833. }
  38834. // 5.11.1.2【5267】异地结算信息时间段查询
  38835. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38836. admin_user_id, _ := c.GetInt64("admin_user_id")
  38837. adminUser := c.GetAdminUserInfo()
  38838. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38839. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38840. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38841. var res Result5267
  38842. if config.IsOpen == 1 {
  38843. if miConfig.MdtrtareaAdmvs == "421300" {
  38844. data := make(map[string]interface{})
  38845. data["bps"] = bp
  38846. data["org_name"] = miConfig.OrgName
  38847. data["doctor"] = role.UserName
  38848. data["fixmedins_code"] = miConfig.Code
  38849. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38850. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38851. data["page"] = page
  38852. data["limit"] = limit
  38853. fmt.Println(data)
  38854. client := &http.Client{}
  38855. bytesData, _ := json.Marshal(data)
  38856. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38857. resp, _ := client.Do(req)
  38858. defer resp.Body.Close()
  38859. body, ioErr := ioutil.ReadAll(resp.Body)
  38860. if ioErr != nil {
  38861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38863. return
  38864. }
  38865. var respJSON map[string]interface{}
  38866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38869. return
  38870. }
  38871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38872. userJSONBytes, _ := json.Marshal(respJSON)
  38873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38874. utils.ErrorLog("解析失败:%v", err)
  38875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38876. return
  38877. }
  38878. }
  38879. if miConfig.MdtrtareaAdmvs == "420200" {
  38880. data := make(map[string]interface{})
  38881. data["bps"] = bp
  38882. data["org_name"] = miConfig.OrgName
  38883. data["doctor"] = role.UserName
  38884. data["fixmedins_code"] = miConfig.Code
  38885. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38886. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38887. data["page"] = page
  38888. data["limit"] = limit
  38889. fmt.Println(data)
  38890. client := &http.Client{}
  38891. bytesData, _ := json.Marshal(data)
  38892. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38893. resp, _ := client.Do(req)
  38894. defer resp.Body.Close()
  38895. body, ioErr := ioutil.ReadAll(resp.Body)
  38896. if ioErr != nil {
  38897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38899. return
  38900. }
  38901. var respJSON map[string]interface{}
  38902. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38905. return
  38906. }
  38907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38908. userJSONBytes, _ := json.Marshal(respJSON)
  38909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38910. utils.ErrorLog("解析失败:%v", err)
  38911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38912. return
  38913. }
  38914. }
  38915. if miConfig.MdtrtareaAdmvs == "421182" {
  38916. data := make(map[string]interface{})
  38917. data["bps"] = bp
  38918. data["org_name"] = miConfig.OrgName
  38919. data["doctor"] = role.UserName
  38920. data["fixmedins_code"] = miConfig.Code
  38921. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38922. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38923. data["page"] = page
  38924. data["limit"] = limit
  38925. fmt.Println(data)
  38926. client := &http.Client{}
  38927. bytesData, _ := json.Marshal(data)
  38928. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38929. resp, _ := client.Do(req)
  38930. defer resp.Body.Close()
  38931. body, ioErr := ioutil.ReadAll(resp.Body)
  38932. if ioErr != nil {
  38933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38935. return
  38936. }
  38937. var respJSON map[string]interface{}
  38938. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38941. return
  38942. }
  38943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38944. userJSONBytes, _ := json.Marshal(respJSON)
  38945. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38946. utils.ErrorLog("解析失败:%v", err)
  38947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38948. return
  38949. }
  38950. }
  38951. if res.Infcode == 0 {
  38952. c.ServeSuccessJSON(map[string]interface{}{
  38953. "order": res.Output.Result,
  38954. "total": res.Output.PageInfo.RecordCounts,
  38955. })
  38956. } else {
  38957. c.ServeSuccessJSON(map[string]interface{}{
  38958. "failed_code": -10,
  38959. "msg": res.ErrMsg,
  38960. })
  38961. }
  38962. }
  38963. }
  38964. func (c *HisApiController) Post3501() {
  38965. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38966. data := make(map[string]interface{})
  38967. var struct3501s []models.Struct3501
  38968. var struct3501 models.Struct3501
  38969. struct3501.OrgName = miConfig.OrgName
  38970. struct3501.AccessKey = miConfig.AccessKey
  38971. struct3501.RequestUrl = miConfig.Url
  38972. struct3501.SecretKey = miConfig.SecretKey
  38973. struct3501.ManuDate = "2022-08-17"
  38974. struct3501.FixmedinsBchno = ""
  38975. struct3501.ManuLotnum = ""
  38976. struct3501.RxFlag = "0"
  38977. struct3501.ExpyEnd = "2022-08-17"
  38978. struct3501.Invdate = "2022-08-17"
  38979. struct3501.InvCnt = "20.25"
  38980. struct3501.Memo = ""
  38981. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38982. struct3501.FixmedinsHilistId = miConfig.Code
  38983. struct3501.FixmedinsHilistName = miConfig.OrgName
  38984. struct3501s = append(struct3501s, struct3501)
  38985. data["struct_3501s"] = struct3501s
  38986. client := &http.Client{}
  38987. bytesData, _ := json.Marshal(data)
  38988. var req *http.Request
  38989. if miConfig.MdtrtareaAdmvs == "320921" {
  38990. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38991. } else {
  38992. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38993. }
  38994. resp, _ := client.Do(req)
  38995. defer resp.Body.Close()
  38996. body, ioErr := ioutil.ReadAll(resp.Body)
  38997. if ioErr != nil {
  38998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39000. return
  39001. }
  39002. var respJSON map[string]interface{}
  39003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39006. return
  39007. }
  39008. var res ResultSix
  39009. var resSix10265 ResultSix10265 //1101结果
  39010. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39011. result, _ := json.Marshal(respJSON)
  39012. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39013. utils.ErrorLog("解析失败:%v", err)
  39014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39015. return
  39016. }
  39017. res.InfRefmsgid = resSix10265.InfRefmsgid
  39018. res.Output = resSix10265.Output
  39019. res.ErrMsg = resSix10265.ErrMsg
  39020. res.Cainfo = resSix10265.Cainfo
  39021. res.WarnMsg = resSix10265.WarnMsg
  39022. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39023. res.Infcode = infocode
  39024. if infocode == 0 {
  39025. c.ServeSuccessJSON(map[string]interface{}{
  39026. "msg": "上传成功",
  39027. })
  39028. return
  39029. } else {
  39030. c.ServeSuccessJSON(map[string]interface{}{
  39031. "failed_code": -10,
  39032. "msg": res.ErrMsg,
  39033. })
  39034. return
  39035. }
  39036. }
  39037. func (c *HisApiController) Post3502() {
  39038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39039. data := make(map[string]interface{})
  39040. var struct3502s []models.Struct3502
  39041. var struct3502 models.Struct3502
  39042. struct3502.OrgName = miConfig.OrgName
  39043. struct3502.AccessKey = miConfig.AccessKey
  39044. struct3502.RequestUrl = miConfig.Url
  39045. struct3502.SecretKey = miConfig.SecretKey
  39046. struct3502.ManuDate = "2022-08-15"
  39047. struct3502.FixmedinsBchno = ""
  39048. struct3502.ManuLotnum = ""
  39049. struct3502.RxFlag = "0"
  39050. struct3502.ExpyEnd = "2022-08-15"
  39051. struct3502.Invdate = "2022-08-15"
  39052. struct3502.InvCnt = "20.25"
  39053. struct3502.Memo = ""
  39054. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39055. struct3502.FixmedinsHilistId = miConfig.Code
  39056. struct3502.FixmedinsHilistName = miConfig.OrgName
  39057. struct3502s = append(struct3502s, struct3502)
  39058. data["struct_3502s"] = struct3502s
  39059. client := &http.Client{}
  39060. bytesData, _ := json.Marshal(data)
  39061. var req *http.Request
  39062. if miConfig.MdtrtareaAdmvs == "320921" {
  39063. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39064. } else {
  39065. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39066. }
  39067. resp, _ := client.Do(req)
  39068. defer resp.Body.Close()
  39069. body, ioErr := ioutil.ReadAll(resp.Body)
  39070. if ioErr != nil {
  39071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39073. return
  39074. }
  39075. var respJSON map[string]interface{}
  39076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39079. return
  39080. }
  39081. var res ResultSix
  39082. var resSix10265 ResultSix10265 //1101结果
  39083. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39084. result, _ := json.Marshal(respJSON)
  39085. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39086. utils.ErrorLog("解析失败:%v", err)
  39087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39088. return
  39089. }
  39090. res.InfRefmsgid = resSix10265.InfRefmsgid
  39091. res.Output = resSix10265.Output
  39092. res.ErrMsg = resSix10265.ErrMsg
  39093. res.Cainfo = resSix10265.Cainfo
  39094. res.WarnMsg = resSix10265.WarnMsg
  39095. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39096. res.Infcode = infocode
  39097. if infocode == 0 {
  39098. c.ServeSuccessJSON(map[string]interface{}{
  39099. "msg": "上传成功",
  39100. })
  39101. return
  39102. } else {
  39103. c.ServeSuccessJSON(map[string]interface{}{
  39104. "failed_code": -10,
  39105. "msg": res.ErrMsg,
  39106. })
  39107. return
  39108. }
  39109. }
  39110. func (c *HisApiController) Post3503() {
  39111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39112. data := make(map[string]interface{})
  39113. var struct3501s []models.Struct3501
  39114. var struct3501 models.Struct3501
  39115. struct3501.OrgName = miConfig.OrgName
  39116. struct3501.AccessKey = miConfig.AccessKey
  39117. struct3501.RequestUrl = miConfig.Url
  39118. struct3501.SecretKey = miConfig.SecretKey
  39119. struct3501.ManuDate = "2022-08-15"
  39120. struct3501.FixmedinsBchno = ""
  39121. struct3501.ManuLotnum = ""
  39122. struct3501.RxFlag = "0"
  39123. struct3501.ExpyEnd = "2022-08-15"
  39124. struct3501.Invdate = "2022-08-15"
  39125. struct3501.InvCnt = "20.25"
  39126. struct3501.Memo = ""
  39127. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39128. struct3501.FixmedinsHilistId = miConfig.Code
  39129. struct3501.FixmedinsHilistName = miConfig.OrgName
  39130. struct3501s = append(struct3501s, struct3501)
  39131. data["struct_3501s"] = struct3501s
  39132. client := &http.Client{}
  39133. bytesData, _ := json.Marshal(data)
  39134. var req *http.Request
  39135. if miConfig.MdtrtareaAdmvs == "320921" {
  39136. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39137. } else {
  39138. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39139. }
  39140. resp, _ := client.Do(req)
  39141. defer resp.Body.Close()
  39142. body, ioErr := ioutil.ReadAll(resp.Body)
  39143. if ioErr != nil {
  39144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39146. return
  39147. }
  39148. var respJSON map[string]interface{}
  39149. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39152. return
  39153. }
  39154. var res ResultSix
  39155. var resSix10265 ResultSix10265 //1101结果
  39156. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39157. result, _ := json.Marshal(respJSON)
  39158. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39159. utils.ErrorLog("解析失败:%v", err)
  39160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39161. return
  39162. }
  39163. res.InfRefmsgid = resSix10265.InfRefmsgid
  39164. res.Output = resSix10265.Output
  39165. res.ErrMsg = resSix10265.ErrMsg
  39166. res.Cainfo = resSix10265.Cainfo
  39167. res.WarnMsg = resSix10265.WarnMsg
  39168. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39169. res.Infcode = infocode
  39170. if infocode == 0 {
  39171. c.ServeSuccessJSON(map[string]interface{}{
  39172. "msg": "上传成功",
  39173. })
  39174. return
  39175. } else {
  39176. c.ServeSuccessJSON(map[string]interface{}{
  39177. "failed_code": -10,
  39178. "msg": res.ErrMsg,
  39179. })
  39180. return
  39181. }
  39182. }
  39183. func (c *HisApiController) Post3504() {
  39184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39185. data := make(map[string]interface{})
  39186. var struct3501s []models.Struct3501
  39187. var struct3501 models.Struct3501
  39188. struct3501.OrgName = miConfig.OrgName
  39189. struct3501.AccessKey = miConfig.AccessKey
  39190. struct3501.RequestUrl = miConfig.Url
  39191. struct3501.SecretKey = miConfig.SecretKey
  39192. struct3501.ManuDate = "2022-08-15"
  39193. struct3501.FixmedinsBchno = ""
  39194. struct3501.ManuLotnum = ""
  39195. struct3501.RxFlag = "0"
  39196. struct3501.ExpyEnd = "2022-08-15"
  39197. struct3501.Invdate = "2022-08-15"
  39198. struct3501.InvCnt = "20.25"
  39199. struct3501.Memo = ""
  39200. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39201. struct3501.FixmedinsHilistId = miConfig.Code
  39202. struct3501.FixmedinsHilistName = miConfig.OrgName
  39203. struct3501s = append(struct3501s, struct3501)
  39204. data["struct_3501s"] = struct3501s
  39205. client := &http.Client{}
  39206. bytesData, _ := json.Marshal(data)
  39207. var req *http.Request
  39208. if miConfig.MdtrtareaAdmvs == "320921" {
  39209. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39210. } else {
  39211. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39212. }
  39213. resp, _ := client.Do(req)
  39214. defer resp.Body.Close()
  39215. body, ioErr := ioutil.ReadAll(resp.Body)
  39216. if ioErr != nil {
  39217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39219. return
  39220. }
  39221. var respJSON map[string]interface{}
  39222. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39225. return
  39226. }
  39227. var res ResultSix
  39228. var resSix10265 ResultSix10265 //1101结果
  39229. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39230. result, _ := json.Marshal(respJSON)
  39231. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39232. utils.ErrorLog("解析失败:%v", err)
  39233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39234. return
  39235. }
  39236. res.InfRefmsgid = resSix10265.InfRefmsgid
  39237. res.Output = resSix10265.Output
  39238. res.ErrMsg = resSix10265.ErrMsg
  39239. res.Cainfo = resSix10265.Cainfo
  39240. res.WarnMsg = resSix10265.WarnMsg
  39241. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39242. res.Infcode = infocode
  39243. if infocode == 0 {
  39244. c.ServeSuccessJSON(map[string]interface{}{
  39245. "msg": "上传成功",
  39246. })
  39247. return
  39248. } else {
  39249. c.ServeSuccessJSON(map[string]interface{}{
  39250. "failed_code": -10,
  39251. "msg": res.ErrMsg,
  39252. })
  39253. return
  39254. }
  39255. }
  39256. func (c *HisApiController) Post3505() {
  39257. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39258. data := make(map[string]interface{})
  39259. var struct3501s []models.Struct3501
  39260. var struct3501 models.Struct3501
  39261. struct3501.OrgName = miConfig.OrgName
  39262. struct3501.AccessKey = miConfig.AccessKey
  39263. struct3501.RequestUrl = miConfig.Url
  39264. struct3501.SecretKey = miConfig.SecretKey
  39265. struct3501.ManuDate = "2022-08-15"
  39266. struct3501.FixmedinsBchno = ""
  39267. struct3501.ManuLotnum = ""
  39268. struct3501.RxFlag = "0"
  39269. struct3501.ExpyEnd = "2022-08-15"
  39270. struct3501.Invdate = "2022-08-15"
  39271. struct3501.InvCnt = "20.25"
  39272. struct3501.Memo = ""
  39273. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39274. struct3501.FixmedinsHilistId = miConfig.Code
  39275. struct3501.FixmedinsHilistName = miConfig.OrgName
  39276. struct3501s = append(struct3501s, struct3501)
  39277. data["struct_3501s"] = struct3501s
  39278. client := &http.Client{}
  39279. bytesData, _ := json.Marshal(data)
  39280. var req *http.Request
  39281. if miConfig.MdtrtareaAdmvs == "320921" {
  39282. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39283. } else {
  39284. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39285. }
  39286. resp, _ := client.Do(req)
  39287. defer resp.Body.Close()
  39288. body, ioErr := ioutil.ReadAll(resp.Body)
  39289. if ioErr != nil {
  39290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39292. return
  39293. }
  39294. var respJSON map[string]interface{}
  39295. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39298. return
  39299. }
  39300. var res ResultSix
  39301. var resSix10265 ResultSix10265 //1101结果
  39302. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39303. result, _ := json.Marshal(respJSON)
  39304. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39305. utils.ErrorLog("解析失败:%v", err)
  39306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39307. return
  39308. }
  39309. res.InfRefmsgid = resSix10265.InfRefmsgid
  39310. res.Output = resSix10265.Output
  39311. res.ErrMsg = resSix10265.ErrMsg
  39312. res.Cainfo = resSix10265.Cainfo
  39313. res.WarnMsg = resSix10265.WarnMsg
  39314. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39315. res.Infcode = infocode
  39316. if infocode == 0 {
  39317. c.ServeSuccessJSON(map[string]interface{}{
  39318. "msg": "上传成功",
  39319. })
  39320. return
  39321. } else {
  39322. c.ServeSuccessJSON(map[string]interface{}{
  39323. "failed_code": -10,
  39324. "msg": res.ErrMsg,
  39325. })
  39326. return
  39327. }
  39328. }
  39329. func (c *HisApiController) Post3506() {
  39330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39331. data := make(map[string]interface{})
  39332. var struct3501s []models.Struct3501
  39333. var struct3501 models.Struct3501
  39334. struct3501.OrgName = miConfig.OrgName
  39335. struct3501.AccessKey = miConfig.AccessKey
  39336. struct3501.RequestUrl = miConfig.Url
  39337. struct3501.SecretKey = miConfig.SecretKey
  39338. struct3501.ManuDate = "2022-08-15"
  39339. struct3501.FixmedinsBchno = ""
  39340. struct3501.ManuLotnum = ""
  39341. struct3501.RxFlag = "0"
  39342. struct3501.ExpyEnd = "2022-08-15"
  39343. struct3501.Invdate = "2022-08-15"
  39344. struct3501.InvCnt = "20.25"
  39345. struct3501.Memo = ""
  39346. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39347. struct3501.FixmedinsHilistId = miConfig.Code
  39348. struct3501.FixmedinsHilistName = miConfig.OrgName
  39349. struct3501s = append(struct3501s, struct3501)
  39350. data["struct_3501s"] = struct3501s
  39351. client := &http.Client{}
  39352. bytesData, _ := json.Marshal(data)
  39353. var req *http.Request
  39354. if miConfig.MdtrtareaAdmvs == "320921" {
  39355. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39356. } else {
  39357. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39358. }
  39359. resp, _ := client.Do(req)
  39360. defer resp.Body.Close()
  39361. body, ioErr := ioutil.ReadAll(resp.Body)
  39362. if ioErr != nil {
  39363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39365. return
  39366. }
  39367. var respJSON map[string]interface{}
  39368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39371. return
  39372. }
  39373. var res ResultSix
  39374. var resSix10265 ResultSix10265 //1101结果
  39375. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39376. result, _ := json.Marshal(respJSON)
  39377. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39378. utils.ErrorLog("解析失败:%v", err)
  39379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39380. return
  39381. }
  39382. res.InfRefmsgid = resSix10265.InfRefmsgid
  39383. res.Output = resSix10265.Output
  39384. res.ErrMsg = resSix10265.ErrMsg
  39385. res.Cainfo = resSix10265.Cainfo
  39386. res.WarnMsg = resSix10265.WarnMsg
  39387. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39388. res.Infcode = infocode
  39389. if infocode == 0 {
  39390. c.ServeSuccessJSON(map[string]interface{}{
  39391. "msg": "上传成功",
  39392. })
  39393. return
  39394. } else {
  39395. c.ServeSuccessJSON(map[string]interface{}{
  39396. "failed_code": -10,
  39397. "msg": res.ErrMsg,
  39398. })
  39399. return
  39400. }
  39401. }
  39402. func (c *HisApiController) Post3507() {
  39403. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39404. data := make(map[string]interface{})
  39405. var struct3501s []models.Struct3501
  39406. var struct3501 models.Struct3501
  39407. struct3501.OrgName = miConfig.OrgName
  39408. struct3501.AccessKey = miConfig.AccessKey
  39409. struct3501.RequestUrl = miConfig.Url
  39410. struct3501.SecretKey = miConfig.SecretKey
  39411. struct3501.ManuDate = "2022-08-15"
  39412. struct3501.FixmedinsBchno = ""
  39413. struct3501.ManuLotnum = ""
  39414. struct3501.RxFlag = "0"
  39415. struct3501.ExpyEnd = "2022-08-15"
  39416. struct3501.Invdate = "2022-08-15"
  39417. struct3501.InvCnt = "20.25"
  39418. struct3501.Memo = ""
  39419. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39420. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39421. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39422. struct3501s = append(struct3501s, struct3501)
  39423. data["struct_3501s"] = struct3501s
  39424. client := &http.Client{}
  39425. bytesData, _ := json.Marshal(data)
  39426. var req *http.Request
  39427. if miConfig.MdtrtareaAdmvs == "320921" {
  39428. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39429. } else {
  39430. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39431. }
  39432. resp, _ := client.Do(req)
  39433. defer resp.Body.Close()
  39434. body, ioErr := ioutil.ReadAll(resp.Body)
  39435. if ioErr != nil {
  39436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39438. return
  39439. }
  39440. var respJSON map[string]interface{}
  39441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39444. return
  39445. }
  39446. var res ResultSix
  39447. var resSix10265 ResultSix10265 //1101结果
  39448. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39449. result, _ := json.Marshal(respJSON)
  39450. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39451. utils.ErrorLog("解析失败:%v", err)
  39452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39453. return
  39454. }
  39455. res.InfRefmsgid = resSix10265.InfRefmsgid
  39456. res.Output = resSix10265.Output
  39457. res.ErrMsg = resSix10265.ErrMsg
  39458. res.Cainfo = resSix10265.Cainfo
  39459. res.WarnMsg = resSix10265.WarnMsg
  39460. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39461. res.Infcode = infocode
  39462. if infocode == 0 {
  39463. c.ServeSuccessJSON(map[string]interface{}{
  39464. "msg": "上传成功",
  39465. })
  39466. return
  39467. } else {
  39468. c.ServeSuccessJSON(map[string]interface{}{
  39469. "failed_code": -10,
  39470. "msg": res.ErrMsg,
  39471. })
  39472. return
  39473. }
  39474. }
  39475. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39476. // WebSocket服务器地址
  39477. serverURL := "ws://127.0.0.1:8899"
  39478. // 解析WebSocket服务器地址
  39479. u, err := url.Parse(serverURL)
  39480. if err != nil {
  39481. }
  39482. // 建立WebSocket连接
  39483. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39484. if err != nil {
  39485. }
  39486. defer conn.Close()
  39487. input2 := make(map[string]interface{})
  39488. input := make(map[string]interface{})
  39489. inputData := make(map[string]interface{})
  39490. inputData["orgId"] = code
  39491. inputData["businessType"] = "01101"
  39492. inputData["operatorId"] = operator_id
  39493. inputData["operatorName"] = operator_name
  39494. inputData["officeId"] = "001"
  39495. inputData["officeName"] = "血透室"
  39496. inputData["deviceType"] = ""
  39497. input["data"] = inputData
  39498. input["orgId"] = code
  39499. input["transType"] = "ec.query"
  39500. //if md == ""
  39501. if md[:4] == "4403" {
  39502. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39503. } else if md[:4] == "4401" {
  39504. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39505. } else {
  39506. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39507. }
  39508. input2["indata"] = input
  39509. fmt.Println(input2)
  39510. bytesData, _ := json.Marshal(input2)
  39511. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39512. if err != nil {
  39513. fmt.Println(err)
  39514. }
  39515. // 接收消息
  39516. _, receivedMessage, err := conn.ReadMessage()
  39517. if err != nil {
  39518. fmt.Println(err)
  39519. }
  39520. return "", string(receivedMessage)
  39521. }
  39522. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39523. // WebSocket服务器地址
  39524. serverURL := "ws://127.0.0.1:8899"
  39525. // 解析WebSocket服务器地址
  39526. u, err := url.Parse(serverURL)
  39527. if err != nil {
  39528. }
  39529. // 建立WebSocket连接
  39530. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39531. if err != nil {
  39532. }
  39533. defer conn.Close()
  39534. input2 := make(map[string]interface{})
  39535. input := make(map[string]interface{})
  39536. inputData := make(map[string]interface{})
  39537. inputData["orgId"] = code
  39538. inputData["businessType"] = "01101"
  39539. inputData["operatorId"] = operator_id
  39540. inputData["operatorName"] = operator_name
  39541. inputData["officeId"] = "001"
  39542. inputData["officeName"] = "血透室"
  39543. inputData["deviceType"] = ""
  39544. input["data"] = inputData
  39545. input["orgId"] = code
  39546. input["transType"] = "ec.query"
  39547. //if md == ""
  39548. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39549. input2["indata"] = input
  39550. fmt.Println(input2)
  39551. bytesData, _ := json.Marshal(input2)
  39552. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39553. if err != nil {
  39554. fmt.Println(err)
  39555. }
  39556. // 接收消息
  39557. _, receivedMessage, err := conn.ReadMessage()
  39558. if err != nil {
  39559. fmt.Println(err)
  39560. }
  39561. return "", string(receivedMessage)
  39562. }
  39563. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39564. // WebSocket服务器地址
  39565. serverURL := "ws://127.0.0.1:8899"
  39566. // 解析WebSocket服务器地址
  39567. u, err := url.Parse(serverURL)
  39568. if err != nil {
  39569. }
  39570. // 建立WebSocket连接
  39571. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39572. if err != nil {
  39573. }
  39574. defer conn.Close()
  39575. input2 := make(map[string]interface{})
  39576. input := make(map[string]interface{})
  39577. inputData := make(map[string]interface{})
  39578. inputData["orgId"] = code
  39579. inputData["businessType"] = "01301"
  39580. inputData["operatorId"] = operator_id
  39581. inputData["operatorName"] = operator_name
  39582. inputData["officeId"] = "001"
  39583. inputData["officeName"] = "血透室"
  39584. inputData["deviceType"] = ""
  39585. input["data"] = inputData
  39586. input["orgId"] = code
  39587. input["transType"] = "ec.query"
  39588. //if md == ""
  39589. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39590. input2["indata"] = input
  39591. fmt.Println(input2)
  39592. bytesData, _ := json.Marshal(input2)
  39593. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39594. if err != nil {
  39595. fmt.Println(err)
  39596. }
  39597. // 接收消息
  39598. _, receivedMessage, err := conn.ReadMessage()
  39599. if err != nil {
  39600. fmt.Println(err)
  39601. }
  39602. return "", string(receivedMessage)
  39603. }
  39604. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39605. // WebSocket服务器地址
  39606. serverURL := "ws://127.0.0.1:8899"
  39607. // 解析WebSocket服务器地址
  39608. u, err := url.Parse(serverURL)
  39609. if err != nil {
  39610. }
  39611. // 建立WebSocket连接
  39612. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39613. if err != nil {
  39614. }
  39615. defer conn.Close()
  39616. input2 := make(map[string]interface{})
  39617. input := make(map[string]interface{})
  39618. inputData := make(map[string]interface{})
  39619. inputData["orgId"] = code
  39620. inputData["businessType"] = "01103"
  39621. inputData["operatorId"] = operator_id
  39622. inputData["operatorName"] = operator_name
  39623. inputData["officeId"] = "001"
  39624. inputData["officeName"] = "血透室"
  39625. inputData["deviceType"] = ""
  39626. input["data"] = inputData
  39627. input["orgId"] = code
  39628. input["transType"] = "ec.query"
  39629. //if md ==
  39630. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39631. input2["indata"] = input
  39632. fmt.Println(input2)
  39633. bytesData, _ := json.Marshal(input2)
  39634. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39635. if err != nil {
  39636. fmt.Println(err)
  39637. }
  39638. // 接收消息
  39639. _, receivedMessage, err := conn.ReadMessage()
  39640. if err != nil {
  39641. fmt.Println(err)
  39642. }
  39643. return "", string(receivedMessage)
  39644. }
  39645. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39646. // WebSocket服务器地址
  39647. serverURL := "ws://127.0.0.1:8899"
  39648. // 解析WebSocket服务器地址
  39649. u, err := url.Parse(serverURL)
  39650. if err != nil {
  39651. }
  39652. // 建立WebSocket连接
  39653. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39654. if err != nil {
  39655. }
  39656. defer conn.Close()
  39657. input2 := make(map[string]interface{})
  39658. input := make(map[string]interface{})
  39659. inputData := make(map[string]interface{})
  39660. inputData["orgId"] = code
  39661. inputData["businessType"] = "01101"
  39662. inputData["operatorId"] = operator_id
  39663. inputData["operatorName"] = operator_name
  39664. inputData["officeId"] = "001"
  39665. inputData["officeName"] = "血透室"
  39666. inputData["deviceType"] = ""
  39667. input["data"] = inputData
  39668. input["orgId"] = code
  39669. input["transType"] = "ec.query"
  39670. //if md == ""
  39671. if md[:4] == "4403" {
  39672. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39673. } else if md[:4] == "4401" {
  39674. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39675. } else {
  39676. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39677. }
  39678. input2["indata"] = input
  39679. fmt.Println(input2)
  39680. bytesData, _ := json.Marshal(input2)
  39681. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39682. if err != nil {
  39683. fmt.Println(err)
  39684. }
  39685. // 接收消息
  39686. _, receivedMessage, err := conn.ReadMessage()
  39687. if err != nil {
  39688. fmt.Println(err)
  39689. }
  39690. return "", string(receivedMessage)
  39691. }
  39692. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39693. // WebSocket服务器地址
  39694. serverURL := "ws://127.0.0.1:8899"
  39695. // 解析WebSocket服务器地址
  39696. u, err := url.Parse(serverURL)
  39697. if err != nil {
  39698. }
  39699. // 建立WebSocket连接
  39700. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39701. if err != nil {
  39702. }
  39703. defer conn.Close()
  39704. input2 := make(map[string]interface{})
  39705. input := make(map[string]interface{})
  39706. inputData := make(map[string]interface{})
  39707. inputData["orgId"] = code
  39708. inputData["businessType"] = "01301"
  39709. inputData["operatorId"] = operator_id
  39710. inputData["operatorName"] = operator_name
  39711. inputData["officeId"] = "001"
  39712. inputData["officeName"] = "血透室"
  39713. inputData["deviceType"] = ""
  39714. input["data"] = inputData
  39715. input["orgId"] = code
  39716. input["transType"] = "ec.query"
  39717. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39718. input2["indata"] = input
  39719. bytesData, _ := json.Marshal(input2)
  39720. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39721. if err != nil {
  39722. fmt.Println(err)
  39723. }
  39724. // 接收消息
  39725. _, receivedMessage, err := conn.ReadMessage()
  39726. if err != nil {
  39727. fmt.Println(err)
  39728. }
  39729. return "", string(receivedMessage)
  39730. }
  39731. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39732. newArr = make([]string, 0)
  39733. for i := 0; i < len(arr); i++ {
  39734. repeat := false
  39735. for j := i + 1; j < len(arr); j++ {
  39736. if arr[i] == arr[j] {
  39737. repeat = true
  39738. break
  39739. }
  39740. }
  39741. if !repeat {
  39742. newArr = append(newArr, arr[i])
  39743. }
  39744. }
  39745. return
  39746. }
  39747. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39748. if len(idNumber) != 18 {
  39749. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39750. }
  39751. // 提取出生日期
  39752. year, err := strconv.Atoi(idNumber[6:10])
  39753. if err != nil {
  39754. return "", 0, err
  39755. }
  39756. month, err := strconv.Atoi(idNumber[10:12])
  39757. if err != nil {
  39758. return "", 0, err
  39759. }
  39760. day, err := strconv.Atoi(idNumber[12:14])
  39761. if err != nil {
  39762. return "", 0, err
  39763. }
  39764. // 格式化生日字符串
  39765. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39766. birthdateFormatted := birthdate.Format("2006-01-02")
  39767. // 计算年龄
  39768. today := time.Now()
  39769. age := today.Year() - birthdate.Year()
  39770. if today.YearDay() < birthdate.YearDay() {
  39771. age--
  39772. }
  39773. return birthdateFormatted, age, nil
  39774. }
  39775. // 从身份证号码中提取出生年月日
  39776. func getBirthDateFromIDCard(idCard string) (string, error) {
  39777. // 身份证号码长度应为18位
  39778. if len(idCard) != 18 {
  39779. return "", fmt.Errorf("身份证号码长度应为18位")
  39780. }
  39781. // 提取出生日期部分 (YYYYMMDD)
  39782. birthDateStr := idCard[6:14]
  39783. // 解析出生日期
  39784. birthDate, err := time.Parse("20060102", birthDateStr)
  39785. if err != nil {
  39786. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39787. }
  39788. // 格式化出生日期为 YYYY-MM-DD
  39789. formattedDate := birthDate.Format("2006-01-02")
  39790. return formattedDate, nil
  39791. }