his_api_controller.go 1.7MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  117. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  172. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  173. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  174. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  175. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  176. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  177. }
  178. func (c *HisApiController) Get5101() {
  179. adminUser := c.GetAdminUserInfo()
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. if miConfig.MdtrtareaAdmvs == "341203" {
  184. fmt.Println(miConfig.SecretKey)
  185. var res models.Result9001Two
  186. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  188. resp, requestErr := http.Get(api)
  189. if requestErr != nil {
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. body, ioErr := ioutil.ReadAll(resp.Body)
  194. if ioErr != nil {
  195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. status := respJSON["data"].(map[string]interface{})["status"].(string)
  206. if status == "0" {
  207. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": err_msg,
  211. })
  212. return
  213. }
  214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  215. result, _ := json.Marshal(respJSON)
  216. fmt.Println("log")
  217. fmt.Println(string(result))
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. sign := models.HisSignIn{
  225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  226. SignNo: res.Output.Signinoutb.SignNo,
  227. SignTime: "",
  228. Ctime: time.Now().Unix(),
  229. Mtime: time.Now().Unix(),
  230. Status: 1,
  231. InputLog: "",
  232. OutputLog: "",
  233. FixmedinsCode: miConfig.Code,
  234. }
  235. err := service.CreateSignIn(&sign)
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "签到成功",
  239. })
  240. }
  241. } else {
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "failed_code": -10,
  244. "msg": res.ErrMsg,
  245. })
  246. return
  247. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  248. //return
  249. }
  250. } else if miConfig.MdtrtareaAdmvs == "340699" {
  251. fmt.Println(miConfig.SecretKey)
  252. var res models.Result9001Two
  253. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  255. resp, requestErr := http.Get(api)
  256. if requestErr != nil {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. body, ioErr := ioutil.ReadAll(resp.Body)
  261. if ioErr != nil {
  262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. var respJSON map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  273. if status == "0" {
  274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  275. c.ServeSuccessJSON(map[string]interface{}{
  276. "failed_code": -10,
  277. "msg": err_msg,
  278. })
  279. return
  280. }
  281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  282. result, _ := json.Marshal(respJSON)
  283. fmt.Println("log")
  284. fmt.Println(string(result))
  285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  286. utils.ErrorLog("解析失败:%v", err)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. if res.Infcode == 0 {
  291. sign := models.HisSignIn{
  292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  293. SignNo: res.Output.Signinoutb.SignNo,
  294. SignTime: "",
  295. Ctime: time.Now().Unix(),
  296. Mtime: time.Now().Unix(),
  297. Status: 1,
  298. InputLog: "",
  299. OutputLog: "",
  300. FixmedinsCode: miConfig.Code,
  301. }
  302. err := service.CreateSignIn(&sign)
  303. if err == nil {
  304. c.ServeSuccessJSON(map[string]interface{}{
  305. "msg": "查询成功",
  306. })
  307. }
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "failed_code": -10,
  311. "msg": res.ErrMsg,
  312. })
  313. return
  314. }
  315. }
  316. }
  317. func (c *HisApiController) Get5102() {
  318. adminUser := c.GetAdminUserInfo()
  319. admin_user_id, _ := c.GetInt64("admin_user_id")
  320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  322. if miConfig.MdtrtareaAdmvs == "341203" {
  323. fmt.Println(miConfig.SecretKey)
  324. var res models.Result9001Two
  325. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  327. resp, requestErr := http.Get(api)
  328. if requestErr != nil {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. body, ioErr := ioutil.ReadAll(resp.Body)
  333. if ioErr != nil {
  334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. }
  338. var respJSON map[string]interface{}
  339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  342. return
  343. }
  344. status := respJSON["data"].(map[string]interface{})["status"].(string)
  345. if status == "0" {
  346. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": err_msg,
  350. })
  351. return
  352. }
  353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  354. result, _ := json.Marshal(respJSON)
  355. fmt.Println("log")
  356. fmt.Println(string(result))
  357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  358. utils.ErrorLog("解析失败:%v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. if res.Infcode == 0 {
  363. sign := models.HisSignIn{
  364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  365. SignNo: res.Output.Signinoutb.SignNo,
  366. SignTime: "",
  367. Ctime: time.Now().Unix(),
  368. Mtime: time.Now().Unix(),
  369. Status: 1,
  370. InputLog: "",
  371. OutputLog: "",
  372. FixmedinsCode: miConfig.Code,
  373. }
  374. err := service.CreateSignIn(&sign)
  375. if err == nil {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "msg": "签到成功",
  378. })
  379. }
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. return
  386. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  387. //return
  388. }
  389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  390. fmt.Println(miConfig.SecretKey)
  391. var res models.Result9001Two
  392. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  394. resp, requestErr := http.Get(api)
  395. if requestErr != nil {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. body, ioErr := ioutil.ReadAll(resp.Body)
  400. if ioErr != nil {
  401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  412. if status == "0" {
  413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "failed_code": -10,
  416. "msg": err_msg,
  417. })
  418. return
  419. }
  420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  421. result, _ := json.Marshal(respJSON)
  422. fmt.Println("log")
  423. fmt.Println(string(result))
  424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == 0 {
  430. sign := models.HisSignIn{
  431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  432. SignNo: res.Output.Signinoutb.SignNo,
  433. SignTime: "",
  434. Ctime: time.Now().Unix(),
  435. Mtime: time.Now().Unix(),
  436. Status: 1,
  437. InputLog: "",
  438. OutputLog: "",
  439. FixmedinsCode: miConfig.Code,
  440. }
  441. err := service.CreateSignIn(&sign)
  442. if err == nil {
  443. c.ServeSuccessJSON(map[string]interface{}{
  444. "msg": "查询成功",
  445. })
  446. }
  447. } else {
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "failed_code": -10,
  450. "msg": res.ErrMsg,
  451. })
  452. return
  453. }
  454. }
  455. }
  456. func (c *HisApiController) Get3201() {
  457. adminUser := c.GetAdminUserInfo()
  458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  459. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  460. var response Response
  461. if err := json.Unmarshal([]byte(result), &response); err != nil {
  462. fmt.Println("Error decoding JSON:", err)
  463. return
  464. }
  465. }
  466. func (c *HisApiController) TestNet() {
  467. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. //return
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "成功",
  471. })
  472. }
  473. func (c *HisApiController) Get3508() {
  474. admin_user_id, _ := c.GetInt64("admin_user_id")
  475. drug_id, _ := c.GetInt64("id")
  476. start_time := c.GetString("start_time")
  477. end_time := c.GetString("end_time")
  478. adminUser := c.GetAdminUserInfo()
  479. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  481. drug, _ := service.GetDrugByID(drug_id)
  482. var struct3508 models.Struct3508
  483. struct3508.OrgName = miConfig.OrgName
  484. struct3508.FixmedinsCode = miConfig.Code
  485. struct3508.AccessKey = miConfig.AccessKey
  486. struct3508.Opter = curRoles.UserName
  487. struct3508.RequestUrl = miConfig.Url
  488. struct3508.Url = miConfig.Url
  489. struct3508.AppId = miConfig.Cainfo
  490. struct3508.AppSecret = miConfig.AppSecret
  491. struct3508.Enckey = miConfig.EncKey
  492. struct3508.SignKey = miConfig.SignKey
  493. struct3508.SecretKey = miConfig.SecretKey
  494. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  495. struct3508.Begndate = start_time
  496. struct3508.Enddate = end_time
  497. result1, result2, _ := service.FJyb3508(struct3508)
  498. saveLog(result1, result2, "3508", "3508")
  499. var res models.Result3508
  500. var respJSON2 map[string]interface{}
  501. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  504. return
  505. }
  506. userJSONBytes2, _ := json.Marshal(respJSON2)
  507. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  508. utils.ErrorLog("解析失败:%v", err)
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  510. return
  511. }
  512. if res.Infcode == -1 {
  513. c.ServeSuccessJSON(map[string]interface{}{
  514. "failed_code": -10,
  515. "msg": res.ErrMsg,
  516. })
  517. } else {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "info": res.Output,
  520. })
  521. }
  522. }
  523. func (c *HisApiController) Get3509() {
  524. admin_user_id, _ := c.GetInt64("admin_user_id")
  525. drug_id, _ := c.GetInt64("id")
  526. start_time := c.GetString("start_time")
  527. end_time := c.GetString("end_time")
  528. adminUser := c.GetAdminUserInfo()
  529. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  530. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  531. drug, _ := service.GetDrugByID(drug_id)
  532. var struct3508 models.Struct3509
  533. struct3508.OrgName = miConfig.OrgName
  534. struct3508.FixmedinsCode = miConfig.Code
  535. struct3508.AccessKey = miConfig.AccessKey
  536. struct3508.Opter = curRoles.UserName
  537. struct3508.RequestUrl = miConfig.Url
  538. struct3508.Url = miConfig.Url
  539. struct3508.AppId = miConfig.Cainfo
  540. struct3508.AppSecret = miConfig.AppSecret
  541. struct3508.Enckey = miConfig.EncKey
  542. struct3508.SignKey = miConfig.SignKey
  543. struct3508.SecretKey = miConfig.SecretKey
  544. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  545. struct3508.Begndate = start_time
  546. struct3508.Enddate = end_time
  547. result1, result2, _ := service.FJyb3509(struct3508)
  548. saveLog(result1, result2, "3509", "3509")
  549. var res models.Result3509
  550. var respJSON2 map[string]interface{}
  551. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  554. return
  555. }
  556. userJSONBytes2, _ := json.Marshal(respJSON2)
  557. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  558. utils.ErrorLog("解析失败:%v", err)
  559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  560. return
  561. }
  562. if res.Infcode == -1 {
  563. c.ServeSuccessJSON(map[string]interface{}{
  564. "failed_code": -10,
  565. "msg": res.ErrMsg,
  566. })
  567. } else {
  568. c.ServeSuccessJSON(map[string]interface{}{
  569. "info": res.Output,
  570. })
  571. }
  572. }
  573. func (c *HisApiController) Get3510() {
  574. admin_user_id, _ := c.GetInt64("admin_user_id")
  575. drug_id, _ := c.GetInt64("id")
  576. start_time := c.GetString("start_time")
  577. end_time := c.GetString("end_time")
  578. adminUser := c.GetAdminUserInfo()
  579. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  580. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  581. drug, _ := service.GetDrugByID(drug_id)
  582. var struct3508 models.Struct3510
  583. struct3508.FixmedinsCode = miConfig.Code
  584. struct3508.OrgName = miConfig.OrgName
  585. struct3508.AccessKey = miConfig.AccessKey
  586. struct3508.Opter = curRoles.UserName
  587. struct3508.RequestUrl = miConfig.Url
  588. struct3508.Url = miConfig.Url
  589. struct3508.AppId = miConfig.Cainfo
  590. struct3508.AppSecret = miConfig.AppSecret
  591. struct3508.Enckey = miConfig.EncKey
  592. struct3508.SignKey = miConfig.SignKey
  593. struct3508.SecretKey = miConfig.SecretKey
  594. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  595. struct3508.Begndate = start_time
  596. struct3508.Enddate = end_time
  597. result1, result2, _ := service.FJyb3510(struct3508)
  598. saveLog(result1, result2, "3510", "3510")
  599. var res models.Result3510
  600. var respJSON2 map[string]interface{}
  601. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  604. return
  605. }
  606. userJSONBytes2, _ := json.Marshal(respJSON2)
  607. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  608. utils.ErrorLog("解析失败:%v", err)
  609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  610. return
  611. }
  612. if res.Infcode == -1 {
  613. c.ServeSuccessJSON(map[string]interface{}{
  614. "failed_code": -10,
  615. "msg": res.ErrMsg,
  616. })
  617. } else {
  618. c.ServeSuccessJSON(map[string]interface{}{
  619. "info": res.Output,
  620. })
  621. }
  622. }
  623. func (c *HisApiController) Get3511() {
  624. admin_user_id, _ := c.GetInt64("admin_user_id")
  625. drug_id, _ := c.GetInt64("id")
  626. start_time := c.GetString("start_time")
  627. end_time := c.GetString("end_time")
  628. adminUser := c.GetAdminUserInfo()
  629. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  631. drug, _ := service.GetDrugByID(drug_id)
  632. var struct3508 models.Struct3511
  633. struct3508.FixmedinsCode = miConfig.Code
  634. struct3508.OrgName = miConfig.OrgName
  635. struct3508.AccessKey = miConfig.AccessKey
  636. struct3508.Opter = curRoles.UserName
  637. struct3508.RequestUrl = miConfig.Url
  638. struct3508.Url = miConfig.Url
  639. struct3508.AppId = miConfig.Cainfo
  640. struct3508.AppSecret = miConfig.AppSecret
  641. struct3508.Enckey = miConfig.EncKey
  642. struct3508.SignKey = miConfig.SignKey
  643. struct3508.SecretKey = miConfig.SecretKey
  644. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  645. struct3508.Begndate = start_time
  646. struct3508.Enddate = end_time
  647. result1, result2, _ := service.FJyb3511(struct3508)
  648. saveLog(result1, result2, "3511", "3511")
  649. var res models.Result3511
  650. var respJSON2 map[string]interface{}
  651. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  654. return
  655. }
  656. userJSONBytes2, _ := json.Marshal(respJSON2)
  657. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  658. utils.ErrorLog("解析失败:%v", err)
  659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  660. return
  661. }
  662. if res.Infcode == -1 {
  663. c.ServeSuccessJSON(map[string]interface{}{
  664. "failed_code": -10,
  665. "msg": res.ErrMsg,
  666. })
  667. } else {
  668. c.ServeSuccessJSON(map[string]interface{}{
  669. "info": res.Output,
  670. })
  671. }
  672. }
  673. func (c *HisApiController) Get3512() {
  674. admin_user_id, _ := c.GetInt64("admin_user_id")
  675. drug_id, _ := c.GetInt64("id")
  676. start_time := c.GetString("start_time")
  677. end_time := c.GetString("end_time")
  678. adminUser := c.GetAdminUserInfo()
  679. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  681. drug, _ := service.GetDrugByID(drug_id)
  682. var struct3508 models.Struct3512
  683. struct3508.FixmedinsCode = miConfig.Code
  684. struct3508.OrgName = miConfig.OrgName
  685. struct3508.AccessKey = miConfig.AccessKey
  686. struct3508.Opter = curRoles.UserName
  687. struct3508.RequestUrl = miConfig.Url
  688. struct3508.Url = miConfig.Url
  689. struct3508.AppId = miConfig.Cainfo
  690. struct3508.AppSecret = miConfig.AppSecret
  691. struct3508.Enckey = miConfig.EncKey
  692. struct3508.SignKey = miConfig.SignKey
  693. struct3508.SecretKey = miConfig.SecretKey
  694. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  695. struct3508.Begndate = start_time
  696. struct3508.Enddate = end_time
  697. result1, result2, _ := service.FJyb3512(struct3508)
  698. saveLog(result1, result2, "3512", "3512")
  699. var res models.Result3512
  700. var respJSON2 map[string]interface{}
  701. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. userJSONBytes2, _ := json.Marshal(respJSON2)
  707. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  708. utils.ErrorLog("解析失败:%v", err)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. return
  711. }
  712. if res.Infcode == -1 {
  713. c.ServeSuccessJSON(map[string]interface{}{
  714. "failed_code": -10,
  715. "msg": res.ErrMsg,
  716. })
  717. } else {
  718. c.ServeSuccessJSON(map[string]interface{}{
  719. "info": res.Output,
  720. })
  721. }
  722. }
  723. func (c *HisApiController) Get3513() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. drug_id, _ := c.GetInt64("id")
  726. start_time := c.GetString("start_time")
  727. end_time := c.GetString("end_time")
  728. adminUser := c.GetAdminUserInfo()
  729. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  731. drug, _ := service.GetDrugByID(drug_id)
  732. var struct3508 models.Struct3513
  733. struct3508.FixmedinsCode = miConfig.Code
  734. struct3508.OrgName = miConfig.OrgName
  735. struct3508.AccessKey = miConfig.AccessKey
  736. struct3508.Opter = curRoles.UserName
  737. struct3508.RequestUrl = miConfig.Url
  738. struct3508.Url = miConfig.Url
  739. struct3508.AppId = miConfig.Cainfo
  740. struct3508.AppSecret = miConfig.AppSecret
  741. struct3508.Enckey = miConfig.EncKey
  742. struct3508.SignKey = miConfig.SignKey
  743. struct3508.SecretKey = miConfig.SecretKey
  744. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  745. struct3508.Begndate = start_time
  746. struct3508.Enddate = end_time
  747. result1, result2, _ := service.FJyb3513(struct3508)
  748. saveLog(result1, result2, "3513", "3513")
  749. var res models.Result3513
  750. var respJSON2 map[string]interface{}
  751. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  754. return
  755. }
  756. userJSONBytes2, _ := json.Marshal(respJSON2)
  757. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  758. utils.ErrorLog("解析失败:%v", err)
  759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  760. return
  761. }
  762. if res.Infcode == -1 {
  763. c.ServeSuccessJSON(map[string]interface{}{
  764. "failed_code": -10,
  765. "msg": res.ErrMsg,
  766. })
  767. } else {
  768. c.ServeSuccessJSON(map[string]interface{}{
  769. "info": res.Output,
  770. })
  771. }
  772. }
  773. func (c *HisApiController) Get35081() {
  774. admin_user_id, _ := c.GetInt64("admin_user_id")
  775. drug_id, _ := c.GetInt64("id")
  776. //start_time := c.GetString("start_time")
  777. //end_time := c.GetString("end_time")
  778. page, _ := c.GetInt("page")
  779. adminUser := c.GetAdminUserInfo()
  780. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  782. drug, _ := service.GetDrugByID(drug_id)
  783. var struct3508 models.Struct35081
  784. struct3508.FixmedinsCode = miConfig.Code
  785. struct3508.OrgName = miConfig.OrgName
  786. struct3508.AccessKey = miConfig.AccessKey
  787. struct3508.Opter = curRoles.UserName
  788. struct3508.RequestUrl = miConfig.Url
  789. struct3508.Url = miConfig.Url
  790. struct3508.AppId = miConfig.Cainfo
  791. struct3508.AppSecret = miConfig.AppSecret
  792. struct3508.Enckey = miConfig.EncKey
  793. struct3508.SignKey = miConfig.SignKey
  794. struct3508.SecretKey = miConfig.SecretKey
  795. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  796. struct3508.PageNum = page
  797. struct3508.PageSize = 10
  798. result1, result2, _ := service.FJyb35081(struct3508)
  799. saveLog(result1, result2, "35081", "35081")
  800. var res models.Result35081
  801. var respJSON2 map[string]interface{}
  802. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  805. return
  806. }
  807. userJSONBytes2, _ := json.Marshal(respJSON2)
  808. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  809. utils.ErrorLog("解析失败:%v", err)
  810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  811. return
  812. }
  813. if res.Infcode == -1 {
  814. c.ServeSuccessJSON(map[string]interface{}{
  815. "failed_code": -10,
  816. "msg": res.ErrMsg,
  817. })
  818. } else {
  819. c.ServeSuccessJSON(map[string]interface{}{
  820. "info": res.Output,
  821. })
  822. }
  823. }
  824. func (c *HisApiController) Get35082() {
  825. admin_user_id, _ := c.GetInt64("admin_user_id")
  826. drug_id, _ := c.GetInt64("id")
  827. //start_time := c.GetString("start_time")
  828. //end_time := c.GetString("end_time")
  829. page, _ := c.GetInt("page")
  830. adminUser := c.GetAdminUserInfo()
  831. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  832. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  833. drug, _ := service.GetDrugByID(drug_id)
  834. var struct3508 models.Struct35082
  835. struct3508.FixmedinsCode = miConfig.Code
  836. struct3508.OrgName = miConfig.OrgName
  837. struct3508.AccessKey = miConfig.AccessKey
  838. struct3508.Opter = curRoles.UserName
  839. struct3508.RequestUrl = miConfig.Url
  840. struct3508.Url = miConfig.Url
  841. struct3508.AppId = miConfig.Cainfo
  842. struct3508.AppSecret = miConfig.AppSecret
  843. struct3508.Enckey = miConfig.EncKey
  844. struct3508.SignKey = miConfig.SignKey
  845. struct3508.SecretKey = miConfig.SecretKey
  846. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  847. struct3508.PageNum = page
  848. struct3508.PageSize = 10
  849. result1, result2, _ := service.FJyb35082(struct3508)
  850. saveLog(result1, result2, "35082", "35082")
  851. var res models.Result35082
  852. var respJSON2 map[string]interface{}
  853. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  856. return
  857. }
  858. userJSONBytes2, _ := json.Marshal(respJSON2)
  859. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  860. utils.ErrorLog("解析失败:%v", err)
  861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  862. return
  863. }
  864. if res.Infcode == -1 {
  865. c.ServeSuccessJSON(map[string]interface{}{
  866. "failed_code": -10,
  867. "msg": res.ErrMsg,
  868. })
  869. } else {
  870. c.ServeSuccessJSON(map[string]interface{}{
  871. "info": res.Output,
  872. })
  873. }
  874. }
  875. func (c *HisApiController) FJ3501AND3502() {
  876. ids := c.GetString("ids")
  877. admin_user_id, _ := c.GetInt64("admin_user_id")
  878. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  879. id_arr := strings.Split(ids, ",")
  880. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  881. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  882. //库盘
  883. var errs []string
  884. for _, drug := range drugs {
  885. if drug.IsPc == 0 {
  886. var res2 ResultSix
  887. var res3 ResultSix
  888. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  889. var struct3501 models.Struct3501
  890. struct3501.Code = miConfig.Code
  891. struct3501.OrgName = miConfig.OrgName
  892. struct3501.AccessKey = miConfig.AccessKey
  893. struct3501.Opter = roles.UserName
  894. struct3501.RequestUrl = miConfig.Url
  895. struct3501.Url = miConfig.Url
  896. struct3501.AppId = miConfig.Cainfo
  897. struct3501.AppSecret = miConfig.AppSecret
  898. struct3501.Enckey = miConfig.EncKey
  899. struct3501.SignKey = miConfig.SignKey
  900. struct3501.SecretKey = miConfig.SecretKey
  901. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  902. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  903. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  904. struct3501.RxFlag = "1"
  905. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  906. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  907. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  908. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  909. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  910. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  911. struct3501.FixmedinsBchno = number
  912. struct3501.DrugTracCodg = drug.DrugCode
  913. memo := make(map[string]interface{})
  914. memo["pric"] = drug.Price
  915. bytesData, _ := json.Marshal(memo)
  916. struct3501.Memo = string(bytesData)
  917. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  918. result1, result2, _ := service.FJyb3501(struct3501)
  919. saveLog(result1, result2, "3501", "3501")
  920. //saveLog(result, requestLog, "2201", "挂号")
  921. var respJSON2 map[string]interface{}
  922. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  925. return
  926. }
  927. userJSONBytes2, _ := json.Marshal(respJSON2)
  928. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  929. utils.ErrorLog("解析失败:%v", err)
  930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  931. return
  932. }
  933. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  934. data := make(map[string]interface{})
  935. data["struct_3501s"] = struct3501
  936. client := &http.Client{}
  937. bytesData, _ := json.Marshal(data)
  938. var req *http.Request
  939. if miConfig.MdtrtareaAdmvs == "320830" {
  940. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  941. } else {
  942. if miConfig.MdtrtareaAdmvs == "320921" {
  943. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  944. } else {
  945. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  946. }
  947. }
  948. resp, _ := client.Do(req)
  949. defer resp.Body.Close()
  950. body, ioErr := ioutil.ReadAll(resp.Body)
  951. if ioErr != nil {
  952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  953. }
  954. var respJSON map[string]interface{}
  955. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  958. return
  959. }
  960. var resSix10265 ResultSix10265 //1101结果
  961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  962. result, _ := json.Marshal(respJSON)
  963. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  964. utils.ErrorLog("解析失败:%v", err)
  965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  966. return
  967. }
  968. res2.InfRefmsgid = resSix10265.InfRefmsgid
  969. res2.Output = resSix10265.Output
  970. res2.ErrMsg = resSix10265.ErrMsg
  971. res2.Cainfo = resSix10265.Cainfo
  972. res2.WarnMsg = resSix10265.WarnMsg
  973. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  974. res2.Infcode = infocode
  975. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  976. data := make(map[string]interface{})
  977. data["struct_3501s"] = struct3501
  978. client := &http.Client{}
  979. bytesData, _ := json.Marshal(data)
  980. var req *http.Request
  981. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  982. resp, _ := client.Do(req)
  983. defer resp.Body.Close()
  984. body, ioErr := ioutil.ReadAll(resp.Body)
  985. if ioErr != nil {
  986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  987. }
  988. var respJSON map[string]interface{}
  989. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. var resSix10265 ResultSix10265 //1101结果
  995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  996. result, _ := json.Marshal(respJSON)
  997. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  998. utils.ErrorLog("解析失败:%v", err)
  999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1000. return
  1001. }
  1002. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1003. res2.Output = resSix10265.Output
  1004. res2.ErrMsg = resSix10265.ErrMsg
  1005. res2.Cainfo = resSix10265.Cainfo
  1006. res2.WarnMsg = resSix10265.WarnMsg
  1007. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1008. res2.Infcode = infocode
  1009. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1010. data := make(map[string]interface{})
  1011. data["struct_3501s"] = struct3501
  1012. client := &http.Client{}
  1013. bytesData, _ := json.Marshal(data)
  1014. var req *http.Request
  1015. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1016. resp, _ := client.Do(req)
  1017. defer resp.Body.Close()
  1018. body, ioErr := ioutil.ReadAll(resp.Body)
  1019. if ioErr != nil {
  1020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1021. }
  1022. var respJSON map[string]interface{}
  1023. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1026. return
  1027. }
  1028. var resSix10265 ResultSix10265 //1101结果
  1029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1030. result, _ := json.Marshal(respJSON)
  1031. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1032. utils.ErrorLog("解析失败:%v", err)
  1033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1034. return
  1035. }
  1036. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1037. res2.Output = resSix10265.Output
  1038. res2.ErrMsg = resSix10265.ErrMsg
  1039. res2.Cainfo = resSix10265.Cainfo
  1040. res2.WarnMsg = resSix10265.WarnMsg
  1041. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1042. res2.Infcode = infocode
  1043. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1044. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1045. saveLog(result1, result2, "3501", "3501")
  1046. //saveLog(result, requestLog, "2201", "挂号")
  1047. var respJSON2 map[string]interface{}
  1048. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1051. return
  1052. }
  1053. userJSONBytes2, _ := json.Marshal(respJSON2)
  1054. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1055. utils.ErrorLog("解析失败:%v", err)
  1056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1057. return
  1058. }
  1059. }
  1060. if res2.Infcode != -1 {
  1061. drug.IsPc = 1
  1062. drug.Bchno = number
  1063. drug.PcDate = time.Now().Unix()
  1064. err := service.SaveW(drug)
  1065. if err == nil {
  1066. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1067. var struct3502 models.Struct3502
  1068. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1069. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1070. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1071. struct3502.FixmedinsCode = miConfig.Code
  1072. struct3502.Code = miConfig.Code
  1073. struct3502.RxFlag = "0"
  1074. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1075. struct3502.OrgName = miConfig.OrgName
  1076. struct3502.Opter = roles.UserName
  1077. struct3502.AccessKey = miConfig.AccessKey
  1078. struct3502.RequestUrl = miConfig.Url
  1079. struct3502.SecretKey = miConfig.SecretKey
  1080. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1081. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1082. struct3502.Url = miConfig.Url
  1083. struct3502.AppId = miConfig.Cainfo
  1084. struct3502.AppSecret = miConfig.AppSecret
  1085. struct3502.Enckey = miConfig.EncKey
  1086. struct3502.SignKey = miConfig.SignKey
  1087. struct3502.SecretKey = miConfig.SecretKey
  1088. struct3502.DrugTracCodg = drug.DrugCode
  1089. struct3502.Memo = ""
  1090. struct3502.InvChgType = "108"
  1091. struct3502.FixmedinsBchno = bg_number
  1092. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1093. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1094. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1095. result11, result22, _ := service.FJyb3502(struct3502)
  1096. saveLog(result11, result22, "3502", "3502")
  1097. var respJSON3 map[string]interface{}
  1098. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1101. return
  1102. }
  1103. userJSONBytes3, _ := json.Marshal(respJSON3)
  1104. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1105. utils.ErrorLog("解析失败:%v", err)
  1106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1107. return
  1108. }
  1109. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1110. data := make(map[string]interface{})
  1111. data["struct_3502s"] = struct3502
  1112. client := &http.Client{}
  1113. bytesData, _ := json.Marshal(data)
  1114. var req *http.Request
  1115. if miConfig.MdtrtareaAdmvs == "320830" {
  1116. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1117. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1118. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1119. } else {
  1120. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1121. }
  1122. resp, _ := client.Do(req)
  1123. defer resp.Body.Close()
  1124. body, ioErr := ioutil.ReadAll(resp.Body)
  1125. if ioErr != nil {
  1126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1127. }
  1128. var respJSON map[string]interface{}
  1129. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1132. return
  1133. }
  1134. var resSix10265 ResultSix10265 //1101结果
  1135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1136. result, _ := json.Marshal(respJSON)
  1137. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1138. utils.ErrorLog("解析失败:%v", err)
  1139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1140. return
  1141. }
  1142. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1143. res3.Output = resSix10265.Output
  1144. res3.ErrMsg = resSix10265.ErrMsg
  1145. res3.Cainfo = resSix10265.Cainfo
  1146. res3.WarnMsg = resSix10265.WarnMsg
  1147. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1148. res3.Infcode = infocode
  1149. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1150. data := make(map[string]interface{})
  1151. data["struct_3502s"] = struct3502
  1152. client := &http.Client{}
  1153. bytesData, _ := json.Marshal(data)
  1154. var req *http.Request
  1155. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1156. resp, _ := client.Do(req)
  1157. defer resp.Body.Close()
  1158. body, ioErr := ioutil.ReadAll(resp.Body)
  1159. if ioErr != nil {
  1160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1161. }
  1162. var respJSON map[string]interface{}
  1163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1166. return
  1167. }
  1168. var resSix10265 ResultSix10265 //1101结果
  1169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1170. result, _ := json.Marshal(respJSON)
  1171. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1172. utils.ErrorLog("解析失败:%v", err)
  1173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1174. return
  1175. }
  1176. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1177. res3.Output = resSix10265.Output
  1178. res3.ErrMsg = resSix10265.ErrMsg
  1179. res3.Cainfo = resSix10265.Cainfo
  1180. res3.WarnMsg = resSix10265.WarnMsg
  1181. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1182. res3.Infcode = infocode
  1183. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1184. data := make(map[string]interface{})
  1185. data["struct_3501s"] = struct3501
  1186. client := &http.Client{}
  1187. bytesData, _ := json.Marshal(data)
  1188. var req *http.Request
  1189. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1190. resp, _ := client.Do(req)
  1191. defer resp.Body.Close()
  1192. body, ioErr := ioutil.ReadAll(resp.Body)
  1193. if ioErr != nil {
  1194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1195. }
  1196. var respJSON map[string]interface{}
  1197. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1200. return
  1201. }
  1202. var resSix10265 ResultSix10265 //1101结果
  1203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1204. result, _ := json.Marshal(respJSON)
  1205. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1206. utils.ErrorLog("解析失败:%v", err)
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1208. return
  1209. }
  1210. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1211. res2.Output = resSix10265.Output
  1212. res2.ErrMsg = resSix10265.ErrMsg
  1213. res2.Cainfo = resSix10265.Cainfo
  1214. res2.WarnMsg = resSix10265.WarnMsg
  1215. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1216. res2.Infcode = infocode
  1217. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1218. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1219. saveLog(result11, result22, "3502", "3502")
  1220. var respJSON3 map[string]interface{}
  1221. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1224. return
  1225. }
  1226. userJSONBytes3, _ := json.Marshal(respJSON3)
  1227. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1228. utils.ErrorLog("解析失败:%v", err)
  1229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1230. return
  1231. }
  1232. }
  1233. if res3.Infcode == -1 {
  1234. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1235. c.ServeSuccessJSON(map[string]interface{}{
  1236. "failed_code": -10,
  1237. "msg": res3.ErrMsg,
  1238. })
  1239. } else {
  1240. drug.IsBg = 1
  1241. drug.BgBchno = bg_number
  1242. service.SaveW(drug)
  1243. }
  1244. }
  1245. } else {
  1246. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1247. }
  1248. }
  1249. //变更
  1250. }
  1251. if len(errs) == 0 {
  1252. c.ServeSuccessJSON(map[string]interface{}{
  1253. "msg": "盘存变更成功",
  1254. })
  1255. } else {
  1256. c.ServeSuccessJSON(map[string]interface{}{
  1257. "failed_code": -10,
  1258. "msg": errs,
  1259. })
  1260. }
  1261. }
  1262. func (c *HisApiController) DeletePCandBG() {
  1263. ids := c.GetString("ids")
  1264. id_arr := strings.Split(ids, ",")
  1265. admin_user_id, _ := c.GetInt64("admin_user_id")
  1266. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1267. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1269. var err []string
  1270. for _, item := range drugs {
  1271. if item.IsPc == 1 && item.IsBg == 1 {
  1272. var res FJ3507Result
  1273. var res2 FJ3507Result
  1274. var struct3507 models.Struct3507
  1275. struct3507.FixmedinsBchno = item.Bchno
  1276. struct3507.InvDataType = "1"
  1277. struct3507.Opter = roles.UserName
  1278. struct3507.OrgName = miConfig.OrgName
  1279. struct3507.AccessKey = miConfig.AccessKey
  1280. struct3507.RequestUrl = miConfig.Url
  1281. struct3507.FixmedinsCode = miConfig.Code
  1282. struct3507.Code = miConfig.Code
  1283. struct3507.SecretKey = miConfig.SecretKey
  1284. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1285. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1286. struct3507.Url = miConfig.Url
  1287. struct3507.AppId = miConfig.Cainfo
  1288. struct3507.AppSecret = miConfig.AppSecret
  1289. struct3507.Enckey = miConfig.EncKey
  1290. struct3507.SignKey = miConfig.SignKey
  1291. struct3507.SecretKey = miConfig.SecretKey
  1292. if miConfig.MdtrtareaAdmvs == "350500" {
  1293. result, result1, _ := service.FJyb3507(struct3507)
  1294. saveLog(result, result1, "3507", "3507")
  1295. var respJSON2 map[string]interface{}
  1296. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return
  1300. }
  1301. userJSONBytes2, _ := json.Marshal(respJSON2)
  1302. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1303. utils.ErrorLog("解析失败:%v", err)
  1304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1305. return
  1306. }
  1307. } else {
  1308. data := make(map[string]interface{})
  1309. data["struct_3507s"] = struct3507
  1310. client := &http.Client{}
  1311. bytesData, _ := json.Marshal(data)
  1312. var req *http.Request
  1313. if miConfig.MdtrtareaAdmvs == "320830" {
  1314. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1315. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1316. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1317. } else {
  1318. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1319. }
  1320. resp, _ := client.Do(req)
  1321. defer resp.Body.Close()
  1322. body, ioErr := ioutil.ReadAll(resp.Body)
  1323. if ioErr != nil {
  1324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1325. }
  1326. var respJSON map[string]interface{}
  1327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1330. return
  1331. }
  1332. var resSix10265 ResultSix10265 //1101结果
  1333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1334. result, _ := json.Marshal(respJSON)
  1335. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1336. utils.ErrorLog("解析失败:%v", err)
  1337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1338. return
  1339. }
  1340. res.InfRefmsgid = resSix10265.InfRefmsgid
  1341. //res.Output = resSix10265.Output
  1342. res.ErrMsg = resSix10265.ErrMsg
  1343. res.Cainfo = resSix10265.Cainfo
  1344. res.WarnMsg = resSix10265.WarnMsg
  1345. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1346. res.Infcode = infocode
  1347. }
  1348. if res.Infcode == 0 {
  1349. item.IsPc = 0
  1350. err2 := service.SaveW(item)
  1351. if err2 == nil {
  1352. var struct3507_2 models.Struct3507
  1353. struct3507_2.OrgName = miConfig.OrgName
  1354. struct3507_2.AccessKey = miConfig.AccessKey
  1355. struct3507_2.RequestUrl = miConfig.Url
  1356. struct3507_2.Opter = roles.UserName
  1357. struct3507_2.FixmedinsCode = miConfig.Code
  1358. struct3507_2.Code = miConfig.Code
  1359. struct3507_2.SecretKey = miConfig.SecretKey
  1360. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1361. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1362. struct3507_2.Url = miConfig.Url
  1363. struct3507_2.AppId = miConfig.Cainfo
  1364. struct3507_2.AppSecret = miConfig.AppSecret
  1365. struct3507_2.Enckey = miConfig.EncKey
  1366. struct3507_2.SignKey = miConfig.SignKey
  1367. struct3507_2.SecretKey = miConfig.SecretKey
  1368. struct3507_2.FixmedinsBchno = item.BgBchno
  1369. struct3507_2.InvDataType = "2"
  1370. if miConfig.MdtrtareaAdmvs == "350500" {
  1371. result11, result22, _ := service.FJyb3507(struct3507_2)
  1372. saveLog(result11, result22, "3507", "3507")
  1373. var respJSON3 map[string]interface{}
  1374. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1377. return
  1378. }
  1379. userJSONBytes3, _ := json.Marshal(respJSON3)
  1380. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1381. utils.ErrorLog("解析失败:%v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. } else {
  1386. data := make(map[string]interface{})
  1387. data["struct_3507s"] = struct3507_2
  1388. client := &http.Client{}
  1389. bytesData, _ := json.Marshal(data)
  1390. var req *http.Request
  1391. if miConfig.MdtrtareaAdmvs == "320830" {
  1392. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1393. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1394. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1395. } else {
  1396. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1397. }
  1398. resp, _ := client.Do(req)
  1399. defer resp.Body.Close()
  1400. body, ioErr := ioutil.ReadAll(resp.Body)
  1401. if ioErr != nil {
  1402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1403. }
  1404. var respJSON map[string]interface{}
  1405. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1408. return
  1409. }
  1410. var resSix10265 ResultSix10265 //1101结果
  1411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1412. result, _ := json.Marshal(respJSON)
  1413. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1414. utils.ErrorLog("解析失败:%v", err)
  1415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1416. return
  1417. }
  1418. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1419. //res2.Output = resSix10265.Output
  1420. res2.ErrMsg = resSix10265.ErrMsg
  1421. res2.Cainfo = resSix10265.Cainfo
  1422. res2.WarnMsg = resSix10265.WarnMsg
  1423. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1424. res2.Infcode = infocode
  1425. }
  1426. if res2.Infcode != -1 {
  1427. item.IsBg = 0
  1428. item.Bchno = ""
  1429. item.BgBchno = ""
  1430. item.PcDate = 0
  1431. service.SaveW(item)
  1432. } else {
  1433. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1434. }
  1435. }
  1436. } else {
  1437. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1438. }
  1439. }
  1440. if item.IsPc == 1 && item.IsBg == 0 {
  1441. var res FJ3507Result
  1442. var struct3507 models.Struct3507
  1443. struct3507.FixmedinsBchno = item.Bchno
  1444. struct3507.InvDataType = "1"
  1445. struct3507.Opter = roles.UserName
  1446. struct3507.FixmedinsCode = miConfig.Code
  1447. struct3507.Code = miConfig.Code
  1448. struct3507.OrgName = miConfig.OrgName
  1449. struct3507.AccessKey = miConfig.AccessKey
  1450. struct3507.RequestUrl = miConfig.Url
  1451. struct3507.SecretKey = miConfig.SecretKey
  1452. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1453. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1454. struct3507.Url = miConfig.Url
  1455. struct3507.AppId = miConfig.Cainfo
  1456. struct3507.AppSecret = miConfig.AppSecret
  1457. struct3507.Enckey = miConfig.EncKey
  1458. struct3507.SignKey = miConfig.SignKey
  1459. struct3507.SecretKey = miConfig.SecretKey
  1460. //result, result1, _ := service.FJyb3507(struct3507)
  1461. //saveLog(result, result1, "3507", "3507")
  1462. if miConfig.MdtrtareaAdmvs == "350500" {
  1463. result, result1, _ := service.FJyb3507(struct3507)
  1464. saveLog(result, result1, "3507", "3507")
  1465. var respJSON2 map[string]interface{}
  1466. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1469. return
  1470. }
  1471. userJSONBytes2, _ := json.Marshal(respJSON2)
  1472. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1473. utils.ErrorLog("解析失败:%v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. } else {
  1478. data := make(map[string]interface{})
  1479. data["struct_3507s"] = struct3507
  1480. client := &http.Client{}
  1481. bytesData, _ := json.Marshal(data)
  1482. var req *http.Request
  1483. if miConfig.MdtrtareaAdmvs == "320830" {
  1484. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1485. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1486. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1487. } else {
  1488. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1489. }
  1490. resp, _ := client.Do(req)
  1491. defer resp.Body.Close()
  1492. body, ioErr := ioutil.ReadAll(resp.Body)
  1493. if ioErr != nil {
  1494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1495. }
  1496. var respJSON map[string]interface{}
  1497. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1500. return
  1501. }
  1502. var resSix10265 ResultSix10265 //1101结果
  1503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1504. result, _ := json.Marshal(respJSON)
  1505. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1506. utils.ErrorLog("解析失败:%v", err)
  1507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1508. return
  1509. }
  1510. res.InfRefmsgid = resSix10265.InfRefmsgid
  1511. //res.Output = resSix10265.Output
  1512. res.ErrMsg = resSix10265.ErrMsg
  1513. res.Cainfo = resSix10265.Cainfo
  1514. res.WarnMsg = resSix10265.WarnMsg
  1515. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1516. res.Infcode = infocode
  1517. }
  1518. if res.Infcode == 0 {
  1519. item.IsPc = 0
  1520. item.Bchno = ""
  1521. item.BgBchno = ""
  1522. item.PcDate = 0
  1523. service.SaveW(item)
  1524. } else {
  1525. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1526. }
  1527. }
  1528. if item.IsPc == 0 && item.IsBg == 1 {
  1529. var res FJ3507Result
  1530. var struct3507 models.Struct3507
  1531. struct3507.FixmedinsBchno = item.BgBchno
  1532. struct3507.InvDataType = "2"
  1533. struct3507.Opter = roles.UserName
  1534. struct3507.FixmedinsCode = miConfig.Code
  1535. struct3507.OrgName = miConfig.OrgName
  1536. struct3507.AccessKey = miConfig.AccessKey
  1537. struct3507.RequestUrl = miConfig.Url
  1538. struct3507.SecretKey = miConfig.SecretKey
  1539. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1540. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1541. struct3507.Url = miConfig.Url
  1542. struct3507.AppId = miConfig.Cainfo
  1543. struct3507.AppSecret = miConfig.AppSecret
  1544. struct3507.Enckey = miConfig.EncKey
  1545. struct3507.SignKey = miConfig.SignKey
  1546. struct3507.SecretKey = miConfig.SecretKey
  1547. //result, result1, _ := service.FJyb3507(struct3507)
  1548. //saveLog(result, result1, "3507", "3507")
  1549. if miConfig.MdtrtareaAdmvs == "350500" {
  1550. result, result1, _ := service.FJyb3507(struct3507)
  1551. saveLog(result, result1, "3507", "3507")
  1552. var respJSON2 map[string]interface{}
  1553. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1556. return
  1557. }
  1558. userJSONBytes2, _ := json.Marshal(respJSON2)
  1559. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1560. utils.ErrorLog("解析失败:%v", err)
  1561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1562. return
  1563. }
  1564. } else {
  1565. data := make(map[string]interface{})
  1566. data["struct_3507s"] = struct3507
  1567. client := &http.Client{}
  1568. bytesData, _ := json.Marshal(data)
  1569. var req *http.Request
  1570. if miConfig.MdtrtareaAdmvs == "320830" {
  1571. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1572. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1573. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1574. } else {
  1575. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1576. }
  1577. resp, _ := client.Do(req)
  1578. defer resp.Body.Close()
  1579. body, ioErr := ioutil.ReadAll(resp.Body)
  1580. if ioErr != nil {
  1581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1582. }
  1583. var respJSON map[string]interface{}
  1584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1587. return
  1588. }
  1589. var resSix10265 ResultSix10265 //1101结果
  1590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1591. result, _ := json.Marshal(respJSON)
  1592. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1593. utils.ErrorLog("解析失败:%v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. return
  1596. }
  1597. res.InfRefmsgid = resSix10265.InfRefmsgid
  1598. //res.Output = resSix10265.Output
  1599. res.ErrMsg = resSix10265.ErrMsg
  1600. res.Cainfo = resSix10265.Cainfo
  1601. res.WarnMsg = resSix10265.WarnMsg
  1602. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1603. res.Infcode = infocode
  1604. }
  1605. if res.Infcode == 0 {
  1606. item.IsBg = 0
  1607. item.Bchno = ""
  1608. item.BgBchno = ""
  1609. item.PcDate = 0
  1610. service.SaveW(item)
  1611. } else {
  1612. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1613. }
  1614. }
  1615. }
  1616. if len(err) == 0 {
  1617. c.ServeSuccessJSON(map[string]interface{}{
  1618. "msg": "删除盘存变更成功",
  1619. })
  1620. } else {
  1621. c.ServeSuccessJSON(map[string]interface{}{
  1622. "failed_code": -10,
  1623. "msg": err,
  1624. })
  1625. }
  1626. }
  1627. func (c *HisApiController) DeleteXSandBG() {
  1628. ids := c.GetString("ids")
  1629. id_arr := strings.Split(ids, ",")
  1630. admin_user_id, _ := c.GetInt64("admin_user_id")
  1631. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1632. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1633. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1634. var err []string
  1635. for _, item := range flows {
  1636. if item.IsSale == 1 && item.IsChange == 1 {
  1637. var res FJ3507Result
  1638. var res2 FJ3507Result
  1639. var struct3507 models.Struct3507
  1640. struct3507.FixmedinsBchno = item.Bchno
  1641. struct3507.InvDataType = "4"
  1642. struct3507.Opter = roles.UserName
  1643. struct3507.OrgName = miConfig.OrgName
  1644. struct3507.AccessKey = miConfig.AccessKey
  1645. struct3507.RequestUrl = miConfig.Url
  1646. struct3507.FixmedinsCode = miConfig.Code
  1647. struct3507.SecretKey = miConfig.SecretKey
  1648. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1649. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1650. struct3507.Url = miConfig.Url
  1651. struct3507.AppId = miConfig.Cainfo
  1652. struct3507.AppSecret = miConfig.AppSecret
  1653. struct3507.Enckey = miConfig.EncKey
  1654. struct3507.SignKey = miConfig.SignKey
  1655. struct3507.SecretKey = miConfig.SecretKey
  1656. //result, result1, _ := service.FJyb3507(struct3507)
  1657. //saveLog(result, result1, "3507", "3507")
  1658. if miConfig.MdtrtareaAdmvs == "350500" {
  1659. result, result1, _ := service.FJyb3507(struct3507)
  1660. saveLog(result, result1, "3507", "3507")
  1661. var respJSON2 map[string]interface{}
  1662. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1665. return
  1666. }
  1667. userJSONBytes2, _ := json.Marshal(respJSON2)
  1668. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1669. utils.ErrorLog("解析失败:%v", err)
  1670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1671. return
  1672. }
  1673. } else {
  1674. data := make(map[string]interface{})
  1675. data["struct_3507s"] = struct3507
  1676. client := &http.Client{}
  1677. bytesData, _ := json.Marshal(data)
  1678. var req *http.Request
  1679. if miConfig.MdtrtareaAdmvs == "320830" {
  1680. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1681. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1682. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1683. } else {
  1684. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1685. }
  1686. resp, _ := client.Do(req)
  1687. defer resp.Body.Close()
  1688. body, ioErr := ioutil.ReadAll(resp.Body)
  1689. if ioErr != nil {
  1690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1691. }
  1692. var respJSON map[string]interface{}
  1693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1696. return
  1697. }
  1698. var resSix10265 ResultSix10265 //1101结果
  1699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1700. result, _ := json.Marshal(respJSON)
  1701. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1702. utils.ErrorLog("解析失败:%v", err)
  1703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1704. return
  1705. }
  1706. res.InfRefmsgid = resSix10265.InfRefmsgid
  1707. //res.Output = resSix10265.Output
  1708. res.ErrMsg = resSix10265.ErrMsg
  1709. res.Cainfo = resSix10265.Cainfo
  1710. res.WarnMsg = resSix10265.WarnMsg
  1711. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1712. res.Infcode = infocode
  1713. }
  1714. if res.Infcode == 0 {
  1715. item.IsSale = 0
  1716. item.SaleDate = ""
  1717. item.Bchno = ""
  1718. err2 := service.SaveDF(item)
  1719. if err2 == nil {
  1720. var struct3507_2 models.Struct3507
  1721. struct3507_2.OrgName = miConfig.OrgName
  1722. struct3507_2.AccessKey = miConfig.AccessKey
  1723. struct3507_2.RequestUrl = miConfig.Url
  1724. struct3507_2.Opter = roles.UserName
  1725. struct3507_2.FixmedinsCode = miConfig.Code
  1726. struct3507_2.Code = miConfig.Code
  1727. struct3507_2.SecretKey = miConfig.SecretKey
  1728. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1729. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1730. struct3507_2.Url = miConfig.Url
  1731. struct3507_2.AppId = miConfig.Cainfo
  1732. struct3507_2.AppSecret = miConfig.AppSecret
  1733. struct3507_2.Enckey = miConfig.EncKey
  1734. struct3507_2.SignKey = miConfig.SignKey
  1735. struct3507_2.SecretKey = miConfig.SecretKey
  1736. struct3507_2.FixmedinsBchno = item.BgBchno
  1737. struct3507_2.InvDataType = "2"
  1738. if miConfig.MdtrtareaAdmvs == "350500" {
  1739. result11, result22, _ := service.FJyb3507(struct3507_2)
  1740. saveLog(result11, result22, "3507", "3507")
  1741. var respJSON3 map[string]interface{}
  1742. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1745. return
  1746. }
  1747. userJSONBytes3, _ := json.Marshal(respJSON3)
  1748. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1749. utils.ErrorLog("解析失败:%v", err)
  1750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1751. return
  1752. }
  1753. } else {
  1754. data := make(map[string]interface{})
  1755. data["struct_3507s"] = struct3507_2
  1756. client := &http.Client{}
  1757. bytesData, _ := json.Marshal(data)
  1758. var req *http.Request
  1759. if miConfig.MdtrtareaAdmvs == "320830" {
  1760. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1761. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1762. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1763. } else {
  1764. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1765. }
  1766. resp, _ := client.Do(req)
  1767. defer resp.Body.Close()
  1768. body, ioErr := ioutil.ReadAll(resp.Body)
  1769. if ioErr != nil {
  1770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1771. }
  1772. var respJSON map[string]interface{}
  1773. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. return
  1777. }
  1778. var resSix10265 ResultSix10265 //1101结果
  1779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1780. result, _ := json.Marshal(respJSON)
  1781. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1782. utils.ErrorLog("解析失败:%v", err)
  1783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1784. return
  1785. }
  1786. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1787. //res.Output = resSix10265.Output
  1788. res2.ErrMsg = resSix10265.ErrMsg
  1789. res2.Cainfo = resSix10265.Cainfo
  1790. res2.WarnMsg = resSix10265.WarnMsg
  1791. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1792. res2.Infcode = infocode
  1793. }
  1794. if res2.Infcode == 0 {
  1795. item.IsChange = 0
  1796. item.BgBchno = ""
  1797. service.SaveDF2(item)
  1798. } else {
  1799. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1800. }
  1801. }
  1802. } else {
  1803. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1804. }
  1805. }
  1806. if item.IsSale == 2 && item.IsChange == 1 {
  1807. var res FJ3507Result
  1808. var res2 FJ3507Result
  1809. var struct3507 models.Struct3507
  1810. struct3507.FixmedinsBchno = item.Bchno
  1811. struct3507.InvDataType = "4"
  1812. struct3507.Opter = roles.UserName
  1813. struct3507.OrgName = miConfig.OrgName
  1814. struct3507.AccessKey = miConfig.AccessKey
  1815. struct3507.RequestUrl = miConfig.Url
  1816. struct3507.FixmedinsCode = miConfig.Code
  1817. struct3507.Code = miConfig.Code
  1818. struct3507.SecretKey = miConfig.SecretKey
  1819. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1820. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1821. struct3507.Url = miConfig.Url
  1822. struct3507.AppId = miConfig.Cainfo
  1823. struct3507.AppSecret = miConfig.AppSecret
  1824. struct3507.Enckey = miConfig.EncKey
  1825. struct3507.SignKey = miConfig.SignKey
  1826. struct3507.SecretKey = miConfig.SecretKey
  1827. //result, result1, _ := service.FJyb3507(struct3507)
  1828. //saveLog(result, result1, "3507", "3507")
  1829. //
  1830. //var respJSON2 map[string]interface{}
  1831. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1832. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1834. // return
  1835. //}
  1836. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1837. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1838. // utils.ErrorLog("解析失败:%v", err)
  1839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1840. // return
  1841. //}
  1842. if miConfig.MdtrtareaAdmvs == "350500" {
  1843. result, result1, _ := service.FJyb3507(struct3507)
  1844. saveLog(result, result1, "3507", "3507")
  1845. var respJSON2 map[string]interface{}
  1846. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1849. return
  1850. }
  1851. userJSONBytes2, _ := json.Marshal(respJSON2)
  1852. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1853. utils.ErrorLog("解析失败:%v", err)
  1854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1855. return
  1856. }
  1857. } else {
  1858. data := make(map[string]interface{})
  1859. data["struct_3507s"] = struct3507
  1860. client := &http.Client{}
  1861. bytesData, _ := json.Marshal(data)
  1862. var req *http.Request
  1863. if miConfig.MdtrtareaAdmvs == "320830" {
  1864. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1865. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1867. } else {
  1868. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1869. }
  1870. resp, _ := client.Do(req)
  1871. defer resp.Body.Close()
  1872. body, ioErr := ioutil.ReadAll(resp.Body)
  1873. if ioErr != nil {
  1874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1875. }
  1876. var respJSON map[string]interface{}
  1877. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1880. return
  1881. }
  1882. var resSix10265 ResultSix10265 //1101结果
  1883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1884. result, _ := json.Marshal(respJSON)
  1885. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1886. utils.ErrorLog("解析失败:%v", err)
  1887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1888. return
  1889. }
  1890. res.InfRefmsgid = resSix10265.InfRefmsgid
  1891. //res.Output = resSix10265.Output
  1892. res.ErrMsg = resSix10265.ErrMsg
  1893. res.Cainfo = resSix10265.Cainfo
  1894. res.WarnMsg = resSix10265.WarnMsg
  1895. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1896. res.Infcode = infocode
  1897. }
  1898. if res.Infcode == 0 {
  1899. item.IsSale = 0
  1900. item.SaleDate = ""
  1901. item.Bchno = ""
  1902. err2 := service.SaveDF(item)
  1903. if err2 == nil {
  1904. var struct3507_2 models.Struct3507
  1905. struct3507_2.OrgName = miConfig.OrgName
  1906. struct3507_2.AccessKey = miConfig.AccessKey
  1907. struct3507_2.RequestUrl = miConfig.Url
  1908. struct3507_2.Opter = roles.UserName
  1909. struct3507_2.FixmedinsCode = miConfig.Code
  1910. struct3507_2.Code = miConfig.Code
  1911. struct3507_2.SecretKey = miConfig.SecretKey
  1912. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1913. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1914. struct3507_2.Url = miConfig.Url
  1915. struct3507_2.AppId = miConfig.Cainfo
  1916. struct3507_2.AppSecret = miConfig.AppSecret
  1917. struct3507_2.Enckey = miConfig.EncKey
  1918. struct3507_2.SignKey = miConfig.SignKey
  1919. struct3507_2.SecretKey = miConfig.SecretKey
  1920. struct3507_2.FixmedinsBchno = item.BgBchno
  1921. struct3507_2.InvDataType = "2"
  1922. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1923. //saveLog(result11, result22, "3507", "3507")
  1924. //var respJSON3 map[string]interface{}
  1925. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1926. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1928. // return
  1929. //}
  1930. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1931. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1932. // utils.ErrorLog("解析失败:%v", err)
  1933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1934. // return
  1935. //}
  1936. if miConfig.MdtrtareaAdmvs == "350500" {
  1937. result11, result22, _ := service.FJyb3507(struct3507_2)
  1938. saveLog(result11, result22, "3507", "3507")
  1939. var respJSON3 map[string]interface{}
  1940. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1943. return
  1944. }
  1945. userJSONBytes3, _ := json.Marshal(respJSON3)
  1946. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1947. utils.ErrorLog("解析失败:%v", err)
  1948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1949. return
  1950. }
  1951. } else {
  1952. data := make(map[string]interface{})
  1953. data["struct_3507s"] = struct3507_2
  1954. client := &http.Client{}
  1955. bytesData, _ := json.Marshal(data)
  1956. var req *http.Request
  1957. if miConfig.MdtrtareaAdmvs == "320830" {
  1958. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1959. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1960. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1961. } else {
  1962. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1963. }
  1964. resp, _ := client.Do(req)
  1965. defer resp.Body.Close()
  1966. body, ioErr := ioutil.ReadAll(resp.Body)
  1967. if ioErr != nil {
  1968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1969. }
  1970. var respJSON map[string]interface{}
  1971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1974. return
  1975. }
  1976. var resSix10265 ResultSix10265 //1101结果
  1977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1978. result, _ := json.Marshal(respJSON)
  1979. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1980. utils.ErrorLog("解析失败:%v", err)
  1981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1982. return
  1983. }
  1984. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1985. //res.Output = resSix10265.Output
  1986. res2.ErrMsg = resSix10265.ErrMsg
  1987. res2.Cainfo = resSix10265.Cainfo
  1988. res2.WarnMsg = resSix10265.WarnMsg
  1989. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1990. res2.Infcode = infocode
  1991. }
  1992. if res2.Infcode == 0 {
  1993. item.IsChange = 0
  1994. item.BgBchno = ""
  1995. service.SaveDF2(item)
  1996. } else {
  1997. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1998. }
  1999. }
  2000. } else {
  2001. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2002. }
  2003. }
  2004. if item.IsSale == 1 && item.IsChange == 0 {
  2005. var res FJ3507Result
  2006. var struct3507 models.Struct3507
  2007. struct3507.FixmedinsBchno = item.Bchno
  2008. struct3507.InvDataType = "4"
  2009. struct3507.Opter = roles.UserName
  2010. struct3507.FixmedinsCode = miConfig.Code
  2011. struct3507.Code = miConfig.Code
  2012. struct3507.OrgName = miConfig.OrgName
  2013. struct3507.AccessKey = miConfig.AccessKey
  2014. struct3507.RequestUrl = miConfig.Url
  2015. struct3507.SecretKey = miConfig.SecretKey
  2016. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2017. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2018. struct3507.Url = miConfig.Url
  2019. struct3507.AppId = miConfig.Cainfo
  2020. struct3507.AppSecret = miConfig.AppSecret
  2021. struct3507.Enckey = miConfig.EncKey
  2022. struct3507.SignKey = miConfig.SignKey
  2023. struct3507.SecretKey = miConfig.SecretKey
  2024. //result, result1, _ := service.FJyb3507(struct3507)
  2025. //saveLog(result, result1, "3507", "3507")
  2026. //
  2027. //var respJSON3 map[string]interface{}
  2028. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2029. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2031. // return
  2032. //}
  2033. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2034. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2035. // utils.ErrorLog("解析失败:%v", err)
  2036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2037. // return
  2038. //}
  2039. if miConfig.MdtrtareaAdmvs == "350500" {
  2040. result, result1, _ := service.FJyb3507(struct3507)
  2041. saveLog(result, result1, "3507", "3507")
  2042. var respJSON2 map[string]interface{}
  2043. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2046. return
  2047. }
  2048. userJSONBytes2, _ := json.Marshal(respJSON2)
  2049. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2050. utils.ErrorLog("解析失败:%v", err)
  2051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2052. return
  2053. }
  2054. } else {
  2055. data := make(map[string]interface{})
  2056. data["struct_3507s"] = struct3507
  2057. client := &http.Client{}
  2058. bytesData, _ := json.Marshal(data)
  2059. var req *http.Request
  2060. if miConfig.MdtrtareaAdmvs == "320830" {
  2061. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2062. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2063. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2064. } else {
  2065. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2066. }
  2067. resp, _ := client.Do(req)
  2068. defer resp.Body.Close()
  2069. body, ioErr := ioutil.ReadAll(resp.Body)
  2070. if ioErr != nil {
  2071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2072. }
  2073. var respJSON map[string]interface{}
  2074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2077. return
  2078. }
  2079. var resSix10265 ResultSix10265 //1101结果
  2080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2081. result, _ := json.Marshal(respJSON)
  2082. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2083. utils.ErrorLog("解析失败:%v", err)
  2084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2085. return
  2086. }
  2087. res.InfRefmsgid = resSix10265.InfRefmsgid
  2088. //res.Output = resSix10265.Output
  2089. res.ErrMsg = resSix10265.ErrMsg
  2090. res.Cainfo = resSix10265.Cainfo
  2091. res.WarnMsg = resSix10265.WarnMsg
  2092. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2093. res.Infcode = infocode
  2094. }
  2095. if res.Infcode == 0 {
  2096. item.IsSale = 0
  2097. item.SaleDate = ""
  2098. service.SaveDF(item)
  2099. } else {
  2100. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2101. }
  2102. }
  2103. if item.IsSale == 2 && item.IsChange == 0 {
  2104. var res FJ3507Result
  2105. var struct3507 models.Struct3507
  2106. struct3507.FixmedinsBchno = item.Bchno
  2107. struct3507.InvDataType = "4"
  2108. struct3507.Opter = roles.UserName
  2109. struct3507.FixmedinsCode = miConfig.Code
  2110. struct3507.Code = miConfig.Code
  2111. struct3507.OrgName = miConfig.OrgName
  2112. struct3507.AccessKey = miConfig.AccessKey
  2113. struct3507.RequestUrl = miConfig.Url
  2114. struct3507.SecretKey = miConfig.SecretKey
  2115. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2116. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2117. struct3507.Url = miConfig.Url
  2118. struct3507.AppId = miConfig.Cainfo
  2119. struct3507.AppSecret = miConfig.AppSecret
  2120. struct3507.Enckey = miConfig.EncKey
  2121. struct3507.SignKey = miConfig.SignKey
  2122. struct3507.SecretKey = miConfig.SecretKey
  2123. //result, result1, _ := service.FJyb3507(struct3507)
  2124. //saveLog(result, result1, "3507", "3507")
  2125. //
  2126. //var respJSON3 map[string]interface{}
  2127. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2128. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2130. // return
  2131. //}
  2132. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2133. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2134. // utils.ErrorLog("解析失败:%v", err)
  2135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2136. // return
  2137. //}
  2138. if miConfig.MdtrtareaAdmvs == "350500" {
  2139. result, result1, _ := service.FJyb3507(struct3507)
  2140. saveLog(result, result1, "3507", "3507")
  2141. var respJSON2 map[string]interface{}
  2142. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. return
  2146. }
  2147. userJSONBytes2, _ := json.Marshal(respJSON2)
  2148. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2149. utils.ErrorLog("解析失败:%v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. return
  2152. }
  2153. } else {
  2154. data := make(map[string]interface{})
  2155. data["struct_3507s"] = struct3507
  2156. client := &http.Client{}
  2157. bytesData, _ := json.Marshal(data)
  2158. var req *http.Request
  2159. if miConfig.MdtrtareaAdmvs == "320830" {
  2160. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2161. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2162. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2163. } else {
  2164. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2165. }
  2166. resp, _ := client.Do(req)
  2167. defer resp.Body.Close()
  2168. body, ioErr := ioutil.ReadAll(resp.Body)
  2169. if ioErr != nil {
  2170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2171. }
  2172. var respJSON map[string]interface{}
  2173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. return
  2177. }
  2178. var resSix10265 ResultSix10265 //1101结果
  2179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2180. result, _ := json.Marshal(respJSON)
  2181. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2182. utils.ErrorLog("解析失败:%v", err)
  2183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2184. return
  2185. }
  2186. res.InfRefmsgid = resSix10265.InfRefmsgid
  2187. //res.Output = resSix10265.Output
  2188. res.ErrMsg = resSix10265.ErrMsg
  2189. res.Cainfo = resSix10265.Cainfo
  2190. res.WarnMsg = resSix10265.WarnMsg
  2191. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2192. res.Infcode = infocode
  2193. }
  2194. if res.Infcode == 0 {
  2195. item.IsSale = 0
  2196. item.SaleDate = ""
  2197. item.Bchno = ""
  2198. service.SaveDF(item)
  2199. } else {
  2200. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2201. }
  2202. }
  2203. if item.IsSale == 0 && item.IsChange == 1 {
  2204. var res FJ3507Result
  2205. var struct3507 models.Struct3507
  2206. struct3507.FixmedinsBchno = item.BgBchno
  2207. struct3507.InvDataType = "2"
  2208. struct3507.Opter = roles.UserName
  2209. struct3507.FixmedinsCode = miConfig.Code
  2210. struct3507.Code = miConfig.Code
  2211. struct3507.OrgName = miConfig.OrgName
  2212. struct3507.AccessKey = miConfig.AccessKey
  2213. struct3507.RequestUrl = miConfig.Url
  2214. struct3507.SecretKey = miConfig.SecretKey
  2215. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2216. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2217. struct3507.Url = miConfig.Url
  2218. struct3507.AppId = miConfig.Cainfo
  2219. struct3507.AppSecret = miConfig.AppSecret
  2220. struct3507.Enckey = miConfig.EncKey
  2221. struct3507.SignKey = miConfig.SignKey
  2222. struct3507.SecretKey = miConfig.SecretKey
  2223. //result, result1, _ := service.FJyb3507(struct3507)
  2224. //saveLog(result, result1, "3507", "3507")
  2225. //
  2226. //var respJSON3 map[string]interface{}
  2227. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2228. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2230. // return
  2231. //}
  2232. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2233. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2234. // utils.ErrorLog("解析失败:%v", err)
  2235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2236. // return
  2237. //}
  2238. if miConfig.MdtrtareaAdmvs == "350500" {
  2239. result, result1, _ := service.FJyb3507(struct3507)
  2240. saveLog(result, result1, "3507", "3507")
  2241. var respJSON2 map[string]interface{}
  2242. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2245. return
  2246. }
  2247. userJSONBytes2, _ := json.Marshal(respJSON2)
  2248. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2249. utils.ErrorLog("解析失败:%v", err)
  2250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. return
  2252. }
  2253. } else {
  2254. data := make(map[string]interface{})
  2255. data["struct_3507s"] = struct3507
  2256. client := &http.Client{}
  2257. bytesData, _ := json.Marshal(data)
  2258. var req *http.Request
  2259. if miConfig.MdtrtareaAdmvs == "320830" {
  2260. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2261. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2262. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2263. } else {
  2264. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2265. }
  2266. resp, _ := client.Do(req)
  2267. defer resp.Body.Close()
  2268. body, ioErr := ioutil.ReadAll(resp.Body)
  2269. if ioErr != nil {
  2270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2271. }
  2272. var respJSON map[string]interface{}
  2273. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2276. return
  2277. }
  2278. var resSix10265 ResultSix10265 //1101结果
  2279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2280. result, _ := json.Marshal(respJSON)
  2281. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2282. utils.ErrorLog("解析失败:%v", err)
  2283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2284. return
  2285. }
  2286. res.InfRefmsgid = resSix10265.InfRefmsgid
  2287. //res.Output = resSix10265.Output
  2288. res.ErrMsg = resSix10265.ErrMsg
  2289. res.Cainfo = resSix10265.Cainfo
  2290. res.WarnMsg = resSix10265.WarnMsg
  2291. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2292. res.Infcode = infocode
  2293. }
  2294. if res.Infcode == 0 {
  2295. item.IsChange = 0
  2296. item.BgBchno = ""
  2297. service.SaveDF2(item)
  2298. } else {
  2299. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2300. }
  2301. }
  2302. }
  2303. if len(err) == 0 {
  2304. c.ServeSuccessJSON(map[string]interface{}{
  2305. "msg": "删除销售变更成功",
  2306. })
  2307. } else {
  2308. c.ServeSuccessJSON(map[string]interface{}{
  2309. "failed_code": -10,
  2310. "msg": err,
  2311. })
  2312. }
  2313. }
  2314. //func (c *HisApiController) BatchFJ3501AND3502() {
  2315. // //ids := c.GetString("ids")
  2316. // start_time := c.GetString("start_time")
  2317. // end_time := c.GetString("end_time")
  2318. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2319. //
  2320. //
  2321. // timeLayout := "2006-01-02"
  2322. // loc, _ := time.LoadLocation("Local")
  2323. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2324. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2325. //
  2326. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2327. // //id_arr := strings.Split(ids, ",")
  2328. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2329. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2330. // //库盘
  2331. // var errs []string
  2332. // for _, drug := range drugs {
  2333. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2334. // var res2 ResultSix
  2335. // var res3 ResultSix
  2336. //
  2337. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2338. // var struct3501 models.Struct3501
  2339. // struct3501.Code = miConfig.Code
  2340. // struct3501.OrgName = miConfig.OrgName
  2341. // struct3501.AccessKey = miConfig.AccessKey
  2342. // struct3501.Opter = roles.UserName
  2343. // struct3501.RequestUrl = miConfig.Url
  2344. // struct3501.Url = miConfig.Url
  2345. // struct3501.AppId = miConfig.Cainfo
  2346. // struct3501.AppSecret = miConfig.AppSecret
  2347. // struct3501.Enckey = miConfig.EncKey
  2348. // struct3501.SignKey = miConfig.SignKey
  2349. // struct3501.SecretKey = miConfig.SecretKey
  2350. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2351. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2352. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2353. // struct3501.RxFlag = "1"
  2354. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2355. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2356. //
  2357. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2358. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2359. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2360. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2361. // struct3501.FixmedinsBchno = number
  2362. // struct3501.DrugTracCodg = drug.DrugCode
  2363. // memo := make(map[string]interface{})
  2364. // memo["pric"] = drug.Price
  2365. // bytesData, _ := json.Marshal(memo)
  2366. // struct3501.Memo = string(bytesData)
  2367. //
  2368. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2369. //
  2370. // result1, result2, _ := service.FJyb3501(struct3501)
  2371. // saveLog(result1, result2, "3501", "3501")
  2372. // //saveLog(result, requestLog, "2201", "挂号")
  2373. //
  2374. // var respJSON2 map[string]interface{}
  2375. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2376. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2378. // return
  2379. // }
  2380. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2381. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2382. // utils.ErrorLog("解析失败:%v", err)
  2383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2384. // return
  2385. // }
  2386. //
  2387. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2388. // data := make(map[string]interface{})
  2389. // data["struct_3501s"] = struct3501
  2390. // client := &http.Client{}
  2391. // bytesData, _ := json.Marshal(data)
  2392. // var req *http.Request
  2393. // if miConfig.MdtrtareaAdmvs == "320921" {
  2394. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2395. // } else {
  2396. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2397. // }
  2398. //
  2399. // resp, _ := client.Do(req)
  2400. // defer resp.Body.Close()
  2401. // body, ioErr := ioutil.ReadAll(resp.Body)
  2402. // if ioErr != nil {
  2403. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2404. // }
  2405. // var respJSON map[string]interface{}
  2406. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2407. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2409. // return
  2410. // }
  2411. // var resSix10265 ResultSix10265 //1101结果
  2412. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2413. // result, _ := json.Marshal(respJSON)
  2414. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2415. // utils.ErrorLog("解析失败:%v", err)
  2416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. // return
  2418. // }
  2419. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2420. // res2.Output = resSix10265.Output
  2421. // res2.ErrMsg = resSix10265.ErrMsg
  2422. // res2.Cainfo = resSix10265.Cainfo
  2423. // res2.WarnMsg = resSix10265.WarnMsg
  2424. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2425. // res2.Infcode = infocode
  2426. //
  2427. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2428. // data := make(map[string]interface{})
  2429. // data["struct_3501s"] = struct3501
  2430. // client := &http.Client{}
  2431. // bytesData, _ := json.Marshal(data)
  2432. // var req *http.Request
  2433. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2434. // resp, _ := client.Do(req)
  2435. // defer resp.Body.Close()
  2436. // body, ioErr := ioutil.ReadAll(resp.Body)
  2437. // if ioErr != nil {
  2438. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2439. // }
  2440. // var respJSON map[string]interface{}
  2441. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2442. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2444. // return
  2445. // }
  2446. // var resSix10265 ResultSix10265 //1101结果
  2447. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2448. // result, _ := json.Marshal(respJSON)
  2449. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2455. // res2.Output = resSix10265.Output
  2456. // res2.ErrMsg = resSix10265.ErrMsg
  2457. // res2.Cainfo = resSix10265.Cainfo
  2458. // res2.WarnMsg = resSix10265.WarnMsg
  2459. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2460. // res2.Infcode = infocode
  2461. //
  2462. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2463. // data := make(map[string]interface{})
  2464. // data["struct_3501s"] = struct3501
  2465. // client := &http.Client{}
  2466. // bytesData, _ := json.Marshal(data)
  2467. // var req *http.Request
  2468. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2469. // resp, _ := client.Do(req)
  2470. // defer resp.Body.Close()
  2471. // body, ioErr := ioutil.ReadAll(resp.Body)
  2472. // if ioErr != nil {
  2473. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2474. // }
  2475. // var respJSON map[string]interface{}
  2476. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2477. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2479. // return
  2480. // }
  2481. // var resSix10265 ResultSix10265 //1101结果
  2482. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2483. // result, _ := json.Marshal(respJSON)
  2484. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2485. // utils.ErrorLog("解析失败:%v", err)
  2486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2487. // return
  2488. // }
  2489. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2490. // res2.Output = resSix10265.Output
  2491. // res2.ErrMsg = resSix10265.ErrMsg
  2492. // res2.Cainfo = resSix10265.Cainfo
  2493. // res2.WarnMsg = resSix10265.WarnMsg
  2494. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2495. // res2.Infcode = infocode
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2498. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2499. // saveLog(result1, result2, "3501", "3501")
  2500. // //saveLog(result, requestLog, "2201", "挂号")
  2501. //
  2502. // var respJSON2 map[string]interface{}
  2503. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2504. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2506. // return
  2507. // }
  2508. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2509. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2510. // utils.ErrorLog("解析失败:%v", err)
  2511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2512. // return
  2513. // }
  2514. //
  2515. // }
  2516. //
  2517. // if res2.Infcode != -1 {
  2518. // drug.IsPc = 1
  2519. // drug.Bchno = number
  2520. // drug.PcDate = time.Now().Unix()
  2521. // err := service.SaveW(drug)
  2522. // if err == nil {
  2523. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2524. // var struct3502 models.Struct3502
  2525. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2526. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2527. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2528. // struct3502.FixmedinsCode = miConfig.Code
  2529. // struct3502.Code = miConfig.Code
  2530. //
  2531. // struct3502.RxFlag = "0"
  2532. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2533. // struct3502.OrgName = miConfig.OrgName
  2534. // struct3502.Opter = roles.UserName
  2535. // struct3502.AccessKey = miConfig.AccessKey
  2536. // struct3502.RequestUrl = miConfig.Url
  2537. // struct3502.SecretKey = miConfig.SecretKey
  2538. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2539. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2540. // struct3502.Url = miConfig.Url
  2541. // struct3502.AppId = miConfig.Cainfo
  2542. // struct3502.AppSecret = miConfig.AppSecret
  2543. // struct3502.Enckey = miConfig.EncKey
  2544. // struct3502.SignKey = miConfig.SignKey
  2545. // struct3502.SecretKey = miConfig.SecretKey
  2546. // struct3502.DrugTracCodg = drug.DrugCode
  2547. //
  2548. // struct3502.Memo = ""
  2549. // struct3502.InvChgType = "108"
  2550. // struct3502.FixmedinsBchno = bg_number
  2551. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2552. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2553. //
  2554. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2555. // result11, result22, _ := service.FJyb3502(struct3502)
  2556. // saveLog(result11, result22, "3502", "3502")
  2557. //
  2558. // var respJSON3 map[string]interface{}
  2559. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2560. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2562. // return
  2563. // }
  2564. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2565. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2566. // utils.ErrorLog("解析失败:%v", err)
  2567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2568. // return
  2569. // }
  2570. //
  2571. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2572. // data := make(map[string]interface{})
  2573. // data["struct_3502s"] = struct3502
  2574. // client := &http.Client{}
  2575. // bytesData, _ := json.Marshal(data)
  2576. // var req *http.Request
  2577. // if miConfig.MdtrtareaAdmvs == "320921" {
  2578. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2579. // } else {
  2580. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2581. // }
  2582. //
  2583. // resp, _ := client.Do(req)
  2584. // defer resp.Body.Close()
  2585. // body, ioErr := ioutil.ReadAll(resp.Body)
  2586. // if ioErr != nil {
  2587. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2588. // }
  2589. // var respJSON map[string]interface{}
  2590. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2591. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2593. // return
  2594. // }
  2595. // var resSix10265 ResultSix10265 //1101结果
  2596. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2597. // result, _ := json.Marshal(respJSON)
  2598. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2599. // utils.ErrorLog("解析失败:%v", err)
  2600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2601. // return
  2602. // }
  2603. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2604. // res3.Output = resSix10265.Output
  2605. // res3.ErrMsg = resSix10265.ErrMsg
  2606. // res3.Cainfo = resSix10265.Cainfo
  2607. // res3.WarnMsg = resSix10265.WarnMsg
  2608. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2609. // res3.Infcode = infocode
  2610. //
  2611. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2612. //
  2613. // data := make(map[string]interface{})
  2614. // data["struct_3502s"] = struct3502
  2615. // client := &http.Client{}
  2616. // bytesData, _ := json.Marshal(data)
  2617. // var req *http.Request
  2618. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2619. // resp, _ := client.Do(req)
  2620. // defer resp.Body.Close()
  2621. // body, ioErr := ioutil.ReadAll(resp.Body)
  2622. // if ioErr != nil {
  2623. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2624. // }
  2625. // var respJSON map[string]interface{}
  2626. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2627. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2629. // return
  2630. // }
  2631. // var resSix10265 ResultSix10265 //1101结果
  2632. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2633. // result, _ := json.Marshal(respJSON)
  2634. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2635. // utils.ErrorLog("解析失败:%v", err)
  2636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2637. // return
  2638. // }
  2639. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2640. // res3.Output = resSix10265.Output
  2641. // res3.ErrMsg = resSix10265.ErrMsg
  2642. // res3.Cainfo = resSix10265.Cainfo
  2643. // res3.WarnMsg = resSix10265.WarnMsg
  2644. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2645. // res3.Infcode = infocode
  2646. //
  2647. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2648. //
  2649. // data := make(map[string]interface{})
  2650. // data["struct_3501s"] = struct3501
  2651. // client := &http.Client{}
  2652. // bytesData, _ := json.Marshal(data)
  2653. // var req *http.Request
  2654. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2655. // resp, _ := client.Do(req)
  2656. // defer resp.Body.Close()
  2657. // body, ioErr := ioutil.ReadAll(resp.Body)
  2658. // if ioErr != nil {
  2659. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2660. // }
  2661. // var respJSON map[string]interface{}
  2662. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2663. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. // return
  2666. // }
  2667. // var resSix10265 ResultSix10265 //1101结果
  2668. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2669. // result, _ := json.Marshal(respJSON)
  2670. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2671. // utils.ErrorLog("解析失败:%v", err)
  2672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. // return
  2674. // }
  2675. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2676. // res2.Output = resSix10265.Output
  2677. // res2.ErrMsg = resSix10265.ErrMsg
  2678. // res2.Cainfo = resSix10265.Cainfo
  2679. // res2.WarnMsg = resSix10265.WarnMsg
  2680. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2681. // res2.Infcode = infocode
  2682. //
  2683. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2684. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2685. // saveLog(result11, result22, "3502", "3502")
  2686. //
  2687. // var respJSON3 map[string]interface{}
  2688. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2689. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2691. // return
  2692. // }
  2693. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2694. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2695. // utils.ErrorLog("解析失败:%v", err)
  2696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2697. // return
  2698. // }
  2699. // }
  2700. // if res3.Infcode == -1 {
  2701. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2702. // c.ServeSuccessJSON(map[string]interface{}{
  2703. // "failed_code": -10,
  2704. // "msg": res3.ErrMsg,
  2705. // })
  2706. // } else {
  2707. // drug.IsBg = 1
  2708. // drug.BgBchno = bg_number
  2709. // service.SaveW(drug)
  2710. // }
  2711. // }
  2712. // } else {
  2713. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2714. // }
  2715. // }
  2716. // //变更
  2717. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2718. // var res3 ResultSix
  2719. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2720. //
  2721. // var struct3502 models.Struct3502
  2722. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2723. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2724. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2725. // struct3502.FixmedinsCode = miConfig.Code
  2726. // struct3502.Code = miConfig.Code
  2727. //
  2728. // struct3502.Opter = roles.UserName
  2729. // struct3502.RxFlag = "0"
  2730. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2731. // struct3502.OrgName = miConfig.OrgName
  2732. // struct3502.AccessKey = miConfig.AccessKey
  2733. // struct3502.RequestUrl = miConfig.Url
  2734. // struct3502.SecretKey = miConfig.SecretKey
  2735. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2736. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2737. // struct3502.InvChgType = "108"
  2738. // struct3502.DrugTracCodg = drug.DrugCode
  2739. //
  2740. // struct3502.Url = miConfig.Url
  2741. // struct3502.AppId = miConfig.Cainfo
  2742. // struct3502.AppSecret = miConfig.AppSecret
  2743. // struct3502.Enckey = miConfig.EncKey
  2744. // struct3502.SignKey = miConfig.SignKey
  2745. // struct3502.SecretKey = miConfig.SecretKey
  2746. //
  2747. // struct3502.FixmedinsBchno = bg_number
  2748. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2749. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2750. //
  2751. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2752. // result1, result2, _ := service.FJyb3502(struct3502)
  2753. // saveLog(result1, result2, "3502", "3502")
  2754. // var respJSON3 map[string]interface{}
  2755. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2758. // return
  2759. // }
  2760. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2761. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2762. // utils.ErrorLog("解析失败:%v", err)
  2763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2764. // return
  2765. // }
  2766. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2767. // data := make(map[string]interface{})
  2768. // data["struct_3502s"] = struct3502
  2769. // client := &http.Client{}
  2770. // bytesData, _ := json.Marshal(data)
  2771. // var req *http.Request
  2772. // if miConfig.MdtrtareaAdmvs == "320921" {
  2773. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2774. // } else {
  2775. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2776. // }
  2777. // resp, _ := client.Do(req)
  2778. // defer resp.Body.Close()
  2779. // body, ioErr := ioutil.ReadAll(resp.Body)
  2780. // if ioErr != nil {
  2781. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2782. // }
  2783. // var respJSON map[string]interface{}
  2784. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2785. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2787. // return
  2788. // }
  2789. // var resSix10265 ResultSix10265 //1101结果
  2790. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2791. // result, _ := json.Marshal(respJSON)
  2792. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2793. // utils.ErrorLog("解析失败:%v", err)
  2794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2795. // return
  2796. // }
  2797. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2798. // res3.Output = resSix10265.Output
  2799. // res3.ErrMsg = resSix10265.ErrMsg
  2800. // res3.Cainfo = resSix10265.Cainfo
  2801. // res3.WarnMsg = resSix10265.WarnMsg
  2802. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2803. // res3.Infcode = infocode
  2804. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2805. //
  2806. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2807. //
  2808. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2809. //
  2810. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2811. //
  2812. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2813. // saveLog(result1, result2, "3501", "3501")
  2814. // //saveLog(result, requestLog, "2201", "挂号")
  2815. //
  2816. // var respJSON2 map[string]interface{}
  2817. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2818. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2820. // return
  2821. // }
  2822. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2823. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2824. // utils.ErrorLog("解析失败:%v", err)
  2825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2826. // return
  2827. // }
  2828. //
  2829. // }
  2830. // if res3.Infcode == -1 {
  2831. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2832. // } else {
  2833. // drug.IsBg = 1
  2834. // drug.BgBchno = bg_number
  2835. // service.SaveW(drug)
  2836. // }
  2837. // }
  2838. // }
  2839. //
  2840. // if len(errs) == 0 {
  2841. // c.ServeSuccessJSON(map[string]interface{}{
  2842. // "msg": "盘存变更成功",
  2843. // })
  2844. // } else {
  2845. // c.ServeSuccessJSON(map[string]interface{}{
  2846. // "failed_code": -10,
  2847. // "msg": errs,
  2848. // })
  2849. // }
  2850. //}
  2851. func (c *HisApiController) DeleteXSandBGTwo() {
  2852. patient_id, _ := c.GetInt64("patient_id")
  2853. admin_user_id, _ := c.GetInt64("admin_user_id")
  2854. times := c.GetString("time", "")
  2855. timeLayout := "2006-01-02"
  2856. loc, _ := time.LoadLocation("Local")
  2857. var stime, etime int64
  2858. if times == "" {
  2859. stime, etime = GetNowTime()
  2860. } else {
  2861. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2862. stime = stmp.Unix()
  2863. etime = stime + 86399
  2864. }
  2865. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2866. var flows []*models.DrugFlow
  2867. for _, item := range advicelist {
  2868. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2869. flows = append(flows, flow...)
  2870. }
  2871. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2872. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2873. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2874. var err []string
  2875. for _, item := range flows {
  2876. if item.IsSale == 1 {
  2877. var res FJ3507Result
  2878. var struct3507 models.Struct3507
  2879. struct3507.FixmedinsBchno = item.Bchno
  2880. struct3507.InvDataType = "4"
  2881. struct3507.Opter = roles.UserName
  2882. struct3507.OrgName = miConfig.OrgName
  2883. struct3507.AccessKey = miConfig.AccessKey
  2884. struct3507.RequestUrl = miConfig.Url
  2885. struct3507.FixmedinsCode = miConfig.Code
  2886. struct3507.SecretKey = miConfig.SecretKey
  2887. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2888. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2889. struct3507.Url = miConfig.Url
  2890. struct3507.AppId = miConfig.Cainfo
  2891. struct3507.AppSecret = miConfig.AppSecret
  2892. struct3507.Enckey = miConfig.EncKey
  2893. struct3507.SignKey = miConfig.SignKey
  2894. struct3507.SecretKey = miConfig.SecretKey
  2895. if miConfig.MdtrtareaAdmvs == "350500" {
  2896. result, result1, _ := service.FJyb3507(struct3507)
  2897. saveLog(result, result1, "3507", "3507")
  2898. var respJSON2 map[string]interface{}
  2899. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. return
  2903. }
  2904. userJSONBytes2, _ := json.Marshal(respJSON2)
  2905. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2906. utils.ErrorLog("解析失败:%v", err)
  2907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2908. return
  2909. }
  2910. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  2911. data := make(map[string]interface{})
  2912. data["struct_3507s"] = struct3507
  2913. client := &http.Client{}
  2914. bytesData, _ := json.Marshal(data)
  2915. var req *http.Request
  2916. if miConfig.MdtrtareaAdmvs == "320830" {
  2917. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2918. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2919. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2920. } else {
  2921. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2922. }
  2923. resp, _ := client.Do(req)
  2924. defer resp.Body.Close()
  2925. body, ioErr := ioutil.ReadAll(resp.Body)
  2926. if ioErr != nil {
  2927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2928. }
  2929. var respJSON map[string]interface{}
  2930. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2933. return
  2934. }
  2935. var resSix10265 ResultSix10265 //1101结果
  2936. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2937. result, _ := json.Marshal(respJSON)
  2938. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2939. utils.ErrorLog("解析失败:%v", err)
  2940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2941. return
  2942. }
  2943. res.InfRefmsgid = resSix10265.InfRefmsgid
  2944. //res.Output = resSix10265.Output
  2945. res.ErrMsg = resSix10265.ErrMsg
  2946. res.Cainfo = resSix10265.Cainfo
  2947. res.WarnMsg = resSix10265.WarnMsg
  2948. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2949. res.Infcode = infocode
  2950. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2951. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2952. saveLog(result2, result1, "3507", "3507")
  2953. var respJSON2 map[string]interface{}
  2954. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2957. return
  2958. }
  2959. userJSONBytes2, _ := json.Marshal(respJSON2)
  2960. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2961. utils.ErrorLog("解析失败:%v", err)
  2962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2963. return
  2964. }
  2965. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2966. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2967. saveLog(result2, result1, "3507", "3507")
  2968. var respJSON2 map[string]interface{}
  2969. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2972. return
  2973. }
  2974. userJSONBytes2, _ := json.Marshal(respJSON2)
  2975. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2976. utils.ErrorLog("解析失败:%v", err)
  2977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2978. return
  2979. }
  2980. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2981. result1, result2 := service.Jxyb3507(struct3507)
  2982. saveLog(result2, result1, "3507", "3507")
  2983. var respJSON2 map[string]interface{}
  2984. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2987. return
  2988. }
  2989. userJSONBytes2, _ := json.Marshal(respJSON2)
  2990. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2991. utils.ErrorLog("解析失败:%v", err)
  2992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2993. return
  2994. }
  2995. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2996. result1, result2 := service.AHyb3507(struct3507)
  2997. saveLog(result2, result1, "3507", "3507")
  2998. var respJSON2 map[string]interface{}
  2999. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3002. return
  3003. }
  3004. userJSONBytes2, _ := json.Marshal(respJSON2)
  3005. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3006. utils.ErrorLog("解析失败:%v", err)
  3007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3008. return
  3009. }
  3010. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3011. data := make(map[string]interface{})
  3012. data["struct_3507s"] = struct3507
  3013. client := &http.Client{}
  3014. bytesData, _ := json.Marshal(data)
  3015. var req *http.Request
  3016. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3017. resp, _ := client.Do(req)
  3018. defer resp.Body.Close()
  3019. body, ioErr := ioutil.ReadAll(resp.Body)
  3020. if ioErr != nil {
  3021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3022. }
  3023. var respJSON map[string]interface{}
  3024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3026. }
  3027. var resSix10265 ResultSix10265 //1101结果
  3028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3029. result, _ := json.Marshal(respJSON)
  3030. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3031. utils.ErrorLog("解析失败:%v", err)
  3032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3033. return
  3034. }
  3035. res.InfRefmsgid = resSix10265.InfRefmsgid
  3036. res.ErrMsg = resSix10265.ErrMsg
  3037. res.Cainfo = resSix10265.Cainfo
  3038. res.WarnMsg = resSix10265.WarnMsg
  3039. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3040. res.Infcode = infocode
  3041. }
  3042. if res.Infcode == 0 {
  3043. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3044. item.IsSale = 0
  3045. item.SaleDate = ""
  3046. item.Bchno = ""
  3047. service.SaveDF(item)
  3048. } else {
  3049. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3050. }
  3051. }
  3052. }
  3053. c.ServeSuccessJSON(map[string]interface{}{
  3054. "msg": "删除销售数据成功",
  3055. })
  3056. }
  3057. // 删除
  3058. func (c *HisApiController) DeleteXSandBGThree() {
  3059. id, _ := c.GetInt64("id")
  3060. admin_user_id, _ := c.GetInt64("admin_user_id")
  3061. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3062. var flows []*models.DrugFlow
  3063. for _, item := range advicelist {
  3064. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3065. flows = append(flows, flow...)
  3066. }
  3067. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3068. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3069. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3070. var err []string
  3071. for _, item := range flows {
  3072. if item.IsSale == 1 {
  3073. var res FJ3507Result
  3074. var struct3507 models.Struct3507
  3075. struct3507.FixmedinsBchno = item.Bchno
  3076. struct3507.InvDataType = "4"
  3077. struct3507.Opter = roles.UserName
  3078. struct3507.OrgName = miConfig.OrgName
  3079. struct3507.AccessKey = miConfig.AccessKey
  3080. struct3507.RequestUrl = miConfig.Url
  3081. struct3507.FixmedinsCode = miConfig.Code
  3082. struct3507.SecretKey = miConfig.SecretKey
  3083. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3084. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3085. struct3507.Url = miConfig.Url
  3086. struct3507.AppId = miConfig.Cainfo
  3087. struct3507.AppSecret = miConfig.AppSecret
  3088. struct3507.Enckey = miConfig.EncKey
  3089. struct3507.SignKey = miConfig.SignKey
  3090. struct3507.SecretKey = miConfig.SecretKey
  3091. if miConfig.MdtrtareaAdmvs == "350500" {
  3092. result, result1, _ := service.FJyb3507(struct3507)
  3093. saveLog(result, result1, "3507", "3507")
  3094. var respJSON2 map[string]interface{}
  3095. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3098. return
  3099. }
  3100. userJSONBytes2, _ := json.Marshal(respJSON2)
  3101. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3102. utils.ErrorLog("解析失败:%v", err)
  3103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3104. return
  3105. }
  3106. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3107. data := make(map[string]interface{})
  3108. data["struct_3507s"] = struct3507
  3109. client := &http.Client{}
  3110. bytesData, _ := json.Marshal(data)
  3111. var req *http.Request
  3112. if miConfig.MdtrtareaAdmvs == "320830" {
  3113. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3114. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3115. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3116. } else {
  3117. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3118. }
  3119. resp, _ := client.Do(req)
  3120. defer resp.Body.Close()
  3121. body, ioErr := ioutil.ReadAll(resp.Body)
  3122. if ioErr != nil {
  3123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3124. }
  3125. var respJSON map[string]interface{}
  3126. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3129. return
  3130. }
  3131. var resSix10265 ResultSix10265 //1101结果
  3132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3133. result, _ := json.Marshal(respJSON)
  3134. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3135. utils.ErrorLog("解析失败:%v", err)
  3136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3137. return
  3138. }
  3139. res.InfRefmsgid = resSix10265.InfRefmsgid
  3140. //res.Output = resSix10265.Output
  3141. res.ErrMsg = resSix10265.ErrMsg
  3142. res.Cainfo = resSix10265.Cainfo
  3143. res.WarnMsg = resSix10265.WarnMsg
  3144. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3145. res.Infcode = infocode
  3146. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3147. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3148. saveLog(result2, result1, "3507", "3507")
  3149. var respJSON2 map[string]interface{}
  3150. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3153. return
  3154. }
  3155. userJSONBytes2, _ := json.Marshal(respJSON2)
  3156. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3157. utils.ErrorLog("解析失败:%v", err)
  3158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3159. return
  3160. }
  3161. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3162. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3163. saveLog(result2, result1, "3507", "3507")
  3164. var respJSON2 map[string]interface{}
  3165. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3168. return
  3169. }
  3170. userJSONBytes2, _ := json.Marshal(respJSON2)
  3171. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3172. utils.ErrorLog("解析失败:%v", err)
  3173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. return
  3175. }
  3176. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3177. result1, result2 := service.Jxyb3507(struct3507)
  3178. saveLog(result2, result1, "3507", "3507")
  3179. var respJSON2 map[string]interface{}
  3180. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3183. return
  3184. }
  3185. userJSONBytes2, _ := json.Marshal(respJSON2)
  3186. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3187. utils.ErrorLog("解析失败:%v", err)
  3188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3189. return
  3190. }
  3191. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3192. result1, result2 := service.AHyb3507(struct3507)
  3193. saveLog(result2, result1, "3507", "3507")
  3194. var respJSON2 map[string]interface{}
  3195. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3198. return
  3199. }
  3200. userJSONBytes2, _ := json.Marshal(respJSON2)
  3201. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3202. utils.ErrorLog("解析失败:%v", err)
  3203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3204. return
  3205. }
  3206. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3207. data := make(map[string]interface{})
  3208. data["struct_3507s"] = struct3507
  3209. client := &http.Client{}
  3210. bytesData, _ := json.Marshal(data)
  3211. var req *http.Request
  3212. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3213. resp, _ := client.Do(req)
  3214. defer resp.Body.Close()
  3215. body, ioErr := ioutil.ReadAll(resp.Body)
  3216. if ioErr != nil {
  3217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3218. }
  3219. var respJSON map[string]interface{}
  3220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3222. }
  3223. var resSix10265 ResultSix10265 //1101结果
  3224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3225. result, _ := json.Marshal(respJSON)
  3226. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3227. utils.ErrorLog("解析失败:%v", err)
  3228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3229. return
  3230. }
  3231. res.InfRefmsgid = resSix10265.InfRefmsgid
  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. if res.Infcode == 0 {
  3239. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3240. item.IsSale = 0
  3241. item.SaleDate = ""
  3242. item.Bchno = ""
  3243. service.SaveDF(item)
  3244. } else {
  3245. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3246. }
  3247. }
  3248. }
  3249. c.ServeSuccessJSON(map[string]interface{}{
  3250. "msg": "删除销售数据成功",
  3251. })
  3252. }
  3253. // 获取当天起止时间戳
  3254. func GetNowTime() (int64, int64) {
  3255. t := time.Now()
  3256. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3257. timesamp := addTime.Unix()
  3258. return timesamp, timesamp + 86399
  3259. }
  3260. func (c *HisApiController) ChangeDrugfour() {
  3261. patient_id, _ := c.GetInt64("patient_id")
  3262. admin_user_id, _ := c.GetInt64("admin_user_id")
  3263. times := c.GetString("time", "")
  3264. timeLayout := "2006-01-02"
  3265. loc, _ := time.LoadLocation("Local")
  3266. var stime, etime int64
  3267. if times == "" {
  3268. stime, etime = GetNowTime()
  3269. } else {
  3270. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3271. stime = stmp.Unix()
  3272. etime = stime + 86399
  3273. }
  3274. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3275. var flows []*models.DrugFlow
  3276. for _, item := range advicelist {
  3277. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3278. flows = append(flows, flow...)
  3279. }
  3280. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3281. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3282. var err []string
  3283. for _, item := range flows {
  3284. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3285. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3286. if prescription.OrderStatus == 2 {
  3287. if item.IsSale == 0 {
  3288. var res FJ3507Result
  3289. var res3507for10188 FJ3507ResultFor10188
  3290. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3291. //进行商品销售接口
  3292. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3293. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3294. var respJSON3 map[string]interface{}
  3295. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3298. return
  3299. }
  3300. userJSONBytes3, _ := json.Marshal(respJSON3)
  3301. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3302. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3303. utils.ErrorLog("解析失败:%v", err)
  3304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3305. return
  3306. }
  3307. //if res3507for10188.Infcode
  3308. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3309. //res.Output = resSix10265.Output
  3310. res.ErrMsg = res3507for10188.ErrMsg
  3311. res.Cainfo = res3507for10188.Cainfo
  3312. res.WarnMsg = res3507for10188.WarnMsg
  3313. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3314. res.Infcode = infocode
  3315. } else {
  3316. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3317. utils.ErrorLog("解析失败:%v", err)
  3318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3319. return
  3320. }
  3321. }
  3322. if res.Infcode == 0 {
  3323. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3324. item.IsSale = 1
  3325. item.Bchno = number
  3326. item.SaleDate = time.Now().Format("2006-01-02")
  3327. service.SaveDF(item)
  3328. } else {
  3329. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3330. }
  3331. }
  3332. } else { //还没结,提示用户去结算,并药品追溯上传
  3333. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3334. }
  3335. }
  3336. }
  3337. str := strings.Join(err, " ")
  3338. saveLog(str, str, "3505", "3505自动上传日志")
  3339. c.ServeSuccessJSON(map[string]interface{}{
  3340. "status": "1",
  3341. "msg": err,
  3342. })
  3343. }
  3344. func (c *HisApiController) ChangeDrugFive() {
  3345. id := c.GetString("id")
  3346. ids := strings.Split(id, ",")
  3347. admin_user_id, _ := c.GetInt64("admin_user_id")
  3348. var err []string
  3349. for _, value := range ids {
  3350. intValue, _ := strconv.ParseInt(value, 10, 64)
  3351. //file := strconv.FormatInt(int64(num), 10)
  3352. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3353. var flows []*models.DrugFlow
  3354. for _, item := range advicelist {
  3355. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3356. flows = append(flows, flow...)
  3357. }
  3358. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3359. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3360. for _, item := range flows {
  3361. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3362. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3363. if prescription.OrderStatus == 2 {
  3364. if item.IsSale == 0 {
  3365. var res FJ3507Result
  3366. var res3507for10188 FJ3507ResultFor10188
  3367. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3368. //进行商品销售接口
  3369. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3370. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3371. var respJSON3 map[string]interface{}
  3372. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3375. return
  3376. }
  3377. userJSONBytes3, _ := json.Marshal(respJSON3)
  3378. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3379. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3380. utils.ErrorLog("解析失败:%v", err)
  3381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3382. return
  3383. }
  3384. //if res3507for10188.Infcode
  3385. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3386. //res.Output = resSix10265.Output
  3387. res.ErrMsg = res3507for10188.ErrMsg
  3388. res.Cainfo = res3507for10188.Cainfo
  3389. res.WarnMsg = res3507for10188.WarnMsg
  3390. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3391. res.Infcode = infocode
  3392. } else {
  3393. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3394. utils.ErrorLog("解析失败:%v", err)
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3396. return
  3397. }
  3398. }
  3399. if res.Infcode == 0 {
  3400. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3401. item.IsSale = 1
  3402. item.Bchno = number
  3403. item.SaleDate = time.Now().Format("2006-01-02")
  3404. service.SaveDF(item)
  3405. } else {
  3406. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3407. }
  3408. }
  3409. } else { //还没结,提示用户去结算,并药品追溯上传
  3410. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3411. }
  3412. }
  3413. }
  3414. str := strings.Join(err, " ")
  3415. saveLog(str, str, "3505", "3505自动上传日志")
  3416. }
  3417. c.ServeSuccessJSON(map[string]interface{}{
  3418. "status": "1",
  3419. "msg": err,
  3420. })
  3421. }
  3422. //func (c *HisApiController) ChangeDrugfour() {
  3423. // patient_id, _ := c.GetInt64("patient_id")
  3424. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3425. // //id_arr := strings.Split(ids, ",")
  3426. // times := c.GetString("time", "")
  3427. // timeLayout := "2006-01-02"
  3428. // loc, _ := time.LoadLocation("Local")
  3429. // var stime, etime int64
  3430. // if times == "" {
  3431. // stime, etime = GetNowTime()
  3432. // } else {
  3433. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3434. // stime = stmp.Unix()
  3435. // etime = stime + 86399
  3436. // }
  3437. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3438. // var flows []*models.DrugFlow
  3439. // for _, item := range advicelist {
  3440. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3441. // flows = append(flows, flow...)
  3442. // }
  3443. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3444. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3445. // var err []string
  3446. //
  3447. // for _, item := range flows {
  3448. // var res3 ResultSix
  3449. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3450. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3451. // if prescription.OrderStatus == 2 {
  3452. // //已经结算
  3453. // //判断是否已经销售
  3454. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3455. // //是否已经变更 1是 0否
  3456. // if item.IsChange == 0 { //没变更,进行变更操作
  3457. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3458. //
  3459. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3460. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3461. // var respJSON3 map[string]interface{}
  3462. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3463. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3465. // return
  3466. // }
  3467. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3468. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3469. // utils.ErrorLog("解析失败:%v", err)
  3470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. // return
  3472. // }
  3473. // if res3.Infcode == 0 {
  3474. // item.IsChange = 1
  3475. // item.BgBchno = bg_number
  3476. // service.SaveDF2(item)
  3477. // } else {
  3478. //
  3479. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3480. // }
  3481. // }
  3482. // } else { //没销售,
  3483. // var res FJ3507Result
  3484. // var res3507for10188 FJ3507ResultFor10188
  3485. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3486. //
  3487. // //进行商品销售接口
  3488. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3489. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3490. // var respJSON3 map[string]interface{}
  3491. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3492. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3494. // return
  3495. // }
  3496. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3497. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3498. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3499. // utils.ErrorLog("解析失败:%v", err)
  3500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. // return
  3502. // }
  3503. // //if res3507for10188.Infcode
  3504. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3505. // //res.Output = resSix10265.Output
  3506. // res.ErrMsg = res3507for10188.ErrMsg
  3507. // res.Cainfo = res3507for10188.Cainfo
  3508. // res.WarnMsg = res3507for10188.WarnMsg
  3509. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3510. // res.Infcode = infocode
  3511. // } else {
  3512. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3513. // utils.ErrorLog("解析失败:%v", err)
  3514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3515. // return
  3516. // }
  3517. //
  3518. // }
  3519. // if res.Infcode == 0 {
  3520. // item.IsSale = 1
  3521. // item.Bchno = number
  3522. // item.SaleDate = time.Now().Format("2006-01-02")
  3523. //
  3524. // err5 := service.SaveDF(item)
  3525. // if err5 == nil {
  3526. // if item.IsChange == 0 { //没变更,进行变更操作
  3527. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3528. //
  3529. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3530. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3531. //
  3532. // var respJSON3 map[string]interface{}
  3533. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3534. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3536. // return
  3537. // }
  3538. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3539. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3540. // utils.ErrorLog("解析失败:%v", err)
  3541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3542. // return
  3543. // }
  3544. // //if res3507for10188.Infcode
  3545. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3546. // //res.Output = resSix10265.Output
  3547. // res3.ErrMsg = res3507for10188.ErrMsg
  3548. // res3.Cainfo = res3507for10188.Cainfo
  3549. // res3.WarnMsg = res3507for10188.WarnMsg
  3550. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3551. // res3.Infcode = infocode
  3552. // } else {
  3553. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3554. // utils.ErrorLog("解析失败:%v", err)
  3555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3556. // return
  3557. // }
  3558. // }
  3559. // if res3.Infcode == 0 {
  3560. // item.IsChange = 1
  3561. // item.BgBchno = bg_number
  3562. // service.SaveDF2(item)
  3563. // } else {
  3564. //
  3565. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3566. // }
  3567. // }
  3568. // }
  3569. // } else {
  3570. //
  3571. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3572. // }
  3573. // }
  3574. //
  3575. // } else { //还没结,提示用户去结算,并药品追溯上传
  3576. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3577. // }
  3578. // }
  3579. // }
  3580. // if len(err) == 0 {
  3581. // c.ServeSuccessJSON(map[string]interface{}{
  3582. // "msg": "销售变更成功",
  3583. // })
  3584. // } else {
  3585. // c.ServeSuccessJSON(map[string]interface{}{
  3586. // "failed_code": -10,
  3587. // "msg": err,
  3588. // })
  3589. // }
  3590. //}
  3591. func (c *HisApiController) ChangeDrug() {
  3592. ids := c.GetString("ids")
  3593. id_arr := strings.Split(ids, ",")
  3594. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3595. admin_user_id, _ := c.GetInt64("admin_user_id")
  3596. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3598. var err []string
  3599. for _, item := range flows {
  3600. var res3 ResultSix
  3601. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3602. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3603. if prescription.OrderStatus == 2 {
  3604. //已经结算
  3605. //判断是否已经销售
  3606. if item.IsSale == 1 { //是否已经销售,1是 0否
  3607. //是否已经变更 1是 0否
  3608. if item.IsChange == 0 { //没变更,进行变更操作
  3609. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3610. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3611. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3612. var respJSON3 map[string]interface{}
  3613. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return
  3617. }
  3618. userJSONBytes3, _ := json.Marshal(respJSON3)
  3619. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3620. utils.ErrorLog("解析失败:%v", err)
  3621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3622. return
  3623. }
  3624. if res3.Infcode == 0 {
  3625. item.IsChange = 1
  3626. item.BgBchno = bg_number
  3627. service.SaveDF2(item)
  3628. } else {
  3629. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3630. }
  3631. }
  3632. } else { //没销售,
  3633. var res FJ3507Result
  3634. var res3507for10188 FJ3507ResultFor10188
  3635. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3636. //进行商品销售接口
  3637. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3638. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3639. var respJSON3 map[string]interface{}
  3640. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3643. return
  3644. }
  3645. userJSONBytes3, _ := json.Marshal(respJSON3)
  3646. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3647. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3648. utils.ErrorLog("解析失败:%v", err)
  3649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3650. return
  3651. }
  3652. //if res3507for10188.Infcode
  3653. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3654. //res.Output = resSix10265.Output
  3655. res.ErrMsg = res3507for10188.ErrMsg
  3656. res.Cainfo = res3507for10188.Cainfo
  3657. res.WarnMsg = res3507for10188.WarnMsg
  3658. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3659. res.Infcode = infocode
  3660. } else {
  3661. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3662. utils.ErrorLog("解析失败:%v", err)
  3663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3664. return
  3665. }
  3666. }
  3667. if res.Infcode == 0 {
  3668. item.IsSale = 1
  3669. item.Bchno = number
  3670. item.SaleDate = time.Now().Format("2006-01-02")
  3671. err5 := service.SaveDF(item)
  3672. if err5 == nil {
  3673. if item.IsChange == 0 { //没变更,进行变更操作
  3674. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3675. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3676. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3677. var respJSON3 map[string]interface{}
  3678. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. return
  3682. }
  3683. userJSONBytes3, _ := json.Marshal(respJSON3)
  3684. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3685. utils.ErrorLog("解析失败:%v", err)
  3686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3687. return
  3688. }
  3689. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3690. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3691. utils.ErrorLog("解析失败:%v", err)
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3693. return
  3694. }
  3695. //if res3507for10188.Infcode
  3696. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3697. //res.Output = resSix10265.Output
  3698. res3.ErrMsg = res3507for10188.ErrMsg
  3699. res3.Cainfo = res3507for10188.Cainfo
  3700. res3.WarnMsg = res3507for10188.WarnMsg
  3701. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3702. res3.Infcode = infocode
  3703. } else {
  3704. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. }
  3710. if res3.Infcode == 0 {
  3711. item.IsChange = 1
  3712. item.BgBchno = bg_number
  3713. service.SaveDF2(item)
  3714. } else {
  3715. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3716. }
  3717. }
  3718. }
  3719. } else {
  3720. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3721. }
  3722. }
  3723. } else { //还没结算
  3724. var res3507for10188 FJ3507ResultFor10188
  3725. if item.IsChange == 0 { //没变更,进行变更操作
  3726. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3727. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3728. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3729. var respJSON3 map[string]interface{}
  3730. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3733. return
  3734. }
  3735. userJSONBytes3, _ := json.Marshal(respJSON3)
  3736. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3737. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3738. utils.ErrorLog("解析失败:%v", err)
  3739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. return
  3741. }
  3742. //if res3507for10188.Infcode
  3743. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3744. //res.Output = resSix10265.Output
  3745. res3.ErrMsg = res3507for10188.ErrMsg
  3746. res3.Cainfo = res3507for10188.Cainfo
  3747. res3.WarnMsg = res3507for10188.WarnMsg
  3748. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3749. res3.Infcode = infocode
  3750. } else {
  3751. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3752. utils.ErrorLog("解析失败:%v", err)
  3753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3754. return
  3755. }
  3756. }
  3757. if res3.Infcode == 0 {
  3758. item.IsChange = 1
  3759. item.BgBchno = bg_number
  3760. service.SaveDF2(item)
  3761. } else {
  3762. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3763. }
  3764. }
  3765. }
  3766. } else if item.ConsumableType == 7 {
  3767. var res3507for10188 FJ3507ResultFor10188
  3768. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3769. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3770. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3771. //判断是否已经销售
  3772. if item.IsSale == 2 { //是否已经销售,1是 0否
  3773. //是否已经变更 1是 0否
  3774. if item.IsChange == 0 { //没变更,进行变更操作
  3775. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3776. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3777. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3778. var respJSON3 map[string]interface{}
  3779. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3782. return
  3783. }
  3784. userJSONBytes3, _ := json.Marshal(respJSON3)
  3785. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3786. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3787. utils.ErrorLog("解析失败:%v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. //if res3507for10188.Infcode
  3792. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3793. //res.Output = resSix10265.Output
  3794. res3.ErrMsg = res3507for10188.ErrMsg
  3795. res3.Cainfo = res3507for10188.Cainfo
  3796. res3.WarnMsg = res3507for10188.WarnMsg
  3797. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3798. res3.Infcode = infocode
  3799. } else {
  3800. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3801. utils.ErrorLog("解析失败:%v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. }
  3806. if res3.Infcode == 0 {
  3807. item.IsChange = 1
  3808. item.BgBchno = bg_number
  3809. service.SaveDF2(item)
  3810. } else {
  3811. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3812. }
  3813. }
  3814. } else { //没销售,
  3815. //进行商品销售退货接口
  3816. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3817. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3818. saveLog(result111, result222, "3506", "销售退货")
  3819. var res7 FJ3507Result
  3820. //进行商品销售接口
  3821. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3822. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3823. var respJSON3 map[string]interface{}
  3824. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3827. return
  3828. }
  3829. userJSONBytes3, _ := json.Marshal(respJSON3)
  3830. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3831. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3832. utils.ErrorLog("解析失败:%v", err)
  3833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3834. return
  3835. }
  3836. //if res3507for10188.Infcode
  3837. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3838. //res.Output = resSix10265.Output
  3839. res7.ErrMsg = res3507for10188.ErrMsg
  3840. res7.Cainfo = res3507for10188.Cainfo
  3841. res7.WarnMsg = res3507for10188.WarnMsg
  3842. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3843. res7.Infcode = infocode
  3844. } else {
  3845. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3846. utils.ErrorLog("解析失败:%v", err)
  3847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3848. return
  3849. }
  3850. }
  3851. if res7.Infcode == 0 {
  3852. item.IsSale = 2
  3853. item.SaleDate = item.SaleDate
  3854. item.Bchno = number
  3855. service.SaveDF(item)
  3856. if item.IsChange == 0 { //没变更,进行变更操作
  3857. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3858. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3859. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3860. var respJSON3 map[string]interface{}
  3861. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. return
  3865. }
  3866. userJSONBytes3, _ := json.Marshal(respJSON3)
  3867. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3868. // utils.ErrorLog("解析失败:%v", err)
  3869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3870. // return
  3871. //}
  3872. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3873. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3874. utils.ErrorLog("解析失败:%v", err)
  3875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3876. return
  3877. }
  3878. //if res3507for10188.Infcode
  3879. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3880. //res.Output = resSix10265.Output
  3881. res3.ErrMsg = res3507for10188.ErrMsg
  3882. res3.Cainfo = res3507for10188.Cainfo
  3883. res3.WarnMsg = res3507for10188.WarnMsg
  3884. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3885. res3.Infcode = infocode
  3886. } else {
  3887. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3888. utils.ErrorLog("解析失败:%v", err)
  3889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3890. return
  3891. }
  3892. }
  3893. if res3.Infcode == 0 {
  3894. item.IsChange = 1
  3895. item.BgBchno = bg_number
  3896. service.SaveDF2(item)
  3897. } else {
  3898. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3899. }
  3900. }
  3901. } else {
  3902. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3903. }
  3904. }
  3905. } else { //还没结算
  3906. if item.IsChange == 0 { //没变更,进行变更操作
  3907. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3908. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3909. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3910. var respJSON3 map[string]interface{}
  3911. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3914. return
  3915. }
  3916. userJSONBytes3, _ := json.Marshal(respJSON3)
  3917. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3918. // utils.ErrorLog("解析失败:%v", err)
  3919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3920. // return
  3921. //}
  3922. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3923. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3924. utils.ErrorLog("解析失败:%v", err)
  3925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3926. return
  3927. }
  3928. //if res3507for10188.Infcode
  3929. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3930. //res.Output = resSix10265.Output
  3931. res3.ErrMsg = res3507for10188.ErrMsg
  3932. res3.Cainfo = res3507for10188.Cainfo
  3933. res3.WarnMsg = res3507for10188.WarnMsg
  3934. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3935. res3.Infcode = infocode
  3936. } else {
  3937. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3938. utils.ErrorLog("解析失败:%v", err)
  3939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. return
  3941. }
  3942. }
  3943. if res3.Infcode == 0 {
  3944. item.IsChange = 1
  3945. item.BgBchno = bg_number
  3946. service.SaveDF2(item)
  3947. } else {
  3948. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3949. }
  3950. }
  3951. }
  3952. }
  3953. }
  3954. if len(err) == 0 {
  3955. c.ServeSuccessJSON(map[string]interface{}{
  3956. "msg": "销售变更成功",
  3957. })
  3958. } else {
  3959. c.ServeSuccessJSON(map[string]interface{}{
  3960. "failed_code": -10,
  3961. "msg": err,
  3962. })
  3963. }
  3964. }
  3965. func (c *HisApiController) ChangeDrugtwo() {
  3966. //ids := c.GetString("ids")
  3967. //id_arr := strings.Split(ids, ",")
  3968. flows, _ := service.GetNewDrugFlowInfothree123()
  3969. admin_user_id, _ := c.GetInt64("admin_user_id")
  3970. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3971. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3972. var err []string
  3973. for _, item := range flows {
  3974. var res3 ResultSix
  3975. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3976. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3977. if prescription.OrderStatus == 2 {
  3978. //已经结算
  3979. //判断是否已经销售
  3980. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3981. // //是否已经变更 1是 0否
  3982. // if item.IsChange == 0 { //没变更,进行变更操作
  3983. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3984. //
  3985. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3986. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3987. // var respJSON3 map[string]interface{}
  3988. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3989. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3991. // return
  3992. // }
  3993. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3994. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3995. // utils.ErrorLog("解析失败:%v", err)
  3996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3997. // return
  3998. // }
  3999. // if res3.Infcode == 0 {
  4000. // item.IsChange = 1
  4001. // item.BgBchno = bg_number
  4002. // service.SaveDF2(item)
  4003. // } else {
  4004. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4005. // }
  4006. // }
  4007. //}
  4008. //else
  4009. { //没销售,
  4010. var res FJ3507Result
  4011. var res3507for10188 FJ3507ResultFor10188
  4012. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4013. //进行商品销售接口
  4014. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4015. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4016. var respJSON3 map[string]interface{}
  4017. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. return
  4021. }
  4022. userJSONBytes3, _ := json.Marshal(respJSON3)
  4023. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4024. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4025. utils.ErrorLog("解析失败:%v", err)
  4026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4027. return
  4028. }
  4029. //if res3507for10188.Infcode
  4030. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4031. //res.Output = resSix10265.Output
  4032. res.ErrMsg = res3507for10188.ErrMsg
  4033. res.Cainfo = res3507for10188.Cainfo
  4034. res.WarnMsg = res3507for10188.WarnMsg
  4035. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4036. res.Infcode = infocode
  4037. } else {
  4038. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4039. utils.ErrorLog("解析失败:%v", err)
  4040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4041. return
  4042. }
  4043. }
  4044. if res.Infcode == 0 {
  4045. item.IsSale = 1
  4046. item.Bchno = number
  4047. item.SaleDate = time.Now().Format("2006-01-02")
  4048. service.SaveDF(item)
  4049. //if err5 == nil {
  4050. // if item.IsChange == 0 { //没变更,进行变更操作
  4051. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4052. //
  4053. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4054. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4055. //
  4056. // var respJSON3 map[string]interface{}
  4057. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4058. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4060. // return
  4061. // }
  4062. //
  4063. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4064. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4065. // utils.ErrorLog("解析失败:%v", err)
  4066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. // return
  4068. // }
  4069. // //if res3507for10188.Infcode
  4070. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4071. // //res.Output = resSix10265.Output
  4072. // res3.ErrMsg = res3507for10188.ErrMsg
  4073. // res3.Cainfo = res3507for10188.Cainfo
  4074. // res3.WarnMsg = res3507for10188.WarnMsg
  4075. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4076. // res3.Infcode = infocode
  4077. // } else {
  4078. //
  4079. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4080. // utils.ErrorLog("解析失败:%v", err)
  4081. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4082. // return
  4083. // }
  4084. //
  4085. // }
  4086. //
  4087. // if res3.Infcode == 0 {
  4088. // item.IsChange = 1
  4089. // item.BgBchno = bg_number
  4090. // service.SaveDF2(item)
  4091. // } else {
  4092. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4093. // }
  4094. // }
  4095. //}
  4096. } else {
  4097. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4098. }
  4099. }
  4100. } else { //还没结算
  4101. var res3507for10188 FJ3507ResultFor10188
  4102. if item.IsChange == 0 { //没变更,进行变更操作
  4103. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4104. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4105. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4106. var respJSON3 map[string]interface{}
  4107. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4110. return
  4111. }
  4112. userJSONBytes3, _ := json.Marshal(respJSON3)
  4113. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4114. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4115. utils.ErrorLog("解析失败:%v", err)
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4117. return
  4118. }
  4119. //if res3507for10188.Infcode
  4120. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4121. //res.Output = resSix10265.Output
  4122. res3.ErrMsg = res3507for10188.ErrMsg
  4123. res3.Cainfo = res3507for10188.Cainfo
  4124. res3.WarnMsg = res3507for10188.WarnMsg
  4125. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4126. res3.Infcode = infocode
  4127. } else {
  4128. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4129. utils.ErrorLog("解析失败:%v", err)
  4130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4131. return
  4132. }
  4133. }
  4134. if res3.Infcode == 0 {
  4135. item.IsChange = 1
  4136. item.BgBchno = bg_number
  4137. service.SaveDF2(item)
  4138. } else {
  4139. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4140. }
  4141. }
  4142. }
  4143. }
  4144. //if item.ConsumableType == 7 {
  4145. // var res3507for10188 FJ3507ResultFor10188
  4146. //
  4147. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4148. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4149. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4150. // //判断是否已经销售
  4151. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4152. // //是否已经变更 1是 0否
  4153. // if item.IsChange == 0 { //没变更,进行变更操作
  4154. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4155. //
  4156. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4157. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4158. //
  4159. // var respJSON3 map[string]interface{}
  4160. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4161. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4163. // return
  4164. // }
  4165. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4166. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4167. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4168. // utils.ErrorLog("解析失败:%v", err)
  4169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. // return
  4171. // }
  4172. // //if res3507for10188.Infcode
  4173. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4174. // //res.Output = resSix10265.Output
  4175. // res3.ErrMsg = res3507for10188.ErrMsg
  4176. // res3.Cainfo = res3507for10188.Cainfo
  4177. // res3.WarnMsg = res3507for10188.WarnMsg
  4178. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4179. // res3.Infcode = infocode
  4180. // } else {
  4181. //
  4182. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4183. // utils.ErrorLog("解析失败:%v", err)
  4184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4185. // return
  4186. // }
  4187. //
  4188. // }
  4189. // if res3.Infcode == 0 {
  4190. // item.IsChange = 1
  4191. // item.BgBchno = bg_number
  4192. // service.SaveDF2(item)
  4193. // } else {
  4194. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4195. // }
  4196. // }
  4197. // } else { //没销售,
  4198. // //进行商品销售退货接口
  4199. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4200. //
  4201. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4202. // saveLog(result111, result222, "3506", "销售退货")
  4203. // var res7 FJ3507Result
  4204. //
  4205. // //进行商品销售接口
  4206. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4207. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4208. // var respJSON3 map[string]interface{}
  4209. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4210. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4212. // return
  4213. // }
  4214. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4215. //
  4216. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4217. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4218. // utils.ErrorLog("解析失败:%v", err)
  4219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4220. // return
  4221. // }
  4222. // //if res3507for10188.Infcode
  4223. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4224. // //res.Output = resSix10265.Output
  4225. // res7.ErrMsg = res3507for10188.ErrMsg
  4226. // res7.Cainfo = res3507for10188.Cainfo
  4227. // res7.WarnMsg = res3507for10188.WarnMsg
  4228. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4229. // res7.Infcode = infocode
  4230. // } else {
  4231. //
  4232. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4233. // utils.ErrorLog("解析失败:%v", err)
  4234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4235. // return
  4236. // }
  4237. //
  4238. // }
  4239. // if res7.Infcode == 0 {
  4240. // item.IsSale = 2
  4241. // item.SaleDate = item.SaleDate
  4242. // item.Bchno = number
  4243. // service.SaveDF(item)
  4244. // if item.IsChange == 0 { //没变更,进行变更操作
  4245. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4246. //
  4247. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4248. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4249. //
  4250. // var respJSON3 map[string]interface{}
  4251. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4252. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4254. // return
  4255. // }
  4256. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4257. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4258. // // utils.ErrorLog("解析失败:%v", err)
  4259. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. // // return
  4261. // //}
  4262. //
  4263. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4264. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4265. // utils.ErrorLog("解析失败:%v", err)
  4266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4267. // return
  4268. // }
  4269. // //if res3507for10188.Infcode
  4270. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4271. // //res.Output = resSix10265.Output
  4272. // res3.ErrMsg = res3507for10188.ErrMsg
  4273. // res3.Cainfo = res3507for10188.Cainfo
  4274. // res3.WarnMsg = res3507for10188.WarnMsg
  4275. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4276. // res3.Infcode = infocode
  4277. // } else {
  4278. //
  4279. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4280. // utils.ErrorLog("解析失败:%v", err)
  4281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4282. // return
  4283. // }
  4284. //
  4285. // }
  4286. // if res3.Infcode == 0 {
  4287. // item.IsChange = 1
  4288. // item.BgBchno = bg_number
  4289. // service.SaveDF2(item)
  4290. // } else {
  4291. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4292. // }
  4293. // }
  4294. // } else {
  4295. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4296. // }
  4297. // }
  4298. // } else { //还没结算
  4299. // if item.IsChange == 0 { //没变更,进行变更操作
  4300. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4301. //
  4302. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4303. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4304. //
  4305. // var respJSON3 map[string]interface{}
  4306. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4307. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. // return
  4310. // }
  4311. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4312. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4313. // // utils.ErrorLog("解析失败:%v", err)
  4314. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4315. // // return
  4316. // //}
  4317. //
  4318. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4319. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4320. // utils.ErrorLog("解析失败:%v", err)
  4321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. // return
  4323. // }
  4324. // //if res3507for10188.Infcode
  4325. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4326. // //res.Output = resSix10265.Output
  4327. // res3.ErrMsg = res3507for10188.ErrMsg
  4328. // res3.Cainfo = res3507for10188.Cainfo
  4329. // res3.WarnMsg = res3507for10188.WarnMsg
  4330. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4331. // res3.Infcode = infocode
  4332. // } else {
  4333. //
  4334. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4335. // utils.ErrorLog("解析失败:%v", err)
  4336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4337. // return
  4338. // }
  4339. //
  4340. // }
  4341. // if res3.Infcode == 0 {
  4342. // item.IsChange = 1
  4343. // item.BgBchno = bg_number
  4344. // service.SaveDF2(item)
  4345. // } else {
  4346. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4347. // }
  4348. // }
  4349. // }
  4350. //}
  4351. }
  4352. if len(err) == 0 {
  4353. c.ServeSuccessJSON(map[string]interface{}{
  4354. "msg": "销售变更成功",
  4355. })
  4356. } else {
  4357. c.ServeSuccessJSON(map[string]interface{}{
  4358. "failed_code": -10,
  4359. "msg": err,
  4360. })
  4361. }
  4362. }
  4363. func (c *HisApiController) ChangeDrugthree() {
  4364. //ids := c.GetString("ids")
  4365. //id_arr := strings.Split(ids, ",")
  4366. flows, _ := service.GetNewDrugFlowInfothree()
  4367. admin_user_id, _ := c.GetInt64("admin_user_id")
  4368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4369. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4370. var err []string
  4371. for _, item := range flows {
  4372. var res3 ResultSix
  4373. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4374. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4375. if prescription.OrderStatus == 2 {
  4376. //已经结算
  4377. //判断是否已经销售
  4378. if item.IsSale == 1 { //是否已经销售,1是 0否
  4379. //是否已经变更 1是 0否
  4380. if item.IsChange == 0 { //没变更,进行变更操作
  4381. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4382. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4383. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4384. var respJSON3 map[string]interface{}
  4385. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. userJSONBytes3, _ := json.Marshal(respJSON3)
  4391. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4392. utils.ErrorLog("解析失败:%v", err)
  4393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. return
  4395. }
  4396. if res3.Infcode == 0 {
  4397. item.IsChange = 1
  4398. item.BgBchno = bg_number
  4399. service.SaveDF2(item)
  4400. } else {
  4401. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4402. }
  4403. }
  4404. } else { //没销售,
  4405. var res FJ3507Result
  4406. var res3507for10188 FJ3507ResultFor10188
  4407. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4408. //进行商品销售接口
  4409. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4410. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4411. var respJSON3 map[string]interface{}
  4412. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4415. return
  4416. }
  4417. userJSONBytes3, _ := json.Marshal(respJSON3)
  4418. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4419. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4420. utils.ErrorLog("解析失败:%v", err)
  4421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4422. return
  4423. }
  4424. //if res3507for10188.Infcode
  4425. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4426. //res.Output = resSix10265.Output
  4427. res.ErrMsg = res3507for10188.ErrMsg
  4428. res.Cainfo = res3507for10188.Cainfo
  4429. res.WarnMsg = res3507for10188.WarnMsg
  4430. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4431. res.Infcode = infocode
  4432. } else {
  4433. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4434. utils.ErrorLog("解析失败:%v", err)
  4435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4436. return
  4437. }
  4438. }
  4439. if res.Infcode == 0 {
  4440. item.IsSale = 1
  4441. item.Bchno = number
  4442. item.SaleDate = time.Now().Format("2006-01-02")
  4443. err5 := service.SaveDF(item)
  4444. if err5 == nil {
  4445. if item.IsChange == 0 { //没变更,进行变更操作
  4446. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4447. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4448. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4449. var respJSON3 map[string]interface{}
  4450. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4453. return
  4454. }
  4455. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4456. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4457. utils.ErrorLog("解析失败:%v", err)
  4458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4459. return
  4460. }
  4461. //if res3507for10188.Infcode
  4462. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4463. //res.Output = resSix10265.Output
  4464. res3.ErrMsg = res3507for10188.ErrMsg
  4465. res3.Cainfo = res3507for10188.Cainfo
  4466. res3.WarnMsg = res3507for10188.WarnMsg
  4467. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4468. res3.Infcode = infocode
  4469. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4470. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4471. utils.ErrorLog("解析失败:%v", err)
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4473. return
  4474. }
  4475. //if res3507for10188.Infcode
  4476. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4477. //res.Output = resSix10265.Output
  4478. res3.ErrMsg = res3507for10188.ErrMsg
  4479. res3.Cainfo = res3507for10188.Cainfo
  4480. res3.WarnMsg = res3507for10188.WarnMsg
  4481. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4482. res3.Infcode = infocode
  4483. } else {
  4484. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4485. utils.ErrorLog("解析失败:%v", err)
  4486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. return
  4488. }
  4489. }
  4490. if res3.Infcode == 0 {
  4491. item.IsChange = 1
  4492. item.BgBchno = bg_number
  4493. service.SaveDF2(item)
  4494. } else {
  4495. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4496. }
  4497. }
  4498. }
  4499. } else {
  4500. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4501. }
  4502. }
  4503. } else { //还没结算
  4504. var res3507for10188 FJ3507ResultFor10188
  4505. if item.IsChange == 0 { //没变更,进行变更操作
  4506. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4507. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4508. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4509. var respJSON3 map[string]interface{}
  4510. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4513. return
  4514. }
  4515. userJSONBytes3, _ := json.Marshal(respJSON3)
  4516. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4517. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4518. utils.ErrorLog("解析失败:%v", err)
  4519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4520. return
  4521. }
  4522. //if res3507for10188.Infcode
  4523. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4524. //res.Output = resSix10265.Output
  4525. res3.ErrMsg = res3507for10188.ErrMsg
  4526. res3.Cainfo = res3507for10188.Cainfo
  4527. res3.WarnMsg = res3507for10188.WarnMsg
  4528. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4529. res3.Infcode = infocode
  4530. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4531. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4532. utils.ErrorLog("解析失败:%v", err)
  4533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4534. return
  4535. }
  4536. //if res3507for10188.Infcode
  4537. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4538. //res.Output = resSix10265.Output
  4539. res3.ErrMsg = res3507for10188.ErrMsg
  4540. res3.Cainfo = res3507for10188.Cainfo
  4541. res3.WarnMsg = res3507for10188.WarnMsg
  4542. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4543. res3.Infcode = infocode
  4544. } else {
  4545. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4546. utils.ErrorLog("解析失败:%v", err)
  4547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4548. return
  4549. }
  4550. }
  4551. if res3.Infcode == 0 {
  4552. item.IsChange = 1
  4553. item.BgBchno = bg_number
  4554. service.SaveDF2(item)
  4555. } else {
  4556. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4557. }
  4558. }
  4559. }
  4560. } else if item.ConsumableType == 7 {
  4561. var res3507for10188 FJ3507ResultFor10188
  4562. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4563. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4564. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4565. //判断是否已经销售
  4566. if item.IsSale == 2 { //是否已经销售,1是 0否
  4567. //是否已经变更 1是 0否
  4568. if item.IsChange == 0 { //没变更,进行变更操作
  4569. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4570. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4571. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4572. var respJSON3 map[string]interface{}
  4573. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4576. return
  4577. }
  4578. userJSONBytes3, _ := json.Marshal(respJSON3)
  4579. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4580. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4581. utils.ErrorLog("解析失败:%v", err)
  4582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4583. return
  4584. }
  4585. //if res3507for10188.Infcode
  4586. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4587. //res.Output = resSix10265.Output
  4588. res3.ErrMsg = res3507for10188.ErrMsg
  4589. res3.Cainfo = res3507for10188.Cainfo
  4590. res3.WarnMsg = res3507for10188.WarnMsg
  4591. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4592. res3.Infcode = infocode
  4593. } else {
  4594. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4595. utils.ErrorLog("解析失败:%v", err)
  4596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4597. return
  4598. }
  4599. }
  4600. if res3.Infcode == 0 {
  4601. item.IsChange = 1
  4602. item.BgBchno = bg_number
  4603. service.SaveDF2(item)
  4604. } else {
  4605. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4606. }
  4607. }
  4608. } else { //没销售,
  4609. //进行商品销售退货接口
  4610. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4611. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4612. saveLog(result111, result222, "3506", "销售退货")
  4613. var res7 FJ3507Result
  4614. //进行商品销售接口
  4615. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4616. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4617. var respJSON3 map[string]interface{}
  4618. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. return
  4622. }
  4623. userJSONBytes3, _ := json.Marshal(respJSON3)
  4624. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4625. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4626. utils.ErrorLog("解析失败:%v", err)
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4628. return
  4629. }
  4630. //if res3507for10188.Infcode
  4631. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4632. //res.Output = resSix10265.Output
  4633. res7.ErrMsg = res3507for10188.ErrMsg
  4634. res7.Cainfo = res3507for10188.Cainfo
  4635. res7.WarnMsg = res3507for10188.WarnMsg
  4636. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4637. res7.Infcode = infocode
  4638. } else {
  4639. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4640. utils.ErrorLog("解析失败:%v", err)
  4641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4642. return
  4643. }
  4644. }
  4645. if res7.Infcode == 0 {
  4646. item.IsSale = 2
  4647. item.SaleDate = item.SaleDate
  4648. item.Bchno = number
  4649. service.SaveDF(item)
  4650. if item.IsChange == 0 { //没变更,进行变更操作
  4651. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4652. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4653. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4654. var respJSON3 map[string]interface{}
  4655. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4658. return
  4659. }
  4660. userJSONBytes3, _ := json.Marshal(respJSON3)
  4661. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4662. // utils.ErrorLog("解析失败:%v", err)
  4663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4664. // return
  4665. //}
  4666. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4667. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4668. utils.ErrorLog("解析失败:%v", err)
  4669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4670. return
  4671. }
  4672. //if res3507for10188.Infcode
  4673. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4674. //res.Output = resSix10265.Output
  4675. res3.ErrMsg = res3507for10188.ErrMsg
  4676. res3.Cainfo = res3507for10188.Cainfo
  4677. res3.WarnMsg = res3507for10188.WarnMsg
  4678. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4679. res3.Infcode = infocode
  4680. } else {
  4681. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4682. utils.ErrorLog("解析失败:%v", err)
  4683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4684. return
  4685. }
  4686. }
  4687. if res3.Infcode == 0 {
  4688. item.IsChange = 1
  4689. item.BgBchno = bg_number
  4690. service.SaveDF2(item)
  4691. } else {
  4692. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4693. }
  4694. }
  4695. } else {
  4696. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4697. }
  4698. }
  4699. } else { //还没结算
  4700. if item.IsChange == 0 { //没变更,进行变更操作
  4701. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4702. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4703. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4704. var respJSON3 map[string]interface{}
  4705. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. userJSONBytes3, _ := json.Marshal(respJSON3)
  4711. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4712. // utils.ErrorLog("解析失败:%v", err)
  4713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. // return
  4715. //}
  4716. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4717. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4718. utils.ErrorLog("解析失败:%v", err)
  4719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4720. return
  4721. }
  4722. //if res3507for10188.Infcode
  4723. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4724. //res.Output = resSix10265.Output
  4725. res3.ErrMsg = res3507for10188.ErrMsg
  4726. res3.Cainfo = res3507for10188.Cainfo
  4727. res3.WarnMsg = res3507for10188.WarnMsg
  4728. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4729. res3.Infcode = infocode
  4730. } else {
  4731. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4732. utils.ErrorLog("解析失败:%v", err)
  4733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4734. return
  4735. }
  4736. }
  4737. if res3.Infcode == 0 {
  4738. item.IsChange = 1
  4739. item.BgBchno = bg_number
  4740. service.SaveDF2(item)
  4741. } else {
  4742. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4743. }
  4744. }
  4745. }
  4746. }
  4747. }
  4748. if len(err) == 0 {
  4749. c.ServeSuccessJSON(map[string]interface{}{
  4750. "msg": "销售变更成功",
  4751. })
  4752. } else {
  4753. c.ServeSuccessJSON(map[string]interface{}{
  4754. "failed_code": -10,
  4755. "msg": err,
  4756. })
  4757. }
  4758. }
  4759. func (c *HisApiController) ChangeDrugTen() {
  4760. start_time_str := c.GetString("start_time")
  4761. end_time_str := c.GetString("end_time")
  4762. //ids := c.GetString("ids")
  4763. //id_arr := strings.Split(ids, ",")
  4764. timeLayout := "2006-01-02"
  4765. loc, _ := time.LoadLocation("Local")
  4766. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4767. recordStartTime := theStartTime.Unix()
  4768. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4769. recordEndTime := theEndTime.Unix()
  4770. //timestamp := int64(1729612800)
  4771. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4772. admin_user_id, _ := c.GetInt64("admin_user_id")
  4773. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4774. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4775. var err []string
  4776. for _, item := range flows {
  4777. var res3 ResultSix
  4778. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4779. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4780. continue
  4781. }
  4782. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4783. continue
  4784. }
  4785. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4786. if prescription.OrderStatus == 2 {
  4787. //已经结算
  4788. //判断 是否已经销售
  4789. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4790. ////是否已经变更 1是 0否
  4791. //if item.IsChange == 0 { //没变更,进行变更操作
  4792. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4793. //
  4794. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4795. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4796. // var respJSON3 map[string]interface{}
  4797. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4798. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4800. // return
  4801. // }
  4802. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4803. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4804. // utils.ErrorLog("解析失败:%v", err)
  4805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4806. // return
  4807. // }
  4808. // if res3.Infcode == 0 {
  4809. // item.IsChange = 1
  4810. // item.BgBchno = bg_number
  4811. // service.SaveDF2(item)
  4812. // } else {
  4813. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4814. // }
  4815. //}
  4816. //} else
  4817. if item.IsSale == 0 { //没销售,
  4818. var res FJ3507Result
  4819. var res3507for10188 FJ3507ResultFor10188
  4820. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4821. //进行商品销售接口
  4822. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4823. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4824. var respJSON3 map[string]interface{}
  4825. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4828. return
  4829. }
  4830. userJSONBytes3, _ := json.Marshal(respJSON3)
  4831. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4832. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4833. utils.ErrorLog("解析失败:%v", err)
  4834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4835. return
  4836. }
  4837. //if res3507for10188.Infcode
  4838. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4839. //res.Output = resSix10265.Output
  4840. res.ErrMsg = res3507for10188.ErrMsg
  4841. res.Cainfo = res3507for10188.Cainfo
  4842. res.WarnMsg = res3507for10188.WarnMsg
  4843. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4844. res.Infcode = infocode
  4845. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4846. } else {
  4847. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4848. utils.ErrorLog("解析失败:%v", err)
  4849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4850. return
  4851. }
  4852. }
  4853. if res.Infcode == 0 {
  4854. item.IsSale = 1
  4855. item.Bchno = number
  4856. item.SaleDate = time.Now().Format("2006-01-02")
  4857. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  4858. err5 := service.SaveDF(item)
  4859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4860. //if err5 == nil {
  4861. //
  4862. // if item.IsChange == 1 { //没变更,进行变更操作
  4863. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4864. //
  4865. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4866. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4867. //
  4868. // var respJSON3 map[string]interface{}
  4869. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4870. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4871. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4872. // return
  4873. // }
  4874. //
  4875. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4876. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4877. // utils.ErrorLog("解析失败:%v", err)
  4878. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4879. // return
  4880. // }
  4881. // //if res3507for10188.Infcode
  4882. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4883. // //res.Output = resSix10265.Output
  4884. // res3.ErrMsg = res3507for10188.ErrMsg
  4885. // res3.Cainfo = res3507for10188.Cainfo
  4886. // res3.WarnMsg = res3507for10188.WarnMsg
  4887. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4888. // res3.Infcode = infocode
  4889. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4890. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4891. // utils.ErrorLog("解析失败:%v", err)
  4892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4893. // return
  4894. // }
  4895. // //if res3507for10188.Infcode
  4896. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4897. // //res.Output = resSix10265.Output
  4898. // res3.ErrMsg = res3507for10188.ErrMsg
  4899. // res3.Cainfo = res3507for10188.Cainfo
  4900. // res3.WarnMsg = res3507for10188.WarnMsg
  4901. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4902. // res3.Infcode = infocode
  4903. //
  4904. // } else {
  4905. //
  4906. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4907. // utils.ErrorLog("解析失败:%v", err)
  4908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. // return
  4910. // }
  4911. //
  4912. // }
  4913. //
  4914. // if res3.Infcode == 0 {
  4915. // item.IsChange = 1
  4916. // item.BgBchno = bg_number
  4917. // service.SaveDF2(item)
  4918. // return
  4919. // } else {
  4920. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4921. // }
  4922. // }
  4923. //}
  4924. } else {
  4925. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4926. }
  4927. }
  4928. }
  4929. } else if item.ConsumableType == 7 {
  4930. var res3507for10188 FJ3507ResultFor10188
  4931. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4932. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4933. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4934. //判断是否已经销售
  4935. if item.IsSale == 2 { //是否已经销售,1是 0否
  4936. //是否已经变更 1是 0否
  4937. if item.IsChange == 0 { //没变更,进行变更操作
  4938. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4939. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4940. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4941. var respJSON3 map[string]interface{}
  4942. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4945. return
  4946. }
  4947. userJSONBytes3, _ := json.Marshal(respJSON3)
  4948. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4949. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4950. utils.ErrorLog("解析失败:%v", err)
  4951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4952. return
  4953. }
  4954. //if res3507for10188.Infcode
  4955. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4956. //res.Output = resSix10265.Output
  4957. res3.ErrMsg = res3507for10188.ErrMsg
  4958. res3.Cainfo = res3507for10188.Cainfo
  4959. res3.WarnMsg = res3507for10188.WarnMsg
  4960. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4961. res3.Infcode = infocode
  4962. } else {
  4963. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4964. utils.ErrorLog("解析失败:%v", err)
  4965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4966. return
  4967. }
  4968. }
  4969. if res3.Infcode == 0 {
  4970. item.IsChange = 1
  4971. item.BgBchno = bg_number
  4972. service.SaveDF2(item)
  4973. } else {
  4974. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4975. }
  4976. }
  4977. } else { //没销售,
  4978. //进行商品销售退货接口
  4979. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4980. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4981. saveLog(result111, result222, "3506", "销售退货")
  4982. var res7 FJ3507Result
  4983. //进行商品销售接口
  4984. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4985. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4986. var respJSON3 map[string]interface{}
  4987. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4990. return
  4991. }
  4992. userJSONBytes3, _ := json.Marshal(respJSON3)
  4993. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4994. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4995. utils.ErrorLog("解析失败:%v", err)
  4996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4997. return
  4998. }
  4999. //if res3507for10188.Infcode
  5000. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5001. //res.Output = resSix10265.Output
  5002. res7.ErrMsg = res3507for10188.ErrMsg
  5003. res7.Cainfo = res3507for10188.Cainfo
  5004. res7.WarnMsg = res3507for10188.WarnMsg
  5005. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5006. res7.Infcode = infocode
  5007. } else {
  5008. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5009. utils.ErrorLog("解析失败:%v", err)
  5010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5011. return
  5012. }
  5013. }
  5014. if res7.Infcode == 0 {
  5015. item.IsSale = 2
  5016. item.SaleDate = item.SaleDate
  5017. item.Bchno = number
  5018. service.SaveDF(item)
  5019. if item.IsChange == 0 { //没变更,进行变更操作
  5020. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5021. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5022. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5023. var respJSON3 map[string]interface{}
  5024. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5027. return
  5028. }
  5029. userJSONBytes3, _ := json.Marshal(respJSON3)
  5030. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5031. // utils.ErrorLog("解析失败:%v", err)
  5032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5033. // return
  5034. //}
  5035. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5036. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5037. utils.ErrorLog("解析失败:%v", err)
  5038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5039. return
  5040. }
  5041. //if res3507for10188.Infcode
  5042. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5043. //res.Output = resSix10265.Output
  5044. res3.ErrMsg = res3507for10188.ErrMsg
  5045. res3.Cainfo = res3507for10188.Cainfo
  5046. res3.WarnMsg = res3507for10188.WarnMsg
  5047. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5048. res3.Infcode = infocode
  5049. } else {
  5050. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5051. utils.ErrorLog("解析失败:%v", err)
  5052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5053. return
  5054. }
  5055. }
  5056. if res3.Infcode == 0 {
  5057. item.IsChange = 1
  5058. item.BgBchno = bg_number
  5059. service.SaveDF2(item)
  5060. } else {
  5061. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5062. }
  5063. }
  5064. } else {
  5065. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5066. }
  5067. }
  5068. } else { //还没结算
  5069. if item.IsChange == 0 { //没变更,进行变更操作
  5070. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5071. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5072. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5073. var respJSON3 map[string]interface{}
  5074. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5077. return
  5078. }
  5079. userJSONBytes3, _ := json.Marshal(respJSON3)
  5080. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5081. // utils.ErrorLog("解析失败:%v", err)
  5082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5083. // return
  5084. //}
  5085. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5086. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5087. utils.ErrorLog("解析失败:%v", err)
  5088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5089. return
  5090. }
  5091. //if res3507for10188.Infcode
  5092. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5093. //res.Output = resSix10265.Output
  5094. res3.ErrMsg = res3507for10188.ErrMsg
  5095. res3.Cainfo = res3507for10188.Cainfo
  5096. res3.WarnMsg = res3507for10188.WarnMsg
  5097. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5098. res3.Infcode = infocode
  5099. } else {
  5100. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5101. utils.ErrorLog("解析失败:%v", err)
  5102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5103. return
  5104. }
  5105. }
  5106. if res3.Infcode == 0 {
  5107. item.IsChange = 1
  5108. item.BgBchno = bg_number
  5109. service.SaveDF2(item)
  5110. } else {
  5111. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5112. }
  5113. }
  5114. }
  5115. }
  5116. }
  5117. if len(err) == 0 {
  5118. c.ServeSuccessJSON(map[string]interface{}{
  5119. "msg": "销售变更成功",
  5120. })
  5121. } else {
  5122. c.ServeSuccessJSON(map[string]interface{}{
  5123. "failed_code": -10,
  5124. "msg": err,
  5125. })
  5126. }
  5127. }
  5128. func ChangeDrugTenone() {
  5129. //ids := c.GetString("ids")
  5130. //id_arr := strings.Split(ids, ",")
  5131. now := time.Now()
  5132. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5133. //timestamp := int64(1729612800)
  5134. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5135. admin_user_id := int64(2463)
  5136. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5137. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5138. var err []string
  5139. for _, item := range flows {
  5140. var res3 ResultSix
  5141. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5142. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5143. continue
  5144. }
  5145. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5146. continue
  5147. }
  5148. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5149. if prescription.OrderStatus == 2 {
  5150. //已经结算
  5151. //判断是否已经销售
  5152. if item.IsSale == 1 { //是否已经销售,1是 0否
  5153. //是否已经变更 1是 0否
  5154. if item.IsChange == 0 { //没变更,进行变更操作
  5155. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5156. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5157. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5158. var respJSON3 map[string]interface{}
  5159. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5161. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5162. return
  5163. }
  5164. userJSONBytes3, _ := json.Marshal(respJSON3)
  5165. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5166. utils.ErrorLog("解析失败:%v", err)
  5167. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. return
  5169. }
  5170. if res3.Infcode == 0 {
  5171. item.IsChange = 1
  5172. item.BgBchno = bg_number
  5173. service.SaveDF2(item)
  5174. } else {
  5175. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5176. }
  5177. }
  5178. } else { //没销售,
  5179. var res FJ3507Result
  5180. var res3507for10188 FJ3507ResultFor10188
  5181. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5182. //进行商品销售接口
  5183. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5184. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5185. var respJSON3 map[string]interface{}
  5186. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5188. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5189. return
  5190. }
  5191. userJSONBytes3, _ := json.Marshal(respJSON3)
  5192. {
  5193. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5194. utils.ErrorLog("解析失败:%v", err)
  5195. return
  5196. }
  5197. //if res3507for10188.Infcode
  5198. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5199. //res.Output = resSix10265.Output
  5200. res.ErrMsg = res3507for10188.ErrMsg
  5201. res.Cainfo = res3507for10188.Cainfo
  5202. res.WarnMsg = res3507for10188.WarnMsg
  5203. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5204. res.Infcode = infocode
  5205. }
  5206. if res.Infcode == 0 {
  5207. item.IsSale = 1
  5208. item.Bchno = number
  5209. item.SaleDate = time.Now().Format("2006-01-02")
  5210. err5 := service.SaveDF(item)
  5211. if err5 == nil {
  5212. if item.IsChange == 1 { //没变更,进行变更操作
  5213. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5214. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5215. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5216. var respJSON3 map[string]interface{}
  5217. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5219. return
  5220. }
  5221. {
  5222. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5223. utils.ErrorLog("解析失败:%v", err)
  5224. return
  5225. }
  5226. //if res3507for10188.Infcode
  5227. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5228. //res.Output = resSix10265.Output
  5229. res3.ErrMsg = res3507for10188.ErrMsg
  5230. res3.Cainfo = res3507for10188.Cainfo
  5231. res3.WarnMsg = res3507for10188.WarnMsg
  5232. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5233. res3.Infcode = infocode
  5234. }
  5235. if res3.Infcode == 0 {
  5236. item.IsChange = 1
  5237. item.BgBchno = bg_number
  5238. service.SaveDF2(item)
  5239. } else {
  5240. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5241. }
  5242. }
  5243. }
  5244. } else {
  5245. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5246. }
  5247. }
  5248. }
  5249. }
  5250. }
  5251. }
  5252. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5253. var struct3502 models.Struct3502
  5254. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5255. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5256. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5257. struct3502.FixmedinsCode = miConfig.Code
  5258. struct3502.Code = miConfig.Code
  5259. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5260. struct3502.Opter = role.UserName
  5261. struct3502.RxFlag = "1"
  5262. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5263. struct3502.OrgName = miConfig.OrgName
  5264. struct3502.AccessKey = miConfig.AccessKey
  5265. struct3502.RequestUrl = miConfig.Url
  5266. struct3502.SecretKey = miConfig.SecretKey
  5267. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5268. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5269. struct3502.Url = miConfig.Url
  5270. struct3502.AppId = miConfig.Cainfo
  5271. struct3502.AppSecret = miConfig.AppSecret
  5272. struct3502.Enckey = miConfig.EncKey
  5273. struct3502.SignKey = miConfig.SignKey
  5274. struct3502.SecretKey = miConfig.SecretKey
  5275. struct3502.InvChgType = chgType
  5276. struct3502.FixmedinsBchno = number
  5277. struct3502.Cnt = strconv.FormatInt(count, 10)
  5278. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5279. //result1, result2, _ := service.FJyb3502(struct3502)
  5280. if miConfig.MdtrtareaAdmvs == "350500" {
  5281. result1, result2, _ := service.FJyb3502(struct3502)
  5282. //saveLog(result1, result2, "3502", "3502")
  5283. return result1, result2
  5284. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5285. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5286. return result1, result2
  5287. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5288. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5289. return result1, result2
  5290. } else {
  5291. data := make(map[string]interface{})
  5292. data["struct_3502s"] = struct3502
  5293. client := &http.Client{}
  5294. bytesData, _ := json.Marshal(data)
  5295. var req *http.Request
  5296. if miConfig.MdtrtareaAdmvs == "320830" {
  5297. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5298. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5299. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5300. } else {
  5301. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5302. }
  5303. resp, _ := client.Do(req)
  5304. defer resp.Body.Close()
  5305. body, ioErr := ioutil.ReadAll(resp.Body)
  5306. if ioErr != nil {
  5307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5308. }
  5309. var respJSON map[string]interface{}
  5310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5312. }
  5313. //var resSix10265 ResultSix10265 //1101结果
  5314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5315. result, _ := json.Marshal(respJSON)
  5316. return string(result), ""
  5317. }
  5318. }
  5319. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5320. var struct3505 models.Struct3505
  5321. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5322. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5323. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5324. struct3505.FixmedinsBchno = number
  5325. struct3505.Opter = role.UserName
  5326. struct3505.Bchno = "---"
  5327. struct3505.FixmedinsCode = miConfig.Code
  5328. struct3505.Code = miConfig.Code
  5329. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5330. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5331. struct3505.PrscDrName = roles.UserName
  5332. if org_id == 10191 {
  5333. struct3505.PharName = "刘水山"
  5334. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5335. }
  5336. if org_id == 10188 {
  5337. struct3505.PharName = "李汉清"
  5338. struct3505.PharPracCertNo = "30220200932022010034"
  5339. }
  5340. if org_id == 10217 {
  5341. struct3505.PharName = "张敏"
  5342. struct3505.PharPracCertNo = "30220230432090100108"
  5343. }
  5344. if org_id == 10318 {
  5345. struct3505.PharName = "邹刘阳"
  5346. struct3505.PharPracCertNo = "210441200001378"
  5347. }
  5348. if org_id == 10402 {
  5349. struct3505.PharName = "刘韶健"
  5350. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5351. }
  5352. if org_id == 9919 {
  5353. struct3505.PharName = "周君权"
  5354. struct3505.PharPracCertNo = "089644396094401375"
  5355. }
  5356. if org_id == 10644 {
  5357. struct3505.PharName = "陈金娣"
  5358. struct3505.PharPracCertNo = "20181441500320100066"
  5359. }
  5360. if org_id == 10567 {
  5361. struct3505.PharName = "范小兰"
  5362. struct3505.PharPracCertNo = "0200102079485"
  5363. }
  5364. if org_id == 10721 {
  5365. struct3505.PharName = "孙莉侠"
  5366. struct3505.PharPracCertNo = "060399"
  5367. }
  5368. if org_id == 10726 {
  5369. struct3505.PharName = "彭建福"
  5370. struct3505.PharPracCertNo = "D445281006261"
  5371. }
  5372. if org_id == 10697 {
  5373. struct3505.PharName = "陶海兰"
  5374. struct3505.PharPracCertNo = "0010933"
  5375. }
  5376. if org_id == 10265 {
  5377. struct3505.PharName = "李彩星"
  5378. struct3505.PharPracCertNo = "20171110600110100019"
  5379. }
  5380. if org_id == 10028 {
  5381. struct3505.PharName = "曾细平"
  5382. struct3505.PharPracCertNo = "D440307022134"
  5383. }
  5384. if org_id == 10138 {
  5385. struct3505.PharName = "彭斯遥"
  5386. struct3505.PharPracCertNo = "30220200943042010052"
  5387. }
  5388. if org_id == 10278 {
  5389. struct3505.PharName = "彭斯遥"
  5390. struct3505.PharPracCertNo = "30220200943042010052"
  5391. }
  5392. if org_id == 10610 {
  5393. struct3505.PharName = "彭斯遥"
  5394. struct3505.PharPracCertNo = "30220200943042010052"
  5395. }
  5396. if org_id == 10537 {
  5397. struct3505.PharName = "彭斯遥"
  5398. struct3505.PharPracCertNo = "30220200943042010052"
  5399. }
  5400. if org_id == 9504 {
  5401. struct3505.PharName = "资美红"
  5402. struct3505.PharPracCertNo = "D440904006635"
  5403. }
  5404. if org_id == 10480 {
  5405. struct3505.PharName = "陈思"
  5406. struct3505.PharPracCertNo = "30220240434110010470"
  5407. }
  5408. if org_id == 10653 {
  5409. struct3505.PharName = "邓树英"
  5410. struct3505.PharPracCertNo = "201910026440004734"
  5411. }
  5412. if org_id == 10571 {
  5413. struct3505.PharName = "廖志平"
  5414. struct3505.PharPracCertNo = "0136425"
  5415. }
  5416. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5417. struct3505.SetlId = order.SetlId
  5418. struct3505.MdtrtSn = order.MdtrtId
  5419. struct3505.ManuLotnum = drug.BatchNumber
  5420. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5421. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5422. struct3505.RxFlag = "1"
  5423. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5424. struct3505.TrdnFlag = "0"
  5425. } else {
  5426. struct3505.TrdnFlag = "1"
  5427. }
  5428. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5429. struct3505.TrdnFlag = "1"
  5430. }
  5431. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5432. struct3505.TrdnFlag = "0"
  5433. }
  5434. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 {
  5435. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5436. struct3505.TrdnFlag = "1"
  5437. }
  5438. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5439. struct3505.TrdnFlag = "0"
  5440. }
  5441. }
  5442. struct3505.RtalDocno = order.Number
  5443. struct3505.PsnCertType = "01"
  5444. struct3505.CertNo = order.Certno
  5445. struct3505.PsnNo = order.PsnNo
  5446. struct3505.PsnName = order.PsnName
  5447. struct3505.Url = miConfig.Url
  5448. struct3505.AppId = miConfig.Cainfo
  5449. struct3505.AppSecret = miConfig.AppSecret
  5450. struct3505.Enckey = miConfig.EncKey
  5451. struct3505.SignKey = miConfig.SignKey
  5452. struct3505.SecretKey = miConfig.SecretKey
  5453. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5454. struct3505.SelRetnCnt = strValue
  5455. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5456. struct3505.SelRetnOpterName = role.UserName
  5457. if order.IsMedicineInsurance == 1 {
  5458. struct3505.MdtrtSetlType = "1"
  5459. } else {
  5460. struct3505.MdtrtSetlType = "2"
  5461. }
  5462. struct3505.OrgName = miConfig.OrgName
  5463. struct3505.AccessKey = miConfig.AccessKey
  5464. struct3505.RequestUrl = miConfig.Url
  5465. struct3505.SecretKey = miConfig.SecretKey
  5466. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5467. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5468. struct3505.Cainfo = miConfig.Cainfo
  5469. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5470. if miConfig.MdtrtareaAdmvs == "350500" {
  5471. result1, result2, _ := service.FJyb3505(struct3505)
  5472. return result1, result2
  5473. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5474. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5475. return result1, result2
  5476. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5477. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5478. return result1, result2
  5479. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5480. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5481. return result1, result2
  5482. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5483. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5484. return result1, result2
  5485. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5486. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5487. return result1, result2
  5488. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5489. data := make(map[string]interface{})
  5490. data["struct_3505s"] = struct3505
  5491. client := &http.Client{}
  5492. bytesData, _ := json.Marshal(data)
  5493. var req *http.Request
  5494. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5495. resp, _ := client.Do(req)
  5496. defer resp.Body.Close()
  5497. body, ioErr := ioutil.ReadAll(resp.Body)
  5498. if ioErr != nil {
  5499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5500. }
  5501. var respJSON map[string]interface{}
  5502. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5504. }
  5505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5506. result, _ := json.Marshal(respJSON)
  5507. return string(result), ""
  5508. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5509. data := make(map[string]interface{})
  5510. data["struct_3505s"] = struct3505
  5511. client := &http.Client{}
  5512. bytesData, _ := json.Marshal(data)
  5513. var req *http.Request
  5514. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5515. resp, _ := client.Do(req)
  5516. defer resp.Body.Close()
  5517. body, ioErr := ioutil.ReadAll(resp.Body)
  5518. if ioErr != nil {
  5519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5520. }
  5521. var respJSON map[string]interface{}
  5522. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5524. }
  5525. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5526. if status == "0" {
  5527. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5528. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5529. }
  5530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5531. result, _ := json.Marshal(respJSON)
  5532. return string(result), ""
  5533. } else {
  5534. data := make(map[string]interface{})
  5535. data["struct_3505s"] = struct3505
  5536. client := &http.Client{}
  5537. bytesData, _ := json.Marshal(data)
  5538. var req *http.Request
  5539. if miConfig.MdtrtareaAdmvs == "320830" {
  5540. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5541. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5542. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5543. } else {
  5544. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5545. }
  5546. resp, _ := client.Do(req)
  5547. defer resp.Body.Close()
  5548. body, ioErr := ioutil.ReadAll(resp.Body)
  5549. if ioErr != nil {
  5550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5551. }
  5552. var respJSON map[string]interface{}
  5553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5555. }
  5556. //var resSix10265 ResultSix10265 //1101结果
  5557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5558. result, _ := json.Marshal(respJSON)
  5559. return string(result), ""
  5560. }
  5561. }
  5562. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5563. var struct3505 models.Struct3505
  5564. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5565. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5566. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5567. struct3505.FixmedinsBchno = number
  5568. struct3505.Opter = role.UserName
  5569. struct3505.FixmedinsCode = miConfig.Code
  5570. struct3505.Code = miConfig.Code
  5571. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5572. struct3505.PrscDrName = roles.UserName
  5573. if org_id == 10191 {
  5574. struct3505.PharName = "刘水山"
  5575. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5576. }
  5577. if org_id == 10188 {
  5578. struct3505.PharName = "李汉清"
  5579. struct3505.PharPracCertNo = "30220200932022010034"
  5580. }
  5581. if org_id == 10217 {
  5582. struct3505.PharName = "张敏"
  5583. struct3505.PharPracCertNo = "30220230432090100108"
  5584. }
  5585. if org_id == 10318 {
  5586. struct3505.PharName = "邹刘阳"
  5587. struct3505.PharPracCertNo = "210441200001378"
  5588. }
  5589. if org_id == 10402 {
  5590. struct3505.PharName = "刘韶健"
  5591. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5592. }
  5593. if org_id == 9919 {
  5594. struct3505.PharName = "周君权"
  5595. struct3505.PharPracCertNo = "089644396094401375"
  5596. }
  5597. if org_id == 10644 {
  5598. struct3505.PharName = "陈金娣"
  5599. struct3505.PharPracCertNo = "20181441500320100066"
  5600. }
  5601. if org_id == 10567 {
  5602. struct3505.PharName = "范小兰"
  5603. struct3505.PharPracCertNo = "0200102079485"
  5604. }
  5605. if org_id == 10721 {
  5606. struct3505.PharName = "孙莉侠"
  5607. struct3505.PharPracCertNo = "060399"
  5608. }
  5609. if org_id == 10726 {
  5610. struct3505.PharName = "彭建福"
  5611. struct3505.PharPracCertNo = "D445281006261"
  5612. }
  5613. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5614. struct3505.SetlId = order.SetlId
  5615. struct3505.MdtrtSn = order.MdtrtId
  5616. struct3505.ManuLotnum = drug.Number
  5617. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5618. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5619. struct3505.RxFlag = "1"
  5620. struct3505.TrdnFlag = "0"
  5621. struct3505.RtalDocno = order.Number
  5622. struct3505.PsnCertType = "01"
  5623. struct3505.CertNo = order.Certno
  5624. struct3505.PsnNo = order.PsnNo
  5625. struct3505.PsnName = order.PsnName
  5626. struct3505.Url = miConfig.Url
  5627. struct3505.AppId = miConfig.Cainfo
  5628. struct3505.AppSecret = miConfig.AppSecret
  5629. struct3505.Enckey = miConfig.EncKey
  5630. struct3505.SignKey = miConfig.SignKey
  5631. struct3505.SecretKey = miConfig.SecretKey
  5632. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5633. struct3505.SelRetnCnt = strValue
  5634. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5635. struct3505.SelRetnOpterName = role.UserName
  5636. if order.IsMedicineInsurance == 1 {
  5637. struct3505.MdtrtSetlType = "1"
  5638. } else {
  5639. struct3505.MdtrtSetlType = "2"
  5640. }
  5641. struct3505.OrgName = miConfig.OrgName
  5642. struct3505.AccessKey = miConfig.AccessKey
  5643. struct3505.RequestUrl = miConfig.Url
  5644. struct3505.SecretKey = miConfig.SecretKey
  5645. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5646. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5647. struct3505.Cainfo = miConfig.Cainfo
  5648. struct3505.DrugTracCodg = drug.DrugCode
  5649. if miConfig.MdtrtareaAdmvs == "350500" {
  5650. result1, result2, _ := service.FJyb3505(struct3505)
  5651. return result1, result2
  5652. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5653. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5654. return result1, result2
  5655. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5656. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5657. return result1, result2
  5658. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5659. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5660. return result1, result2
  5661. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5662. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5663. return result1, result2
  5664. } else {
  5665. data := make(map[string]interface{})
  5666. data["struct_3505s"] = struct3505
  5667. client := &http.Client{}
  5668. bytesData, _ := json.Marshal(data)
  5669. var req *http.Request
  5670. if miConfig.MdtrtareaAdmvs == "320830" {
  5671. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5672. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5673. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5674. } else {
  5675. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5676. }
  5677. resp, _ := client.Do(req)
  5678. defer resp.Body.Close()
  5679. body, ioErr := ioutil.ReadAll(resp.Body)
  5680. if ioErr != nil {
  5681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5682. }
  5683. var respJSON map[string]interface{}
  5684. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5686. }
  5687. //var resSix10265 ResultSix10265 //1101结果
  5688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5689. result, _ := json.Marshal(respJSON)
  5690. return string(result), ""
  5691. }
  5692. }
  5693. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5694. var struct3506 models.Struct3506
  5695. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5696. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5697. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5698. struct3506.FixmedinsCode = miConfig.Code
  5699. struct3506.Code = miConfig.Code
  5700. struct3506.FixmedinsBchno = number
  5701. struct3506.Opter = role.UserName
  5702. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5703. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5704. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5705. struct3506.MdtrtSn = order.MdtrtId
  5706. struct3506.ExpyEnd = ""
  5707. struct3506.RxFlag = "0"
  5708. struct3506.TrdnFlag = "1"
  5709. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5710. struct3506.SelRetnCnt = strValue
  5711. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5712. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5713. struct3506.SelRetnOpterName = role.UserName
  5714. struct3506.OrgName = miConfig.OrgName
  5715. struct3506.AccessKey = miConfig.AccessKey
  5716. struct3506.RequestUrl = miConfig.Url
  5717. struct3506.SecretKey = miConfig.SecretKey
  5718. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5719. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5720. struct3506.Url = miConfig.Url
  5721. struct3506.AppId = miConfig.Cainfo
  5722. struct3506.AppSecret = miConfig.AppSecret
  5723. struct3506.Enckey = miConfig.EncKey
  5724. struct3506.SignKey = miConfig.SignKey
  5725. struct3506.SecretKey = miConfig.SecretKey
  5726. struct3506.DrugTracCodg = drug.DrugCode
  5727. if miConfig.MdtrtareaAdmvs == "350500" {
  5728. result1, result2, _ := service.FJyb3506(struct3506)
  5729. return result1, result2
  5730. } else {
  5731. data := make(map[string]interface{})
  5732. data["struct_3506s"] = struct3506
  5733. client := &http.Client{}
  5734. bytesData, _ := json.Marshal(data)
  5735. var req *http.Request
  5736. if miConfig.MdtrtareaAdmvs == "320830" {
  5737. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5738. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5739. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5740. } else {
  5741. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5742. }
  5743. resp, _ := client.Do(req)
  5744. defer resp.Body.Close()
  5745. body, ioErr := ioutil.ReadAll(resp.Body)
  5746. if ioErr != nil {
  5747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5748. }
  5749. var respJSON map[string]interface{}
  5750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5752. }
  5753. //var resSix10265 ResultSix10265 //1101结果
  5754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5755. result, _ := json.Marshal(respJSON)
  5756. return string(result), ""
  5757. }
  5758. }
  5759. func (c *HisApiController) Get1318() {
  5760. adminUser := c.GetAdminUserInfo()
  5761. admin_user_id, _ := c.GetInt64("admin_user_id")
  5762. code := c.GetString("code")
  5763. code = ""
  5764. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5765. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5766. api := ""
  5767. if miConfig.MdtrtareaAdmvs == "320830" {
  5768. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5769. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5770. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5771. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5772. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5773. } else {
  5774. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5775. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5776. }
  5777. resp, requestErr := http.Get(api)
  5778. if requestErr != nil {
  5779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5780. return
  5781. }
  5782. body, ioErr := ioutil.ReadAll(resp.Body)
  5783. if ioErr != nil {
  5784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5786. return
  5787. }
  5788. var respJSON map[string]interface{}
  5789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5792. return
  5793. }
  5794. //var res Result2406
  5795. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5796. result, _ := json.Marshal(respJSON)
  5797. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5798. utils.ErrorLog("解析失败:%v", err)
  5799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5800. return
  5801. }
  5802. if res.Infcode == "0" {
  5803. c.ServeSuccessJSON(map[string]interface{}{
  5804. "result": "",
  5805. })
  5806. } else {
  5807. c.ServeSuccessJSON(map[string]interface{}{
  5808. "failed_code": -10,
  5809. "msg": res.ErrMsg,
  5810. })
  5811. */return
  5812. //}
  5813. }
  5814. func (c *HisApiController) Get2503() {
  5815. adminUser := c.GetAdminUserInfo()
  5816. admin_user_id, _ := c.GetInt64("admin_user_id")
  5817. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5818. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5819. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5820. }
  5821. func (c *HisApiController) Get2406() {
  5822. id, _ := c.GetInt64("id")
  5823. record_time := c.GetString("record_time")
  5824. his_patient_id, _ := c.GetInt64("his_patient_id")
  5825. admin_user_id, _ := c.GetInt64("admin_user_id")
  5826. diagnosis_id := c.GetString("diagnosis")
  5827. timeLayout := "2006-01-02"
  5828. loc, _ := time.LoadLocation("Local")
  5829. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5830. if err != nil {
  5831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5832. return
  5833. }
  5834. recordDateTime := theTime.Unix()
  5835. adminUser := c.GetAdminUserInfo()
  5836. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5837. var config []*models.HisXtDiagnoseConfig
  5838. for _, item := range diagnosis_ids {
  5839. id, _ := strconv.ParseInt(item, 10, 64)
  5840. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5841. config = append(config, &diagnosisConfig)
  5842. }
  5843. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5844. fmt.Println(his_patient_id)
  5845. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5846. //timestamp := time.Now().Unix()
  5847. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5848. var patientPrescription models.HisPrescriptionInfo
  5849. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5850. if patientPrescription.ID == 0 {
  5851. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5852. }
  5853. var res2 Result2406
  5854. if miConfig.MdtrtareaAdmvs == "341203" {
  5855. data := make(map[string]interface{})
  5856. client := &http.Client{}
  5857. data["psn_no"] = his.PsnNo
  5858. data["mdtrt_id"] = his.Number
  5859. data["operator"] = roles.UserName
  5860. data["cert_no"] = his.IdCardNo
  5861. data["org_name"] = miConfig.OrgName
  5862. data["psn_name"] = his.Name
  5863. data["ipt_otp_no"] = his.IptOtpNo
  5864. data["ipt_psn_sp_flag_type"] = "0901"
  5865. data["ipt_psn_sp_flag"] = "1"
  5866. data["fixmedins_code"] = miConfig.Code
  5867. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5868. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5869. data["url"] = miConfig.Url
  5870. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5871. bytesData, _ := json.Marshal(data)
  5872. var req *http.Request
  5873. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5874. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5875. resp, _ := client.Do(req)
  5876. defer resp.Body.Close()
  5877. body, ioErr := ioutil.ReadAll(resp.Body)
  5878. if ioErr != nil {
  5879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5881. return
  5882. }
  5883. var respJSON map[string]interface{}
  5884. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5887. return
  5888. }
  5889. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5890. if status == "0" {
  5891. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5892. c.ServeSuccessJSON(map[string]interface{}{
  5893. "failed_code": -10,
  5894. "msg": err_msg,
  5895. })
  5896. return
  5897. }
  5898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5899. userJSONBytes, _ := json.Marshal(respJSON)
  5900. fmt.Println("log")
  5901. fmt.Println(string(userJSONBytes))
  5902. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5903. utils.ErrorLog("解析失败:%v", err)
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5908. data := make(map[string]interface{})
  5909. client := &http.Client{}
  5910. data["psn_no"] = his.PsnNo
  5911. data["mdtrt_id"] = his.Number
  5912. data["operator"] = roles.UserName
  5913. data["cert_no"] = his.IdCardNo
  5914. data["org_name"] = miConfig.OrgName
  5915. data["psn_name"] = his.Name
  5916. data["ipt_otp_no"] = his.IptOtpNo
  5917. data["ipt_psn_sp_flag_type"] = "0901"
  5918. data["ipt_psn_sp_flag"] = "1"
  5919. data["fixmedins_code"] = miConfig.Code
  5920. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5921. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5922. data["url"] = miConfig.Url
  5923. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5924. bytesData, _ := json.Marshal(data)
  5925. var req *http.Request
  5926. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5927. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5928. resp, _ := client.Do(req)
  5929. defer resp.Body.Close()
  5930. body, ioErr := ioutil.ReadAll(resp.Body)
  5931. if ioErr != nil {
  5932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. var respJSON map[string]interface{}
  5937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5940. return
  5941. }
  5942. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5943. if status == "0" {
  5944. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5945. c.ServeSuccessJSON(map[string]interface{}{
  5946. "failed_code": -10,
  5947. "msg": err_msg,
  5948. })
  5949. return
  5950. }
  5951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5952. userJSONBytes, _ := json.Marshal(respJSON)
  5953. fmt.Println("log")
  5954. fmt.Println(string(userJSONBytes))
  5955. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5956. utils.ErrorLog("解析失败:%v", err)
  5957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5958. return
  5959. }
  5960. }
  5961. if res2.Infcode != 0 {
  5962. adminUser := c.GetAdminUserInfo()
  5963. errlog := &models.HisOrderError{
  5964. UserOrgId: adminUser.CurrentOrgId,
  5965. Ctime: time.Now().Unix(),
  5966. Mtime: time.Now().Unix(),
  5967. ErrMsg: res2.ErrMsg,
  5968. Status: 1,
  5969. PatientId: id,
  5970. RecordTime: recordDateTime,
  5971. Stage: 3,
  5972. }
  5973. service.CreateErrMsgLog(errlog)
  5974. c.ServeSuccessJSON(map[string]interface{}{
  5975. "failed_code": -10,
  5976. "msg": res2.ErrMsg,
  5977. })
  5978. return
  5979. } else {
  5980. c.ServeSuccessJSON(map[string]interface{}{
  5981. "msg": "上传成功",
  5982. })
  5983. return
  5984. }
  5985. }
  5986. func (c *HisApiController) Get4105() {
  5987. }
  5988. func (c *HisApiController) Post5302() {
  5989. patient_id, _ := c.GetInt64("id")
  5990. admin_user_id, _ := c.GetInt64("admin_user_id")
  5991. p, _ := service.GetHisPatientById(patient_id)
  5992. adminUser := c.GetAdminUserInfo()
  5993. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5994. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5995. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5996. }
  5997. func (c *HisApiController) Get4104() {
  5998. }
  5999. type Output struct {
  6000. CertNo string `json:"certno"`
  6001. PsnName string `json:"psn_name"`
  6002. CardNo string `json:"card_no"`
  6003. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6004. CardSN string `json:"card_sn"`
  6005. PsnCertType string `json:"psn_cert_type"`
  6006. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6007. MdtrtCertType string `json:"mdtrt_cert_type"`
  6008. QRCode string `json:"qrCode"`
  6009. EcToken string `json:"ecToken"`
  6010. }
  6011. type AHResponse struct {
  6012. Body AHBody `json:"body"`
  6013. Code int `json:"code"`
  6014. CSBCode int `json:"csbCode"`
  6015. Message string `json:"message"`
  6016. RequestID string `json:"requestId"`
  6017. State struct{} `json:"state"`
  6018. }
  6019. type AHBody struct {
  6020. ErrMsg string `json:"err_msg"`
  6021. InfRefMsgID string `json:"inf_refmsgid"`
  6022. InfCode int `json:"infcode"`
  6023. Output struct {
  6024. Result []struct {
  6025. BasMednFlag string `json:"bas_medn_flag"`
  6026. ChldMedcFlag string `json:"chld_medc_flag"`
  6027. ChrgitmLv string `json:"chrgitm_lv"`
  6028. Cnt float64 `json:"cnt"`
  6029. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6030. DrtReimFlag string `json:"drt_reim_flag"`
  6031. FeedetlSn string `json:"feedetl_sn"`
  6032. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6033. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6034. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6035. ListSpItemFlag string `json:"list_sp_item_flag"`
  6036. LmtUsedFlag string `json:"lmt_used_flag"`
  6037. MedChrgitmType string `json:"med_chrgitm_type"`
  6038. Memo string `json:"memo"`
  6039. OverlmtAmt float64 `json:"overlmt_amt"`
  6040. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6041. Pric float64 `json:"pric"`
  6042. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6043. SelfpayProp float64 `json:"selfpay_prop"`
  6044. } `json:"result"`
  6045. } `json:"output"`
  6046. }
  6047. type Response struct {
  6048. Output Output `json:"output"`
  6049. Infcode int `json:"infcode"`
  6050. InfRefMsgID string `json:"inf_refmsgid"`
  6051. RefMsgTime string `json:"refmsg_time"`
  6052. RespondTime string `json:"respond_time"`
  6053. ErrMsg string `json:"err_msg"`
  6054. WarnMsg string `json:"warn_msg"`
  6055. SignType string `json:"signtype"`
  6056. CAInfo string `json:"cainfo"`
  6057. }
  6058. func (c *HisApiController) Getquerydata() {
  6059. query_type, _ := c.GetInt64("type")
  6060. refd_setl_flag := c.GetString("refd_setl_flag")
  6061. med_type := c.GetString("med_type")
  6062. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6063. cert_no := c.GetString("cert_no")
  6064. psn_no := c.GetString("psn_no")
  6065. start_time := c.GetString("start_time")
  6066. end_time := c.GetString("end_time")
  6067. page, _ := c.GetInt64("page")
  6068. limit, _ := c.GetInt64("limit")
  6069. var bp models.BusinessParams5262
  6070. bp.RefdSetlFlag = refd_setl_flag
  6071. bp.MedType = med_type
  6072. bp.Certno = cert_no
  6073. bp.Psnno = psn_no
  6074. bp.QBegntime = start_time
  6075. bp.QEndtime = end_time
  6076. if query_type == 1 { //本地
  6077. Post5262(c, bp, page, limit)
  6078. } else { //异地
  6079. Post5267(c, bp, page, limit)
  6080. }
  6081. }
  6082. func (c *HisApiController) Drugscheck() {
  6083. admin_user_id, _ := c.GetInt64("admin_user_id")
  6084. adminUser := c.GetAdminUserInfo()
  6085. var queryResult []QueryResult
  6086. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6087. for _, item := range drugs {
  6088. result := QueryResult{
  6089. ID: item.ID,
  6090. Name: item.DrugName,
  6091. Code: item.MedicalInsuranceNumber,
  6092. List_type_code: "101",
  6093. }
  6094. queryResult = append(queryResult, result)
  6095. }
  6096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6097. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6098. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6099. for _, item := range queryResult {
  6100. 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)
  6101. }
  6102. }
  6103. func (c *HisApiController) Goodcheck() {
  6104. admin_user_id, _ := c.GetInt64("admin_user_id")
  6105. adminUser := c.GetAdminUserInfo()
  6106. var queryResult []QueryResult
  6107. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6108. for _, item := range goods {
  6109. result := QueryResult{
  6110. ID: item.ID,
  6111. Name: item.GoodName,
  6112. Code: item.SocialSecurityDirectoryCode,
  6113. List_type_code: "301",
  6114. }
  6115. queryResult = append(queryResult, result)
  6116. }
  6117. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6118. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6119. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6120. for _, item := range queryResult {
  6121. 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)
  6122. //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)
  6123. }
  6124. }
  6125. func (c *HisApiController) Projectcheck() {
  6126. admin_user_id, _ := c.GetInt64("admin_user_id")
  6127. adminUser := c.GetAdminUserInfo()
  6128. var queryResult []QueryResult
  6129. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6130. for _, item := range projects {
  6131. result := QueryResult{
  6132. ID: item.ID,
  6133. Name: item.ProjectName,
  6134. Code: item.MedicalCode,
  6135. List_type_code: "201",
  6136. }
  6137. queryResult = append(queryResult, result)
  6138. }
  6139. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6140. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6141. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6142. for _, item := range queryResult {
  6143. 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)
  6144. }
  6145. }
  6146. //func (c *HisApiController)CancleDia(){
  6147. //
  6148. // id, _ := c.GetInt64("id")
  6149. // record_time := c.GetString("record_time")
  6150. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6151. //
  6152. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6153. //
  6154. // diagnosis_id := c.GetString("diagnosis")
  6155. // sick_type, _ := c.GetInt64("sick_type")
  6156. // reg_type, _ := c.GetInt64("p_type")
  6157. // begin_time := c.GetString("begin_time")
  6158. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6159. //
  6160. //
  6161. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6162. //
  6163. // fmt.Println(acct_used_flag)
  6164. //
  6165. //
  6166. // timeLayout := "2006-01-02"
  6167. // loc, _ := time.LoadLocation("Local")
  6168. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6169. // if err != nil {
  6170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6171. // return
  6172. // }
  6173. // recordDateTime := theTime.Unix()
  6174. // adminUser := c.GetAdminUserInfo()
  6175. //
  6176. //
  6177. //
  6178. //
  6179. //
  6180. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6181. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6182. // var patientPrescription models.HisPrescriptionInfo
  6183. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6184. // if patientPrescription.ID == 0 {
  6185. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6186. // }
  6187. // //if patientPrescription.Do
  6188. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6189. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6190. //
  6191. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6192. //
  6193. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6194. //
  6195. // var config []*models.HisXtDiagnoseConfig
  6196. // for _, item := range diagnosis_ids {
  6197. // id, _ := strconv.ParseInt(item, 10, 64)
  6198. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6199. // config = append(config, &diagnosisConfig)
  6200. // }
  6201. //
  6202. // sickConfig, _ := service.FindSickById(sick_type)
  6203. //
  6204. //
  6205. // data := make(map[string]interface{})
  6206. // client := &http.Client{}
  6207. // data["psn_no"] = his.PsnNo
  6208. // data["mdtrt_id"] = his.Number
  6209. // data["doctor"] = roles.UserName
  6210. // data["department"] = department.Name
  6211. // data["org_name"] = miConfig.OrgName
  6212. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6213. // data["doctor_id"] = doctor_info.DoctorNumber
  6214. // data["new_doctor_name"] = doctor_info.UserName
  6215. // data["fixmedins_code"] = miConfig.Code
  6216. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6217. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6218. // data["secret_key"] = miConfig.SecretKey
  6219. // data["sick_code"] = sickConfig.CountryCode
  6220. // data["sick_name"] = sickConfig.ClassName
  6221. // data["url"] = miConfig.Url
  6222. // data["ak"] = miConfig.AccessKey
  6223. // data["begin_time"] = begin_time
  6224. // data["cainfo"] = miConfig.Cainfo
  6225. // data["is_vaild"] = "0"
  6226. //
  6227. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6228. // data["config"] = config
  6229. // bytesData, _ := json.Marshal(data)
  6230. //
  6231. // var req *http.Request
  6232. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6233. // resp, _ := client.Do(req)
  6234. // defer resp.Body.Close()
  6235. // body, ioErr := ioutil.ReadAll(resp.Body)
  6236. // if ioErr != nil {
  6237. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6239. // return
  6240. // }
  6241. // var respJSON map[string]interface{}
  6242. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6243. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6245. // return
  6246. // }
  6247. //
  6248. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6249. // userJSONBytes, _ := json.Marshal(respJSON)
  6250. // fmt.Println("log")
  6251. // fmt.Println(string(userJSONBytes))
  6252. //
  6253. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6254. // utils.ErrorLog("解析失败:%v", err)
  6255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6256. // return
  6257. // }
  6258. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6259. // res2.Output = ressix10265.Output
  6260. // res2.ErrMsg = ressix10265.ErrMsg
  6261. // res2.Cainfo = ressix10265.Cainfo
  6262. // res2.WarnMsg = ressix10265.WarnMsg
  6263. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6264. // res2.Infcode = infocode
  6265. //
  6266. //}
  6267. func (c *HisApiController) Get4102() {
  6268. order_id, _ := c.GetInt64("order_id")
  6269. admin_user_id, _ := c.GetInt64("admin_user_id")
  6270. stas_type := c.GetString("stas_type")
  6271. order, _ := service.GetHisOrderByIDTwo(order_id)
  6272. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6273. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6274. var pp models.PublicParams
  6275. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6276. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6277. pp.FixmedinsName = miConfig.OrgName
  6278. pp.FixmedinsCode = miConfig.Code
  6279. pp.RequestUrl = miConfig.Url
  6280. pp.Cainfo = miConfig.Cainfo
  6281. pp.SecretKey = miConfig.SecretKey
  6282. pp.AccessKey = miConfig.AccessKey
  6283. pp.OpterName = curRoles.UserName
  6284. if miConfig.MdtrtareaAdmvs == "350500" {
  6285. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6286. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6287. saveLog(result, request, "4102", "清单确认")
  6288. var dat map[string]interface{}
  6289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6290. fmt.Println(dat)
  6291. } else {
  6292. fmt.Println(err)
  6293. }
  6294. var empty ResultFourteen
  6295. userJSONBytes, _ := json.Marshal(dat)
  6296. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6297. utils.ErrorLog("解析失败:%v", err)
  6298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6299. return
  6300. }
  6301. if empty.Infcode == 0 {
  6302. c.ServeSuccessJSON(map[string]interface{}{
  6303. "msg": "确认成功",
  6304. })
  6305. return
  6306. }
  6307. } else {
  6308. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6309. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6310. result3, request3 := service.Jxyb4105(pp)
  6311. saveLog(result, request, "4102", "清单确认")
  6312. saveLog(result2, request2, "4103", "清单确认")
  6313. saveLog(result3, request3, "4105", "清单统计")
  6314. var dat map[string]interface{}
  6315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6316. fmt.Println(dat)
  6317. } else {
  6318. fmt.Println(err)
  6319. }
  6320. var empty ResultFourteen
  6321. userJSONBytes, _ := json.Marshal(dat)
  6322. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6323. utils.ErrorLog("解析失败:%v", err)
  6324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6325. return
  6326. }
  6327. if empty.Infcode == 0 {
  6328. c.ServeSuccessJSON(map[string]interface{}{
  6329. "msg": "确认成功",
  6330. })
  6331. return
  6332. }
  6333. }
  6334. }
  6335. // 对账权限查询
  6336. func (c *HisApiController) Get3260() {
  6337. admin_user_id, _ := c.GetInt64("admin_user_id")
  6338. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6339. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6340. var api string
  6341. var res models.JSResult3260
  6342. if miConfig.MdtrtareaAdmvs == "320830" {
  6343. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6344. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6345. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6346. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6347. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6348. } else {
  6349. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6350. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6351. }
  6352. resp, requestErr := http.Get(api)
  6353. if requestErr != nil {
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6355. return
  6356. }
  6357. body, ioErr := ioutil.ReadAll(resp.Body)
  6358. if ioErr != nil {
  6359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6361. return
  6362. }
  6363. var respJSON map[string]interface{}
  6364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. return
  6368. }
  6369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6370. result, _ := json.Marshal(respJSON)
  6371. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6372. utils.ErrorLog("解析失败:%v", err)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. return
  6375. }
  6376. if res.Infcode == "0" {
  6377. c.ServeSuccessJSON(map[string]interface{}{
  6378. "result": res.Output.Data,
  6379. })
  6380. } else {
  6381. c.ServeSuccessJSON(map[string]interface{}{
  6382. "failed_code": -10,
  6383. "msg": res.ErrMsg,
  6384. })
  6385. return
  6386. }
  6387. }
  6388. func (c *HisApiController) Get3261() {
  6389. admin_user_id, _ := c.GetInt64("admin_user_id")
  6390. //month := c.GetString("month")
  6391. startTime := c.GetString("start_time")
  6392. //endTime, _ := c.GetString("end_time")
  6393. times := strings.Split(startTime, "-")
  6394. stmt_mon := times[0] + times[1]
  6395. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6396. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6397. var api string
  6398. var res models.JSResult3261
  6399. //var res10265 Result5301For10265
  6400. if miConfig.MdtrtareaAdmvs == "320830" {
  6401. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6402. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6403. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6404. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6405. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6406. } else {
  6407. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6408. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6409. }
  6410. resp, requestErr := http.Get(api)
  6411. if requestErr != nil {
  6412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6413. return
  6414. }
  6415. body, ioErr := ioutil.ReadAll(resp.Body)
  6416. if ioErr != nil {
  6417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6419. return
  6420. }
  6421. var respJSON map[string]interface{}
  6422. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6425. return
  6426. }
  6427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6428. result, _ := json.Marshal(respJSON)
  6429. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6430. utils.ErrorLog("解析失败:%v", err)
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6432. return
  6433. }
  6434. if res.Infcode == "0" {
  6435. c.ServeSuccessJSON(map[string]interface{}{
  6436. "result": res.Output,
  6437. })
  6438. } else {
  6439. c.ServeSuccessJSON(map[string]interface{}{
  6440. "failed_code": -10,
  6441. "msg": res.ErrMsg,
  6442. })
  6443. return
  6444. }
  6445. }
  6446. type TempFun struct {
  6447. FundKey string
  6448. FundCode string
  6449. }
  6450. func (c *HisApiController) Get3262() {
  6451. admin_user_id, _ := c.GetInt64("admin_user_id")
  6452. startTime := c.GetString("start_time")
  6453. endTime := c.GetString("end_time")
  6454. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6455. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6456. //timeLayout := "2006-01-02"
  6457. //loc, _ := time.LoadLocation("Local")
  6458. //var theStartTIme int64
  6459. //if len(startTime) > 0 {
  6460. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6461. // if err != nil {
  6462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6463. // return
  6464. // }
  6465. // theStartTIme = theTime.Unix()
  6466. //}
  6467. //var theEndtTIme int64
  6468. //if len(endTime) > 0 {
  6469. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6470. // if err != nil {
  6471. // utils.ErrorLog(err.Error())
  6472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6473. // return
  6474. // }
  6475. // theEndtTIme = theTime.Unix()
  6476. //}
  6477. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6478. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6479. for _, team := range datas {
  6480. fmt.Println(team.PsnTime)
  6481. for _, team_two := range datas_two {
  6482. fmt.Println(team_two.PsnTime)
  6483. if team.FundKey == team_two.FundKey {
  6484. fmt.Println(team_two.PsnTime)
  6485. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6486. fmt.Println(team.PsnTime)
  6487. }
  6488. }
  6489. }
  6490. fmt.Println("1111")
  6491. fmt.Println(datas)
  6492. fmt.Println("1111")
  6493. var twos []models.FixMonRecDetailFileInTwo
  6494. for _, team := range datas {
  6495. var two models.FixMonRecDetailFileInTwo
  6496. two.MedType = team.MedType
  6497. two.Insutype = team.Insutype
  6498. two.PsnType = team.PsnType
  6499. two.MedType = team.MedType
  6500. two.FixBlngAdmdvs = "999999"
  6501. two.InsuAdmdvs = "555555"
  6502. two.PsnTime = team.PsnTime
  6503. two.PsnCnt = team.PsnCnt
  6504. two.FundKey = team.FundKey
  6505. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6506. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6507. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6508. two.MedfeeSumAmt = ms
  6509. two.InscpAmt = ia
  6510. two.FundPaySumAmt = fps
  6511. twos = append(twos, two)
  6512. }
  6513. //startTime := c.GetString("start_time")
  6514. //endTime, _ := c.GetString("end_time")
  6515. times := strings.Split(startTime, "-")
  6516. stmt_mon := times[0] + times[1]
  6517. var funs []models.FundDetail
  6518. for _, item := range datas {
  6519. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6520. funs = append(funs, fun...)
  6521. }
  6522. var funInfos []models.Fund
  6523. //for _, item := range funs {
  6524. // var rf []models.FundInfo
  6525. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6526. // for _, subitem := range rf {
  6527. // var fund models.Fund
  6528. // fund.FundCode = subitem.FundPayType
  6529. // fund.FundName = subitem.FundPayTypeName
  6530. // fund.FundAmt = subitem.FundPayAmt
  6531. // fund.FundKey = item.FundKey
  6532. // fund.InsuAdmdvs = "555555"
  6533. // fund.FixBlngAdmdvs = "999999"
  6534. // funInfos = append(funInfos, fund)
  6535. // }
  6536. //}
  6537. var tempFuns []TempFun
  6538. for _, funInfo := range funInfos {
  6539. var tempFun TempFun
  6540. tempFun.FundKey = funInfo.FundKey
  6541. tempFun.FundCode = funInfo.FundCode
  6542. tempFuns = append(tempFuns, tempFun)
  6543. }
  6544. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6545. fmt.Println(tempFuns)
  6546. var funInfosTwo []models.Fund
  6547. decimal.DivisionPrecision = 2
  6548. for _, item := range tempFuns {
  6549. var fund models.Fund
  6550. for _, subItem := range funInfos {
  6551. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6552. fund.FundKey = subItem.FundKey
  6553. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6554. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6555. fund.FundName = subItem.FundName
  6556. fund.FundCode = subItem.FundCode
  6557. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6558. }
  6559. }
  6560. funInfosTwo = append(funInfosTwo, fund)
  6561. }
  6562. fmt.Println("funInfosTwo")
  6563. fmt.Println(funInfosTwo)
  6564. var upld_btch string
  6565. var empty models.JSResultEmpty
  6566. data := make(map[string]interface{})
  6567. data["org_name"] = miConfig.OrgName
  6568. data["doctor"] = curRoles.UserName
  6569. data["doctor_name"] = curRoles.UserName
  6570. data["fixmedins_code"] = miConfig.Code
  6571. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6572. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6573. data["secret_key"] = miConfig.SecretKey
  6574. data["url"] = miConfig.Url
  6575. data["ak"] = miConfig.AccessKey
  6576. data["cainfo"] = miConfig.Cainfo
  6577. data["datas"] = twos
  6578. data["fund"] = funInfosTwo
  6579. fmt.Println(twos)
  6580. month := time.Unix(1557042972, 0).Format("1")
  6581. year := time.Now().Format("2006")
  6582. month = time.Now().Format("01")
  6583. day := time.Now().Format("02")
  6584. hour := time.Now().Format("15")
  6585. min := time.Now().Format("04")
  6586. sec := time.Now().Format("05")
  6587. fix_fill_date := year + month + day + hour + min + sec
  6588. data["fix_fill_dept"] = miConfig.OrgName
  6589. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6590. data["fix_fill_psn"] = curRoles.UserName
  6591. data["fix_fill_date"] = fix_fill_date
  6592. data["stmt_loc"] = "2"
  6593. data["setl_mon"] = stmt_mon
  6594. upld_btch = "0"
  6595. data["upld_btch"] = upld_btch
  6596. //fmt.Println(data)
  6597. client := &http.Client{}
  6598. bytesData, _ := json.Marshal(data)
  6599. var req *http.Request
  6600. if miConfig.MdtrtareaAdmvs == "320830" {
  6601. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6602. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6603. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6604. } else {
  6605. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6606. }
  6607. resp, _ := client.Do(req)
  6608. defer resp.Body.Close()
  6609. body, ioErr := ioutil.ReadAll(resp.Body)
  6610. if ioErr != nil {
  6611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6613. }
  6614. var respJSON map[string]interface{}
  6615. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6618. }
  6619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6620. //fmt.Println(respJSON)
  6621. result, _ := json.Marshal(respJSON)
  6622. //fmt.Println(result)
  6623. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6624. utils.ErrorLog("解析失败:%v", err)
  6625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6626. }
  6627. if empty.Infcode != "0" {
  6628. c.ServeSuccessJSON(map[string]interface{}{
  6629. "failed_code": -10,
  6630. "msg": empty.ErrMsg,
  6631. })
  6632. return
  6633. } else {
  6634. c.ServeSuccessJSON(map[string]interface{}{
  6635. "msg": "上传成功",
  6636. })
  6637. return
  6638. }
  6639. }
  6640. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6641. newArr = make([]TempFun, 0)
  6642. for i := 0; i < len(arr); i++ {
  6643. repeat := false
  6644. for j := i + 1; j < len(arr); j++ {
  6645. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6646. repeat = true
  6647. break
  6648. }
  6649. }
  6650. if !repeat {
  6651. newArr = append(newArr, arr[i])
  6652. }
  6653. }
  6654. return
  6655. }
  6656. func (c *HisApiController) Get3263() {
  6657. admin_user_id, _ := c.GetInt64("admin_user_id")
  6658. startTime := c.GetString("start_time")
  6659. //endTime, _ := c.GetString("end_time")
  6660. times := strings.Split(startTime, "-")
  6661. setl_mon := times[0] + times[1]
  6662. upld_btch := "0"
  6663. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6664. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6665. var result3263 models.JSResult3263
  6666. data := make(map[string]interface{})
  6667. data["org_name"] = miConfig.OrgName
  6668. data["doctor"] = curRoles.UserName
  6669. data["doctor_name"] = curRoles.UserName
  6670. data["fixmedins_code"] = miConfig.Code
  6671. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6672. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6673. data["secret_key"] = miConfig.SecretKey
  6674. data["url"] = miConfig.Url
  6675. data["ak"] = miConfig.AccessKey
  6676. data["cainfo"] = miConfig.Cainfo
  6677. data["setl_mon"] = setl_mon
  6678. data["stmt_loc"] = "2"
  6679. data["upld_btch"] = upld_btch
  6680. client := &http.Client{}
  6681. bytesData, _ := json.Marshal(data)
  6682. var req *http.Request
  6683. if miConfig.MdtrtareaAdmvs == "320830" {
  6684. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6685. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6686. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6687. } else {
  6688. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6689. }
  6690. resp, _ := client.Do(req)
  6691. defer resp.Body.Close()
  6692. body, ioErr := ioutil.ReadAll(resp.Body)
  6693. if ioErr != nil {
  6694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6696. }
  6697. var respJSON map[string]interface{}
  6698. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6701. }
  6702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6703. fmt.Println(respJSON)
  6704. result, _ := json.Marshal(respJSON)
  6705. fmt.Println(result)
  6706. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6707. utils.ErrorLog("解析失败:%v", err)
  6708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6709. }
  6710. if result3263.Infcode != "0" {
  6711. c.ServeSuccessJSON(map[string]interface{}{
  6712. "failed_code": -10,
  6713. "msg": result3263.ErrMsg,
  6714. })
  6715. return
  6716. } else {
  6717. c.ServeSuccessJSON(map[string]interface{}{
  6718. "list": result3263.Output,
  6719. })
  6720. return
  6721. }
  6722. }
  6723. func (c *HisApiController) Get3264() {
  6724. admin_user_id, _ := c.GetInt64("admin_user_id")
  6725. startTime := c.GetString("start_time")
  6726. //endTime, _ := c.GetString("end_time")
  6727. times := strings.Split(startTime, "-")
  6728. setl_mon := times[0] + times[1]
  6729. upld_btch := "0"
  6730. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6731. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6732. //solidify_id := []
  6733. var result3263 models.JSResult3263
  6734. data := make(map[string]interface{})
  6735. data["org_name"] = miConfig.OrgName
  6736. data["doctor"] = curRoles.UserName
  6737. data["doctor_name"] = curRoles.UserName
  6738. data["fixmedins_code"] = miConfig.Code
  6739. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6740. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6741. data["secret_key"] = miConfig.SecretKey
  6742. data["url"] = miConfig.Url
  6743. data["ak"] = miConfig.AccessKey
  6744. data["cainfo"] = miConfig.Cainfo
  6745. data["setl_mon"] = setl_mon
  6746. data["stmt_loc"] = "2"
  6747. data["upld_btch"] = upld_btch
  6748. client := &http.Client{}
  6749. bytesData, _ := json.Marshal(data)
  6750. var req3263 *http.Request
  6751. if miConfig.MdtrtareaAdmvs == "320830" {
  6752. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6753. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6754. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6755. } else {
  6756. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6757. }
  6758. resp, _ := client.Do(req3263)
  6759. defer resp.Body.Close()
  6760. body, ioErr := ioutil.ReadAll(resp.Body)
  6761. if ioErr != nil {
  6762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6764. }
  6765. var respJSON3263 map[string]interface{}
  6766. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6769. }
  6770. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6771. fmt.Println(respJSON3263)
  6772. result, _ := json.Marshal(respJSON3263)
  6773. fmt.Println(result)
  6774. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6775. utils.ErrorLog("解析失败:%v", err)
  6776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6777. }
  6778. var ids []string
  6779. for _, item := range result3263.Output {
  6780. ids = append(ids, item.SolidifyID)
  6781. }
  6782. var empty models.JSResultEmpty
  6783. data2 := make(map[string]interface{})
  6784. data2["org_name"] = miConfig.OrgName
  6785. data2["doctor"] = curRoles.UserName
  6786. data2["doctor_name"] = curRoles.UserName
  6787. data2["fixmedins_code"] = miConfig.Code
  6788. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6789. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6790. data2["secret_key"] = miConfig.SecretKey
  6791. data2["url"] = miConfig.Url
  6792. data2["ak"] = miConfig.AccessKey
  6793. data2["cainfo"] = miConfig.Cainfo
  6794. data2["setl_mon"] = setl_mon
  6795. data2["stmt_loc"] = "2"
  6796. data2["upld_btch"] = upld_btch
  6797. data2["solidify_id"] = ids
  6798. client2 := &http.Client{}
  6799. bytesData2, _ := json.Marshal(data2)
  6800. var req *http.Request
  6801. if miConfig.MdtrtareaAdmvs == "320830" {
  6802. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6803. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6804. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6805. } else {
  6806. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6807. }
  6808. resp2, _ := client2.Do(req)
  6809. defer resp.Body.Close()
  6810. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6811. if ioErr2 != nil {
  6812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6814. }
  6815. var respJSON map[string]interface{}
  6816. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6819. }
  6820. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6821. fmt.Println(respJSON)
  6822. result2, _ := json.Marshal(respJSON)
  6823. fmt.Println(result2)
  6824. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6825. utils.ErrorLog("解析失败:%v", err)
  6826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6827. }
  6828. if empty.Infcode != "0" {
  6829. c.ServeSuccessJSON(map[string]interface{}{
  6830. "failed_code": -10,
  6831. "msg": empty.ErrMsg,
  6832. })
  6833. return
  6834. } else {
  6835. c.ServeSuccessJSON(map[string]interface{}{
  6836. "msg": "",
  6837. })
  6838. return
  6839. }
  6840. }
  6841. func (c *HisApiController) Get3265() {
  6842. admin_user_id, _ := c.GetInt64("admin_user_id")
  6843. startTime := c.GetString("start_time")
  6844. //endTime, _ := c.GetString("end_time")
  6845. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6846. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6847. times := strings.Split(startTime, "-")
  6848. setl_mon := times[0] + times[1]
  6849. var upld_btch string
  6850. upld_btch = "0"
  6851. //var empty models.JSResultEmpty
  6852. var result3265 models.JSResult3264
  6853. var result3263 models.JSResult3263
  6854. data2 := make(map[string]interface{})
  6855. data2["org_name"] = miConfig.OrgName
  6856. data2["doctor"] = curRoles.UserName
  6857. data2["doctor_name"] = curRoles.UserName
  6858. data2["fixmedins_code"] = miConfig.Code
  6859. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6860. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6861. data2["secret_key"] = miConfig.SecretKey
  6862. data2["url"] = miConfig.Url
  6863. data2["ak"] = miConfig.AccessKey
  6864. data2["cainfo"] = miConfig.Cainfo
  6865. data2["setl_mon"] = setl_mon
  6866. data2["stmt_loc"] = "2"
  6867. data2["upld_btch"] = upld_btch
  6868. client2 := &http.Client{}
  6869. bytesData2, _ := json.Marshal(data2)
  6870. var req3263 *http.Request
  6871. if miConfig.MdtrtareaAdmvs == "320830" {
  6872. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  6873. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6874. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6875. } else {
  6876. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6877. }
  6878. resp2, _ := client2.Do(req3263)
  6879. defer resp2.Body.Close()
  6880. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6881. if ioErr2 != nil {
  6882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6884. }
  6885. var respJSON3263 map[string]interface{}
  6886. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. }
  6890. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6891. fmt.Println(respJSON3263)
  6892. result2, _ := json.Marshal(respJSON3263)
  6893. fmt.Println(result2)
  6894. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6895. utils.ErrorLog("解析失败:%v", err)
  6896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6897. }
  6898. var ids []string
  6899. for _, item := range result3263.Output {
  6900. ids = append(ids, item.SolidifyID)
  6901. }
  6902. data := make(map[string]interface{})
  6903. data["org_name"] = miConfig.OrgName
  6904. data["doctor"] = curRoles.UserName
  6905. data["doctor_name"] = curRoles.UserName
  6906. data["fixmedins_code"] = miConfig.Code
  6907. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6908. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6909. data["secret_key"] = miConfig.SecretKey
  6910. data["url"] = miConfig.Url
  6911. data["ak"] = miConfig.AccessKey
  6912. data["cainfo"] = miConfig.Cainfo
  6913. data["setl_mon"] = setl_mon
  6914. data["solidify_id"] = ids
  6915. month := time.Unix(1557042972, 0).Format("1")
  6916. year := time.Now().Format("2006")
  6917. month = time.Now().Format("01")
  6918. day := time.Now().Format("02")
  6919. hour := time.Now().Format("15")
  6920. min := time.Now().Format("04")
  6921. sec := time.Now().Format("05")
  6922. fix_fill_date := year + month + day + hour + min + sec
  6923. data["fix_fill_dept"] = miConfig.OrgName
  6924. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6925. data["fix_fill_psn"] = curRoles.UserName
  6926. data["fix_fill_date"] = fix_fill_date
  6927. data["stmt_loc"] = "2"
  6928. data["upld_btch"] = upld_btch
  6929. client := &http.Client{}
  6930. bytesData, _ := json.Marshal(data)
  6931. var req *http.Request
  6932. if miConfig.MdtrtareaAdmvs == "320830" {
  6933. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  6934. } else 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 == "320830" {
  7014. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7015. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7016. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7017. } else {
  7018. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7019. }
  7020. resp, _ := client.Do(req)
  7021. defer resp.Body.Close()
  7022. body, ioErr := ioutil.ReadAll(resp.Body)
  7023. if ioErr != nil {
  7024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. }
  7027. var respJSON map[string]interface{}
  7028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7031. }
  7032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7033. fmt.Println(respJSON)
  7034. result, _ := json.Marshal(respJSON)
  7035. fmt.Println(result)
  7036. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7037. utils.ErrorLog("解析失败:%v", err)
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. }
  7040. if result3265.Infcode != "0" {
  7041. c.ServeSuccessJSON(map[string]interface{}{
  7042. "failed_code": -10,
  7043. "msg": result3265.ErrMsg,
  7044. })
  7045. return
  7046. } else {
  7047. c.ServeSuccessJSON(map[string]interface{}{
  7048. "info": result3265.Output,
  7049. })
  7050. return
  7051. }
  7052. }
  7053. func (c *HisApiController) Get3267() {
  7054. admin_user_id, _ := c.GetInt64("admin_user_id")
  7055. startTime := c.GetString("start_time")
  7056. //endTime, _ := c.GetString("end_time")
  7057. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7058. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7059. times := strings.Split(startTime, "-")
  7060. setl_mon := times[0] + times[1]
  7061. var upld_btch string
  7062. //var empty models.JSResultEmpty
  7063. var result3265 models.JSResult3264
  7064. upld_btch = "0"
  7065. data := make(map[string]interface{})
  7066. data["org_name"] = miConfig.OrgName
  7067. data["doctor"] = curRoles.UserName
  7068. data["doctor_name"] = curRoles.UserName
  7069. data["fixmedins_code"] = miConfig.Code
  7070. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7071. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7072. data["secret_key"] = miConfig.SecretKey
  7073. data["url"] = miConfig.Url
  7074. data["ak"] = miConfig.AccessKey
  7075. data["cainfo"] = miConfig.Cainfo
  7076. data["setl_mon"] = setl_mon
  7077. data["stmt_loc"] = "2"
  7078. data["upld_btch"] = upld_btch
  7079. client := &http.Client{}
  7080. bytesData, _ := json.Marshal(data)
  7081. var req *http.Request
  7082. if miConfig.MdtrtareaAdmvs == "320830" {
  7083. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7084. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7085. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7086. } else {
  7087. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7088. }
  7089. resp, _ := client.Do(req)
  7090. defer resp.Body.Close()
  7091. body, ioErr := ioutil.ReadAll(resp.Body)
  7092. if ioErr != nil {
  7093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7095. }
  7096. var respJSON map[string]interface{}
  7097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7100. }
  7101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7102. fmt.Println(respJSON)
  7103. result, _ := json.Marshal(respJSON)
  7104. fmt.Println(result)
  7105. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7106. utils.ErrorLog("解析失败:%v", err)
  7107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7108. }
  7109. if result3265.Infcode != "0" {
  7110. c.ServeSuccessJSON(map[string]interface{}{
  7111. "failed_code": -10,
  7112. "msg": result3265.ErrMsg,
  7113. })
  7114. return
  7115. } else {
  7116. c.ServeSuccessJSON(map[string]interface{}{
  7117. "info": result3265.Output.Data,
  7118. })
  7119. return
  7120. }
  7121. }
  7122. func (c *HisApiController) Get3268() {
  7123. admin_user_id, _ := c.GetInt64("admin_user_id")
  7124. startTime := c.GetString("start_time")
  7125. endTime := c.GetString("end_time")
  7126. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7127. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7128. times := strings.Split(startTime, "-")
  7129. setl_mon := times[0] + times[1]
  7130. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7131. var twos []models.FixMonRecDetailFileInTwo
  7132. var funs []models.FundDetail
  7133. for _, item := range datas {
  7134. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7135. funs = append(funs, fun...)
  7136. }
  7137. var funInfos []models.Fund
  7138. //for _, item := range funs {
  7139. // var rf []models.FundInfo
  7140. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7141. // for _, subitem := range rf {
  7142. // var fund models.Fund
  7143. // fund.FundCode = subitem.FundPayType
  7144. // fund.FundName = subitem.FundPayTypeName
  7145. // fund.FundAmt = subitem.FundPayAmt
  7146. // fund.FundKey = item.FundKey
  7147. // fund.InsuAdmdvs = "555555"
  7148. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7149. // funInfos = append(funInfos, fund)
  7150. // }
  7151. //}
  7152. for _, team := range datas {
  7153. var two models.FixMonRecDetailFileInTwo
  7154. two.SetlDate = time.Now().Format("2006-01-02")
  7155. two.MedType = team.MedType
  7156. two.Insutype = team.Insutype
  7157. two.PsnType = team.PsnType
  7158. two.MedType = team.MedType
  7159. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7160. two.InsuAdmdvs = team.InsuAdmdvs
  7161. two.PsnTime = team.PsnTime
  7162. two.PsnCnt = team.PsnCnt
  7163. two.FundKey = team.FundKey
  7164. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7165. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7166. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7167. two.MedfeeSumAmt = ms
  7168. two.InscpAmt = ia
  7169. two.FundPaySumAmt = fps
  7170. twos = append(twos, two)
  7171. }
  7172. var upld_btch string
  7173. upld_btch = "0"
  7174. var empty models.JSResultEmpty
  7175. data := make(map[string]interface{})
  7176. data["org_name"] = miConfig.OrgName
  7177. data["doctor"] = curRoles.UserName
  7178. data["doctor_name"] = curRoles.UserName
  7179. data["fixmedins_code"] = miConfig.Code
  7180. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7181. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7182. data["secret_key"] = miConfig.SecretKey
  7183. data["url"] = miConfig.Url
  7184. data["ak"] = miConfig.AccessKey
  7185. data["cainfo"] = miConfig.Cainfo
  7186. data["datas"] = twos
  7187. data["fund"] = funInfos
  7188. data["setl_mon"] = setl_mon
  7189. month := time.Unix(1557042972, 0).Format("1")
  7190. year := time.Now().Format("2006")
  7191. month = time.Now().Format("01")
  7192. day := time.Now().Format("02")
  7193. hour := time.Now().Format("15")
  7194. min := time.Now().Format("04")
  7195. sec := time.Now().Format("05")
  7196. fix_fill_date := year + month + day + hour + min + sec
  7197. data["fix_fill_dept"] = miConfig.OrgName
  7198. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7199. data["fix_fill_psn"] = curRoles.UserName
  7200. data["fix_fill_date"] = fix_fill_date
  7201. data["stmt_loc"] = "2"
  7202. data["upld_btch"] = upld_btch
  7203. client := &http.Client{}
  7204. bytesData, _ := json.Marshal(data)
  7205. var req *http.Request
  7206. if miConfig.MdtrtareaAdmvs == "320830" {
  7207. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7208. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7209. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7210. } else {
  7211. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7212. }
  7213. resp, _ := client.Do(req)
  7214. defer resp.Body.Close()
  7215. body, ioErr := ioutil.ReadAll(resp.Body)
  7216. if ioErr != nil {
  7217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. }
  7220. var respJSON map[string]interface{}
  7221. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7224. }
  7225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7226. fmt.Println(respJSON)
  7227. result, _ := json.Marshal(respJSON)
  7228. fmt.Println(result)
  7229. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7230. utils.ErrorLog("解析失败:%v", err)
  7231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7232. }
  7233. if empty.Infcode != "0" {
  7234. c.ServeSuccessJSON(map[string]interface{}{
  7235. "failed_code": -10,
  7236. "msg": empty.ErrMsg,
  7237. })
  7238. return
  7239. } else {
  7240. c.ServeSuccessJSON(map[string]interface{}{
  7241. "msg": "上传成功",
  7242. })
  7243. return
  7244. }
  7245. }
  7246. func (c *HisApiController) Get3269() {
  7247. admin_user_id, _ := c.GetInt64("admin_user_id")
  7248. startTime := c.GetString("start_time")
  7249. //endTime, _ := c.GetString("end_time")
  7250. times := strings.Split(startTime, "-")
  7251. setl_mon := times[0] + times[1]
  7252. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7253. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7254. var result3263 models.JSResult3263
  7255. data := make(map[string]interface{})
  7256. data["org_name"] = miConfig.OrgName
  7257. data["doctor"] = curRoles.UserName
  7258. data["doctor_name"] = curRoles.UserName
  7259. data["fixmedins_code"] = miConfig.Code
  7260. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7261. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7262. data["secret_key"] = miConfig.SecretKey
  7263. data["url"] = miConfig.Url
  7264. data["ak"] = miConfig.AccessKey
  7265. data["cainfo"] = miConfig.Cainfo
  7266. data["setl_mon"] = setl_mon
  7267. data["stmt_loc"] = "2"
  7268. client := &http.Client{}
  7269. bytesData, _ := json.Marshal(data)
  7270. var req *http.Request
  7271. if miConfig.MdtrtareaAdmvs == "320830" {
  7272. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7273. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7274. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7275. } else {
  7276. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7277. }
  7278. resp, _ := client.Do(req)
  7279. defer resp.Body.Close()
  7280. body, ioErr := ioutil.ReadAll(resp.Body)
  7281. if ioErr != nil {
  7282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7284. }
  7285. var respJSON map[string]interface{}
  7286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. }
  7290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7291. fmt.Println(respJSON)
  7292. result, _ := json.Marshal(respJSON)
  7293. fmt.Println(result)
  7294. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7295. utils.ErrorLog("解析失败:%v", err)
  7296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7297. }
  7298. if result3263.Infcode != "0" {
  7299. c.ServeSuccessJSON(map[string]interface{}{
  7300. "failed_code": -10,
  7301. "msg": result3263.ErrMsg,
  7302. })
  7303. return
  7304. } else {
  7305. c.ServeSuccessJSON(map[string]interface{}{
  7306. "msg": "上传成功",
  7307. })
  7308. return
  7309. }
  7310. }
  7311. func (c *HisApiController) Get3270() {
  7312. admin_user_id, _ := c.GetInt64("admin_user_id")
  7313. startTime := c.GetString("start_time")
  7314. //endTime, _ := c.GetString("end_time")
  7315. times := strings.Split(startTime, "-")
  7316. setl_mon := times[0] + times[1]
  7317. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7318. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7319. var result3263 models.JSResult3263
  7320. data2 := make(map[string]interface{})
  7321. data2["org_name"] = miConfig.OrgName
  7322. data2["doctor"] = curRoles.UserName
  7323. data2["doctor_name"] = curRoles.UserName
  7324. data2["fixmedins_code"] = miConfig.Code
  7325. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7326. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7327. data2["secret_key"] = miConfig.SecretKey
  7328. data2["url"] = miConfig.Url
  7329. data2["ak"] = miConfig.AccessKey
  7330. data2["cainfo"] = miConfig.Cainfo
  7331. data2["setl_mon"] = setl_mon
  7332. data2["stmt_loc"] = "2"
  7333. client2 := &http.Client{}
  7334. bytesData2, _ := json.Marshal(data2)
  7335. var req3263 *http.Request
  7336. if miConfig.MdtrtareaAdmvs == "320830" {
  7337. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7338. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7339. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7340. } else {
  7341. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7342. }
  7343. resp2, _ := client2.Do(req3263)
  7344. defer resp2.Body.Close()
  7345. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7346. if ioErr2 != nil {
  7347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. }
  7350. var respJSON3263 map[string]interface{}
  7351. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7354. }
  7355. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7356. fmt.Println(respJSON3263)
  7357. result2, _ := json.Marshal(respJSON3263)
  7358. fmt.Println(result2)
  7359. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7360. utils.ErrorLog("解析失败:%v", err)
  7361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. }
  7363. var ids []string
  7364. for _, item := range result3263.Output {
  7365. ids = append(ids, item.SolidifyID)
  7366. }
  7367. var result3264 models.JSResult3264
  7368. data := make(map[string]interface{})
  7369. data["org_name"] = miConfig.OrgName
  7370. data["doctor"] = curRoles.UserName
  7371. data["doctor_name"] = curRoles.UserName
  7372. data["fixmedins_code"] = miConfig.Code
  7373. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7375. data["secret_key"] = miConfig.SecretKey
  7376. data["url"] = miConfig.Url
  7377. data["ak"] = miConfig.AccessKey
  7378. data["cainfo"] = miConfig.Cainfo
  7379. data["setl_mon"] = setl_mon
  7380. data["stmt_loc"] = "2"
  7381. data["solidify_id"] = ids
  7382. client := &http.Client{}
  7383. bytesData, _ := json.Marshal(data)
  7384. var req *http.Request
  7385. if miConfig.MdtrtareaAdmvs == "320830" {
  7386. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7387. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7388. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7389. } else {
  7390. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7391. }
  7392. resp, _ := client.Do(req)
  7393. defer resp.Body.Close()
  7394. body, ioErr := ioutil.ReadAll(resp.Body)
  7395. if ioErr != nil {
  7396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7398. }
  7399. var respJSON map[string]interface{}
  7400. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. }
  7404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7405. fmt.Println(respJSON)
  7406. result, _ := json.Marshal(respJSON)
  7407. fmt.Println(result)
  7408. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7409. utils.ErrorLog("解析失败:%v", err)
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7411. }
  7412. if result3264.Infcode != "0" {
  7413. c.ServeSuccessJSON(map[string]interface{}{
  7414. "failed_code": -10,
  7415. "msg": result3264.ErrMsg,
  7416. })
  7417. return
  7418. } else {
  7419. c.ServeSuccessJSON(map[string]interface{}{
  7420. "info": result3264.Output,
  7421. })
  7422. return
  7423. }
  7424. }
  7425. func (c *HisApiController) Get3271() {
  7426. admin_user_id, _ := c.GetInt64("admin_user_id")
  7427. startTime := c.GetString("start_time")
  7428. //endTime, _ := c.GetString("end_time")
  7429. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7430. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7431. times := strings.Split(startTime, "-")
  7432. setl_mon := times[0] + times[1]
  7433. //var empty models.JSResultEmpty
  7434. var result3265 models.JSResult3264
  7435. var result3263 models.JSResult3263
  7436. data2 := make(map[string]interface{})
  7437. data2["org_name"] = miConfig.OrgName
  7438. data2["doctor"] = curRoles.UserName
  7439. data2["doctor_name"] = curRoles.UserName
  7440. data2["fixmedins_code"] = miConfig.Code
  7441. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7442. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7443. data2["secret_key"] = miConfig.SecretKey
  7444. data2["url"] = miConfig.Url
  7445. data2["ak"] = miConfig.AccessKey
  7446. data2["cainfo"] = miConfig.Cainfo
  7447. data2["setl_mon"] = setl_mon
  7448. data2["stmt_loc"] = "2"
  7449. client2 := &http.Client{}
  7450. bytesData2, _ := json.Marshal(data2)
  7451. var req3263 *http.Request
  7452. if miConfig.MdtrtareaAdmvs == "320830" {
  7453. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7454. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7455. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7456. } else {
  7457. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7458. }
  7459. resp2, _ := client2.Do(req3263)
  7460. defer resp2.Body.Close()
  7461. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7462. if ioErr2 != nil {
  7463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7465. }
  7466. var respJSON3263 map[string]interface{}
  7467. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7470. }
  7471. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7472. fmt.Println(respJSON3263)
  7473. result2, _ := json.Marshal(respJSON3263)
  7474. fmt.Println(result2)
  7475. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7476. utils.ErrorLog("解析失败:%v", err)
  7477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7478. }
  7479. var ids []string
  7480. for _, item := range result3263.Output {
  7481. ids = append(ids, item.SolidifyID)
  7482. }
  7483. data := make(map[string]interface{})
  7484. data["org_name"] = miConfig.OrgName
  7485. data["doctor"] = curRoles.UserName
  7486. data["doctor_name"] = curRoles.UserName
  7487. data["fixmedins_code"] = miConfig.Code
  7488. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7489. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7490. data["secret_key"] = miConfig.SecretKey
  7491. data["url"] = miConfig.Url
  7492. data["ak"] = miConfig.AccessKey
  7493. data["cainfo"] = miConfig.Cainfo
  7494. data["setl_mon"] = setl_mon
  7495. data["solidify_id"] = ids
  7496. month := time.Unix(1557042972, 0).Format("1")
  7497. year := time.Now().Format("2006")
  7498. month = time.Now().Format("01")
  7499. day := time.Now().Format("02")
  7500. hour := time.Now().Format("15")
  7501. min := time.Now().Format("04")
  7502. sec := time.Now().Format("05")
  7503. fix_fill_date := year + month + day + hour + min + sec
  7504. data["fix_fill_dept"] = miConfig.OrgName
  7505. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7506. data["fix_fill_psn"] = curRoles.UserName
  7507. data["fix_fill_date"] = fix_fill_date
  7508. data["stmt_loc"] = "2"
  7509. client := &http.Client{}
  7510. bytesData, _ := json.Marshal(data)
  7511. var req *http.Request
  7512. if miConfig.MdtrtareaAdmvs == "320830" {
  7513. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7514. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7515. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7516. } else {
  7517. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7518. }
  7519. resp, _ := client.Do(req)
  7520. defer resp.Body.Close()
  7521. body, ioErr := ioutil.ReadAll(resp.Body)
  7522. if ioErr != nil {
  7523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. }
  7526. var respJSON map[string]interface{}
  7527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7530. }
  7531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7532. fmt.Println(respJSON)
  7533. result, _ := json.Marshal(respJSON)
  7534. fmt.Println(result)
  7535. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7536. utils.ErrorLog("解析失败:%v", err)
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7538. }
  7539. if result3265.Infcode != "0" {
  7540. c.ServeSuccessJSON(map[string]interface{}{
  7541. "failed_code": -10,
  7542. "msg": result3265.ErrMsg,
  7543. })
  7544. return
  7545. } else {
  7546. c.ServeSuccessJSON(map[string]interface{}{
  7547. "info": result3265.Output.Data,
  7548. })
  7549. return
  7550. }
  7551. }
  7552. func (c *HisApiController) Get3272() {
  7553. admin_user_id, _ := c.GetInt64("admin_user_id")
  7554. startTime := c.GetString("start_time")
  7555. //endTime, _ := c.GetString("end_time")
  7556. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7557. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7558. times := strings.Split(startTime, "-")
  7559. setl_mon := times[0] + times[1]
  7560. var upld_btch string
  7561. //var empty models.JSResultEmpty
  7562. var result3265 models.JSResult3264
  7563. data := make(map[string]interface{})
  7564. data["org_name"] = miConfig.OrgName
  7565. data["doctor"] = curRoles.UserName
  7566. data["doctor_name"] = curRoles.UserName
  7567. data["fixmedins_code"] = miConfig.Code
  7568. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7569. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7570. data["secret_key"] = miConfig.SecretKey
  7571. data["url"] = miConfig.Url
  7572. data["ak"] = miConfig.AccessKey
  7573. data["cainfo"] = miConfig.Cainfo
  7574. data["setl_mon"] = setl_mon
  7575. month := time.Unix(1557042972, 0).Format("1")
  7576. year := time.Now().Format("2006")
  7577. month = time.Now().Format("01")
  7578. day := time.Now().Format("02")
  7579. hour := time.Now().Format("15")
  7580. min := time.Now().Format("04")
  7581. sec := time.Now().Format("05")
  7582. fix_fill_date := year + month + day + hour + min + sec
  7583. data["fix_fill_dept"] = miConfig.OrgName
  7584. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7585. data["fix_fill_psn"] = curRoles.UserName
  7586. data["fix_fill_date"] = fix_fill_date
  7587. data["stmt_loc"] = "2"
  7588. data["upld_btch"] = upld_btch
  7589. client := &http.Client{}
  7590. bytesData, _ := json.Marshal(data)
  7591. var req *http.Request
  7592. if miConfig.MdtrtareaAdmvs == "320830" {
  7593. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7594. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7595. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7596. } else {
  7597. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7598. }
  7599. resp, _ := client.Do(req)
  7600. defer resp.Body.Close()
  7601. body, ioErr := ioutil.ReadAll(resp.Body)
  7602. if ioErr != nil {
  7603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. }
  7606. var respJSON map[string]interface{}
  7607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7610. }
  7611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7612. fmt.Println(respJSON)
  7613. result, _ := json.Marshal(respJSON)
  7614. fmt.Println(result)
  7615. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7616. utils.ErrorLog("解析失败:%v", err)
  7617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7618. }
  7619. if result3265.Infcode != "0" {
  7620. c.ServeSuccessJSON(map[string]interface{}{
  7621. "failed_code": -10,
  7622. "msg": result3265.ErrMsg,
  7623. })
  7624. return
  7625. } else {
  7626. c.ServeSuccessJSON(map[string]interface{}{
  7627. "info": result3265.Output,
  7628. })
  7629. return
  7630. }
  7631. }
  7632. func (c *HisApiController) Get3273() {
  7633. admin_user_id, _ := c.GetInt64("admin_user_id")
  7634. startTime := c.GetString("start_time")
  7635. //endTime, _ := c.GetString("end_time")
  7636. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7637. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7638. times := strings.Split(startTime, "-")
  7639. setl_mon := times[0] + times[1]
  7640. var result3265 models.JSResult3264
  7641. data := make(map[string]interface{})
  7642. data["org_name"] = miConfig.OrgName
  7643. data["doctor"] = curRoles.UserName
  7644. data["doctor_name"] = curRoles.UserName
  7645. data["fixmedins_code"] = miConfig.Code
  7646. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7647. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7648. data["secret_key"] = miConfig.SecretKey
  7649. data["url"] = miConfig.Url
  7650. data["ak"] = miConfig.AccessKey
  7651. data["cainfo"] = miConfig.Cainfo
  7652. data["setl_mon"] = setl_mon
  7653. data["stmt_loc"] = "2"
  7654. client := &http.Client{}
  7655. bytesData, _ := json.Marshal(data)
  7656. var req *http.Request
  7657. if miConfig.MdtrtareaAdmvs == "320921" {
  7658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7659. } else {
  7660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7661. }
  7662. resp, _ := client.Do(req)
  7663. defer resp.Body.Close()
  7664. body, ioErr := ioutil.ReadAll(resp.Body)
  7665. if ioErr != nil {
  7666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7668. }
  7669. var respJSON map[string]interface{}
  7670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. }
  7674. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7675. fmt.Println(respJSON)
  7676. result, _ := json.Marshal(respJSON)
  7677. fmt.Println(result)
  7678. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7679. utils.ErrorLog("解析失败:%v", err)
  7680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7681. }
  7682. if result3265.Infcode != "0" {
  7683. c.ServeSuccessJSON(map[string]interface{}{
  7684. "failed_code": -10,
  7685. "msg": result3265.ErrMsg,
  7686. })
  7687. return
  7688. } else {
  7689. c.ServeSuccessJSON(map[string]interface{}{
  7690. "info": result3265.Output.Data,
  7691. })
  7692. return
  7693. }
  7694. }
  7695. func (c *HisApiController) Get3274() {
  7696. //if miConfig.MdtrtareaAdmvs == "320921" {
  7697. // api = "http://192.168.2.3:9532/" + "jsyb/3274?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. //} else {
  7702. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7703. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7704. // "&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
  7705. //
  7706. //}
  7707. }
  7708. func (c *HisApiController) Get3275() {
  7709. //if miConfig.MdtrtareaAdmvs == "320921" {
  7710. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7711. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7712. // "&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
  7713. //
  7714. //} else {
  7715. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7716. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7717. // "&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
  7718. //
  7719. //}
  7720. }
  7721. func (c *HisApiController) Get3276() {
  7722. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7723. //month := c.GetString("month")
  7724. //
  7725. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7726. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7727. //var api string
  7728. //var res Result5301
  7729. //
  7730. //if miConfig.MdtrtareaAdmvs == "320921" {
  7731. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7732. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7733. //} else {
  7734. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7735. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7736. //}
  7737. //
  7738. //resp, requestErr := http.Get(api)
  7739. //if requestErr != nil {
  7740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7741. // return
  7742. //}
  7743. //
  7744. //body, ioErr := ioutil.ReadAll(resp.Body)
  7745. //if ioErr != nil {
  7746. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7748. // return
  7749. //}
  7750. //var respJSON map[string]interface{}
  7751. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7752. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7754. // return
  7755. //}
  7756. //
  7757. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7758. //result, _ := json.Marshal(respJSON)
  7759. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7760. // utils.ErrorLog("解析失败:%v", err)
  7761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7762. // return
  7763. //}
  7764. }
  7765. func (c *HisApiController) Get3277() {
  7766. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7767. //month := c.GetString("month")
  7768. //
  7769. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7770. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7771. //var api string
  7772. //var res Result5301
  7773. //
  7774. //if miConfig.MdtrtareaAdmvs == "320921" {
  7775. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7776. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7777. //} else {
  7778. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7779. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7780. //}
  7781. //
  7782. //resp, requestErr := http.Get(api)
  7783. //if requestErr != nil {
  7784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. // return
  7786. //}
  7787. //
  7788. //body, ioErr := ioutil.ReadAll(resp.Body)
  7789. //if ioErr != nil {
  7790. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. // return
  7793. //}
  7794. //var respJSON map[string]interface{}
  7795. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7796. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. // return
  7799. //}
  7800. //
  7801. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7802. //result, _ := json.Marshal(respJSON)
  7803. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7804. // utils.ErrorLog("解析失败:%v", err)
  7805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. // return
  7807. //}
  7808. }
  7809. func (c *HisApiController) GetCFYLJG001() {
  7810. admin_user_id, _ := c.GetInt64("admin_user_id")
  7811. patient_id, _ := c.GetInt64("patient_id")
  7812. his_patient_id, _ := c.GetInt64("his_patient_id")
  7813. record_time := c.GetString("record_time")
  7814. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7815. psn, _ := service.GetPsnByPatientId(patient_id)
  7816. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7817. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7818. var cFYLJG001 models.CFYLJG001
  7819. timeLayout := "2006-01-02"
  7820. loc, _ := time.LoadLocation("Local")
  7821. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7822. if err != nil {
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7824. return
  7825. }
  7826. recordDateTime := theTime.Unix()
  7827. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7828. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7829. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7830. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7831. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7832. for _, item := range prescriptions {
  7833. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7834. if his.IdCardType == 1 {
  7835. bas := strings.Split(psn.CardInfo, "|")
  7836. basNumber := bas[1]
  7837. fmt.Println(basNumber)
  7838. card_sn := bas[3]
  7839. card_no := bas[2]
  7840. cFYLJG001.MdtrtCertType = "03"
  7841. cFYLJG001.CardSn = card_sn
  7842. cFYLJG001.MdtrtCertNo = card_no
  7843. cFYLJG001.EcToken = ""
  7844. cFYLJG001.AuthNo = ""
  7845. } else if his.IdCardType == 2 {
  7846. cFYLJG001.MdtrtCertType = "02"
  7847. cFYLJG001.CardSn = ""
  7848. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7849. cFYLJG001.EcToken = ""
  7850. cFYLJG001.AuthNo = ""
  7851. } else if his.IdCardType == 4 {
  7852. cFYLJG001.MdtrtCertType = "01"
  7853. cFYLJG001.CardSn = ""
  7854. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7855. cFYLJG001.EcToken = psn.VerifyNumber
  7856. cFYLJG001.AuthNo = ""
  7857. }
  7858. cFYLJG001.BizTypeCode = "01"
  7859. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7860. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7861. cFYLJG001.RxTypeCode = "1"
  7862. tempTime := time.Unix(item.PreTime, 0)
  7863. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7864. cFYLJG001.PrscTime = timeFormatOne
  7865. var count float64
  7866. if item.Type == 1 {
  7867. for _, sumItem := range item.HisDoctorAdviceInfo {
  7868. count = count + sumItem.PrescribingNumber
  7869. }
  7870. }
  7871. cFYLJG001.RxDrugCnt = count
  7872. cFYLJG001.ValiDays = "2"
  7873. ts := time.Unix(item.PreTime, 0)
  7874. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7875. tempTime3 := time.Unix(record_time2, 0)
  7876. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7877. cFYLJG001.ValiEndTime = timeFormat3
  7878. cFYLJG001.RxCotnFlag = "0"
  7879. for _, subItem := range item.HisDoctorAdviceInfo {
  7880. var drug models.RxDrug
  7881. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7882. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7883. drug.RxItemTypeCode = "11"
  7884. drug.DrugDosform = "剂" //TODO
  7885. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7886. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7887. }
  7888. drug.MedcWayDscr = subItem.DeliveryWay
  7889. tempTime2 := time.Unix(subItem.StartTime, 0)
  7890. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7891. drug.MedcBegntime = timeFormatTwo
  7892. if subItem.Day > 0 {
  7893. ts := time.Unix(subItem.StartTime, 0)
  7894. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7895. tempTime4 := time.Unix(record_time, 0)
  7896. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7897. drug.MedcEndtime = timeFormat5
  7898. } else {
  7899. tempTime2 := time.Unix(subItem.StartTime, 0)
  7900. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7901. drug.MedcEndtime = timeFormatTwo
  7902. }
  7903. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7904. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7905. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7906. drug.DrugCnt = subItem.PrescribingNumber
  7907. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7908. drug.DrugGenname = subItem.AdviceName
  7909. drug.MedcWayCodg = subItem.DeliveryWay
  7910. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7911. drug.SinDoscnt = subItem.SingleDose
  7912. drug.SinDosunt = subItem.SingleDoseUnit
  7913. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7914. drug.UsedFrquName = subItem.ExecutionFrequency
  7915. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7916. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7917. drug.HospApprFlag = "1"
  7918. cFYLJG001.List = append(cFYLJG001.List, drug)
  7919. }
  7920. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7921. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7922. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7923. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7924. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7925. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7926. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7927. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7928. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7929. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7930. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7931. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7932. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7933. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7934. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7935. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7936. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7937. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7938. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7939. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7940. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7941. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7942. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7943. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7944. tempTime2 := time.Now().Unix()
  7945. tempTime6 := time.Unix(tempTime2, 0)
  7946. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7947. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7948. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  7949. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7950. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  7951. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  7952. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7953. var config []*models.HisXtDiagnoseConfig
  7954. for _, item := range diagnosis_ids {
  7955. id, _ := strconv.ParseInt(item, 10, 64)
  7956. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7957. config = append(config, &diagnosisConfig)
  7958. }
  7959. for index, subitem := range config {
  7960. if index == 0 {
  7961. var dia models.DiseInfo
  7962. dia.DiagType = "1"
  7963. dia.MaindiagFlag = "1"
  7964. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7965. dia.DiagCode = subitem.CountryCode
  7966. dia.DiagName = subitem.ClassName
  7967. dia.DiagDept = "肾内科"
  7968. dia.DiagDrNo = doctor.DoctorNumber
  7969. dia.DiagDrName = doctor.UserName
  7970. tempTime3 := time.Unix(item.PreTime, 0)
  7971. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7972. dia.DiagTime = timeFormatTwo
  7973. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7974. } else {
  7975. var dia models.DiseInfo
  7976. dia.DiagType = "1"
  7977. dia.MaindiagFlag = "0"
  7978. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7979. dia.DiagCode = subitem.CountryCode
  7980. dia.DiagName = subitem.ClassName
  7981. dia.DiagDept = "肾内科"
  7982. dia.DiagDrNo = doctor.DoctorNumber
  7983. dia.DiagDrName = doctor.UserName
  7984. tempTime3 := time.Unix(item.PreTime, 0)
  7985. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7986. dia.DiagTime = timeFormatTwo
  7987. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7988. }
  7989. }
  7990. if miConfig.MdtrtareaAdmvs == "340699" {
  7991. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  7992. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7993. var res ResultCFYLJG001AH
  7994. var respJSON2 map[string]interface{}
  7995. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7998. return
  7999. }
  8000. userJSONBytes2, _ := json.Marshal(respJSON2)
  8001. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8002. utils.ErrorLog("解析失败:%v", err)
  8003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8004. return
  8005. }
  8006. var flow models.HisPrescriptionFlow
  8007. flow.Ctime = time.Now().Unix()
  8008. flow.SignDigest = ""
  8009. flow.RxTraceCode = res.RxTraceCode
  8010. flow.HiRxno = res.HiRxno
  8011. flow.MID = his.Number
  8012. flow.Status = 1
  8013. flow.DCode = doctor_info.DoctorNumber
  8014. flow.OriginalRxFile = ""
  8015. flow.OriginalValue = ""
  8016. flow.SignCertDn = ""
  8017. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8018. flow.SignCertSn = ""
  8019. flow.Mtime = time.Now().Unix()
  8020. service.Createflow(&flow)
  8021. c.ServeSuccessJSON(map[string]interface{}{
  8022. "msg": "上传成功",
  8023. })
  8024. } else {
  8025. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8026. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8027. var res ResultCFYLJG001
  8028. var respJSON2 map[string]interface{}
  8029. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8032. return
  8033. }
  8034. userJSONBytes2, _ := json.Marshal(respJSON2)
  8035. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8036. utils.ErrorLog("解析失败:%v", err)
  8037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8038. return
  8039. }
  8040. if res.Infcode == -1 {
  8041. c.ServeSuccessJSON(map[string]interface{}{
  8042. "failed_code": -10,
  8043. "msg": res.ErrMsg,
  8044. })
  8045. return
  8046. } else {
  8047. var flow models.HisPrescriptionFlow
  8048. flow.Ctime = time.Now().Unix()
  8049. flow.SignDigest = ""
  8050. flow.RxTraceCode = res.Output.RxTraceCode
  8051. flow.HiRxno = res.Output.HiRxno
  8052. flow.MID = his.Number
  8053. flow.Status = 1
  8054. flow.DCode = doctor_info.DoctorNumber
  8055. flow.OriginalRxFile = ""
  8056. flow.OriginalValue = ""
  8057. flow.SignCertDn = ""
  8058. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8059. flow.SignCertSn = ""
  8060. flow.Mtime = time.Now().Unix()
  8061. service.Createflow(&flow)
  8062. c.ServeSuccessJSON(map[string]interface{}{
  8063. "msg": "上传成功",
  8064. })
  8065. }
  8066. }
  8067. }
  8068. }
  8069. func (c *HisApiController) GetCFYLJG12() {
  8070. admin_user_id, _ := c.GetInt64("admin_user_id")
  8071. his_patient_id, _ := c.GetInt64("his_patient_id")
  8072. record_time := c.GetString("record_time")
  8073. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8074. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8075. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8076. flow, _ := service.Getflowtwo(his.Number)
  8077. patient_id, _ := c.GetInt64("patient_id")
  8078. timeLayout := "2006-01-02"
  8079. loc, _ := time.LoadLocation("Local")
  8080. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8081. if err != nil {
  8082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8083. return
  8084. }
  8085. recordDateTime := theTime.Unix()
  8086. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8087. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8088. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8089. dept, _ := service.GetDepartMentDetail(info.Departments)
  8090. inputData := make(map[string]interface{})
  8091. inputData["rxTraceCode"] = flow.RxTraceCode
  8092. inputData["hiRxno"] = flow.HiRxno
  8093. inputData["mdtrtId"] = flow.MID
  8094. inputData["patnName"] = his.PsnName
  8095. inputData["psnCertType"] = his.PsnCertType
  8096. inputData["certno"] = his.Certno
  8097. inputData["fixmedinsName"] = miConfig.OrgName
  8098. inputData["fixmedinsCode"] = miConfig.Code
  8099. inputData["drCode"] = doctor_info.DoctorNumber
  8100. inputData["prscDrName"] = doctor_info.UserName
  8101. inputData["pharDeptName"] = dept.Name
  8102. inputData["pharDeptCode"] = dept.Number
  8103. inputData["pharProfttlCodg"] = ""
  8104. inputData["pharProfttlName"] = ""
  8105. inputData["pharCode"] = "HY340621000425"
  8106. inputData["pharCertType"] = "01"
  8107. inputData["pharCertno"] = ""
  8108. inputData["pharName"] = "孙莉侠"
  8109. inputData["pharPracCertNo"] = ""
  8110. tempTime2 := time.Unix(info.Ctime, 0)
  8111. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8112. inputData["pharChkTime"] = timeFormatTwo
  8113. bytesData, _ := json.Marshal(inputData)
  8114. fmt.Println(string(bytesData))
  8115. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8116. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8117. if err != nil {
  8118. fmt.Println("Error reading PDF file:", err)
  8119. return
  8120. }
  8121. // 将 PDF 文件内容进行 Base64 编码
  8122. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8123. fmt.Println(err)
  8124. if miConfig.MdtrtareaAdmvs == "340699" {
  8125. data := make(map[string]interface{})
  8126. data["rx_encoded"] = rx_encoded
  8127. data["code"] = miConfig.Code
  8128. data["url"] = "http://10.66.149.64:8080/epc/api"
  8129. data["encoded"] = encoded
  8130. client := &http.Client{}
  8131. bytesData, _ := json.Marshal(data)
  8132. var req *http.Request
  8133. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8134. resp, _ := client.Do(req)
  8135. defer resp.Body.Close()
  8136. body, ioErr := ioutil.ReadAll(resp.Body)
  8137. if ioErr != nil {
  8138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8139. }
  8140. var respJSON map[string]interface{}
  8141. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8144. return
  8145. }
  8146. var resSix10265 ResultSix10265 //1101结果
  8147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8148. result, _ := json.Marshal(respJSON)
  8149. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8150. utils.ErrorLog("解析失败:%v", err)
  8151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8152. return
  8153. }
  8154. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8155. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8156. } else {
  8157. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8158. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8159. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8160. var res2 AhResult002
  8161. var respJSON2 map[string]interface{}
  8162. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8165. return
  8166. }
  8167. userJSONBytes2, _ := json.Marshal(respJSON2)
  8168. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8169. utils.ErrorLog("解析失败:%v", err)
  8170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8171. return
  8172. }
  8173. flow.Ctime = time.Now().Unix()
  8174. flow.SignDigest = res2.SignDigest
  8175. flow.RxFile = res2.RxFile
  8176. flow.MID = his.Number
  8177. flow.Status = 1
  8178. flow.DCode = doctor_info.DoctorNumber
  8179. flow.OriginalRxFile = rx_encoded
  8180. flow.OriginalValue = encoded
  8181. flow.SignCertDn = res2.SignCertDn
  8182. flow.SignCertSn = res2.SignCertSn
  8183. flow.Mtime = time.Now().Unix()
  8184. service.Saveflow(flow)
  8185. c.ServeSuccessJSON(map[string]interface{}{
  8186. "msg": "预签名成功",
  8187. })
  8188. }
  8189. }
  8190. func (c *HisApiController) GetCFYLJG13() {
  8191. admin_user_id, _ := c.GetInt64("admin_user_id")
  8192. his_patient_id, _ := c.GetInt64("his_patient_id")
  8193. record_time := c.GetString("record_time")
  8194. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8195. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8196. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8197. flow, _ := service.Getflowtwo(his.Number)
  8198. patient_id, _ := c.GetInt64("patient_id")
  8199. timeLayout := "2006-01-02"
  8200. loc, _ := time.LoadLocation("Local")
  8201. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8202. if err != nil {
  8203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8204. return
  8205. }
  8206. recordDateTime := theTime.Unix()
  8207. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8208. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8209. dept, _ := service.GetDepartMentDetail(info.Departments)
  8210. var cFYLJG003 models.CFYLJG003
  8211. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8212. cFYLJG003.HiRxno = flow.HiRxno
  8213. cFYLJG003.MdtrtID = flow.MID
  8214. cFYLJG003.PatnName = his.Name
  8215. cFYLJG003.Certno = his.Certno
  8216. cFYLJG003.FixmedinsName = miConfig.OrgName
  8217. cFYLJG003.FixmedinsCode = miConfig.Code
  8218. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8219. cFYLJG003.PrscDrName = doctor_info.UserName
  8220. cFYLJG003.PharDeptName = dept.Name
  8221. cFYLJG003.PharDeptCode = dept.Number
  8222. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8223. cFYLJG003.PharName = "孙莉侠"
  8224. cFYLJG003.PharPracCertNo = "060399"
  8225. cFYLJG003.PharCode = "HY340621000425"
  8226. cFYLJG003.PharCertType = "01"
  8227. cFYLJG003.PharCertno = ""
  8228. } else {
  8229. cFYLJG003.PharName = "彭斯遥"
  8230. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8231. cFYLJG003.PharCode = "HY440309002107"
  8232. cFYLJG003.PharCertType = "01"
  8233. cFYLJG003.PharCertno = "430482199408260023"
  8234. }
  8235. cFYLJG003.PsnCertType = "01"
  8236. cFYLJG003.RxFile = flow.RxFile
  8237. cFYLJG003.SignDigest = flow.SignDigest
  8238. cFYLJG003.FixmedinsCode = miConfig.Code
  8239. cFYLJG003.PsnCertType = "01"
  8240. cFYLJG003.PharProfttlCodg = dept.Name
  8241. tempTime2 := time.Unix(info.Ctime, 0)
  8242. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8243. cFYLJG003.PharChkTime = timeFormatTwo
  8244. if miConfig.MdtrtareaAdmvs == "340699" {
  8245. data := make(map[string]interface{})
  8246. data["url"] = "http://10.66.149.64:8080/epc/api"
  8247. data["13"] = cFYLJG003
  8248. client := &http.Client{}
  8249. bytesData, _ := json.Marshal(data)
  8250. var req *http.Request
  8251. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8252. resp, _ := client.Do(req)
  8253. defer resp.Body.Close()
  8254. body, ioErr := ioutil.ReadAll(resp.Body)
  8255. if ioErr != nil {
  8256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8257. }
  8258. var respJSON map[string]interface{}
  8259. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8262. return
  8263. }
  8264. var resSix10265 ResultSix10265 //1101结果
  8265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8266. result, _ := json.Marshal(respJSON)
  8267. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8268. utils.ErrorLog("解析失败:%v", err)
  8269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8270. return
  8271. }
  8272. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8273. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8274. } else {
  8275. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8276. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8277. var res ResultCFYLJG003
  8278. var respJSON2 map[string]interface{}
  8279. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8282. return
  8283. }
  8284. userJSONBytes2, _ := json.Marshal(respJSON2)
  8285. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8286. utils.ErrorLog("解析失败:%v", err)
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. return
  8289. }
  8290. if res.Infcode == -1 {
  8291. c.ServeSuccessJSON(map[string]interface{}{
  8292. "failed_code": -10,
  8293. "msg": res.ErrMsg,
  8294. })
  8295. return
  8296. } else {
  8297. c.ServeSuccessJSON(map[string]interface{}{
  8298. "info": res.Output,
  8299. })
  8300. }
  8301. }
  8302. }
  8303. func (c *HisApiController) GetCFYLJG002() {
  8304. admin_user_id, _ := c.GetInt64("admin_user_id")
  8305. his_patient_id, _ := c.GetInt64("his_patient_id")
  8306. record_time := c.GetString("record_time")
  8307. admin_user_id = 3626
  8308. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8309. //id, _ := c.GetInt64("id")
  8310. admin_user_id = 3626
  8311. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8312. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8313. flow, _ := service.Getflowtwo(his.Number)
  8314. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8315. //record_time := c.GetString("record_time")
  8316. patient_id, _ := c.GetInt64("patient_id")
  8317. //patient_id = 23834
  8318. //record_time = "2023-09-18"
  8319. timeLayout := "2006-01-02"
  8320. loc, _ := time.LoadLocation("Local")
  8321. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8322. if err != nil {
  8323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8324. return
  8325. }
  8326. recordDateTime := theTime.Unix()
  8327. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8328. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8329. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8330. dept, _ := service.GetDepartMentDetail(info.Departments)
  8331. inputData := make(map[string]interface{})
  8332. inputData["rxTraceCode"] = flow.RxTraceCode
  8333. inputData["hiRxno"] = flow.HiRxno
  8334. inputData["mdtrtId"] = flow.MID
  8335. inputData["patnName"] = his.PsnName
  8336. inputData["psnCertType"] = his.PsnCertType
  8337. inputData["certno"] = his.Certno
  8338. inputData["fixmedinsName"] = miConfig.OrgName
  8339. inputData["fixmedinsCode"] = miConfig.Code
  8340. inputData["drCode"] = doctor_info.DoctorNumber
  8341. inputData["prscDrName"] = doctor_info.UserName
  8342. inputData["pharDeptName"] = dept.Name
  8343. inputData["pharDeptCode"] = dept.Number
  8344. inputData["pharProfttlCodg"] = ""
  8345. inputData["pharProfttlName"] = ""
  8346. inputData["pharCode"] = "HY340621000425"
  8347. inputData["pharCertType"] = "01"
  8348. inputData["pharCertno"] = ""
  8349. inputData["pharName"] = "孙莉侠"
  8350. inputData["pharPracCertNo"] = "060399"
  8351. tempTime2 := time.Unix(info.Ctime, 0)
  8352. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8353. inputData["pharChkTime"] = timeFormatTwo
  8354. bytesData, _ := json.Marshal(inputData)
  8355. fmt.Println(string(bytesData))
  8356. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8357. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8358. if err != nil {
  8359. fmt.Println("Error reading PDF file:", err)
  8360. return
  8361. }
  8362. // 将 PDF 文件内容进行 Base64 编码
  8363. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8364. fmt.Println(err)
  8365. if miConfig.MdtrtareaAdmvs == "340699" {
  8366. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8367. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8368. var res2 AhResult002
  8369. var respJSON2 map[string]interface{}
  8370. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8373. return
  8374. }
  8375. userJSONBytes2, _ := json.Marshal(respJSON2)
  8376. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8377. utils.ErrorLog("解析失败:%v", err)
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. flow.Ctime = time.Now().Unix()
  8382. flow.SignDigest = res2.SignDigest
  8383. flow.RxFile = res2.RxFile
  8384. flow.MID = his.Number
  8385. flow.Status = 1
  8386. flow.DCode = doctor_info.DoctorNumber
  8387. flow.OriginalRxFile = rx_encoded
  8388. flow.OriginalValue = encoded
  8389. flow.SignCertDn = res2.SignCertDn
  8390. flow.SignCertSn = res2.SignCertSn
  8391. flow.Mtime = time.Now().Unix()
  8392. service.Saveflow(flow)
  8393. c.ServeSuccessJSON(map[string]interface{}{
  8394. "msg": "预签名成功",
  8395. })
  8396. } else {
  8397. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8398. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8399. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8400. var res2 Result002
  8401. var respJSON2 map[string]interface{}
  8402. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. userJSONBytes2, _ := json.Marshal(respJSON2)
  8408. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8409. utils.ErrorLog("解析失败:%v", err)
  8410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8411. return
  8412. }
  8413. if res2.Infcode == 0 {
  8414. flow.Ctime = time.Now().Unix()
  8415. flow.SignDigest = res2.Output.SignDigest
  8416. flow.RxFile = res2.Output.RxFile
  8417. flow.MID = his.Number
  8418. flow.Status = 1
  8419. flow.DCode = doctor_info.DoctorNumber
  8420. flow.OriginalRxFile = rx_encoded
  8421. flow.OriginalValue = encoded
  8422. flow.SignCertDn = res2.Output.SignCertDn
  8423. flow.SignCertSn = res2.Output.SignCertSn
  8424. flow.Mtime = time.Now().Unix()
  8425. service.Saveflow(flow)
  8426. c.ServeSuccessJSON(map[string]interface{}{
  8427. "msg": "预签名成功",
  8428. })
  8429. } else {
  8430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8431. return
  8432. }
  8433. }
  8434. }
  8435. func (c *HisApiController) GetCFYLJG003() {
  8436. admin_user_id, _ := c.GetInt64("admin_user_id")
  8437. his_patient_id, _ := c.GetInt64("his_patient_id")
  8438. record_time := c.GetString("record_time")
  8439. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8440. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8441. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8442. flow, _ := service.Getflowtwo(his.Number)
  8443. patient_id, _ := c.GetInt64("patient_id")
  8444. timeLayout := "2006-01-02"
  8445. loc, _ := time.LoadLocation("Local")
  8446. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8447. if err != nil {
  8448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8449. return
  8450. }
  8451. recordDateTime := theTime.Unix()
  8452. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8453. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8454. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8455. dept, _ := service.GetDepartMentDetail(info.Departments)
  8456. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8457. var cFYLJG003 models.CFYLJG003
  8458. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8459. cFYLJG003.HiRxno = flow.HiRxno
  8460. cFYLJG003.MdtrtID = flow.MID
  8461. cFYLJG003.PatnName = his.PsnName
  8462. cFYLJG003.Certno = his.Certno
  8463. cFYLJG003.FixmedinsName = miConfig.OrgName
  8464. cFYLJG003.FixmedinsCode = miConfig.Code
  8465. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8466. cFYLJG003.PrscDrName = doctor_info.UserName
  8467. cFYLJG003.PharDeptName = dept.Name
  8468. cFYLJG003.PharDeptCode = dept.Number
  8469. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8470. cFYLJG003.PharName = "孙莉侠"
  8471. cFYLJG003.PharPracCertNo = "060399"
  8472. cFYLJG003.PharCode = "HY340621000425"
  8473. cFYLJG003.PharCertType = "01"
  8474. cFYLJG003.PharCertno = ""
  8475. } else {
  8476. cFYLJG003.PharName = "彭斯遥"
  8477. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8478. cFYLJG003.PharCode = "HY440309002107"
  8479. cFYLJG003.PharCertType = "01"
  8480. cFYLJG003.PharCertno = "430482199408260023"
  8481. }
  8482. cFYLJG003.RxFile = flow.RxFile
  8483. cFYLJG003.SignDigest = flow.SignDigest
  8484. cFYLJG003.FixmedinsCode = miConfig.Code
  8485. cFYLJG003.PsnCertType = his.PsnCertType
  8486. tempTime2 := time.Unix(info.Ctime, 0)
  8487. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8488. cFYLJG003.PharChkTime = timeFormatTwo
  8489. if miConfig.MdtrtareaAdmvs == "340699" {
  8490. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8491. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8492. var res AHResult003
  8493. var respJSON2 map[string]interface{}
  8494. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8497. return
  8498. }
  8499. userJSONBytes2, _ := json.Marshal(respJSON2)
  8500. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8501. utils.ErrorLog("解析失败:%v", err)
  8502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8503. return
  8504. }
  8505. {
  8506. c.ServeSuccessJSON(map[string]interface{}{
  8507. "info": res,
  8508. })
  8509. }
  8510. } else {
  8511. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8512. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8513. var res ResultCFYLJG003
  8514. var respJSON2 map[string]interface{}
  8515. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8518. return
  8519. }
  8520. userJSONBytes2, _ := json.Marshal(respJSON2)
  8521. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8522. utils.ErrorLog("解析失败:%v", err)
  8523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8524. return
  8525. }
  8526. if res.Infcode == -1 {
  8527. c.ServeSuccessJSON(map[string]interface{}{
  8528. "failed_code": -10,
  8529. "msg": res.ErrMsg,
  8530. })
  8531. return
  8532. } else {
  8533. c.ServeSuccessJSON(map[string]interface{}{
  8534. "info": res.Output,
  8535. })
  8536. }
  8537. }
  8538. }
  8539. func (c *HisApiController) GetCFYLJG004() {
  8540. admin_user_id, _ := c.GetInt64("admin_user_id")
  8541. his_patient_id, _ := c.GetInt64("his_patient_id")
  8542. record_time := c.GetString("record_time")
  8543. admin_user_id = 3626
  8544. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8545. //id, _ := c.GetInt64("id")
  8546. admin_user_id = 3626
  8547. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8549. flow, _ := service.Getflowtwo(his.Number)
  8550. //id = 3
  8551. patient_id, _ := c.GetInt64("patient_id")
  8552. //patient_id = 23834
  8553. //record_time = "2023-09-18"
  8554. timeLayout := "2006-01-02"
  8555. loc, _ := time.LoadLocation("Local")
  8556. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8557. if err != nil {
  8558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8559. return
  8560. }
  8561. recordDateTime := theTime.Unix()
  8562. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8563. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8564. var cFYLJG004 models.CFYLJG004
  8565. cFYLJG004.HiRxno = flow.HiRxno
  8566. cFYLJG004.FixmedinsCode = miConfig.Code
  8567. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8568. cFYLJG004.UndoDrCertType = "01"
  8569. cFYLJG004.UndoRea = "撤销处方"
  8570. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8571. cFYLJG004.UndoDrName = doctor_info.UserName
  8572. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8573. if miConfig.MdtrtareaAdmvs == "340699" {
  8574. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8575. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8576. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8577. } else {
  8578. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8579. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8580. var res ResultCFYLJG004
  8581. var respJSON2 map[string]interface{}
  8582. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8585. return
  8586. }
  8587. userJSONBytes2, _ := json.Marshal(respJSON2)
  8588. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8589. utils.ErrorLog("解析失败:%v", err)
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8591. return
  8592. }
  8593. if res.Infcode == -1 {
  8594. c.ServeSuccessJSON(map[string]interface{}{
  8595. "failed_code": -10,
  8596. "msg": res.ErrMsg,
  8597. })
  8598. return
  8599. } else {
  8600. flow.Status = 0
  8601. service.Saveflow(flow)
  8602. c.ServeSuccessJSON(map[string]interface{}{
  8603. "msg": "撤销成功",
  8604. })
  8605. return
  8606. }
  8607. }
  8608. }
  8609. func (c *HisApiController) GetCFYLJG005() {
  8610. admin_user_id, _ := c.GetInt64("admin_user_id")
  8611. his_patient_id, _ := c.GetInt64("his_patient_id")
  8612. //record_time := c.GetString("record_time")
  8613. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8614. //id, _ := c.GetInt64("id")
  8615. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8616. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8617. flow, _ := service.Getflowtwo(his.Number)
  8618. //id = 3
  8619. var cFYLJG005 models.CFYLJG005
  8620. //patient_id, _ := c.GetInt64("patient_id")
  8621. cFYLJG005.HiRxno = flow.HiRxno
  8622. cFYLJG005.MdtrtID = flow.MID
  8623. cFYLJG005.EcToken = ""
  8624. cFYLJG005.PsnName = his.Name
  8625. cFYLJG005.PsnCertType = "01"
  8626. cFYLJG005.Certno = his.IdCardNo
  8627. if miConfig.MdtrtareaAdmvs == "340699" {
  8628. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8629. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8630. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8631. } else {
  8632. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8633. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8634. var res ResultCFYLJG005
  8635. var respJSON2 map[string]interface{}
  8636. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8639. return
  8640. }
  8641. userJSONBytes2, _ := json.Marshal(respJSON2)
  8642. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8643. utils.ErrorLog("解析失败:%v", err)
  8644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8645. return
  8646. }
  8647. if res.Infcode == -1 {
  8648. c.ServeSuccessJSON(map[string]interface{}{
  8649. "failed_code": -10,
  8650. "msg": res.ErrMsg,
  8651. })
  8652. return
  8653. } else {
  8654. c.ServeSuccessJSON(map[string]interface{}{
  8655. "info": res.Output,
  8656. })
  8657. return
  8658. }
  8659. }
  8660. }
  8661. func (c *HisApiController) GetCFYLJG006() {
  8662. admin_user_id, _ := c.GetInt64("admin_user_id")
  8663. his_patient_id, _ := c.GetInt64("his_patient_id")
  8664. admin_user_id = 3626
  8665. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8666. //id, _ := c.GetInt64("id")
  8667. admin_user_id = 3626
  8668. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8669. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8670. flow, _ := service.Getflowtwo(his.Number)
  8671. //id = 3
  8672. patient_id, _ := c.GetInt64("patient_id")
  8673. var cFYLJG006 models.CFYLJG006
  8674. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8675. cFYLJG006.HiRxno = flow.HiRxno
  8676. cFYLJG006.MdtrtID = flow.MID
  8677. cFYLJG006.PsnName = patient.Name
  8678. cFYLJG006.PsnCertType = "01"
  8679. cFYLJG006.Certno = patient.IdCardNo
  8680. if miConfig.MdtrtareaAdmvs == "340699" {
  8681. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8682. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8683. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8684. } else {
  8685. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8686. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8687. var res ResultCFYLJG006
  8688. var respJSON2 map[string]interface{}
  8689. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. return
  8693. }
  8694. userJSONBytes2, _ := json.Marshal(respJSON2)
  8695. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8696. utils.ErrorLog("解析失败:%v", err)
  8697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8698. return
  8699. }
  8700. if res.Infcode == -1 {
  8701. c.ServeSuccessJSON(map[string]interface{}{
  8702. "failed_code": -10,
  8703. "msg": res.ErrMsg,
  8704. })
  8705. return
  8706. } else {
  8707. c.ServeSuccessJSON(map[string]interface{}{
  8708. "info": res.Output,
  8709. })
  8710. return
  8711. }
  8712. }
  8713. }
  8714. func (c *HisApiController) GetCFYLJG007() {
  8715. admin_user_id, _ := c.GetInt64("admin_user_id")
  8716. his_patient_id, _ := c.GetInt64("his_patient_id")
  8717. admin_user_id = 3626
  8718. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8719. //id, _ := c.GetInt64("id")
  8720. admin_user_id = 3626
  8721. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8722. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8723. flow, _ := service.Getflowtwo(his.Number)
  8724. //id = 3
  8725. patient_id, _ := c.GetInt64("patient_id")
  8726. var cFYLJG007 models.CFYLJG007
  8727. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8728. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8729. cFYLJG007.HiRxno = flow.HiRxno
  8730. cFYLJG007.MdtrtID = flow.MID
  8731. cFYLJG007.PsnNo = his.PsnNo
  8732. cFYLJG007.PsnCertType = "01"
  8733. cFYLJG007.Certno = patient.IdCardNo
  8734. cFYLJG007.PsnName = patient.Name
  8735. if miConfig.MdtrtareaAdmvs == "340699" {
  8736. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8737. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8738. } else {
  8739. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8740. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8741. var res ResultCFYLJG007
  8742. var respJSON2 map[string]interface{}
  8743. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8746. return
  8747. }
  8748. userJSONBytes2, _ := json.Marshal(respJSON2)
  8749. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8750. utils.ErrorLog("解析失败:%v", err)
  8751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8752. return
  8753. }
  8754. if res.Infcode == -1 {
  8755. c.ServeSuccessJSON(map[string]interface{}{
  8756. "failed_code": -10,
  8757. "msg": res.ErrMsg,
  8758. })
  8759. return
  8760. } else {
  8761. c.ServeSuccessJSON(map[string]interface{}{
  8762. "info": res,
  8763. })
  8764. return
  8765. }
  8766. }
  8767. }
  8768. func (c *HisApiController) GetCFYLJG008() {
  8769. admin_user_id, _ := c.GetInt64("admin_user_id")
  8770. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8771. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8772. var cFYLJG008 models.CFYLJG008
  8773. //id, _ := c.GetInt64("id")
  8774. patient_id, _ := c.GetInt64("patient_id")
  8775. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8776. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8777. //id = 3
  8778. //flow, _ := service.Getflow(id)
  8779. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8780. //
  8781. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8782. //patient_id, _ := c.GetInt64("patient_id")
  8783. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8784. record_time := c.GetString("record_time")
  8785. admin_user_id = 3626
  8786. patient_id = 19424
  8787. //his_patient_id = 263947
  8788. record_time = "2023-08-29"
  8789. timeLayout := "2006-01-02"
  8790. loc, _ := time.LoadLocation("Local")
  8791. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8792. if err != nil {
  8793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8794. return
  8795. }
  8796. recordDateTime := theTime.Unix()
  8797. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8798. cFYLJG008.FixmedinsName = ""
  8799. cFYLJG008.Lat = ""
  8800. cFYLJG008.Lng = ""
  8801. cFYLJG008.OrderType = "1"
  8802. cFYLJG008.PoolareaNo = ""
  8803. cFYLJG008.Lng = ""
  8804. cFYLJG008.PageNum = 1
  8805. cFYLJG008.PageSize = 10
  8806. var MPI models.MedinsProdInvChgDDTO
  8807. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8808. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8809. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8810. if miConfig.MdtrtareaAdmvs == "340699" {
  8811. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8812. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8813. } else {
  8814. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8815. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8816. var res ResultCFYLJG008
  8817. var respJSON2 map[string]interface{}
  8818. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8821. return
  8822. }
  8823. userJSONBytes2, _ := json.Marshal(respJSON2)
  8824. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8825. utils.ErrorLog("解析失败:%v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. if res.Infcode == -1 {
  8830. c.ServeSuccessJSON(map[string]interface{}{
  8831. "failed_code": -10,
  8832. "msg": res.ErrMsg,
  8833. })
  8834. return
  8835. } else {
  8836. c.ServeSuccessJSON(map[string]interface{}{
  8837. "info": res.Output,
  8838. })
  8839. return
  8840. }
  8841. }
  8842. }
  8843. func (c *HisApiController) GetBL4201A() {
  8844. order_id, _ := c.GetInt64("order_id")
  8845. admin_user_id, _ := c.GetInt64("admin_user_id")
  8846. order, _ := service.GetHisOrderByIDTwo(order_id)
  8847. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8848. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8849. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8850. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8851. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8852. department, _ := service.GetDepartMentDetail(his.Departments)
  8853. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8854. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8855. if order.ID == 0 {
  8856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8857. return
  8858. }
  8859. var struct4201A models.Struct4201A
  8860. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8861. for _, items := range order_info {
  8862. memo := make(map[string]interface{})
  8863. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8864. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8865. fsiOPFLD.MedType = "14"
  8866. fsiOPFLD.BkkpSn = items.FeedetlSn
  8867. fsiOPFLD.FixmedinsCode = miConfig.Code
  8868. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8869. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8870. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8871. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8872. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8873. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8874. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8875. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8876. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8877. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8878. fsiOPFLD.BilgDeptName = department.Name
  8879. fsiOPFLD.BilgDeptCodg = department.Number
  8880. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8881. fsiOPFLD.BilgDrName = doctor.UserName
  8882. fsiOPFLD.MedChrgitmType = "09"
  8883. memo["hosp_appr_flag"] = "1"
  8884. memo["invoice_no"] = order.MdtrtId
  8885. memo["memo"] = "自费"
  8886. bytesData, _ := json.Marshal(memo)
  8887. fsiOPFLD.Memo = string(bytesData)
  8888. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8889. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8890. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8891. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8892. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8893. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8894. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8895. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8896. fsiOPFLD.BilgDeptName = department.Name
  8897. fsiOPFLD.BilgDeptCodg = department.Number
  8898. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8899. fsiOPFLD.BilgDrName = doctor.UserName
  8900. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8901. case 0:
  8902. break
  8903. case 1:
  8904. fsiOPFLD.MedChrgitmType = "14"
  8905. break
  8906. case 2:
  8907. fsiOPFLD.MedChrgitmType = "05"
  8908. break
  8909. case 3:
  8910. fsiOPFLD.MedChrgitmType = "03"
  8911. break
  8912. case 4:
  8913. fsiOPFLD.MedChrgitmType = "03"
  8914. break
  8915. case 5:
  8916. fsiOPFLD.MedChrgitmType = "08"
  8917. break
  8918. case 6:
  8919. fsiOPFLD.MedChrgitmType = "14"
  8920. break
  8921. case 7:
  8922. fsiOPFLD.MedChrgitmType = "14"
  8923. break
  8924. case 8:
  8925. fsiOPFLD.MedChrgitmType = "03"
  8926. break
  8927. case 9:
  8928. fsiOPFLD.MedChrgitmType = "14"
  8929. break
  8930. case 10:
  8931. fsiOPFLD.MedChrgitmType = "14"
  8932. break
  8933. case 11:
  8934. fsiOPFLD.MedChrgitmType = "06"
  8935. break
  8936. case 12:
  8937. fsiOPFLD.MedChrgitmType = "12"
  8938. break
  8939. case 13:
  8940. fsiOPFLD.MedChrgitmType = "01"
  8941. break
  8942. case 14:
  8943. fsiOPFLD.MedChrgitmType = "04"
  8944. break
  8945. case 15:
  8946. fsiOPFLD.MedChrgitmType = "14"
  8947. break
  8948. }
  8949. memo["hosp_appr_flag"] = "1"
  8950. memo["invoice_no"] = order.MdtrtId
  8951. memo["memo"] = "自费"
  8952. bytesData, _ := json.Marshal(memo)
  8953. fsiOPFLD.Memo = string(bytesData)
  8954. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8955. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8956. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8957. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8958. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8959. fsiOPFLD.BilgDeptName = department.Name
  8960. fsiOPFLD.BilgDeptCodg = department.Number
  8961. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8962. fsiOPFLD.BilgDrName = doctor.UserName
  8963. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8964. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8965. fsiOPFLD.MedChrgitmType = "08"
  8966. memo["hosp_appr_flag"] = "1"
  8967. memo["invoice_no"] = order.MdtrtId
  8968. memo["memo"] = "自费"
  8969. bytesData, _ := json.Marshal(memo)
  8970. fsiOPFLD.Memo = string(bytesData)
  8971. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8972. }
  8973. }
  8974. }
  8975. for _, items := range order_info_two {
  8976. memo := make(map[string]interface{})
  8977. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8978. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8979. fsiOPFLD.MedType = "14"
  8980. fsiOPFLD.BkkpSn = items.FeedetlSn
  8981. fsiOPFLD.FixmedinsCode = miConfig.Code
  8982. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8983. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8984. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8985. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8986. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8987. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8988. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8989. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8990. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8991. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8992. fsiOPFLD.BilgDeptName = department.Name
  8993. fsiOPFLD.BilgDeptCodg = department.Number
  8994. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8995. fsiOPFLD.BilgDrName = doctor.UserName
  8996. fsiOPFLD.MedChrgitmType = "09"
  8997. memo["hosp_appr_flag"] = "1"
  8998. memo["invoice_no"] = order.MdtrtId
  8999. memo["memo"] = "自费"
  9000. bytesData, _ := json.Marshal(memo)
  9001. fsiOPFLD.Memo = string(bytesData)
  9002. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9003. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9004. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9005. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9006. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9007. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9008. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9009. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9010. fsiOPFLD.BilgDeptName = department.Name
  9011. fsiOPFLD.BilgDeptCodg = department.Number
  9012. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9013. fsiOPFLD.BilgDrName = doctor.UserName
  9014. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9015. case 0:
  9016. break
  9017. case 1:
  9018. fsiOPFLD.MedChrgitmType = "14"
  9019. break
  9020. case 2:
  9021. fsiOPFLD.MedChrgitmType = "05"
  9022. break
  9023. case 3:
  9024. fsiOPFLD.MedChrgitmType = "03"
  9025. break
  9026. case 4:
  9027. fsiOPFLD.MedChrgitmType = "03"
  9028. break
  9029. case 5:
  9030. fsiOPFLD.MedChrgitmType = "08"
  9031. break
  9032. case 6:
  9033. fsiOPFLD.MedChrgitmType = "14"
  9034. break
  9035. case 7:
  9036. fsiOPFLD.MedChrgitmType = "14"
  9037. break
  9038. case 8:
  9039. fsiOPFLD.MedChrgitmType = "03"
  9040. break
  9041. case 9:
  9042. fsiOPFLD.MedChrgitmType = "14"
  9043. break
  9044. case 10:
  9045. fsiOPFLD.MedChrgitmType = "14"
  9046. break
  9047. case 11:
  9048. fsiOPFLD.MedChrgitmType = "06"
  9049. break
  9050. case 12:
  9051. fsiOPFLD.MedChrgitmType = "12"
  9052. break
  9053. case 13:
  9054. fsiOPFLD.MedChrgitmType = "01"
  9055. break
  9056. case 14:
  9057. fsiOPFLD.MedChrgitmType = "04"
  9058. break
  9059. case 15:
  9060. fsiOPFLD.MedChrgitmType = "14"
  9061. break
  9062. }
  9063. memo["hosp_appr_flag"] = "1"
  9064. memo["invoice_no"] = order.MdtrtId
  9065. memo["memo"] = "自费"
  9066. bytesData, _ := json.Marshal(memo)
  9067. fsiOPFLD.Memo = string(bytesData)
  9068. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9069. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9070. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9071. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9072. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9073. fsiOPFLD.BilgDeptName = department.Name
  9074. fsiOPFLD.BilgDeptCodg = department.Number
  9075. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9076. fsiOPFLD.BilgDrName = doctor.UserName
  9077. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9078. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9079. fsiOPFLD.MedChrgitmType = "08"
  9080. memo["hosp_appr_flag"] = "1"
  9081. memo["invoice_no"] = order.MdtrtId
  9082. memo["memo"] = "自费"
  9083. bytesData, _ := json.Marshal(memo)
  9084. fsiOPFLD.Memo = string(bytesData)
  9085. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9086. }
  9087. }
  9088. }
  9089. fmt.Println(fsiOPFLDs)
  9090. struct4201A.Fopfd = fsiOPFLDs
  9091. fmt.Println(struct4201A.Fopfd)
  9092. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9093. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9094. var res2 ResultSix
  9095. var respJSON2 map[string]interface{}
  9096. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9099. return
  9100. }
  9101. userJSONBytes2, _ := json.Marshal(respJSON2)
  9102. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9103. utils.ErrorLog("解析失败:%v", err)
  9104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9105. return
  9106. }
  9107. if res2.Infcode != 0 {
  9108. c.ServeSuccessJSON(map[string]interface{}{
  9109. "failed_code": -10,
  9110. "msg": res2.ErrMsg,
  9111. })
  9112. return
  9113. } else {
  9114. order.IsUploadOrderInfo = 1
  9115. service.UpdateOrder(order)
  9116. c.ServeSuccessJSON(map[string]interface{}{
  9117. "msg": "上传成功",
  9118. })
  9119. }
  9120. }
  9121. func (c *HisApiController) Get3103() {
  9122. admin_user_id, _ := c.GetInt64("admin_user_id")
  9123. warm_type, _ := c.GetInt64("warm_type")
  9124. fk_state, _ := c.GetInt64("fk_state")
  9125. warm_ids := c.GetString("warm_ids")
  9126. desc := c.GetString("desc")
  9127. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9128. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9129. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9130. saveLog(result, requestLog, "3103", "反馈")
  9131. var res2 ResultSix3103
  9132. var respJSON2 map[string]interface{}
  9133. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9136. return
  9137. }
  9138. userJSONBytes2, _ := json.Marshal(respJSON2)
  9139. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9140. utils.ErrorLog("解析失败:%v", err)
  9141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9142. return
  9143. }
  9144. if res2.Infcode != 0 {
  9145. c.ServeSuccessJSON(map[string]interface{}{
  9146. "failed_code": -10,
  9147. "msg": res2.ErrMsg,
  9148. })
  9149. return
  9150. } else {
  9151. c.ServeSuccessJSON(map[string]interface{}{
  9152. "msg": "反馈成功",
  9153. })
  9154. return
  9155. }
  9156. }
  9157. func (c *HisApiController) Get4201A() {
  9158. order_id, _ := c.GetInt64("order_id")
  9159. admin_user_id, _ := c.GetInt64("admin_user_id")
  9160. order, _ := service.GetHisOrderByIDTwo(order_id)
  9161. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9162. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9163. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9164. //order_info = append(order_info, order_info_two...)
  9165. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9166. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9167. department, _ := service.GetDepartMentDetail(his.Departments)
  9168. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9169. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9170. if order.ID == 0 {
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9172. return
  9173. }
  9174. var struct4201A models.Struct4201A
  9175. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9176. for _, items := range order_info {
  9177. memo := make(map[string]interface{})
  9178. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9179. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9180. fsiOPFLD.MedType = "14"
  9181. fsiOPFLD.BkkpSn = items.FeedetlSn
  9182. fsiOPFLD.FixmedinsCode = miConfig.Code
  9183. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9184. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9185. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9186. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9187. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9188. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9189. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9190. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9191. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9192. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9193. fsiOPFLD.BilgDeptName = department.Name
  9194. fsiOPFLD.BilgDeptCodg = department.Number
  9195. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9196. fsiOPFLD.BilgDrName = doctor.UserName
  9197. fsiOPFLD.MedChrgitmType = "09"
  9198. memo["hosp_appr_flag"] = "1"
  9199. memo["invoice_no"] = order.MdtrtId
  9200. memo["memo"] = "自费"
  9201. bytesData, _ := json.Marshal(memo)
  9202. fsiOPFLD.Memo = string(bytesData)
  9203. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9204. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9205. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9206. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9207. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9208. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9209. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9210. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9211. fsiOPFLD.BilgDeptName = department.Name
  9212. fsiOPFLD.BilgDeptCodg = department.Number
  9213. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9214. fsiOPFLD.BilgDrName = doctor.UserName
  9215. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9216. case 0:
  9217. break
  9218. case 1:
  9219. fsiOPFLD.MedChrgitmType = "14"
  9220. break
  9221. case 2:
  9222. fsiOPFLD.MedChrgitmType = "05"
  9223. break
  9224. case 3:
  9225. fsiOPFLD.MedChrgitmType = "03"
  9226. break
  9227. case 4:
  9228. fsiOPFLD.MedChrgitmType = "03"
  9229. break
  9230. case 5:
  9231. fsiOPFLD.MedChrgitmType = "08"
  9232. break
  9233. case 6:
  9234. fsiOPFLD.MedChrgitmType = "14"
  9235. break
  9236. case 7:
  9237. fsiOPFLD.MedChrgitmType = "14"
  9238. break
  9239. case 8:
  9240. fsiOPFLD.MedChrgitmType = "03"
  9241. break
  9242. case 9:
  9243. fsiOPFLD.MedChrgitmType = "14"
  9244. break
  9245. case 10:
  9246. fsiOPFLD.MedChrgitmType = "14"
  9247. break
  9248. case 11:
  9249. fsiOPFLD.MedChrgitmType = "06"
  9250. break
  9251. case 12:
  9252. fsiOPFLD.MedChrgitmType = "12"
  9253. break
  9254. case 13:
  9255. fsiOPFLD.MedChrgitmType = "01"
  9256. break
  9257. case 14:
  9258. fsiOPFLD.MedChrgitmType = "04"
  9259. break
  9260. case 15:
  9261. fsiOPFLD.MedChrgitmType = "14"
  9262. break
  9263. }
  9264. memo["hosp_appr_flag"] = "1"
  9265. memo["invoice_no"] = order.MdtrtId
  9266. memo["memo"] = "自费"
  9267. bytesData, _ := json.Marshal(memo)
  9268. fsiOPFLD.Memo = string(bytesData)
  9269. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9270. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9271. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9272. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9273. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9274. fsiOPFLD.BilgDeptName = department.Name
  9275. fsiOPFLD.BilgDeptCodg = department.Number
  9276. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9277. fsiOPFLD.BilgDrName = doctor.UserName
  9278. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9279. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9280. fsiOPFLD.MedChrgitmType = "08"
  9281. memo["hosp_appr_flag"] = "1"
  9282. memo["invoice_no"] = order.MdtrtId
  9283. memo["memo"] = "自费"
  9284. bytesData, _ := json.Marshal(memo)
  9285. fsiOPFLD.Memo = string(bytesData)
  9286. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9287. }
  9288. }
  9289. }
  9290. for _, items := range order_info_two {
  9291. memo := make(map[string]interface{})
  9292. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9293. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9294. fsiOPFLD.MedType = "14"
  9295. fsiOPFLD.BkkpSn = items.FeedetlSn
  9296. fsiOPFLD.FixmedinsCode = miConfig.Code
  9297. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9298. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9299. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9300. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9301. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9302. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9303. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9304. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9305. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9306. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9307. fsiOPFLD.BilgDeptName = department.Name
  9308. fsiOPFLD.BilgDeptCodg = department.Number
  9309. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9310. fsiOPFLD.BilgDrName = doctor.UserName
  9311. fsiOPFLD.MedChrgitmType = "09"
  9312. memo["hosp_appr_flag"] = "1"
  9313. memo["invoice_no"] = order.MdtrtId
  9314. memo["memo"] = "自费"
  9315. bytesData, _ := json.Marshal(memo)
  9316. fsiOPFLD.Memo = string(bytesData)
  9317. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9318. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9319. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9320. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9321. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9322. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9323. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9324. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9325. fsiOPFLD.BilgDeptName = department.Name
  9326. fsiOPFLD.BilgDeptCodg = department.Number
  9327. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9328. fsiOPFLD.BilgDrName = doctor.UserName
  9329. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9330. case 0:
  9331. break
  9332. case 1:
  9333. fsiOPFLD.MedChrgitmType = "14"
  9334. break
  9335. case 2:
  9336. fsiOPFLD.MedChrgitmType = "05"
  9337. break
  9338. case 3:
  9339. fsiOPFLD.MedChrgitmType = "03"
  9340. break
  9341. case 4:
  9342. fsiOPFLD.MedChrgitmType = "03"
  9343. break
  9344. case 5:
  9345. fsiOPFLD.MedChrgitmType = "08"
  9346. break
  9347. case 6:
  9348. fsiOPFLD.MedChrgitmType = "14"
  9349. break
  9350. case 7:
  9351. fsiOPFLD.MedChrgitmType = "14"
  9352. break
  9353. case 8:
  9354. fsiOPFLD.MedChrgitmType = "03"
  9355. break
  9356. case 9:
  9357. fsiOPFLD.MedChrgitmType = "14"
  9358. break
  9359. case 10:
  9360. fsiOPFLD.MedChrgitmType = "14"
  9361. break
  9362. case 11:
  9363. fsiOPFLD.MedChrgitmType = "06"
  9364. break
  9365. case 12:
  9366. fsiOPFLD.MedChrgitmType = "12"
  9367. break
  9368. case 13:
  9369. fsiOPFLD.MedChrgitmType = "01"
  9370. break
  9371. case 14:
  9372. fsiOPFLD.MedChrgitmType = "04"
  9373. break
  9374. case 15:
  9375. fsiOPFLD.MedChrgitmType = "14"
  9376. break
  9377. }
  9378. memo["hosp_appr_flag"] = "1"
  9379. memo["invoice_no"] = order.MdtrtId
  9380. memo["memo"] = "自费"
  9381. bytesData, _ := json.Marshal(memo)
  9382. fsiOPFLD.Memo = string(bytesData)
  9383. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9384. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9385. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9386. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9387. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9388. fsiOPFLD.BilgDeptName = department.Name
  9389. fsiOPFLD.BilgDeptCodg = department.Number
  9390. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9391. fsiOPFLD.BilgDrName = doctor.UserName
  9392. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9393. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9394. fsiOPFLD.MedChrgitmType = "08"
  9395. memo["hosp_appr_flag"] = "1"
  9396. memo["invoice_no"] = order.MdtrtId
  9397. memo["memo"] = "自费"
  9398. bytesData, _ := json.Marshal(memo)
  9399. fsiOPFLD.Memo = string(bytesData)
  9400. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9401. }
  9402. }
  9403. }
  9404. fmt.Println(fsiOPFLDs)
  9405. struct4201A.Fopfd = fsiOPFLDs
  9406. fmt.Println(struct4201A.Fopfd)
  9407. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9408. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9409. var res2 ResultSix
  9410. var respJSON2 map[string]interface{}
  9411. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9414. return
  9415. }
  9416. userJSONBytes2, _ := json.Marshal(respJSON2)
  9417. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9418. utils.ErrorLog("解析失败:%v", err)
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9420. return
  9421. }
  9422. if res2.Infcode != 0 {
  9423. c.ServeSuccessJSON(map[string]interface{}{
  9424. "failed_code": -10,
  9425. "msg": res2.ErrMsg,
  9426. })
  9427. return
  9428. } else {
  9429. order.IsUploadOrderInfo = 1
  9430. service.UpdateOrder(order)
  9431. c.ServeSuccessJSON(map[string]interface{}{
  9432. "msg": "上传成功",
  9433. })
  9434. }
  9435. }
  9436. func (c *HisApiController) Get4202() {
  9437. order_id, _ := c.GetInt64("order_id")
  9438. admin_user_id, _ := c.GetInt64("admin_user_id")
  9439. order, _ := service.GetHisOrderByIDTwo(order_id)
  9440. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9441. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9442. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9443. if order.ID == 0 {
  9444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9445. return
  9446. }
  9447. var struct4202 models.Struct4202
  9448. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9449. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9450. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9451. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9452. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9453. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9454. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9455. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9456. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9457. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9458. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9459. var config []*models.HisXtDiagnoseConfig
  9460. for _, item := range diagnosis_ids {
  9461. id, _ := strconv.ParseInt(item, 10, 64)
  9462. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9463. config = append(config, &diagnosisConfig)
  9464. }
  9465. var tempDiaginfos []models.OwnPayPatnDiagListD
  9466. for index, item := range config {
  9467. if index == 0 {
  9468. var tempDiaginfo models.OwnPayPatnDiagListD
  9469. tempDiaginfo.InoutDiagType = "1"
  9470. tempDiaginfo.DiagCode = item.CountryCode
  9471. tempDiaginfo.DiagName = item.CountryContentName
  9472. tempDiaginfo.DiagType = "1"
  9473. tempDiaginfo.DiagSrtNo = "1"
  9474. tempDiaginfo.MaindiagFlag = "1"
  9475. tempDiaginfo.ValiFlag = "1"
  9476. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9477. } else {
  9478. var tempDiaginfo models.OwnPayPatnDiagListD
  9479. tempDiaginfo.DiagCode = item.CountryCode
  9480. tempDiaginfo.DiagName = item.CountryContentName
  9481. tempDiaginfo.DiagType = "2"
  9482. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9483. tempDiaginfo.MaindiagFlag = "0"
  9484. tempDiaginfo.ValiFlag = "1"
  9485. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9486. }
  9487. }
  9488. struct4202.ODiagListD = tempDiaginfos
  9489. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9490. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9491. var res2 ResultSix
  9492. var respJSON2 map[string]interface{}
  9493. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9496. return
  9497. }
  9498. userJSONBytes2, _ := json.Marshal(respJSON2)
  9499. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9500. utils.ErrorLog("解析失败:%v", err)
  9501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9502. return
  9503. }
  9504. if res2.Infcode != 0 {
  9505. c.ServeSuccessJSON(map[string]interface{}{
  9506. "failed_code": -10,
  9507. "msg": res2.ErrMsg,
  9508. })
  9509. return
  9510. } else {
  9511. order.IsUploadDiagnose = 1
  9512. service.UpdateOrder(order)
  9513. c.ServeSuccessJSON(map[string]interface{}{
  9514. "msg": "上传成功",
  9515. })
  9516. }
  9517. }
  9518. func (c *HisApiController) Get4203() {
  9519. admin_user_id, _ := c.GetInt64("admin_user_id")
  9520. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9521. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9522. order_id, _ := c.GetInt64("order_id")
  9523. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9524. number := ""
  9525. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9526. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9527. if his.ID == 0 {
  9528. number = hospital.Number
  9529. } else {
  9530. number = his.Number
  9531. }
  9532. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9533. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9534. var res2 ResultSix
  9535. var respJSON2 map[string]interface{}
  9536. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9539. return
  9540. }
  9541. userJSONBytes2, _ := json.Marshal(respJSON2)
  9542. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9543. utils.ErrorLog("解析失败:%v", err)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. if res2.Infcode != 0 {
  9548. c.ServeSuccessJSON(map[string]interface{}{
  9549. "failed_code": -10,
  9550. "msg": res2.ErrMsg,
  9551. })
  9552. return
  9553. } else {
  9554. order.IsUploadSuccess = 1
  9555. service.UpdateOrderTwo(order)
  9556. c.ServeSuccessJSON(map[string]interface{}{
  9557. "msg": "上传成功",
  9558. })
  9559. }
  9560. }
  9561. func (c *HisApiController) Get4205() {
  9562. order_id, _ := c.GetInt64("order_id")
  9563. admin_user_id, _ := c.GetInt64("admin_user_id")
  9564. fapiao_code := c.GetString("fapiao_code")
  9565. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9566. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9567. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9568. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9569. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9570. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9571. //order_info = append(order_info, order_info_two...)
  9572. department, _ := service.GetDepartMentDetail(his.Departments)
  9573. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9574. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9575. if order.ID == 0 {
  9576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9577. return
  9578. }
  9579. var struct4201A models.Struct4201A
  9580. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9581. for _, items := range order_info {
  9582. memo := make(map[string]interface{})
  9583. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9584. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9585. fsiOPFLD.MedType = pre.MedType
  9586. fsiOPFLD.FixmedinsCode = miConfig.Code
  9587. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9588. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9589. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9590. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9591. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9592. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9593. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9594. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9595. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9596. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9597. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9598. fsiOPFLD.BilgDeptName = department.Name
  9599. fsiOPFLD.BilgDeptCodg = department.Number
  9600. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9601. fsiOPFLD.BilgDrName = doctor.UserName
  9602. fsiOPFLD.MedChrgitmType = "09"
  9603. memo["hosp_appr_flag"] = "1"
  9604. memo["invoice_no"] = fapiao_code
  9605. memo["memo"] = "自费"
  9606. bytesData, _ := json.Marshal(memo)
  9607. fsiOPFLD.Memo = string(bytesData)
  9608. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9609. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9610. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9611. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9612. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9613. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9614. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9615. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9616. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9617. fsiOPFLD.BilgDeptName = department.Name
  9618. fsiOPFLD.BilgDeptCodg = department.Number
  9619. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9620. fsiOPFLD.BilgDrName = doctor.UserName
  9621. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9622. case 0:
  9623. break
  9624. case 1:
  9625. fsiOPFLD.MedChrgitmType = "14"
  9626. break
  9627. case 2:
  9628. fsiOPFLD.MedChrgitmType = "05"
  9629. break
  9630. case 3:
  9631. fsiOPFLD.MedChrgitmType = "03"
  9632. break
  9633. case 4:
  9634. fsiOPFLD.MedChrgitmType = "03"
  9635. break
  9636. case 5:
  9637. fsiOPFLD.MedChrgitmType = "08"
  9638. break
  9639. case 6:
  9640. fsiOPFLD.MedChrgitmType = "14"
  9641. break
  9642. case 7:
  9643. fsiOPFLD.MedChrgitmType = "14"
  9644. break
  9645. case 8:
  9646. fsiOPFLD.MedChrgitmType = "03"
  9647. break
  9648. case 9:
  9649. fsiOPFLD.MedChrgitmType = "14"
  9650. break
  9651. case 10:
  9652. fsiOPFLD.MedChrgitmType = "14"
  9653. break
  9654. case 11:
  9655. fsiOPFLD.MedChrgitmType = "06"
  9656. break
  9657. case 12:
  9658. fsiOPFLD.MedChrgitmType = "12"
  9659. break
  9660. case 13:
  9661. fsiOPFLD.MedChrgitmType = "01"
  9662. break
  9663. case 14:
  9664. fsiOPFLD.MedChrgitmType = "04"
  9665. break
  9666. case 15:
  9667. fsiOPFLD.MedChrgitmType = "14"
  9668. break
  9669. }
  9670. memo["hosp_appr_flag"] = "1"
  9671. memo["invoice_no"] = fapiao_code
  9672. memo["memo"] = "自费"
  9673. bytesData, _ := json.Marshal(memo)
  9674. fsiOPFLD.Memo = string(bytesData)
  9675. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9676. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9677. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9678. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9679. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9680. fsiOPFLD.BilgDeptName = department.Name
  9681. fsiOPFLD.BilgDeptCodg = department.Number
  9682. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9683. fsiOPFLD.BilgDrName = doctor.UserName
  9684. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9685. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9686. fsiOPFLD.MedChrgitmType = "08"
  9687. memo["hosp_appr_flag"] = "1"
  9688. memo["invoice_no"] = fapiao_code
  9689. memo["memo"] = "自费"
  9690. bytesData, _ := json.Marshal(memo)
  9691. fsiOPFLD.Memo = string(bytesData)
  9692. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9693. }
  9694. }
  9695. }
  9696. for _, items := range order_info_two {
  9697. memo := make(map[string]interface{})
  9698. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9699. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9700. fsiOPFLD.MedType = pre.MedType
  9701. fsiOPFLD.BkkpSn = items.FeedetlSn
  9702. fsiOPFLD.FixmedinsCode = miConfig.Code
  9703. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9704. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9705. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9706. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9707. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9708. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9709. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9710. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9711. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9712. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9713. fsiOPFLD.BilgDeptName = department.Name
  9714. fsiOPFLD.BilgDeptCodg = department.Number
  9715. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9716. fsiOPFLD.BilgDrName = doctor.UserName
  9717. fsiOPFLD.MedChrgitmType = "09"
  9718. memo["hosp_appr_flag"] = "1"
  9719. memo["invoice_no"] = fapiao_code
  9720. memo["memo"] = "自费"
  9721. bytesData, _ := json.Marshal(memo)
  9722. fsiOPFLD.Memo = string(bytesData)
  9723. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9724. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9725. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9726. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9727. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9728. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9729. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9730. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9731. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9732. fsiOPFLD.BilgDeptName = department.Name
  9733. fsiOPFLD.BilgDeptCodg = department.Number
  9734. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9735. fsiOPFLD.BilgDrName = doctor.UserName
  9736. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9737. case 0:
  9738. break
  9739. case 1:
  9740. fsiOPFLD.MedChrgitmType = "14"
  9741. break
  9742. case 2:
  9743. fsiOPFLD.MedChrgitmType = "05"
  9744. break
  9745. case 3:
  9746. fsiOPFLD.MedChrgitmType = "03"
  9747. break
  9748. case 4:
  9749. fsiOPFLD.MedChrgitmType = "03"
  9750. break
  9751. case 5:
  9752. fsiOPFLD.MedChrgitmType = "08"
  9753. break
  9754. case 6:
  9755. fsiOPFLD.MedChrgitmType = "14"
  9756. break
  9757. case 7:
  9758. fsiOPFLD.MedChrgitmType = "14"
  9759. break
  9760. case 8:
  9761. fsiOPFLD.MedChrgitmType = "03"
  9762. break
  9763. case 9:
  9764. fsiOPFLD.MedChrgitmType = "14"
  9765. break
  9766. case 10:
  9767. fsiOPFLD.MedChrgitmType = "14"
  9768. break
  9769. case 11:
  9770. fsiOPFLD.MedChrgitmType = "06"
  9771. break
  9772. case 12:
  9773. fsiOPFLD.MedChrgitmType = "12"
  9774. break
  9775. case 13:
  9776. fsiOPFLD.MedChrgitmType = "01"
  9777. break
  9778. case 14:
  9779. fsiOPFLD.MedChrgitmType = "04"
  9780. break
  9781. case 15:
  9782. fsiOPFLD.MedChrgitmType = "14"
  9783. break
  9784. }
  9785. memo["hosp_appr_flag"] = "1"
  9786. memo["invoice_no"] = fapiao_code
  9787. memo["memo"] = "自费"
  9788. bytesData, _ := json.Marshal(memo)
  9789. fsiOPFLD.Memo = string(bytesData)
  9790. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9791. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9792. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9793. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9794. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9795. fsiOPFLD.BilgDeptName = department.Name
  9796. fsiOPFLD.BilgDeptCodg = department.Number
  9797. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9798. fsiOPFLD.BilgDrName = doctor.UserName
  9799. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9800. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9801. fsiOPFLD.MedChrgitmType = "08"
  9802. memo["hosp_appr_flag"] = "1"
  9803. memo["invoice_no"] = fapiao_code
  9804. memo["memo"] = "自费"
  9805. bytesData, _ := json.Marshal(memo)
  9806. fsiOPFLD.Memo = string(bytesData)
  9807. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9808. }
  9809. }
  9810. }
  9811. fmt.Println(fsiOPFLDs)
  9812. struct4201A.Fopfd = fsiOPFLDs
  9813. fmt.Println(struct4201A.Fopfd)
  9814. var struct4202 models.Struct4202
  9815. timeLayout := "2006-01-02 15:04:05"
  9816. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9817. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9818. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9819. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9820. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9821. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9822. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9823. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9824. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9825. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9826. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9827. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9828. var config []*models.HisXtDiagnoseConfig
  9829. for _, item := range diagnosis_ids {
  9830. id, _ := strconv.ParseInt(item, 10, 64)
  9831. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9832. config = append(config, &diagnosisConfig)
  9833. }
  9834. var tempDiaginfos []models.OwnPayPatnDiagListD
  9835. for index, item := range config {
  9836. if index == 0 {
  9837. var tempDiaginfo models.OwnPayPatnDiagListD
  9838. tempDiaginfo.InoutDiagType = "1"
  9839. tempDiaginfo.DiagCode = item.CountryCode
  9840. tempDiaginfo.DiagName = item.CountryContentName
  9841. tempDiaginfo.DiagType = "1"
  9842. tempDiaginfo.DiagSrtNo = "1"
  9843. tempDiaginfo.MaindiagFlag = "1"
  9844. tempDiaginfo.ValiFlag = "1"
  9845. tempDiaginfo.DiagDrName = doctor.UserName
  9846. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9847. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9848. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9849. } else {
  9850. var tempDiaginfo models.OwnPayPatnDiagListD
  9851. tempDiaginfo.DiagCode = item.CountryCode
  9852. tempDiaginfo.DiagName = item.CountryContentName
  9853. tempDiaginfo.DiagType = "2"
  9854. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9855. tempDiaginfo.MaindiagFlag = "0"
  9856. tempDiaginfo.ValiFlag = "1"
  9857. tempDiaginfo.DiagDrName = doctor.UserName
  9858. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9859. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9860. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9861. }
  9862. }
  9863. struct4202.ODiagListD = tempDiaginfos
  9864. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9865. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9866. var res2 ResultSix
  9867. var respJSON2 map[string]interface{}
  9868. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9871. return
  9872. }
  9873. userJSONBytes2, _ := json.Marshal(respJSON2)
  9874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9875. utils.ErrorLog("解析失败:%v", err)
  9876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9877. return
  9878. }
  9879. if res2.Infcode != 0 {
  9880. c.ServeSuccessJSON(map[string]interface{}{
  9881. "failed_code": -10,
  9882. "msg": res2.ErrMsg,
  9883. })
  9884. return
  9885. } else {
  9886. order.IsUploadDiagnose = 1
  9887. order.IsUploadOrderInfo = 1
  9888. service.UpdateOrderTwo(order)
  9889. c.ServeSuccessJSON(map[string]interface{}{
  9890. "msg": "上传成功",
  9891. })
  9892. }
  9893. }
  9894. func (c *HisApiController) Get4207() {
  9895. admin_user_id, _ := c.GetInt64("admin_user_id")
  9896. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9897. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9898. order_id, _ := c.GetInt64("order_id")
  9899. order, _ := service.GetHisOrderByIDTwo(order_id)
  9900. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9901. var struct4207 models.Struct4207
  9902. struct4207.PageNum = "1"
  9903. struct4207.PageSize = "1000"
  9904. struct4207.FixmedinsCode = miConfig.Code
  9905. struct4207.FixmedinsMdtrtID = order.Number
  9906. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9907. saveLog(result, requestLog, "4207", "查询")
  9908. var res2 ResultSix
  9909. var respJSON2 map[string]interface{}
  9910. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9913. return
  9914. }
  9915. userJSONBytes2, _ := json.Marshal(respJSON2)
  9916. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9917. utils.ErrorLog("解析失败:%v", err)
  9918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9919. return
  9920. }
  9921. if res2.Infcode != 0 {
  9922. c.ServeSuccessJSON(map[string]interface{}{
  9923. "failed_code": -10,
  9924. "msg": res2.ErrMsg,
  9925. })
  9926. return
  9927. } else {
  9928. c.ServeSuccessJSON(map[string]interface{}{
  9929. "msg": "查询成功",
  9930. })
  9931. }
  9932. }
  9933. func (c *HisApiController) Get4208() {
  9934. admin_user_id, _ := c.GetInt64("admin_user_id")
  9935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9936. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9937. order_id, _ := c.GetInt64("order_id")
  9938. order, _ := service.GetHisOrderByIDTwo(order_id)
  9939. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9940. var struct4208 models.Struct4208
  9941. struct4208.PageNum = "1"
  9942. struct4208.PageSize = "1000"
  9943. struct4208.PsnCertType = "01"
  9944. struct4208.Certno = his.Certno
  9945. struct4208.MedType = order.MedType
  9946. struct4208.PsnName = his.Name
  9947. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9948. saveLog(result, requestLog, "4208", "查询")
  9949. var res2 ResultSix
  9950. var respJSON2 map[string]interface{}
  9951. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9954. return
  9955. }
  9956. userJSONBytes2, _ := json.Marshal(respJSON2)
  9957. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9958. utils.ErrorLog("解析失败:%v", err)
  9959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9960. return
  9961. }
  9962. if res2.Infcode != 0 {
  9963. c.ServeSuccessJSON(map[string]interface{}{
  9964. "failed_code": -10,
  9965. "msg": res2.ErrMsg,
  9966. })
  9967. return
  9968. } else {
  9969. c.ServeSuccessJSON(map[string]interface{}{
  9970. "msg": "查询成功",
  9971. })
  9972. }
  9973. }
  9974. func (c *HisApiController) Get4209() {
  9975. admin_user_id, _ := c.GetInt64("admin_user_id")
  9976. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9978. order_id, _ := c.GetInt64("order_id")
  9979. order, _ := service.GetHisOrderByIDTwo(order_id)
  9980. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9981. var struct4209 models.Struct4209
  9982. struct4209.FixmedinsMdtrtID = order.Number
  9983. struct4209.FixmedinsCode = miConfig.Code
  9984. struct4209.PageSize = "1000"
  9985. struct4209.PageNum = "1"
  9986. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9987. saveLog(result, requestLog, "4209", "查询")
  9988. var res2 ResultSix
  9989. var respJSON2 map[string]interface{}
  9990. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9993. return
  9994. }
  9995. userJSONBytes2, _ := json.Marshal(respJSON2)
  9996. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9997. utils.ErrorLog("解析失败:%v", err)
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9999. return
  10000. }
  10001. if res2.Infcode != 0 {
  10002. c.ServeSuccessJSON(map[string]interface{}{
  10003. "failed_code": -10,
  10004. "msg": res2.ErrMsg,
  10005. })
  10006. return
  10007. } else {
  10008. c.ServeSuccessJSON(map[string]interface{}{
  10009. "msg": "查询成功",
  10010. })
  10011. }
  10012. }
  10013. type Result3101 struct {
  10014. Infcode string `json:"infcode"`
  10015. InfRefmsgid string `json:"inf_refmsgid"`
  10016. RefmsgTime string `json:"refmsg_time"`
  10017. RespondTime string `json:"respond_time"`
  10018. Enctype string `json:"enctype"`
  10019. Signtype string `json:"signtype"`
  10020. ErrMsg string `json:"err_msg"`
  10021. Output struct {
  10022. Result []struct {
  10023. JudgeResultDetailDtos []struct {
  10024. VolaItemType string `json:"vola_item_type"`
  10025. MdtrtID string `json:"mdtrt_id"`
  10026. JrdID string `json:"jrd_id"`
  10027. PatnID string `json:"patn_id"`
  10028. RxID string `json:"rx_id"`
  10029. VolaAmt interface{} `json:"vola_amt"`
  10030. } `json:"judge_result_detail_dtos"`
  10031. RuleID string `json:"rule_id"`
  10032. VolaEvid string `json:"vola_evid"`
  10033. MdtrtID string `json:"mdtrt_id"`
  10034. RuleName string `json:"rule_name"`
  10035. VolaAmtStas string `json:"vola_amt_stas"`
  10036. JrID string `json:"jr_id"`
  10037. PatnID string `json:"patn_id"`
  10038. SevDeg string `json:"sev_deg"`
  10039. VolaAmt float64 `json:"vola_amt"`
  10040. VolaBhvrType string `json:"vola_bhvr_type"`
  10041. VolaCont string `json:"vola_cont"`
  10042. } `json:"result"`
  10043. } `json:"output"`
  10044. }
  10045. type Resultgd3101 struct {
  10046. Infcode int64 `json:"infcode"`
  10047. InfRefmsgid string `json:"inf_refmsgid"`
  10048. RefmsgTime string `json:"refmsg_time"`
  10049. RespondTime string `json:"respond_time"`
  10050. Enctype string `json:"enctype"`
  10051. Signtype string `json:"signtype"`
  10052. ErrMsg string `json:"err_msg"`
  10053. Output struct {
  10054. Result []struct {
  10055. JudgeResultDetailDtos []struct {
  10056. VolaItemType string `json:"vola_item_type"`
  10057. MdtrtID string `json:"mdtrt_id"`
  10058. JrdID string `json:"jrd_id"`
  10059. PatnID string `json:"patn_id"`
  10060. RxID string `json:"rx_id"`
  10061. VolaAmt interface{} `json:"vola_amt"`
  10062. } `json:"judge_result_detail_dtos"`
  10063. RuleID string `json:"rule_id"`
  10064. VolaEvid string `json:"vola_evid"`
  10065. MdtrtID string `json:"mdtrt_id"`
  10066. RuleName string `json:"rule_name"`
  10067. VolaAmtStas string `json:"vola_amt_stas"`
  10068. JrID string `json:"jr_id"`
  10069. PatnID string `json:"patn_id"`
  10070. SevDeg string `json:"sev_deg"`
  10071. VolaAmt float64 `json:"vola_amt"`
  10072. VolaBhvrType string `json:"vola_bhvr_type"`
  10073. VolaCont string `json:"vola_cont"`
  10074. } `json:"result"`
  10075. } `json:"output"`
  10076. }
  10077. func (c *HisApiController) ReadEleToken() {
  10078. admin_user_id, _ := c.GetInt64("admin_user_id")
  10079. his_patient_id, _ := c.GetInt64("his_patient_id")
  10080. adminUser := c.GetAdminUserInfo()
  10081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10082. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10083. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10084. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10085. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10086. if len(tokens) > 0 {
  10087. c.ServeSuccessJSON(map[string]interface{}{
  10088. "msg": "读取成功",
  10089. })
  10090. } else {
  10091. c.ServeSuccessJSON(map[string]interface{}{
  10092. "failed_code": -10,
  10093. "msg": "读取失败",
  10094. })
  10095. }
  10096. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10097. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10098. if len(tokens) > 0 {
  10099. c.ServeSuccessJSON(map[string]interface{}{
  10100. "msg": "读取成功",
  10101. })
  10102. } else {
  10103. c.ServeSuccessJSON(map[string]interface{}{
  10104. "failed_code": -10,
  10105. "msg": "读取失败",
  10106. })
  10107. }
  10108. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10109. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10110. if len(tokens) > 0 {
  10111. c.ServeSuccessJSON(map[string]interface{}{
  10112. "msg": "读取成功",
  10113. })
  10114. } else {
  10115. c.ServeSuccessJSON(map[string]interface{}{
  10116. "failed_code": -10,
  10117. "msg": "读取失败",
  10118. })
  10119. }
  10120. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10121. var api string
  10122. 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 +
  10123. "&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"
  10124. resp, requestErr := http.Get(api)
  10125. if requestErr != nil {
  10126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10127. }
  10128. body, ioErr := ioutil.ReadAll(resp.Body)
  10129. if ioErr != nil {
  10130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10132. }
  10133. var respJSON map[string]interface{}
  10134. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10137. return
  10138. }
  10139. var status string
  10140. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10141. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10142. var token string
  10143. var res ResultTwo //1101结果
  10144. var res10265 ResultTwo10265 //1101结果
  10145. if status == "0" { //读卡成功
  10146. var card_info string //卡信息
  10147. var busi_card_info string
  10148. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10149. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10150. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10151. fmt.Println(card_info)
  10152. fmt.Println(busi_card_info)
  10153. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10154. result, _ := json.Marshal(respJSON)
  10155. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10156. utils.ErrorLog("解析失败:%v", err)
  10157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10158. return
  10159. }
  10160. res.ErrMsg = res10265.ErrMsg
  10161. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10162. res.Infcode = infocode
  10163. res.Output = res10265.Output
  10164. res.InfRefmsgid = res10265.InfRefmsgid
  10165. if res.Infcode == 0 {
  10166. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10167. if err == gorm.ErrRecordNotFound {
  10168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10169. return
  10170. } else if err != nil {
  10171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10172. return
  10173. } else {
  10174. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10175. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10176. infoStr := string(Iinfos)
  10177. idetinfoStr := string(Idetinfos)
  10178. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10179. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10180. psn := &models.HisPsn{
  10181. PsnNo: res.Output.Baseinfo.PsnNo,
  10182. PatientId: patient.ID,
  10183. Certno: res.Output.Baseinfo.Certno,
  10184. Gend: res.Output.Baseinfo.Gend,
  10185. Naty: res.Output.Baseinfo.Naty,
  10186. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10187. PsnName: res.Output.Baseinfo.PsnName,
  10188. Age: float64(age),
  10189. Brdy: b,
  10190. Idetinfo: idetinfoStr,
  10191. Insuinfo: infoStr,
  10192. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10193. CardInfo: card_info,
  10194. VerifyNumber: token,
  10195. IdCardType: 4,
  10196. }
  10197. var rf []*ResultFive
  10198. json.Unmarshal([]byte(infoStr), &rf)
  10199. var insutypes []*ResultFive
  10200. var insutype string
  10201. var is390 int = 0
  10202. var is310 int = 0
  10203. for _, item := range rf {
  10204. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10205. insutypes = append(insutypes, item)
  10206. }
  10207. }
  10208. if len(insutypes) == 1 {
  10209. insutype = insutypes[0].Insutype
  10210. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10211. } else {
  10212. for _, i := range insutypes {
  10213. if i.Insutype == "390" {
  10214. is390 = 1
  10215. }
  10216. if i.Insutype == "310" {
  10217. is310 = 1
  10218. }
  10219. }
  10220. }
  10221. if is390 == 1 {
  10222. insutype = "390"
  10223. }
  10224. if is310 == 1 {
  10225. insutype = "310"
  10226. }
  10227. if len(insutypes) == 0 {
  10228. insutype = "310"
  10229. }
  10230. service.CreateHisPsn(psn)
  10231. c.ServeSuccessJSON(map[string]interface{}{
  10232. "patient": patient,
  10233. "number": token,
  10234. "insutype": insutype,
  10235. })
  10236. }
  10237. } else {
  10238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10239. return
  10240. }
  10241. } else { //读卡失败
  10242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10243. return
  10244. }
  10245. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10246. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10247. if len(errMsg) == 0 {
  10248. type ELeData struct {
  10249. Data struct {
  10250. IdNo string `json:"idNo"`
  10251. IdType string `json:"idType"`
  10252. UserName string `json:"userName"`
  10253. EcToken string `json:"ecToken"`
  10254. InsuOrg string `json:"insuOrg"`
  10255. Gender string `json:"gender"`
  10256. Birthday string `json:"birthday"`
  10257. Nationality string `json:"nationality"`
  10258. Email string `json:"email"`
  10259. Extra string `json:"extra"`
  10260. } `json:"data"`
  10261. Code int `json:"code"`
  10262. Message string `json:"message"`
  10263. }
  10264. var ele ELeData
  10265. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10266. if err != nil {
  10267. utils.ErrorLog("解析失败:%v", err)
  10268. }
  10269. token := ele.Data.EcToken
  10270. if len(token) > 0 {
  10271. psn := &models.HisPsn{
  10272. PsnNo: his.PsnNo,
  10273. Age: 0,
  10274. PatientId: his.PatientId,
  10275. Certno: his.Certno,
  10276. Brdy: his.Brdy,
  10277. Gend: his.Gend,
  10278. Naty: his.Naty,
  10279. PsnCertType: his.PsnCertType,
  10280. PsnName: his.PsnName,
  10281. Idetinfo: his.Idetinfo,
  10282. Insuinfo: his.Iinfo,
  10283. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10284. CardInfo: outPutInfo,
  10285. VerifyNumber: token,
  10286. }
  10287. service.CreateHisPsn(psn)
  10288. }
  10289. if len(token) > 0 {
  10290. c.ServeSuccessJSON(map[string]interface{}{
  10291. "msg": "读取成功",
  10292. })
  10293. } else {
  10294. c.ServeSuccessJSON(map[string]interface{}{
  10295. "failed_code": -10,
  10296. "msg": "读取失败",
  10297. })
  10298. }
  10299. }
  10300. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10301. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10302. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10303. type ELeData struct {
  10304. Data struct {
  10305. IdNo string `json:"idNo"`
  10306. IdType string `json:"idType"`
  10307. UserName string `json:"userName"`
  10308. EcToken string `json:"ecToken"`
  10309. InsuOrg string `json:"insuOrg"`
  10310. Gender string `json:"gender"`
  10311. Birthday string `json:"birthday"`
  10312. Nationality string `json:"nationality"`
  10313. Email string `json:"email"`
  10314. Extra string `json:"extra"`
  10315. } `json:"data"`
  10316. Code int `json:"code"`
  10317. Message string `json:"message"`
  10318. }
  10319. var ele ELeData
  10320. err := json.Unmarshal([]byte(result), &ele)
  10321. if err != nil {
  10322. utils.ErrorLog("解析失败:%v", err)
  10323. }
  10324. token := ele.Data.EcToken
  10325. token = Remove0000(token)
  10326. fmt.Println(ele.Data.UserName)
  10327. 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)
  10328. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10329. var res ResultTwo
  10330. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10331. utils.ErrorLog("解析失败:%v", err)
  10332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10333. return
  10334. }
  10335. if res.Infcode == 0 {
  10336. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10337. if err == gorm.ErrRecordNotFound {
  10338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10339. return
  10340. } else if err != nil {
  10341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10342. return
  10343. } else {
  10344. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10345. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10346. infoStr := string(Iinfos)
  10347. idetinfoStr := string(Idetinfos)
  10348. psn := &models.HisPsn{
  10349. PsnNo: res.Output.Baseinfo.PsnNo,
  10350. PatientId: patient.ID,
  10351. Certno: res.Output.Baseinfo.Certno,
  10352. Gend: res.Output.Baseinfo.Gend,
  10353. Naty: res.Output.Baseinfo.Naty,
  10354. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10355. PsnName: res.Output.Baseinfo.PsnName,
  10356. Idetinfo: idetinfoStr,
  10357. Insuinfo: infoStr,
  10358. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10359. CardInfo: "",
  10360. VerifyNumber: token,
  10361. }
  10362. service.CreateHisPsn(psn)
  10363. c.ServeSuccessJSON(map[string]interface{}{
  10364. "patient": patient,
  10365. "number": token,
  10366. })
  10367. }
  10368. } else {
  10369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10370. return
  10371. }
  10372. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10373. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10374. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10375. type ELeData struct {
  10376. Data struct {
  10377. IdNo string `json:"idNo"`
  10378. IdType string `json:"idType"`
  10379. UserName string `json:"userName"`
  10380. EcToken string `json:"ecToken"`
  10381. InsuOrg string `json:"insuOrg"`
  10382. Gender string `json:"gender"`
  10383. Birthday string `json:"birthday"`
  10384. Nationality string `json:"nationality"`
  10385. Email string `json:"email"`
  10386. Extra string `json:"extra"`
  10387. } `json:"data"`
  10388. Code int `json:"code"`
  10389. Message string `json:"message"`
  10390. }
  10391. var ele ELeData
  10392. err := json.Unmarshal([]byte(result), &ele)
  10393. if err != nil {
  10394. utils.ErrorLog("解析失败:%v", err)
  10395. }
  10396. token := ele.Data.EcToken
  10397. token = Remove0000(token)
  10398. fmt.Println(ele.Data.UserName)
  10399. 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)
  10400. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10401. var res ResultTwo
  10402. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10403. utils.ErrorLog("解析失败:%v", err)
  10404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10405. return
  10406. }
  10407. if res.Infcode == 0 {
  10408. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10409. if err == gorm.ErrRecordNotFound {
  10410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10411. return
  10412. } else if err != nil {
  10413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10414. return
  10415. } else {
  10416. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10417. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10418. infoStr := string(Iinfos)
  10419. idetinfoStr := string(Idetinfos)
  10420. psn := &models.HisPsn{
  10421. PsnNo: res.Output.Baseinfo.PsnNo,
  10422. PatientId: patient.ID,
  10423. Certno: res.Output.Baseinfo.Certno,
  10424. Gend: res.Output.Baseinfo.Gend,
  10425. Naty: res.Output.Baseinfo.Naty,
  10426. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10427. PsnName: res.Output.Baseinfo.PsnName,
  10428. Idetinfo: idetinfoStr,
  10429. Insuinfo: infoStr,
  10430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10431. CardInfo: "",
  10432. VerifyNumber: token,
  10433. }
  10434. service.CreateHisPsn(psn)
  10435. c.ServeSuccessJSON(map[string]interface{}{
  10436. "patient": patient,
  10437. "number": token,
  10438. })
  10439. }
  10440. } else {
  10441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10442. return
  10443. }
  10444. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10445. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10446. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10447. type ELeData struct {
  10448. Data struct {
  10449. IdNo string `json:"idNo"`
  10450. IdType string `json:"idType"`
  10451. UserName string `json:"userName"`
  10452. EcToken string `json:"ecToken"`
  10453. InsuOrg string `json:"insuOrg"`
  10454. Gender string `json:"gender"`
  10455. Birthday string `json:"birthday"`
  10456. Nationality string `json:"nationality"`
  10457. Email string `json:"email"`
  10458. Extra string `json:"extra"`
  10459. } `json:"data"`
  10460. Code int `json:"code"`
  10461. Message string `json:"message"`
  10462. }
  10463. var ele ELeData
  10464. err := json.Unmarshal([]byte(result), &ele)
  10465. if err != nil {
  10466. utils.ErrorLog("解析失败:%v", err)
  10467. }
  10468. token := ele.Data.EcToken
  10469. token = Remove0000(token)
  10470. fmt.Println(ele.Data.UserName)
  10471. 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)
  10472. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10473. var res ResultTwo
  10474. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10475. utils.ErrorLog("解析失败:%v", err)
  10476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10477. return
  10478. }
  10479. if res.Infcode == 0 {
  10480. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10481. if err == gorm.ErrRecordNotFound {
  10482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10483. return
  10484. } else if err != nil {
  10485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10486. return
  10487. } else {
  10488. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10489. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10490. infoStr := string(Iinfos)
  10491. idetinfoStr := string(Idetinfos)
  10492. psn := &models.HisPsn{
  10493. PsnNo: res.Output.Baseinfo.PsnNo,
  10494. PatientId: patient.ID,
  10495. Certno: res.Output.Baseinfo.Certno,
  10496. Gend: res.Output.Baseinfo.Gend,
  10497. Naty: res.Output.Baseinfo.Naty,
  10498. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10499. PsnName: res.Output.Baseinfo.PsnName,
  10500. Idetinfo: idetinfoStr,
  10501. Insuinfo: infoStr,
  10502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10503. CardInfo: "",
  10504. VerifyNumber: token,
  10505. }
  10506. service.CreateHisPsn(psn)
  10507. c.ServeSuccessJSON(map[string]interface{}{
  10508. "patient": patient,
  10509. "number": token,
  10510. })
  10511. }
  10512. } else {
  10513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10514. return
  10515. }
  10516. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10517. //if initFlag == 0 {
  10518. //c.TestGetJiangXiBasBaseInit()
  10519. //}
  10520. //if initEleFlag == 0 {
  10521. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10522. //}
  10523. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10524. utils.ErrorLog("解析失败:%v", json_result)
  10525. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10526. type ELeData struct {
  10527. Data struct {
  10528. IdNo string `json:"idNo"`
  10529. IdType string `json:"idType"`
  10530. UserName string `json:"userName"`
  10531. EcToken string `json:"ecToken"`
  10532. InsuOrg string `json:"insuOrg"`
  10533. Gender string `json:"gender"`
  10534. Birthday string `json:"birthday"`
  10535. Nationality string `json:"nationality"`
  10536. Email string `json:"email"`
  10537. Extra string `json:"extra"`
  10538. } `json:"data"`
  10539. Code int `json:"code"`
  10540. Message string `json:"message"`
  10541. }
  10542. var ele ELeData
  10543. err := json.Unmarshal([]byte(json_result), &ele)
  10544. if err != nil {
  10545. utils.ErrorLog("解析失败:%v", err)
  10546. }
  10547. token := ele.Data.EcToken
  10548. token = Remove0000(token)
  10549. //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)
  10550. 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)
  10551. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10552. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10553. var res ResultTwo
  10554. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10555. utils.ErrorLog("解析失败:%v", err)
  10556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10557. return
  10558. }
  10559. if res.Infcode == 0 {
  10560. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10561. if err == gorm.ErrRecordNotFound {
  10562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10563. return
  10564. } else if err != nil {
  10565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10566. return
  10567. } else {
  10568. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10569. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10570. infoStr := string(Iinfos)
  10571. idetinfoStr := string(Idetinfos)
  10572. psn := &models.HisPsn{
  10573. PsnNo: res.Output.Baseinfo.PsnNo,
  10574. PatientId: patient.ID,
  10575. Certno: res.Output.Baseinfo.Certno,
  10576. Gend: res.Output.Baseinfo.Gend,
  10577. Naty: res.Output.Baseinfo.Naty,
  10578. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10579. PsnName: res.Output.Baseinfo.PsnName,
  10580. Idetinfo: idetinfoStr,
  10581. Insuinfo: infoStr,
  10582. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10583. CardInfo: "",
  10584. VerifyNumber: token,
  10585. InsuplcAdmdvs: ele.Data.InsuOrg,
  10586. }
  10587. service.CreateHisPsn(psn)
  10588. c.ServeSuccessJSON(map[string]interface{}{
  10589. "patient": patient,
  10590. "number": token,
  10591. })
  10592. }
  10593. } else {
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10595. return
  10596. }
  10597. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10598. res := c.GetoleInfo()
  10599. if res.Infcode == 0 {
  10600. var result string
  10601. if res.Output.MdtrtCertType == "01" {
  10602. 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)
  10603. } else if res.Output.MdtrtCertType == "02" {
  10604. 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)
  10605. } else if res.Output.MdtrtCertType == "03" {
  10606. 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)
  10607. }
  10608. var dat map[string]interface{}
  10609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10610. fmt.Println(dat)
  10611. } else {
  10612. fmt.Println(err)
  10613. }
  10614. userJSONBytes, _ := json.Marshal(dat)
  10615. var res2 ResultTwo
  10616. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10617. utils.ErrorLog("解析失败:%v", err)
  10618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10619. return
  10620. }
  10621. if res2.Infcode == 0 {
  10622. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10623. if err == gorm.ErrRecordNotFound {
  10624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10625. return
  10626. } else if err != nil {
  10627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10628. return
  10629. } else {
  10630. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10631. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10632. infoStr := string(Iinfos)
  10633. idetinfoStr := string(Idetinfos)
  10634. var rf []*ResultFive
  10635. json.Unmarshal([]byte(infoStr), &rf)
  10636. var insutypes []*ResultFive
  10637. var insutype string
  10638. var is390 int = 0
  10639. var is310 int = 0
  10640. //var insuplc_admdvs string
  10641. for _, item := range rf {
  10642. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10643. insutypes = append(insutypes, item)
  10644. }
  10645. }
  10646. if len(insutypes) == 1 {
  10647. insutype = insutypes[0].Insutype
  10648. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10649. } else {
  10650. for _, i := range insutypes {
  10651. if i.Insutype == "390" {
  10652. is390 = 1
  10653. }
  10654. if i.Insutype == "310" {
  10655. is310 = 1
  10656. }
  10657. }
  10658. }
  10659. if is390 == 1 {
  10660. insutype = "390"
  10661. }
  10662. if is310 == 1 {
  10663. insutype = "310"
  10664. }
  10665. if len(insutypes) == 0 {
  10666. insutype = "310"
  10667. }
  10668. psn := &models.HisPsn{
  10669. PsnNo: res2.Output.Baseinfo.PsnNo,
  10670. PatientId: patient.ID,
  10671. Certno: res2.Output.Baseinfo.Certno,
  10672. Gend: res2.Output.Baseinfo.Gend,
  10673. Naty: res2.Output.Baseinfo.Naty,
  10674. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10675. PsnName: res2.Output.Baseinfo.PsnName,
  10676. Idetinfo: idetinfoStr,
  10677. Insuinfo: infoStr,
  10678. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10679. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10680. VerifyNumber: res.Output.EcToken,
  10681. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10682. }
  10683. service.CreateHisPsn(psn)
  10684. c.ServeSuccessJSON(map[string]interface{}{
  10685. "patient": patient,
  10686. "number": res.Output.CardNo,
  10687. "insutype": insutype,
  10688. })
  10689. }
  10690. } else {
  10691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10692. return
  10693. }
  10694. } else {
  10695. c.ServeSuccessJSON(map[string]interface{}{
  10696. "failed_code": -10,
  10697. "msg": res.ErrMsg,
  10698. })
  10699. }
  10700. } else {
  10701. //if initFlag == 0 {
  10702. // c.TestGetBasBaseInit()
  10703. //}
  10704. //token := c.GetEleBaseInfo()
  10705. //token = Remove0000(token)
  10706. type ELeData struct {
  10707. Code string `json:"code"`
  10708. Data struct {
  10709. Aac002 string `json:"aac002"`
  10710. Aaz500 string `json:"aaz500"`
  10711. ActCardNo string `json:"actCardNo"`
  10712. Bab520 string `json:"bab520"`
  10713. Bkz543 string `json:"bkz543"`
  10714. BusinessType string `json:"businessType"`
  10715. CertfCodg string `json:"certfCodg"`
  10716. EcIndexNo string `json:"ecIndexNo"`
  10717. EcToken string `json:"ecToken"`
  10718. ID0000 string `json:"id0000"`
  10719. IDNo string `json:"idNo"`
  10720. IDType string `json:"idType"`
  10721. Idcode string `json:"idcode"`
  10722. IdentityToken string `json:"identity_token"`
  10723. InsuOrg string `json:"insuOrg"`
  10724. OfficeID string `json:"officeId"`
  10725. OfficeName string `json:"officeName"`
  10726. OperatorID string `json:"operatorId"`
  10727. OperatorName string `json:"operatorName"`
  10728. OrgID string `json:"orgId"`
  10729. UserName string `json:"userName"`
  10730. } `json:"data"`
  10731. Infno interface{} `json:"infno"`
  10732. Message string `json:"message"`
  10733. OrgID string `json:"orgId"`
  10734. TransType string `json:"transType"`
  10735. }
  10736. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10737. fmt.Println(result)
  10738. outPutInfo := Remove0000(result)
  10739. fmt.Println(outPutInfo)
  10740. var ele ELeData
  10741. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10742. if err != nil {
  10743. utils.ErrorLog("解析失败:%v", err)
  10744. }
  10745. token := ele.Data.EcToken
  10746. var result2 string
  10747. var requestLog2 string
  10748. if len(token) > 0 {
  10749. if strings.Contains(ele.Data.IDNo, "HKG") {
  10750. 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)
  10751. } else {
  10752. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10753. }
  10754. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10755. var res ResultTwo
  10756. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10757. utils.ErrorLog("解析失败:%v", err)
  10758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10759. return
  10760. }
  10761. if res.Infcode == 0 {
  10762. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10763. if err == gorm.ErrRecordNotFound {
  10764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10765. return
  10766. } else if err != nil {
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10768. return
  10769. } else {
  10770. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10771. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10772. infoStr := string(Iinfos)
  10773. idetinfoStr := string(Idetinfos)
  10774. psn := &models.HisPsn{
  10775. PsnNo: res.Output.Baseinfo.PsnNo,
  10776. PatientId: patient.ID,
  10777. Certno: res.Output.Baseinfo.Certno,
  10778. Gend: res.Output.Baseinfo.Gend,
  10779. Naty: res.Output.Baseinfo.Naty,
  10780. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10781. PsnName: res.Output.Baseinfo.PsnName,
  10782. Idetinfo: idetinfoStr,
  10783. Insuinfo: infoStr,
  10784. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10785. CardInfo: "",
  10786. VerifyNumber: token,
  10787. }
  10788. service.CreateHisPsn(psn)
  10789. c.ServeSuccessJSON(map[string]interface{}{
  10790. "msg": "读取成功",
  10791. })
  10792. }
  10793. } else {
  10794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10795. return
  10796. }
  10797. } else {
  10798. c.ServeSuccessJSON(map[string]interface{}{
  10799. "failed_code": -10,
  10800. "msg": "读取失败",
  10801. })
  10802. }
  10803. }
  10804. }
  10805. func (c *HisApiController) ReadEleFace() {
  10806. admin_user_id, _ := c.GetInt64("admin_user_id")
  10807. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10808. adminUser := c.GetAdminUserInfo()
  10809. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10810. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10811. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10812. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10813. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10814. if len(tokens) > 0 {
  10815. c.ServeSuccessJSON(map[string]interface{}{
  10816. "msg": "读取成功",
  10817. })
  10818. } else {
  10819. c.ServeSuccessJSON(map[string]interface{}{
  10820. "failed_code": -10,
  10821. "msg": "读取失败",
  10822. })
  10823. }
  10824. }
  10825. }
  10826. func timestampToBirthdayString(timestamp int64) string {
  10827. // 将时间戳转换为 time.Time
  10828. t := time.Unix(timestamp, 0)
  10829. // 格式化时间为生日字符串,例如 "2006-01-02"
  10830. birthday := t.Format("2006-01-02")
  10831. return birthday
  10832. }
  10833. func (c *HisApiController) Get9001() {
  10834. adminUser := c.GetAdminUserInfo()
  10835. admin_user_id, _ := c.GetInt64("admin_user_id")
  10836. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10837. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10838. if miConfig.MdtrtareaAdmvs == "350500" {
  10839. service.GetFjAuthorizationInfo(miConfig.Code)
  10840. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10841. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10842. var dat map[string]interface{}
  10843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10844. fmt.Println(dat)
  10845. } else {
  10846. fmt.Println(err)
  10847. }
  10848. userJSONBytes, _ := json.Marshal(dat)
  10849. var res models.Result9001
  10850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10851. utils.ErrorLog("解析失败:%v", err)
  10852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10853. return
  10854. }
  10855. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10856. fmt.Println(miConfig.SecretKey)
  10857. var res models.Result9001Two
  10858. 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 +
  10859. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10860. resp, requestErr := http.Get(api)
  10861. if requestErr != nil {
  10862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10863. return
  10864. }
  10865. body, ioErr := ioutil.ReadAll(resp.Body)
  10866. if ioErr != nil {
  10867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10869. return
  10870. }
  10871. var respJSON map[string]interface{}
  10872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10875. return
  10876. }
  10877. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10878. if status == "0" {
  10879. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10880. c.ServeSuccessJSON(map[string]interface{}{
  10881. "failed_code": -10,
  10882. "msg": err_msg,
  10883. })
  10884. return
  10885. }
  10886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10887. result, _ := json.Marshal(respJSON)
  10888. fmt.Println("log")
  10889. fmt.Println(string(result))
  10890. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10891. utils.ErrorLog("解析失败:%v", err)
  10892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10893. return
  10894. }
  10895. if res.Infcode == 0 {
  10896. sign := models.HisSignIn{
  10897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10898. SignNo: res.Output.Signinoutb.SignNo,
  10899. SignTime: "",
  10900. Ctime: time.Now().Unix(),
  10901. Mtime: time.Now().Unix(),
  10902. Status: 1,
  10903. InputLog: "",
  10904. OutputLog: "",
  10905. FixmedinsCode: miConfig.Code,
  10906. }
  10907. err := service.CreateSignIn(&sign)
  10908. if err == nil {
  10909. c.ServeSuccessJSON(map[string]interface{}{
  10910. "msg": "签到成功",
  10911. })
  10912. }
  10913. } else {
  10914. c.ServeSuccessJSON(map[string]interface{}{
  10915. "failed_code": -10,
  10916. "msg": res.ErrMsg,
  10917. })
  10918. return
  10919. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10920. //return
  10921. }
  10922. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10923. fmt.Println(miConfig.SecretKey)
  10924. var res models.Result9001Two
  10925. 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 +
  10926. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10927. resp, requestErr := http.Get(api)
  10928. if requestErr != nil {
  10929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10930. return
  10931. }
  10932. body, ioErr := ioutil.ReadAll(resp.Body)
  10933. if ioErr != nil {
  10934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10936. return
  10937. }
  10938. var respJSON map[string]interface{}
  10939. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10942. return
  10943. }
  10944. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10945. if status == "0" {
  10946. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10947. c.ServeSuccessJSON(map[string]interface{}{
  10948. "failed_code": -10,
  10949. "msg": err_msg,
  10950. })
  10951. return
  10952. }
  10953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10954. result, _ := json.Marshal(respJSON)
  10955. fmt.Println("log")
  10956. fmt.Println(string(result))
  10957. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10958. utils.ErrorLog("解析失败:%v", err)
  10959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10960. return
  10961. }
  10962. if res.Infcode == 0 {
  10963. sign := models.HisSignIn{
  10964. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10965. SignNo: res.Output.Signinoutb.SignNo,
  10966. SignTime: "",
  10967. Ctime: time.Now().Unix(),
  10968. Mtime: time.Now().Unix(),
  10969. Status: 1,
  10970. InputLog: "",
  10971. OutputLog: "",
  10972. FixmedinsCode: miConfig.Code,
  10973. }
  10974. err := service.CreateSignIn(&sign)
  10975. if err == nil {
  10976. c.ServeSuccessJSON(map[string]interface{}{
  10977. "msg": "签到成功",
  10978. })
  10979. }
  10980. } else {
  10981. c.ServeSuccessJSON(map[string]interface{}{
  10982. "failed_code": -10,
  10983. "msg": res.ErrMsg,
  10984. })
  10985. return
  10986. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10987. //return
  10988. }
  10989. } else {
  10990. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10991. var dat map[string]interface{}
  10992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10993. fmt.Println(dat)
  10994. } else {
  10995. fmt.Println(err)
  10996. }
  10997. userJSONBytes, _ := json.Marshal(dat)
  10998. var res models.Result9001
  10999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11000. utils.ErrorLog("解析失败:%v", err)
  11001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11002. return
  11003. }
  11004. if res.Infcode == 0 {
  11005. sign := models.HisSignIn{
  11006. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11007. SignNo: res.Output.Signinoutb.SignNo,
  11008. SignTime: res.Output.Signinoutb.SignTime,
  11009. Ctime: time.Now().Unix(),
  11010. Mtime: time.Now().Unix(),
  11011. Status: 1,
  11012. InputLog: "",
  11013. OutputLog: "",
  11014. FixmedinsCode: miConfig.Code,
  11015. }
  11016. err := service.CreateSignIn(&sign)
  11017. if err == nil {
  11018. c.ServeSuccessJSON(map[string]interface{}{
  11019. "msg": "签到成功",
  11020. })
  11021. }
  11022. }
  11023. }
  11024. }
  11025. 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) {
  11026. var res Result3101
  11027. adminUser := c.GetAdminUserInfo()
  11028. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11029. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11030. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11031. //record_time := c.GetString("record_time")
  11032. //trig_scen := c.GetString("trig_scen")
  11033. timeLayout := "2006-01-02"
  11034. loc, _ := time.LoadLocation("Local")
  11035. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11036. if err != nil {
  11037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11038. return res
  11039. }
  11040. recordDateTime := theTime.Unix()
  11041. var patientPrescription models.HisPrescriptionInfo
  11042. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11043. //if patientPrescription.ID == 0 {
  11044. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11045. //}
  11046. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11047. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11048. //
  11049. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11050. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11051. var pp models.PublicParams
  11052. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11053. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11054. pp.FixmedinsName = miConfig.OrgName
  11055. pp.FixmedinsCode = miConfig.Code
  11056. pp.RequestUrl = miConfig.Url
  11057. pp.Cainfo = miConfig.Cainfo
  11058. pp.SecretKey = miConfig.SecretKey
  11059. pp.AccessKey = miConfig.AccessKey
  11060. pp.OpterName = roles.UserName
  11061. var config []*models.HisXtDiagnoseConfig
  11062. for _, item := range diagnosis_ids {
  11063. id, _ := strconv.ParseInt(item, 10, 64)
  11064. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11065. config = append(config, &diagnosisConfig)
  11066. }
  11067. var pd models.PatientDtos
  11068. pd.PatnID = his.PsnNo
  11069. pd.PatnName = his.Name
  11070. pd.Gend = his.Gend
  11071. pd.Brdy = his.Brdy
  11072. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11073. pd.CurrMdtrtID = his.Number
  11074. var fed models.FsiEncounterDtos
  11075. fed.MdtrtID = his.Number
  11076. fed.MedinsID = miConfig.Code
  11077. fed.MedinsName = miConfig.OrgName
  11078. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11079. fed.MedMdtrtType = "1"
  11080. fed.MedinsType = "1"
  11081. fed.MedinsLv = "11"
  11082. tm := time.Unix(his.RecordDate, 0)
  11083. s_tm := tm.Format("2006-01-02 15:04:05")
  11084. fed.AdmDate = s_tm
  11085. fed.DscgDate = s_tm
  11086. fed.DscgMainDiseCodg = config[0].CountryCode
  11087. fed.DscgMainDiseName = config[0].CountryContentName
  11088. //诊断信息
  11089. var fdds []*models.FsiDiagnoseDtos
  11090. for index, item := range config {
  11091. if index == 0 {
  11092. var fdd models.FsiDiagnoseDtos
  11093. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11094. fdd.InoutDiseType = "1"
  11095. fdd.MaindiseFlag = "1"
  11096. fdd.DiseDate = s_tm
  11097. fdd.DiasSrtNo = "1"
  11098. fdd.DiseName = item.CountryContentName
  11099. fdd.DiseCodg = item.CountryCode
  11100. fdds = append(fdds, &fdd)
  11101. } else {
  11102. var fdd models.FsiDiagnoseDtos
  11103. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11104. fdd.InoutDiseType = "1"
  11105. fdd.MaindiseFlag = "1"
  11106. fdd.DiseDate = s_tm
  11107. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11108. fdd.DiseName = item.CountryContentName
  11109. fdd.DiseCodg = item.CountryCode
  11110. fdds = append(fdds, &fdd)
  11111. }
  11112. }
  11113. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11114. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11115. fed.AdmDeptName = de.Name
  11116. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11117. fed.DscgDeptName = de.Name
  11118. fed.MedMdtrtType = "1"
  11119. fed.MedType = "11"
  11120. //if his.Insutype == "390" {
  11121. // fed.MedType = "1402"
  11122. //} else {
  11123. // fed.MedType = "9933"
  11124. //}
  11125. var orders []*models.FsiOrderDtos
  11126. if trig_scen == "2" {
  11127. //处方医嘱信息
  11128. for _, item := range prescriptions {
  11129. for _, subItem := range item.HisDoctorAdviceInfo {
  11130. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11131. var order models.FsiOrderDtos
  11132. order.RxID = strconv.FormatInt(item.ID, 10)
  11133. order.Rxno = strconv.FormatInt(item.ID, 10)
  11134. order.LongDrordFlag = "0"
  11135. order.HilistType = "1"
  11136. order.ChrgType = "1"
  11137. order.DrordBhvr = "-"
  11138. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11139. order.HosplistName = subItem.BaseDrugLib.DrugName
  11140. order.HilistLv = "1"
  11141. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11142. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11143. order.HosplistName = subItem.BaseDrugLib.DrugName
  11144. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11145. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11146. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11147. order.OwnpayAmt = ""
  11148. order.SelfpayAmt = ""
  11149. order.Spec = ""
  11150. order.SpecUnt = ""
  11151. order.DrordBegnDate = s_tm
  11152. order.DrordStopDate = ""
  11153. order.DrordDrCodg = doctor_info.DoctorNumber
  11154. order.DrordDeptName = department.Name
  11155. order.DrordDeptCodg = department.Number
  11156. order.DrordDrName = doctor_info.UserName
  11157. order.DrordDrProfttl = "234"
  11158. order.CurrDrordFlag = "1"
  11159. orders = append(orders, &order)
  11160. }
  11161. }
  11162. for _, subItem := range item.HisPrescriptionProject {
  11163. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11164. var order models.FsiOrderDtos
  11165. order.RxID = strconv.FormatInt(item.ID, 10)
  11166. order.Rxno = strconv.FormatInt(item.ID, 10)
  11167. order.LongDrordFlag = "0"
  11168. order.HilistType = "1"
  11169. order.ChrgType = "1"
  11170. order.DrordBhvr = "-"
  11171. order.HilistCode = subItem.HisProject.MedicalCode
  11172. order.HosplistName = subItem.HisProject.ProjectName
  11173. order.HilistLv = "1"
  11174. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11175. order.HosplistCode = subItem.HisProject.MedicalCode
  11176. order.HosplistName = subItem.HisProject.ProjectName
  11177. order.Cnt = subItem.Count
  11178. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11179. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11180. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11181. order.OwnpayAmt = ""
  11182. order.SelfpayAmt = ""
  11183. order.Spec = ""
  11184. order.SpecUnt = ""
  11185. order.DrordBegnDate = s_tm
  11186. order.DrordStopDate = ""
  11187. order.DrordDrCodg = doctor_info.DoctorNumber
  11188. order.DrordDeptName = department.Name
  11189. order.DrordDeptCodg = department.Number
  11190. order.DrordDrName = doctor_info.UserName
  11191. order.DrordDrProfttl = "234"
  11192. order.CurrDrordFlag = "1"
  11193. orders = append(orders, &order)
  11194. }
  11195. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11196. var order models.FsiOrderDtos
  11197. order.RxID = strconv.FormatInt(item.ID, 10)
  11198. order.Rxno = strconv.FormatInt(item.ID, 10)
  11199. order.LongDrordFlag = "0"
  11200. order.HilistType = "1"
  11201. order.ChrgType = "1"
  11202. order.DrordBhvr = "-"
  11203. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11204. order.HosplistName = subItem.GoodInfo.GoodName
  11205. order.HilistLv = "1"
  11206. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11207. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11208. order.HosplistName = subItem.GoodInfo.GoodName
  11209. order.Cnt = subItem.Count
  11210. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11211. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11212. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11213. order.OwnpayAmt = ""
  11214. order.SelfpayAmt = ""
  11215. order.Spec = ""
  11216. order.SpecUnt = ""
  11217. order.DrordBegnDate = s_tm
  11218. order.DrordStopDate = ""
  11219. order.DrordDrCodg = doctor_info.DoctorNumber
  11220. order.DrordDeptName = department.Name
  11221. order.DrordDeptCodg = department.Number
  11222. order.DrordDrName = doctor_info.UserName
  11223. order.DrordDrProfttl = "234"
  11224. order.CurrDrordFlag = "1"
  11225. orders = append(orders, &order)
  11226. }
  11227. }
  11228. }
  11229. //处方医嘱信息
  11230. }
  11231. fed.MatnStas = "0"
  11232. fed.MedfeeSumamt = "0"
  11233. fed.OwnpayAmt = "0"
  11234. fed.SelfpayAmt = "0"
  11235. fed.AcctPayamt = "0"
  11236. fed.MaAmt = "0"
  11237. fed.HifpPayamt = "0"
  11238. fed.SetlTotlnum = "1"
  11239. fed.Insutype = his.Insutype
  11240. fed.ReimFlag = "0"
  11241. fed.OutSetlFlag = "0"
  11242. var fopd []*models.FsiOperationDtosData
  11243. data := make(map[string]interface{})
  11244. data["fed"] = fed
  11245. data["fdd"] = fdds
  11246. data["fod"] = orders
  11247. data["pd"] = pd
  11248. data["pp"] = pp
  11249. data["fopd"] = fopd
  11250. data["trig_scen"] = trig_scen
  11251. fmt.Println(data)
  11252. fmt.Println(fed)
  11253. fmt.Println(fdds)
  11254. fmt.Println(orders)
  11255. fmt.Println(pd)
  11256. fmt.Println(pp)
  11257. fmt.Println(fopd)
  11258. client := &http.Client{}
  11259. bytesData, _ := json.Marshal(data)
  11260. var req *http.Request
  11261. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11262. if miConfig.MdtrtareaAdmvs == "320830" {
  11263. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11264. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11265. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11266. } else {
  11267. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11268. }
  11269. resp, _ := client.Do(req)
  11270. defer resp.Body.Close()
  11271. body, ioErr := ioutil.ReadAll(resp.Body)
  11272. if ioErr != nil {
  11273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11275. return res
  11276. }
  11277. var respJSON map[string]interface{}
  11278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11281. return res
  11282. }
  11283. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11284. fmt.Println(respJSON)
  11285. result, _ := json.Marshal(respJSON)
  11286. fmt.Println(result)
  11287. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11288. utils.ErrorLog("解析失败:%v", err)
  11289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11290. return res
  11291. }
  11292. return res
  11293. } else {
  11294. //if miConfig.MdtrtareaAdmvs == "441202" {
  11295. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11296. saveLog(output, input, "3101", "事前")
  11297. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11298. utils.ErrorLog("解析失败:%v", err)
  11299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11300. return
  11301. }
  11302. return res
  11303. //}
  11304. }
  11305. }
  11306. 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) {
  11307. adminUser := c.GetAdminUserInfo()
  11308. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11309. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11311. //record_time := c.GetString("record_time")
  11312. //trig_scen := c.GetString("trig_scen")
  11313. timeLayout := "2006-01-02"
  11314. loc, _ := time.LoadLocation("Local")
  11315. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11316. if err != nil {
  11317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11318. return res
  11319. }
  11320. recordDateTime := theTime.Unix()
  11321. var patientPrescription models.HisPrescriptionInfo
  11322. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11323. if patientPrescription.ID == 0 {
  11324. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11325. }
  11326. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11327. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11328. //
  11329. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11330. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11331. var pp models.PublicParams
  11332. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11333. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11334. pp.FixmedinsName = miConfig.OrgName
  11335. pp.FixmedinsCode = miConfig.Code
  11336. pp.RequestUrl = miConfig.Url
  11337. pp.Cainfo = miConfig.Cainfo
  11338. pp.SecretKey = miConfig.SecretKey
  11339. pp.AccessKey = miConfig.AccessKey
  11340. pp.OpterName = roles.UserName
  11341. var config []*models.HisXtDiagnoseConfig
  11342. for _, item := range diagnosis_ids {
  11343. id, _ := strconv.ParseInt(item, 10, 64)
  11344. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11345. config = append(config, &diagnosisConfig)
  11346. }
  11347. var pd models.PatientDtos
  11348. pd.PatnID = his.PsnNo
  11349. pd.PatnName = his.Name
  11350. pd.Gend = his.Gend
  11351. pd.Brdy = his.Brdy
  11352. pd.Poolarea = his.InsuplcAdmdvs
  11353. pd.CurrMdtrtID = his.Number
  11354. var fed models.FsiEncounterDtos
  11355. fed.MdtrtID = his.Number
  11356. fed.MedinsID = miConfig.Code
  11357. fed.MedinsName = miConfig.OrgName
  11358. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11359. fed.MedMdtrtType = "1"
  11360. fed.MedinsType = "1"
  11361. fed.MedinsLv = "11"
  11362. tm := time.Unix(his.RecordDate, 0)
  11363. s_tm := tm.Format("2006-01-02 15:04:05")
  11364. fed.AdmDate = s_tm
  11365. fed.DscgDate = s_tm
  11366. fed.DscgMainDiseCodg = config[0].CountryCode
  11367. fed.DscgMainDiseName = config[0].CountryContentName
  11368. //诊断信息
  11369. var fdds []*models.FsiDiagnoseDtos
  11370. for index, item := range config {
  11371. if index == 0 {
  11372. var fdd models.FsiDiagnoseDtos
  11373. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11374. fdd.InoutDiseType = "1"
  11375. fdd.MaindiseFlag = "1"
  11376. fdd.DiseDate = s_tm
  11377. fdd.DiasSrtNo = "1"
  11378. fdd.DiseName = item.CountryContentName
  11379. fdd.DiseCodg = item.CountryCode
  11380. fdds = append(fdds, &fdd)
  11381. } else {
  11382. var fdd models.FsiDiagnoseDtos
  11383. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11384. fdd.InoutDiseType = "1"
  11385. fdd.MaindiseFlag = "1"
  11386. fdd.DiseDate = s_tm
  11387. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11388. fdd.DiseName = item.CountryContentName
  11389. fdd.DiseCodg = item.CountryCode
  11390. fdds = append(fdds, &fdd)
  11391. }
  11392. }
  11393. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11394. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11395. fed.AdmDeptName = department.Name
  11396. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11397. fed.DscgDeptName = department.Name
  11398. fed.MedMdtrtType = "1"
  11399. fed.MedType = "11"
  11400. //if his.Insutype == "390" {
  11401. // fed.MedType = "1402"
  11402. //} else {
  11403. // fed.MedType = "9933"
  11404. //}
  11405. var orders []*models.FsiOrderDtos
  11406. if trig_scen == "2" {
  11407. //处方医嘱信息
  11408. for _, item := range prescriptions {
  11409. for _, subItem := range item.HisDoctorAdviceInfo {
  11410. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11411. var order models.FsiOrderDtos
  11412. order.RxID = strconv.FormatInt(item.ID, 10)
  11413. order.Rxno = strconv.FormatInt(item.ID, 10)
  11414. order.LongDrordFlag = "0"
  11415. order.HilistType = "1"
  11416. order.ChrgType = "1"
  11417. order.DrordBhvr = "-"
  11418. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11419. order.HosplistName = subItem.BaseDrugLib.DrugName
  11420. order.HilistLv = "1"
  11421. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11422. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11423. order.HosplistName = subItem.BaseDrugLib.DrugName
  11424. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11425. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11426. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11427. order.OwnpayAmt = ""
  11428. order.SelfpayAmt = ""
  11429. order.Spec = ""
  11430. order.SpecUnt = ""
  11431. order.DrordBegnDate = s_tm
  11432. order.DrordStopDate = ""
  11433. order.DrordDrCodg = doctor_info.DoctorNumber
  11434. order.DrordDeptName = department.Name
  11435. order.DrordDeptCodg = department.Number
  11436. order.DrordDrName = doctor_info.UserName
  11437. order.DrordDrProfttl = "234"
  11438. order.CurrDrordFlag = "1"
  11439. orders = append(orders, &order)
  11440. }
  11441. }
  11442. for _, subItem := range item.HisPrescriptionProject {
  11443. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11444. var order models.FsiOrderDtos
  11445. order.RxID = strconv.FormatInt(item.ID, 10)
  11446. order.Rxno = strconv.FormatInt(item.ID, 10)
  11447. order.LongDrordFlag = "0"
  11448. order.HilistType = "1"
  11449. order.ChrgType = "1"
  11450. order.DrordBhvr = "-"
  11451. order.HilistCode = subItem.HisProject.MedicalCode
  11452. order.HosplistName = subItem.HisProject.ProjectName
  11453. order.HilistLv = "1"
  11454. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11455. order.HosplistCode = subItem.HisProject.MedicalCode
  11456. order.HosplistName = subItem.HisProject.ProjectName
  11457. order.Cnt = subItem.Count
  11458. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11459. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11460. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11461. order.OwnpayAmt = ""
  11462. order.SelfpayAmt = ""
  11463. order.Spec = ""
  11464. order.SpecUnt = ""
  11465. order.DrordBegnDate = s_tm
  11466. order.DrordStopDate = ""
  11467. order.DrordDrCodg = doctor_info.DoctorNumber
  11468. order.DrordDeptName = department.Name
  11469. order.DrordDeptCodg = department.Number
  11470. order.DrordDrName = doctor_info.UserName
  11471. order.DrordDrProfttl = "234"
  11472. order.CurrDrordFlag = "1"
  11473. orders = append(orders, &order)
  11474. }
  11475. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11476. var order models.FsiOrderDtos
  11477. order.RxID = strconv.FormatInt(item.ID, 10)
  11478. order.Rxno = strconv.FormatInt(item.ID, 10)
  11479. order.LongDrordFlag = "0"
  11480. order.HilistType = "1"
  11481. order.ChrgType = "1"
  11482. order.DrordBhvr = "-"
  11483. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11484. order.HosplistName = subItem.GoodInfo.GoodName
  11485. order.HilistLv = "1"
  11486. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11487. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11488. order.HosplistName = subItem.GoodInfo.GoodName
  11489. order.Cnt = subItem.Count
  11490. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11491. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11492. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11493. order.OwnpayAmt = ""
  11494. order.SelfpayAmt = ""
  11495. order.Spec = ""
  11496. order.SpecUnt = ""
  11497. order.DrordBegnDate = s_tm
  11498. order.DrordStopDate = ""
  11499. order.DrordDrCodg = doctor_info.DoctorNumber
  11500. order.DrordDeptName = department.Name
  11501. order.DrordDeptCodg = department.Number
  11502. order.DrordDrName = doctor_info.UserName
  11503. order.DrordDrProfttl = "234"
  11504. order.CurrDrordFlag = "1"
  11505. orders = append(orders, &order)
  11506. }
  11507. }
  11508. }
  11509. //处方医嘱信息
  11510. }
  11511. fed.MatnStas = "0"
  11512. fed.MedfeeSumamt = "0"
  11513. fed.OwnpayAmt = "0"
  11514. fed.SelfpayAmt = "0"
  11515. fed.AcctPayamt = "0"
  11516. fed.MaAmt = "0"
  11517. fed.HifpPayamt = "0"
  11518. fed.SetlTotlnum = "1"
  11519. fed.Insutype = his.Insutype
  11520. fed.ReimFlag = "0"
  11521. fed.OutSetlFlag = "0"
  11522. var fopd []*models.FsiOperationDtosData
  11523. data := make(map[string]interface{})
  11524. data["fed"] = fed
  11525. data["fdd"] = fdds
  11526. data["fod"] = orders
  11527. data["pd"] = pd
  11528. data["pp"] = pp
  11529. data["fopd"] = fopd
  11530. data["trig_scen"] = trig_scen
  11531. fmt.Println(data)
  11532. fmt.Println(fed)
  11533. fmt.Println(fdds)
  11534. fmt.Println(orders)
  11535. fmt.Println(pd)
  11536. fmt.Println(pp)
  11537. fmt.Println(fopd)
  11538. client := &http.Client{}
  11539. bytesData, _ := json.Marshal(data)
  11540. var req *http.Request
  11541. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11542. if miConfig.MdtrtareaAdmvs == "320830" {
  11543. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11544. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11545. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11546. } else {
  11547. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11548. }
  11549. resp, _ := client.Do(req)
  11550. defer resp.Body.Close()
  11551. body, ioErr := ioutil.ReadAll(resp.Body)
  11552. if ioErr != nil {
  11553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11555. return res
  11556. }
  11557. var respJSON map[string]interface{}
  11558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11561. return res
  11562. }
  11563. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11564. fmt.Println(respJSON)
  11565. result, _ := json.Marshal(respJSON)
  11566. fmt.Println(result)
  11567. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11568. utils.ErrorLog("解析失败:%v", err)
  11569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11570. return res
  11571. }
  11572. return res
  11573. } else {
  11574. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11575. saveLog(output, input, "3101", "事前")
  11576. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11577. utils.ErrorLog("解析失败:%v", err)
  11578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11579. return
  11580. }
  11581. return res
  11582. }
  11583. return res
  11584. }
  11585. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11586. ////patient_id, _ := c.GetInt64("patient_id")
  11587. //order_id, _ := c.GetInt64("order_id")
  11588. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11589. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11590. //trig_scen := c.GetString("trig_scen")
  11591. adminUser := c.GetAdminUserInfo()
  11592. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11593. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11594. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11595. record_time := c.GetString("record_time")
  11596. order, _ := service.GetHisOrderByID(order_id)
  11597. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11598. timeLayout := "2006-01-02"
  11599. loc, _ := time.LoadLocation("Local")
  11600. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11601. if err != nil {
  11602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11603. return
  11604. }
  11605. recordDateTime := theTime.Unix()
  11606. var patientPrescription models.HisPrescriptionInfo
  11607. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11608. if patientPrescription.ID == 0 {
  11609. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11610. }
  11611. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11612. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11613. //
  11614. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11615. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11616. var pp models.PublicParams
  11617. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11618. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11619. pp.FixmedinsName = miConfig.OrgName
  11620. pp.FixmedinsCode = miConfig.Code
  11621. pp.RequestUrl = miConfig.Url
  11622. pp.Cainfo = miConfig.Cainfo
  11623. pp.SecretKey = miConfig.SecretKey
  11624. pp.AccessKey = miConfig.AccessKey
  11625. pp.OpterName = roles.UserName
  11626. var config []*models.HisXtDiagnoseConfig
  11627. for _, item := range diagnosis_ids {
  11628. id, _ := strconv.ParseInt(item, 10, 64)
  11629. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11630. config = append(config, &diagnosisConfig)
  11631. }
  11632. var pd models.PatientDtos
  11633. pd.PatnID = his.PsnNo
  11634. pd.PatnName = his.Name
  11635. pd.Gend = his.Gend
  11636. pd.Brdy = psn_info.Brdy
  11637. pd.Poolarea = his.InsuplcAdmdvs
  11638. pd.CurrMdtrtID = his.Number
  11639. var fed models.FsiEncounterDtos
  11640. fed.MdtrtID = his.Number
  11641. fed.MedinsID = miConfig.Code
  11642. fed.MedinsName = miConfig.OrgName
  11643. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11644. fed.MedMdtrtType = "1"
  11645. fed.MedinsType = "1"
  11646. fed.MedinsLv = "11"
  11647. tm := time.Unix(his.RecordDate, 0)
  11648. s_tm := tm.Format("2006-01-02 15:04:05")
  11649. fed.AdmDate = s_tm
  11650. fed.DscgDate = s_tm
  11651. fed.DscgMainDiseCodg = config[0].CountryCode
  11652. fed.DscgMainDiseName = config[0].CountryContentName
  11653. //诊断信息
  11654. var fdds []*models.FsiDiagnoseDtos
  11655. for index, item := range config {
  11656. if index == 0 {
  11657. var fdd models.FsiDiagnoseDtos
  11658. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11659. fdd.InoutDiseType = "1"
  11660. fdd.MaindiseFlag = "1"
  11661. fdd.DiseDate = s_tm
  11662. fdd.DiasSrtNo = "1"
  11663. fdd.DiseName = item.CountryContentName
  11664. fdd.DiseCodg = item.CountryCode
  11665. fdds = append(fdds, &fdd)
  11666. } else {
  11667. var fdd models.FsiDiagnoseDtos
  11668. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11669. fdd.InoutDiseType = "1"
  11670. fdd.MaindiseFlag = "1"
  11671. fdd.DiseDate = s_tm
  11672. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11673. fdd.DiseName = item.CountryContentName
  11674. fdd.DiseCodg = item.CountryCode
  11675. fdds = append(fdds, &fdd)
  11676. }
  11677. }
  11678. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11679. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11680. fed.AdmDeptName = department.Name
  11681. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11682. fed.DscgDeptName = department.Name
  11683. fed.MedType = order.MedType
  11684. //处方医嘱信息
  11685. var orders []*models.FsiOrderDtos
  11686. //for _, item := range prescriptions {
  11687. // for _, subItem := range item.HisDoctorAdviceInfo {
  11688. // var order models.FsiOrderDtos
  11689. // order.RxID = strconv.FormatInt(item.ID, 10)
  11690. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11691. // order.LongDrordFlag = "0"
  11692. // order.HilistType = "1"
  11693. // order.ChrgType = "1"
  11694. // order.DrordBhvr = "-"
  11695. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11696. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11697. // order.HilistLv = "1"
  11698. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11699. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11700. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11701. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11702. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11703. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11704. // order.OwnpayAmt = ""
  11705. // order.SelfpayAmt = ""
  11706. // order.Spec = ""
  11707. // order.SpecUnt = ""
  11708. // order.DrordBegnDate = s_tm
  11709. // order.DrordStopDate = ""
  11710. // order.DrordDrCodg = "1"
  11711. // order.DrordDeptName = department.Name
  11712. // order.DrordDrCodg = "1"
  11713. // order.DrordDrName = doctor_info.UserName
  11714. // order.DrordDrProfttl = ""
  11715. // order.CurrDrordFlag = "1"
  11716. // orders = append(orders, &order)
  11717. // }
  11718. // for _, subItem := range item.HisPrescriptionProject {
  11719. // if subItem.Type == 2 {
  11720. // var order models.FsiOrderDtos
  11721. // order.RxID = strconv.FormatInt(item.ID, 10)
  11722. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11723. // order.LongDrordFlag = "0"
  11724. // order.HilistType = "1"
  11725. // order.ChrgType = "1"
  11726. // order.DrordBhvr = "-"
  11727. // order.HilistCode = subItem.HisProject.MedicalCode
  11728. // order.HosplistName = subItem.HisProject.ProjectName
  11729. // order.HilistLv = "1"
  11730. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11731. // order.HosplistCode = subItem.HisProject.MedicalCode
  11732. // order.HosplistName = subItem.HisProject.ProjectName
  11733. // order.Cnt = subItem.Count
  11734. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11735. //
  11736. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11737. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11738. // order.OwnpayAmt = ""
  11739. // order.SelfpayAmt = ""
  11740. // order.Spec = ""
  11741. // order.SpecUnt = ""
  11742. // order.DrordBegnDate = s_tm
  11743. // order.DrordStopDate = ""
  11744. // order.DrordDrCodg = "1"
  11745. // order.DrordDeptName = department.Name
  11746. // order.DrordDrCodg = "1"
  11747. // order.DrordDrName = doctor_info.UserName
  11748. // order.DrordDrProfttl = ""
  11749. // order.CurrDrordFlag = "1"
  11750. // orders = append(orders, &order)
  11751. //
  11752. // }
  11753. // if subItem.Type == 3 {
  11754. //
  11755. // var order models.FsiOrderDtos
  11756. // order.RxID = strconv.FormatInt(item.ID, 10)
  11757. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11758. // order.LongDrordFlag = "0"
  11759. // order.HilistType = "1"
  11760. // order.ChrgType = "1"
  11761. // order.DrordBhvr = "-"
  11762. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11763. // order.HosplistName = subItem.GoodInfo.GoodName
  11764. // order.HilistLv = "1"
  11765. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11766. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11767. // order.HosplistName = subItem.GoodInfo.GoodName
  11768. // order.Cnt = subItem.Count
  11769. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11770. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11771. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11772. // order.OwnpayAmt = ""
  11773. // order.SelfpayAmt = ""
  11774. // order.Spec = ""
  11775. // order.SpecUnt = ""
  11776. // order.DrordBegnDate = s_tm
  11777. // order.DrordStopDate = ""
  11778. // order.DrordDrCodg = "1"
  11779. // order.DrordDeptName = department.Name
  11780. // order.DrordDrCodg = "1"
  11781. // order.DrordDrName = doctor_info.UserName
  11782. // order.DrordDrProfttl = ""
  11783. // order.CurrDrordFlag = "1"
  11784. // orders = append(orders, &order)
  11785. //
  11786. // }
  11787. // }
  11788. //}
  11789. for _, item := range prescriptions {
  11790. for _, subItem := range item.HisDoctorAdviceInfo {
  11791. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11792. var order models.FsiOrderDtos
  11793. order.RxID = strconv.FormatInt(item.ID, 10)
  11794. order.Rxno = strconv.FormatInt(item.ID, 10)
  11795. order.LongDrordFlag = "0"
  11796. order.HilistType = "101"
  11797. order.ChrgType = "1"
  11798. order.DrordBhvr = "-"
  11799. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11800. order.HosplistName = subItem.BaseDrugLib.DrugName
  11801. order.HilistLv = "1"
  11802. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11803. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11804. order.HosplistName = subItem.BaseDrugLib.DrugName
  11805. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11806. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11807. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11808. order.OwnpayAmt = ""
  11809. order.SelfpayAmt = ""
  11810. order.Spec = ""
  11811. order.SpecUnt = ""
  11812. order.DrordBegnDate = s_tm
  11813. order.DrordStopDate = ""
  11814. order.DrordDrCodg = doctor_info.DoctorNumber
  11815. order.DrordDeptName = department.Name
  11816. order.DrordDeptCodg = department.Number
  11817. order.DrordDrName = doctor_info.UserName
  11818. order.DrordDrProfttl = "234"
  11819. order.CurrDrordFlag = "1"
  11820. orders = append(orders, &order)
  11821. }
  11822. }
  11823. for _, subItem := range item.HisPrescriptionProject {
  11824. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11825. var order models.FsiOrderDtos
  11826. order.RxID = strconv.FormatInt(item.ID, 10)
  11827. order.Rxno = strconv.FormatInt(item.ID, 10)
  11828. order.LongDrordFlag = "0"
  11829. order.HilistType = "201"
  11830. order.ChrgType = "1"
  11831. order.DrordBhvr = "-"
  11832. order.HilistCode = subItem.HisProject.MedicalCode
  11833. order.HosplistName = subItem.HisProject.ProjectName
  11834. order.HilistLv = "1"
  11835. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11836. order.HosplistCode = subItem.HisProject.MedicalCode
  11837. order.HosplistName = subItem.HisProject.ProjectName
  11838. order.Cnt = subItem.Count
  11839. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11840. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11841. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11842. order.OwnpayAmt = ""
  11843. order.SelfpayAmt = ""
  11844. order.Spec = ""
  11845. order.SpecUnt = ""
  11846. order.DrordBegnDate = s_tm
  11847. order.DrordStopDate = ""
  11848. order.DrordDrCodg = doctor_info.DoctorNumber
  11849. order.DrordDeptName = department.Name
  11850. order.DrordDeptCodg = department.Number
  11851. order.DrordDrName = doctor_info.UserName
  11852. order.DrordDrProfttl = "234"
  11853. order.CurrDrordFlag = "1"
  11854. orders = append(orders, &order)
  11855. }
  11856. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11857. var order models.FsiOrderDtos
  11858. order.RxID = strconv.FormatInt(item.ID, 10)
  11859. order.Rxno = strconv.FormatInt(item.ID, 10)
  11860. order.LongDrordFlag = "0"
  11861. order.HilistType = "301"
  11862. order.ChrgType = "1"
  11863. order.DrordBhvr = "0"
  11864. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11865. order.HosplistName = subItem.GoodInfo.GoodName
  11866. order.HilistLv = "1"
  11867. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11868. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11869. order.HosplistName = subItem.GoodInfo.GoodName
  11870. order.Cnt = subItem.Count
  11871. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11872. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11873. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11874. order.OwnpayAmt = ""
  11875. order.SelfpayAmt = ""
  11876. order.Spec = ""
  11877. order.SpecUnt = ""
  11878. order.DrordBegnDate = s_tm
  11879. order.DrordStopDate = ""
  11880. order.DrordDrCodg = doctor_info.DoctorNumber
  11881. order.DrordDeptName = department.Name
  11882. order.DrordDeptCodg = department.Number
  11883. order.DrordDrName = doctor_info.UserName
  11884. order.DrordDrProfttl = "234"
  11885. order.CurrDrordFlag = "1"
  11886. orders = append(orders, &order)
  11887. }
  11888. }
  11889. }
  11890. //处方医嘱信息
  11891. fed.MatnStas = "0"
  11892. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11893. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11894. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11895. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11896. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11897. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11898. fed.SetlTotlnum = "1"
  11899. fed.Insutype = his.Insutype
  11900. fed.ReimFlag = "0"
  11901. fed.OutSetlFlag = "0"
  11902. var fopd []*models.FsiOperationDtosData
  11903. data := make(map[string]interface{})
  11904. data["fed"] = fed
  11905. data["fdd"] = fdds
  11906. data["fod"] = orders
  11907. data["pd"] = pd
  11908. data["pp"] = pp
  11909. data["fopd"] = fopd
  11910. data["trig_scen"] = trig_scen
  11911. client := &http.Client{}
  11912. bytesData, _ := json.Marshal(data)
  11913. var req *http.Request
  11914. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11915. if miConfig.MdtrtareaAdmvs == "320830" {
  11916. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  11917. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11918. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11919. } else {
  11920. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11921. }
  11922. resp, _ := client.Do(req)
  11923. defer resp.Body.Close()
  11924. body, ioErr := ioutil.ReadAll(resp.Body)
  11925. if ioErr != nil {
  11926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11928. return res
  11929. }
  11930. var respJSON map[string]interface{}
  11931. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11934. return res
  11935. }
  11936. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11937. result, _ := json.Marshal(respJSON)
  11938. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11939. utils.ErrorLog("解析失败:%v", err)
  11940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11941. return res
  11942. }
  11943. return res
  11944. } else {
  11945. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11946. saveLog(output, input, "3102", "事中")
  11947. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11948. utils.ErrorLog("解析失败:%v", err)
  11949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11950. return
  11951. }
  11952. return res
  11953. }
  11954. return res
  11955. }
  11956. 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) {
  11957. var res Resultgd3101
  11958. adminUser := c.GetAdminUserInfo()
  11959. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11960. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11962. //record_time := c.GetString("record_time")
  11963. //trig_scen := c.GetString("trig_scen")
  11964. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11965. //psn_info, _ := service.GetPatientId(patient_id)
  11966. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11967. timeLayout := "2006-01-02"
  11968. loc, _ := time.LoadLocation("Local")
  11969. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11970. if err != nil {
  11971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11972. return res
  11973. }
  11974. recordDateTime := theTime.Unix()
  11975. var patientPrescription models.HisPrescriptionInfo
  11976. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11977. //if patientPrescription.ID == 0 {
  11978. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11979. //}
  11980. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11981. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11982. //
  11983. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11984. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11985. var str string
  11986. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  11987. str = timestampToBirthdayString(patient.Birthday)
  11988. } else {
  11989. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  11990. }
  11991. var pp models.PublicParams
  11992. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11993. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11994. pp.FixmedinsName = miConfig.OrgName
  11995. pp.FixmedinsCode = miConfig.Code
  11996. pp.RequestUrl = miConfig.Url
  11997. pp.Cainfo = miConfig.Cainfo
  11998. pp.SecretKey = miConfig.SecretKey
  11999. pp.AccessKey = miConfig.AccessKey
  12000. pp.OpterName = roles.UserName
  12001. var config []*models.HisXtDiagnoseConfig
  12002. for _, item := range diagnosis_ids {
  12003. id, _ := strconv.ParseInt(item, 10, 64)
  12004. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12005. config = append(config, &diagnosisConfig)
  12006. }
  12007. var pd models.PatientDtos
  12008. pd.PatnID = his.PsnNo
  12009. pd.PatnName = his.Name
  12010. pd.Gend = his.Gend
  12011. pd.Brdy = str
  12012. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12013. pd.CurrMdtrtID = his.Number
  12014. var fed models.FsiEncounterDtos
  12015. fed.MdtrtID = his.Number
  12016. fed.MedinsID = miConfig.Code
  12017. fed.MedinsName = miConfig.OrgName
  12018. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12019. fed.MedMdtrtType = "1"
  12020. fed.MedinsType = "1"
  12021. fed.MedinsLv = "11"
  12022. tm := time.Unix(his.RecordDate, 0)
  12023. s_tm := tm.Format("2006-01-02 15:04:05")
  12024. fed.AdmDate = s_tm
  12025. fed.DscgDate = s_tm
  12026. fed.DscgMainDiseCodg = config[0].CountryCode
  12027. fed.DscgMainDiseName = config[0].CountryContentName
  12028. //诊断信息
  12029. var fdds []*models.FsiDiagnoseDtos
  12030. for index, item := range config {
  12031. if index == 0 {
  12032. var fdd models.FsiDiagnoseDtos
  12033. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12034. fdd.InoutDiseType = "1"
  12035. fdd.MaindiseFlag = "1"
  12036. fdd.DiseDate = s_tm
  12037. fdd.DiasSrtNo = "1"
  12038. fdd.DiseName = item.CountryContentName
  12039. fdd.DiseCodg = item.CountryCode
  12040. fdds = append(fdds, &fdd)
  12041. } else {
  12042. var fdd models.FsiDiagnoseDtos
  12043. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12044. fdd.InoutDiseType = "1"
  12045. fdd.MaindiseFlag = "1"
  12046. fdd.DiseDate = s_tm
  12047. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12048. fdd.DiseName = item.CountryContentName
  12049. fdd.DiseCodg = item.CountryCode
  12050. fdds = append(fdds, &fdd)
  12051. }
  12052. }
  12053. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12054. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12055. fed.AdmDeptName = de.Name
  12056. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12057. fed.DscgDeptName = de.Name
  12058. fed.MedMdtrtType = "1"
  12059. fed.MedType = "11"
  12060. //if his.Insutype == "390" {
  12061. // fed.MedType = "1402"
  12062. //} else {
  12063. // fed.MedType = "9933"
  12064. //}
  12065. var orders []*models.FsiOrderDtos
  12066. if trig_scen == "2" {
  12067. //处方医嘱信息
  12068. for _, item := range prescriptions {
  12069. for _, subItem := range item.HisDoctorAdviceInfo {
  12070. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12071. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12072. var order models.FsiOrderDtos
  12073. order.RxID = strconv.FormatInt(item.ID, 10)
  12074. order.Rxno = strconv.FormatInt(item.ID, 10)
  12075. order.LongDrordFlag = "0"
  12076. order.HilistType = "101"
  12077. order.ChrgType = "1"
  12078. order.DrordBhvr = "0"
  12079. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12080. order.HosplistName = subItem.BaseDrugLib.DrugName
  12081. order.HilistLv = "1"
  12082. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12083. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12084. order.HosplistName = subItem.BaseDrugLib.DrugName
  12085. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12086. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12087. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12088. order.OwnpayAmt = ""
  12089. order.SelfpayAmt = ""
  12090. order.Spec = spec
  12091. order.SpecUnt = subItem.PrescribingNumberUnit
  12092. order.DrordBegnDate = s_tm
  12093. order.DrordStopDate = ""
  12094. order.DrordDrCodg = doctor_info.DoctorNumber
  12095. order.DrordDeptName = department.Name
  12096. order.DrordDeptCodg = department.Number
  12097. order.DrordDrName = doctor_info.UserName
  12098. order.DrordDrProfttl = "234"
  12099. order.CurrDrordFlag = "1"
  12100. orders = append(orders, &order)
  12101. }
  12102. }
  12103. for _, subItem := range item.HisPrescriptionProject {
  12104. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12105. var order models.FsiOrderDtos
  12106. order.RxID = strconv.FormatInt(item.ID, 10)
  12107. order.Rxno = strconv.FormatInt(item.ID, 10)
  12108. order.LongDrordFlag = "0"
  12109. order.HilistType = "201"
  12110. order.ChrgType = "1"
  12111. order.DrordBhvr = "0"
  12112. order.HilistCode = subItem.HisProject.MedicalCode
  12113. order.HosplistName = subItem.HisProject.ProjectName
  12114. order.HilistLv = "1"
  12115. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12116. order.HosplistCode = subItem.HisProject.MedicalCode
  12117. order.HosplistName = subItem.HisProject.ProjectName
  12118. order.Cnt = subItem.Count
  12119. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12120. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12121. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12122. order.OwnpayAmt = ""
  12123. order.SelfpayAmt = ""
  12124. order.Spec = subItem.Unit
  12125. order.SpecUnt = subItem.Unit
  12126. order.DrordBegnDate = s_tm
  12127. order.DrordStopDate = ""
  12128. order.DrordDrCodg = doctor_info.DoctorNumber
  12129. order.DrordDeptName = department.Name
  12130. order.DrordDeptCodg = department.Number
  12131. order.DrordDrName = doctor_info.UserName
  12132. order.DrordDrProfttl = "234"
  12133. order.CurrDrordFlag = "1"
  12134. orders = append(orders, &order)
  12135. }
  12136. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12137. var order models.FsiOrderDtos
  12138. order.RxID = strconv.FormatInt(item.ID, 10)
  12139. order.Rxno = strconv.FormatInt(item.ID, 10)
  12140. order.LongDrordFlag = "0"
  12141. order.HilistType = "301"
  12142. order.ChrgType = "1"
  12143. order.DrordBhvr = "0"
  12144. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12145. order.HosplistName = subItem.GoodInfo.GoodName
  12146. order.HilistLv = "1"
  12147. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12148. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12149. order.HosplistName = subItem.GoodInfo.GoodName
  12150. order.Cnt = subItem.Count
  12151. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12152. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12153. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12154. order.OwnpayAmt = ""
  12155. order.SelfpayAmt = ""
  12156. order.Spec = subItem.GoodInfo.SpecificationName
  12157. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12158. order.DrordBegnDate = s_tm
  12159. order.DrordStopDate = ""
  12160. order.DrordDrCodg = doctor_info.DoctorNumber
  12161. order.DrordDeptName = department.Name
  12162. order.DrordDeptCodg = department.Number
  12163. order.DrordDrName = doctor_info.UserName
  12164. order.DrordDrProfttl = "234"
  12165. order.CurrDrordFlag = "1"
  12166. orders = append(orders, &order)
  12167. }
  12168. }
  12169. }
  12170. //处方医嘱信息
  12171. }
  12172. fed.MatnStas = "0"
  12173. fed.MedfeeSumamt = "0"
  12174. fed.OwnpayAmt = "0"
  12175. fed.SelfpayAmt = "0"
  12176. fed.AcctPayamt = "0"
  12177. fed.MaAmt = "0"
  12178. fed.HifpPayamt = "0"
  12179. fed.SetlTotlnum = "1"
  12180. fed.Insutype = his.Insutype
  12181. fed.ReimFlag = "0"
  12182. fed.OutSetlFlag = "0"
  12183. var fopd []*models.FsiOperationDtosData
  12184. data := make(map[string]interface{})
  12185. data["fed"] = fed
  12186. data["fdd"] = fdds
  12187. data["fod"] = orders
  12188. data["pd"] = pd
  12189. data["pp"] = pp
  12190. data["fopd"] = fopd
  12191. data["trig_scen"] = trig_scen
  12192. fmt.Println(data)
  12193. fmt.Println(fed)
  12194. fmt.Println(fdds)
  12195. fmt.Println(orders)
  12196. fmt.Println(pd)
  12197. fmt.Println(pp)
  12198. fmt.Println(fopd)
  12199. client := &http.Client{}
  12200. bytesData, _ := json.Marshal(data)
  12201. var req *http.Request
  12202. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12203. if miConfig.MdtrtareaAdmvs == "320830" {
  12204. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12205. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12206. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12207. } else {
  12208. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12209. }
  12210. resp, _ := client.Do(req)
  12211. defer resp.Body.Close()
  12212. body, ioErr := ioutil.ReadAll(resp.Body)
  12213. if ioErr != nil {
  12214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12216. return res
  12217. }
  12218. var respJSON map[string]interface{}
  12219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12222. return res
  12223. }
  12224. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12225. fmt.Println(respJSON)
  12226. result, _ := json.Marshal(respJSON)
  12227. fmt.Println(result)
  12228. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12229. utils.ErrorLog("解析失败:%v", err)
  12230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12231. return res
  12232. }
  12233. return res
  12234. } else {
  12235. //if miConfig.MdtrtareaAdmvs == "441202" {
  12236. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12237. saveLog(output, input, "3101", "事前")
  12238. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12239. utils.ErrorLog("解析失败:%v", err)
  12240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. return
  12242. }
  12243. return res
  12244. //}
  12245. }
  12246. }
  12247. 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) {
  12248. adminUser := c.GetAdminUserInfo()
  12249. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12250. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12251. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12252. //record_time := c.GetString("record_time")
  12253. //trig_scen := c.GetString("trig_scen")
  12254. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12255. timeLayout := "2006-01-02"
  12256. loc, _ := time.LoadLocation("Local")
  12257. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12258. if err != nil {
  12259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12260. return res
  12261. }
  12262. recordDateTime := theTime.Unix()
  12263. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12264. var patientPrescription models.HisPrescriptionInfo
  12265. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12266. if patientPrescription.ID == 0 {
  12267. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12268. }
  12269. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12270. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12271. //
  12272. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12273. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12274. var pp models.PublicParams
  12275. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12276. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12277. pp.FixmedinsName = miConfig.OrgName
  12278. pp.FixmedinsCode = miConfig.Code
  12279. pp.RequestUrl = miConfig.Url
  12280. pp.Cainfo = miConfig.Cainfo
  12281. pp.SecretKey = miConfig.SecretKey
  12282. pp.AccessKey = miConfig.AccessKey
  12283. pp.OpterName = roles.UserName
  12284. var config []*models.HisXtDiagnoseConfig
  12285. for _, item := range diagnosis_ids {
  12286. id, _ := strconv.ParseInt(item, 10, 64)
  12287. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12288. config = append(config, &diagnosisConfig)
  12289. }
  12290. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12291. var str string
  12292. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12293. str = timestampToBirthdayString(patient.Birthday)
  12294. } else {
  12295. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12296. }
  12297. var pd models.PatientDtos
  12298. pd.PatnID = his.PsnNo
  12299. pd.PatnName = his.Name
  12300. pd.Gend = his.Gend
  12301. pd.Brdy = str
  12302. pd.Poolarea = his.InsuplcAdmdvs
  12303. pd.CurrMdtrtID = his.Number
  12304. var fed models.FsiEncounterDtos
  12305. fed.MdtrtID = his.Number
  12306. fed.MedinsID = miConfig.Code
  12307. fed.MedinsName = miConfig.OrgName
  12308. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12309. fed.MedMdtrtType = "1"
  12310. fed.MedinsType = "1"
  12311. fed.MedinsLv = "11"
  12312. tm := time.Unix(his.RecordDate, 0)
  12313. s_tm := tm.Format("2006-01-02 15:04:05")
  12314. fed.AdmDate = s_tm
  12315. fed.DscgDate = s_tm
  12316. fed.DscgMainDiseCodg = config[0].CountryCode
  12317. fed.DscgMainDiseName = config[0].CountryContentName
  12318. //诊断信息
  12319. var fdds []*models.FsiDiagnoseDtos
  12320. for index, item := range config {
  12321. if index == 0 {
  12322. var fdd models.FsiDiagnoseDtos
  12323. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12324. fdd.InoutDiseType = "1"
  12325. fdd.MaindiseFlag = "1"
  12326. fdd.DiseDate = s_tm
  12327. fdd.DiasSrtNo = "1"
  12328. fdd.DiseName = item.CountryContentName
  12329. fdd.DiseCodg = item.CountryCode
  12330. fdds = append(fdds, &fdd)
  12331. } else {
  12332. var fdd models.FsiDiagnoseDtos
  12333. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12334. fdd.InoutDiseType = "1"
  12335. fdd.MaindiseFlag = "1"
  12336. fdd.DiseDate = s_tm
  12337. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12338. fdd.DiseName = item.CountryContentName
  12339. fdd.DiseCodg = item.CountryCode
  12340. fdds = append(fdds, &fdd)
  12341. }
  12342. }
  12343. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12344. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12345. fed.AdmDeptName = department.Name
  12346. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12347. fed.DscgDeptName = department.Name
  12348. fed.MedMdtrtType = "1"
  12349. fed.MedType = "11"
  12350. //if his.Insutype == "390" {
  12351. // fed.MedType = "1402"
  12352. //} else {
  12353. // fed.MedType = "9933"
  12354. //}
  12355. var orders []*models.FsiOrderDtos
  12356. if trig_scen == "2" {
  12357. //处方医嘱信息
  12358. for _, item := range prescriptions {
  12359. for _, subItem := range item.HisDoctorAdviceInfo {
  12360. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12361. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12362. var order models.FsiOrderDtos
  12363. order.RxID = strconv.FormatInt(item.ID, 10)
  12364. order.Rxno = strconv.FormatInt(item.ID, 10)
  12365. order.LongDrordFlag = "0"
  12366. order.HilistType = "101"
  12367. order.ChrgType = "1"
  12368. order.DrordBhvr = "0"
  12369. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12370. order.HosplistName = subItem.BaseDrugLib.DrugName
  12371. order.HilistLv = "1"
  12372. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12373. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12374. order.HosplistName = subItem.BaseDrugLib.DrugName
  12375. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12376. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12377. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12378. order.OwnpayAmt = ""
  12379. order.SelfpayAmt = ""
  12380. order.Spec = spec
  12381. order.SpecUnt = subItem.PrescribingNumberUnit
  12382. order.DrordBegnDate = s_tm
  12383. order.DrordStopDate = ""
  12384. order.DrordDrCodg = doctor_info.DoctorNumber
  12385. order.DrordDeptName = department.Name
  12386. order.DrordDeptCodg = department.Number
  12387. order.DrordDrName = doctor_info.UserName
  12388. order.DrordDrProfttl = "234"
  12389. order.CurrDrordFlag = "1"
  12390. orders = append(orders, &order)
  12391. }
  12392. }
  12393. for _, subItem := range item.HisPrescriptionProject {
  12394. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12395. var order models.FsiOrderDtos
  12396. order.RxID = strconv.FormatInt(item.ID, 10)
  12397. order.Rxno = strconv.FormatInt(item.ID, 10)
  12398. order.LongDrordFlag = "0"
  12399. order.HilistType = "201"
  12400. order.ChrgType = "1"
  12401. order.DrordBhvr = "0"
  12402. order.HilistCode = subItem.HisProject.MedicalCode
  12403. order.HosplistName = subItem.HisProject.ProjectName
  12404. order.HilistLv = "1"
  12405. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12406. order.HosplistCode = subItem.HisProject.MedicalCode
  12407. order.HosplistName = subItem.HisProject.ProjectName
  12408. order.Cnt = subItem.Count
  12409. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12410. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12411. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12412. order.OwnpayAmt = ""
  12413. order.SelfpayAmt = ""
  12414. order.Spec = subItem.Unit
  12415. order.SpecUnt = subItem.Unit
  12416. order.DrordBegnDate = s_tm
  12417. order.DrordStopDate = ""
  12418. order.DrordDrCodg = doctor_info.DoctorNumber
  12419. order.DrordDeptName = department.Name
  12420. order.DrordDeptCodg = department.Number
  12421. order.DrordDrName = doctor_info.UserName
  12422. order.DrordDrProfttl = "234"
  12423. order.CurrDrordFlag = "1"
  12424. orders = append(orders, &order)
  12425. }
  12426. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12427. var order models.FsiOrderDtos
  12428. order.RxID = strconv.FormatInt(item.ID, 10)
  12429. order.Rxno = strconv.FormatInt(item.ID, 10)
  12430. order.LongDrordFlag = "0"
  12431. order.HilistType = "301"
  12432. order.ChrgType = "1"
  12433. order.DrordBhvr = "0"
  12434. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12435. order.HosplistName = subItem.GoodInfo.GoodName
  12436. order.HilistLv = "1"
  12437. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12438. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12439. order.HosplistName = subItem.GoodInfo.GoodName
  12440. order.Cnt = subItem.Count
  12441. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12442. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12443. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12444. order.OwnpayAmt = ""
  12445. order.SelfpayAmt = ""
  12446. order.Spec = subItem.GoodInfo.SpecificationName
  12447. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12448. order.DrordBegnDate = s_tm
  12449. order.DrordStopDate = ""
  12450. order.DrordDrCodg = doctor_info.DoctorNumber
  12451. order.DrordDeptName = department.Name
  12452. order.DrordDeptCodg = department.Number
  12453. order.DrordDrName = doctor_info.UserName
  12454. order.DrordDrProfttl = "234"
  12455. order.CurrDrordFlag = "1"
  12456. orders = append(orders, &order)
  12457. }
  12458. }
  12459. }
  12460. //处方医嘱信息
  12461. }
  12462. fed.MatnStas = "0"
  12463. fed.MedfeeSumamt = "0"
  12464. fed.OwnpayAmt = "0"
  12465. fed.SelfpayAmt = "0"
  12466. fed.AcctPayamt = "0"
  12467. fed.MaAmt = "0"
  12468. fed.HifpPayamt = "0"
  12469. fed.SetlTotlnum = "1"
  12470. fed.Insutype = his.Insutype
  12471. fed.ReimFlag = "0"
  12472. fed.OutSetlFlag = "0"
  12473. var fopd []*models.FsiOperationDtosData
  12474. data := make(map[string]interface{})
  12475. data["fed"] = fed
  12476. data["fdd"] = fdds
  12477. data["fod"] = orders
  12478. data["pd"] = pd
  12479. data["pp"] = pp
  12480. data["fopd"] = fopd
  12481. data["trig_scen"] = trig_scen
  12482. fmt.Println(data)
  12483. fmt.Println(fed)
  12484. fmt.Println(fdds)
  12485. fmt.Println(orders)
  12486. fmt.Println(pd)
  12487. fmt.Println(pp)
  12488. fmt.Println(fopd)
  12489. client := &http.Client{}
  12490. bytesData, _ := json.Marshal(data)
  12491. var req *http.Request
  12492. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12493. if miConfig.MdtrtareaAdmvs == "320830" {
  12494. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12495. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12496. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12497. } else {
  12498. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12499. }
  12500. resp, _ := client.Do(req)
  12501. defer resp.Body.Close()
  12502. body, ioErr := ioutil.ReadAll(resp.Body)
  12503. if ioErr != nil {
  12504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12506. return res
  12507. }
  12508. var respJSON map[string]interface{}
  12509. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12512. return res
  12513. }
  12514. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12515. fmt.Println(respJSON)
  12516. result, _ := json.Marshal(respJSON)
  12517. fmt.Println(result)
  12518. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12519. utils.ErrorLog("解析失败:%v", err)
  12520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12521. return res
  12522. }
  12523. return res
  12524. } else {
  12525. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12526. saveLog(output, input, "3101", "事前")
  12527. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12528. utils.ErrorLog("解析失败:%v", err)
  12529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12530. return
  12531. }
  12532. return res
  12533. }
  12534. return res
  12535. }
  12536. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12537. adminUser := c.GetAdminUserInfo()
  12538. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12539. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12540. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12541. record_time := c.GetString("record_time")
  12542. order, _ := service.GetHisOrderByID(order_id)
  12543. timeLayout := "2006-01-02"
  12544. loc, _ := time.LoadLocation("Local")
  12545. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12546. if err != nil {
  12547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12548. return
  12549. }
  12550. recordDateTime := theTime.Unix()
  12551. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12552. var patientPrescription models.HisPrescriptionInfo
  12553. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12554. if patientPrescription.ID == 0 {
  12555. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12556. }
  12557. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12558. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12559. //
  12560. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12561. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12562. var pp models.PublicParams
  12563. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12564. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12565. pp.FixmedinsName = miConfig.OrgName
  12566. pp.FixmedinsCode = miConfig.Code
  12567. pp.RequestUrl = miConfig.Url
  12568. pp.Cainfo = miConfig.Cainfo
  12569. pp.SecretKey = miConfig.SecretKey
  12570. pp.AccessKey = miConfig.AccessKey
  12571. pp.OpterName = roles.UserName
  12572. var config []*models.HisXtDiagnoseConfig
  12573. for _, item := range diagnosis_ids {
  12574. id, _ := strconv.ParseInt(item, 10, 64)
  12575. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12576. config = append(config, &diagnosisConfig)
  12577. }
  12578. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12579. var str string
  12580. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12581. str = timestampToBirthdayString(patient.Birthday)
  12582. } else {
  12583. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12584. }
  12585. var pd models.PatientDtos
  12586. pd.PatnID = his.PsnNo
  12587. pd.PatnName = his.Name
  12588. pd.Gend = his.Gend
  12589. pd.Brdy = str
  12590. pd.Poolarea = his.InsuplcAdmdvs
  12591. pd.CurrMdtrtID = his.Number
  12592. var fed models.FsiEncounterDtos
  12593. fed.MdtrtID = his.Number
  12594. fed.MedinsID = miConfig.Code
  12595. fed.MedinsName = miConfig.OrgName
  12596. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12597. fed.MedMdtrtType = "1"
  12598. fed.MedinsType = "1"
  12599. fed.MedinsLv = "11"
  12600. tm := time.Unix(his.RecordDate, 0)
  12601. s_tm := tm.Format("2006-01-02 15:04:05")
  12602. fed.AdmDate = s_tm
  12603. fed.DscgDate = s_tm
  12604. fed.DscgMainDiseCodg = config[0].CountryCode
  12605. fed.DscgMainDiseName = config[0].CountryContentName
  12606. //诊断信息
  12607. var fdds []*models.FsiDiagnoseDtos
  12608. for index, item := range config {
  12609. if index == 0 {
  12610. var fdd models.FsiDiagnoseDtos
  12611. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12612. fdd.InoutDiseType = "1"
  12613. fdd.MaindiseFlag = "1"
  12614. fdd.DiseDate = s_tm
  12615. fdd.DiasSrtNo = "1"
  12616. fdd.DiseName = item.CountryContentName
  12617. fdd.DiseCodg = item.CountryCode
  12618. fdds = append(fdds, &fdd)
  12619. } else {
  12620. var fdd models.FsiDiagnoseDtos
  12621. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12622. fdd.InoutDiseType = "1"
  12623. fdd.MaindiseFlag = "1"
  12624. fdd.DiseDate = s_tm
  12625. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12626. fdd.DiseName = item.CountryContentName
  12627. fdd.DiseCodg = item.CountryCode
  12628. fdds = append(fdds, &fdd)
  12629. }
  12630. }
  12631. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12632. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12633. fed.AdmDeptName = department.Name
  12634. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12635. fed.DscgDeptName = department.Name
  12636. fed.MedType = order.MedType
  12637. //处方医嘱信息
  12638. var orders []*models.FsiOrderDtos
  12639. //for _, item := range prescriptions {
  12640. // for _, subItem := range item.HisDoctorAdviceInfo {
  12641. // var order models.FsiOrderDtos
  12642. // order.RxID = strconv.FormatInt(item.ID, 10)
  12643. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12644. // order.LongDrordFlag = "0"
  12645. // order.HilistType = "1"
  12646. // order.ChrgType = "1"
  12647. // order.DrordBhvr = "-"
  12648. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12649. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12650. // order.HilistLv = "1"
  12651. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12652. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12653. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12654. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12655. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12656. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12657. // order.OwnpayAmt = ""
  12658. // order.SelfpayAmt = ""
  12659. // order.Spec = ""
  12660. // order.SpecUnt = ""
  12661. // order.DrordBegnDate = s_tm
  12662. // order.DrordStopDate = ""
  12663. // order.DrordDrCodg = "1"
  12664. // order.DrordDeptName = department.Name
  12665. // order.DrordDrCodg = "1"
  12666. // order.DrordDrName = doctor_info.UserName
  12667. // order.DrordDrProfttl = ""
  12668. // order.CurrDrordFlag = "1"
  12669. // orders = append(orders, &order)
  12670. // }
  12671. // for _, subItem := range item.HisPrescriptionProject {
  12672. // if subItem.Type == 2 {
  12673. // var order models.FsiOrderDtos
  12674. // order.RxID = strconv.FormatInt(item.ID, 10)
  12675. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12676. // order.LongDrordFlag = "0"
  12677. // order.HilistType = "1"
  12678. // order.ChrgType = "1"
  12679. // order.DrordBhvr = "-"
  12680. // order.HilistCode = subItem.HisProject.MedicalCode
  12681. // order.HosplistName = subItem.HisProject.ProjectName
  12682. // order.HilistLv = "1"
  12683. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12684. // order.HosplistCode = subItem.HisProject.MedicalCode
  12685. // order.HosplistName = subItem.HisProject.ProjectName
  12686. // order.Cnt = subItem.Count
  12687. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12688. //
  12689. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12690. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12691. // order.OwnpayAmt = ""
  12692. // order.SelfpayAmt = ""
  12693. // order.Spec = ""
  12694. // order.SpecUnt = ""
  12695. // order.DrordBegnDate = s_tm
  12696. // order.DrordStopDate = ""
  12697. // order.DrordDrCodg = "1"
  12698. // order.DrordDeptName = department.Name
  12699. // order.DrordDrCodg = "1"
  12700. // order.DrordDrName = doctor_info.UserName
  12701. // order.DrordDrProfttl = ""
  12702. // order.CurrDrordFlag = "1"
  12703. // orders = append(orders, &order)
  12704. //
  12705. // }
  12706. // if subItem.Type == 3 {
  12707. //
  12708. // var order models.FsiOrderDtos
  12709. // order.RxID = strconv.FormatInt(item.ID, 10)
  12710. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12711. // order.LongDrordFlag = "0"
  12712. // order.HilistType = "1"
  12713. // order.ChrgType = "1"
  12714. // order.DrordBhvr = "-"
  12715. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12716. // order.HosplistName = subItem.GoodInfo.GoodName
  12717. // order.HilistLv = "1"
  12718. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12719. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12720. // order.HosplistName = subItem.GoodInfo.GoodName
  12721. // order.Cnt = subItem.Count
  12722. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12723. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12724. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12725. // order.OwnpayAmt = ""
  12726. // order.SelfpayAmt = ""
  12727. // order.Spec = ""
  12728. // order.SpecUnt = ""
  12729. // order.DrordBegnDate = s_tm
  12730. // order.DrordStopDate = ""
  12731. // order.DrordDrCodg = "1"
  12732. // order.DrordDeptName = department.Name
  12733. // order.DrordDrCodg = "1"
  12734. // order.DrordDrName = doctor_info.UserName
  12735. // order.DrordDrProfttl = ""
  12736. // order.CurrDrordFlag = "1"
  12737. // orders = append(orders, &order)
  12738. //
  12739. // }
  12740. // }
  12741. //}
  12742. for _, item := range prescriptions {
  12743. for _, subItem := range item.HisDoctorAdviceInfo {
  12744. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12745. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12746. var order models.FsiOrderDtos
  12747. order.RxID = strconv.FormatInt(item.ID, 10)
  12748. order.Rxno = strconv.FormatInt(item.ID, 10)
  12749. order.LongDrordFlag = "0"
  12750. order.HilistType = "101"
  12751. order.ChrgType = "01"
  12752. order.DrordBhvr = "0"
  12753. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12754. order.HosplistName = subItem.BaseDrugLib.DrugName
  12755. order.HilistLv = "1"
  12756. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12757. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12758. order.HosplistName = subItem.BaseDrugLib.DrugName
  12759. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12760. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12761. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12762. order.OwnpayAmt = ""
  12763. order.SelfpayAmt = ""
  12764. order.Spec = spec
  12765. order.SpecUnt = subItem.PrescribingNumberUnit
  12766. order.DrordBegnDate = s_tm
  12767. order.DrordStopDate = ""
  12768. order.DrordDrCodg = doctor_info.DoctorNumber
  12769. order.DrordDeptName = department.Name
  12770. order.DrordDeptCodg = department.Number
  12771. order.DrordDrName = doctor_info.UserName
  12772. order.DrordDrProfttl = "234"
  12773. order.CurrDrordFlag = "1"
  12774. orders = append(orders, &order)
  12775. }
  12776. }
  12777. for _, subItem := range item.HisPrescriptionProject {
  12778. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12779. var order models.FsiOrderDtos
  12780. order.RxID = strconv.FormatInt(item.ID, 10)
  12781. order.Rxno = strconv.FormatInt(item.ID, 10)
  12782. order.LongDrordFlag = "0"
  12783. order.HilistType = "201"
  12784. order.ChrgType = "05"
  12785. order.DrordBhvr = "0"
  12786. order.HilistCode = subItem.HisProject.MedicalCode
  12787. order.HosplistName = subItem.HisProject.ProjectName
  12788. order.HilistLv = "1"
  12789. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12790. order.HosplistCode = subItem.HisProject.MedicalCode
  12791. order.HosplistName = subItem.HisProject.ProjectName
  12792. order.Cnt = subItem.Count
  12793. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12794. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12795. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12796. order.OwnpayAmt = ""
  12797. order.SelfpayAmt = ""
  12798. order.Spec = subItem.Unit
  12799. order.SpecUnt = subItem.Unit
  12800. order.DrordBegnDate = s_tm
  12801. order.DrordStopDate = ""
  12802. order.DrordDrCodg = doctor_info.DoctorNumber
  12803. order.DrordDeptName = department.Name
  12804. order.DrordDeptCodg = department.Number
  12805. order.DrordDrName = doctor_info.UserName
  12806. order.DrordDrProfttl = "234"
  12807. order.CurrDrordFlag = "1"
  12808. orders = append(orders, &order)
  12809. }
  12810. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12811. var order models.FsiOrderDtos
  12812. order.RxID = strconv.FormatInt(item.ID, 10)
  12813. order.Rxno = strconv.FormatInt(item.ID, 10)
  12814. order.LongDrordFlag = "0"
  12815. order.HilistType = "301"
  12816. order.ChrgType = "08"
  12817. order.DrordBhvr = "0"
  12818. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12819. order.HosplistName = subItem.GoodInfo.GoodName
  12820. order.HilistLv = "1"
  12821. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12822. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12823. order.HosplistName = subItem.GoodInfo.GoodName
  12824. order.Cnt = subItem.Count
  12825. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12826. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12827. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12828. order.OwnpayAmt = ""
  12829. order.SelfpayAmt = ""
  12830. order.Spec = subItem.GoodInfo.SpecificationName
  12831. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12832. order.DrordBegnDate = s_tm
  12833. order.DrordStopDate = ""
  12834. order.DrordDrCodg = doctor_info.DoctorNumber
  12835. order.DrordDeptName = department.Name
  12836. order.DrordDeptCodg = department.Number
  12837. order.DrordDrName = doctor_info.UserName
  12838. order.DrordDrProfttl = "234"
  12839. order.CurrDrordFlag = "1"
  12840. orders = append(orders, &order)
  12841. }
  12842. }
  12843. }
  12844. //处方医嘱信息
  12845. fed.MatnStas = "0"
  12846. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12847. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12848. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12849. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12850. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12851. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12852. fed.SetlTotlnum = "1"
  12853. fed.Insutype = his.Insutype
  12854. fed.ReimFlag = "0"
  12855. fed.OutSetlFlag = "0"
  12856. var fopd []*models.FsiOperationDtosData
  12857. data := make(map[string]interface{})
  12858. data["fed"] = fed
  12859. data["fdd"] = fdds
  12860. data["fod"] = orders
  12861. data["pd"] = pd
  12862. data["pp"] = pp
  12863. data["fopd"] = fopd
  12864. data["trig_scen"] = trig_scen
  12865. client := &http.Client{}
  12866. bytesData, _ := json.Marshal(data)
  12867. var req *http.Request
  12868. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12869. if miConfig.MdtrtareaAdmvs == "320830" {
  12870. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12871. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12872. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12873. } else {
  12874. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12875. }
  12876. resp, _ := client.Do(req)
  12877. defer resp.Body.Close()
  12878. body, ioErr := ioutil.ReadAll(resp.Body)
  12879. if ioErr != nil {
  12880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12882. return res
  12883. }
  12884. var respJSON map[string]interface{}
  12885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12888. return res
  12889. }
  12890. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12891. result, _ := json.Marshal(respJSON)
  12892. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12893. utils.ErrorLog("解析失败:%v", err)
  12894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12895. return res
  12896. }
  12897. return res
  12898. } else {
  12899. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12900. saveLog(output, input, "3102", "事中")
  12901. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12902. utils.ErrorLog("解析失败:%v", err)
  12903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12904. return
  12905. }
  12906. return res
  12907. }
  12908. return res
  12909. }
  12910. func (c *HisApiController) Check() {
  12911. psn_no := c.GetString("psn_no")
  12912. in := c.GetString("in")
  12913. mt := c.GetString("mt")
  12914. baseParams := models.BaseParams{
  12915. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12916. FixmedinsCode: "H15049901371",
  12917. InsuplcAdmdvs: "150499",
  12918. MdtrtareaAdmvs: "150499",
  12919. OrgName: "赤峰费森血液透析中心",
  12920. Doctor: "1111",
  12921. }
  12922. service.Gdyb2001(baseParams, psn_no, in, mt)
  12923. }
  12924. func (c *HisApiController) GetPsnNcdsInfo() {
  12925. admin_user_id, _ := c.GetInt64("admin_user_id")
  12926. patient_id, _ := c.GetInt64("patient_id")
  12927. //id, _ := c.GetInt64("id")
  12928. adminUser := c.GetAdminUserInfo()
  12929. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12930. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12931. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12932. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12933. //psn_record, _ := service.GetP(id)
  12934. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12935. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12936. //
  12937. //if psn_record.ID == 0 {
  12938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12939. // return
  12940. //}
  12941. var res Result5301
  12942. var res10265 Result5301For10265
  12943. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12944. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12945. var api string
  12946. if miConfig.MdtrtareaAdmvs == "320830" {
  12947. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12948. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12949. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12950. 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 +
  12951. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12952. } else {
  12953. 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 +
  12954. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12955. }
  12956. resp, requestErr := http.Get(api)
  12957. if requestErr != nil {
  12958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12959. return
  12960. }
  12961. body, ioErr := ioutil.ReadAll(resp.Body)
  12962. if ioErr != nil {
  12963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12965. return
  12966. }
  12967. var respJSON map[string]interface{}
  12968. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12971. return
  12972. }
  12973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12974. result, _ := json.Marshal(respJSON)
  12975. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12976. utils.ErrorLog("解析失败:%v", err)
  12977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12978. return
  12979. }
  12980. res.ErrMsg = res10265.ErrMsg
  12981. res.Output = res10265.Output
  12982. res.InfRefmsgid = res10265.InfRefmsgid
  12983. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12984. res.Infcode = infocode
  12985. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12986. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12987. var api string
  12988. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12989. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12990. resp, requestErr := http.Get(api)
  12991. if requestErr != nil {
  12992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12993. return
  12994. }
  12995. body, ioErr := ioutil.ReadAll(resp.Body)
  12996. if ioErr != nil {
  12997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12999. return
  13000. }
  13001. var respJSON map[string]interface{}
  13002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13005. return
  13006. }
  13007. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13008. if status == "0" {
  13009. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13010. c.ServeSuccessJSON(map[string]interface{}{
  13011. "failed_code": -10,
  13012. "msg": err_msg,
  13013. })
  13014. return
  13015. }
  13016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13017. result, _ := json.Marshal(respJSON)
  13018. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13019. utils.ErrorLog("解析失败:%v", err)
  13020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13021. return
  13022. }
  13023. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13024. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13025. var api string
  13026. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13027. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13028. resp, requestErr := http.Get(api)
  13029. if requestErr != nil {
  13030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13031. return
  13032. }
  13033. body, ioErr := ioutil.ReadAll(resp.Body)
  13034. if ioErr != nil {
  13035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13037. return
  13038. }
  13039. var respJSON map[string]interface{}
  13040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13043. return
  13044. }
  13045. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13046. if status == "0" {
  13047. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13048. c.ServeSuccessJSON(map[string]interface{}{
  13049. "failed_code": -10,
  13050. "msg": err_msg,
  13051. })
  13052. return
  13053. }
  13054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13055. result, _ := json.Marshal(respJSON)
  13056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13057. utils.ErrorLog("解析失败:%v", err)
  13058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13059. return
  13060. }
  13061. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13062. p, _ := service.GetHisPatientById(patient_id)
  13063. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13064. var dat map[string]interface{}
  13065. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13066. fmt.Println(dat)
  13067. } else {
  13068. fmt.Println(err)
  13069. }
  13070. userJSONBytes, _ := json.Marshal(dat)
  13071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13072. utils.ErrorLog("解析失败:%v", err)
  13073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13074. return
  13075. }
  13076. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13077. p, _ := service.GetHisPatientById(patient_id)
  13078. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13079. var dat map[string]interface{}
  13080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13081. fmt.Println(dat)
  13082. } else {
  13083. fmt.Println(err)
  13084. }
  13085. userJSONBytes, _ := json.Marshal(dat)
  13086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13087. utils.ErrorLog("解析失败:%v", err)
  13088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13089. return
  13090. }
  13091. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13092. p, _ := service.GetHisPatientById(patient_id)
  13093. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13094. var dat map[string]interface{}
  13095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13096. fmt.Println(dat)
  13097. } else {
  13098. fmt.Println(err)
  13099. }
  13100. userJSONBytes, _ := json.Marshal(dat)
  13101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13102. utils.ErrorLog("解析失败:%v", err)
  13103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13104. return
  13105. }
  13106. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13107. p, _ := service.GetHisPatientById(patient_id)
  13108. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13109. var dat map[string]interface{}
  13110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13111. fmt.Println(dat)
  13112. } else {
  13113. fmt.Println(err)
  13114. }
  13115. userJSONBytes, _ := json.Marshal(dat)
  13116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13117. utils.ErrorLog("解析失败:%v", err)
  13118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13119. return
  13120. }
  13121. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13122. p, _ := service.GetHisPatientById(patient_id)
  13123. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13124. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13125. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13126. resp, requestErr := http.Get(api)
  13127. if requestErr != nil {
  13128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13129. return
  13130. }
  13131. body, ioErr := ioutil.ReadAll(resp.Body)
  13132. if ioErr != nil {
  13133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13135. return
  13136. }
  13137. var respJSON map[string]interface{}
  13138. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13141. return
  13142. }
  13143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13144. result, _ := json.Marshal(respJSON)
  13145. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13146. utils.ErrorLog("解析失败:%v", err)
  13147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13148. return
  13149. }
  13150. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13151. p, _ := service.GetHisPatientById(patient_id)
  13152. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13153. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13155. resp, requestErr := http.Get(api)
  13156. if requestErr != nil {
  13157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13158. return
  13159. }
  13160. body, ioErr := ioutil.ReadAll(resp.Body)
  13161. if ioErr != nil {
  13162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13164. return
  13165. }
  13166. var respJSON map[string]interface{}
  13167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13170. return
  13171. }
  13172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13173. result, _ := json.Marshal(respJSON)
  13174. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13175. utils.ErrorLog("解析失败:%v", err)
  13176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13177. return
  13178. }
  13179. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13180. p, _ := service.GetHisPatientById(patient_id)
  13181. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13182. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13183. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13184. resp, requestErr := http.Get(api)
  13185. if requestErr != nil {
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13187. return
  13188. }
  13189. body, ioErr := ioutil.ReadAll(resp.Body)
  13190. if ioErr != nil {
  13191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. var respJSON map[string]interface{}
  13196. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13199. return
  13200. }
  13201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13202. result, _ := json.Marshal(respJSON)
  13203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13204. utils.ErrorLog("解析失败:%v", err)
  13205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13206. return
  13207. }
  13208. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13209. p, _ := service.GetHisPatientById(patient_id)
  13210. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13211. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13212. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13213. resp, requestErr := http.Get(api)
  13214. if requestErr != nil {
  13215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13216. return
  13217. }
  13218. body, ioErr := ioutil.ReadAll(resp.Body)
  13219. if ioErr != nil {
  13220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13222. return
  13223. }
  13224. var respJSON map[string]interface{}
  13225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13228. return
  13229. }
  13230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13231. result, _ := json.Marshal(respJSON)
  13232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13233. utils.ErrorLog("解析失败:%v", err)
  13234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13235. return
  13236. }
  13237. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13238. p, _ := service.GetHisPatientById(patient_id)
  13239. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13240. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13241. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13242. resp, requestErr := http.Get(api)
  13243. if requestErr != nil {
  13244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13245. return
  13246. }
  13247. body, ioErr := ioutil.ReadAll(resp.Body)
  13248. if ioErr != nil {
  13249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13251. return
  13252. }
  13253. var respJSON map[string]interface{}
  13254. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13257. return
  13258. }
  13259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13260. result, _ := json.Marshal(respJSON)
  13261. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13262. utils.ErrorLog("解析失败:%v", err)
  13263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13264. return
  13265. }
  13266. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13267. p, _ := service.GetHisPatientById(patient_id)
  13268. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13269. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13270. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13271. resp, requestErr := http.Get(api)
  13272. if requestErr != nil {
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13274. return
  13275. }
  13276. body, ioErr := ioutil.ReadAll(resp.Body)
  13277. if ioErr != nil {
  13278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13280. return
  13281. }
  13282. var respJSON map[string]interface{}
  13283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13286. return
  13287. }
  13288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13289. result, _ := json.Marshal(respJSON)
  13290. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13291. utils.ErrorLog("解析失败:%v", err)
  13292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13293. return
  13294. }
  13295. } else {
  13296. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13297. var dat map[string]interface{}
  13298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13299. fmt.Println(dat)
  13300. } else {
  13301. fmt.Println(err)
  13302. }
  13303. userJSONBytes, _ := json.Marshal(dat)
  13304. if miConfig.Code == "H15049901371" {
  13305. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13306. utils.ErrorLog("解析失败:%v", err)
  13307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13308. return
  13309. }
  13310. res.InfRefmsgid = res10265.InfRefmsgid
  13311. res.Output = res10265.Output
  13312. res.ErrMsg = res10265.ErrMsg
  13313. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13314. res.Infcode = infocode
  13315. } else {
  13316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13317. utils.ErrorLog("解析失败:%v", err)
  13318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13319. return
  13320. }
  13321. }
  13322. }
  13323. if res.Infcode == 0 {
  13324. c.ServeSuccessJSON(map[string]interface{}{
  13325. "result": res.Output.Result,
  13326. })
  13327. }
  13328. }
  13329. func (c *HisApiController) CheckInsutype() {
  13330. his_patient_id, _ := c.GetInt64("his_patient_id")
  13331. admin_user_id, _ := c.GetInt64("admin_user_id")
  13332. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13333. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13334. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13335. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13336. var dat map[string]interface{}
  13337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13338. fmt.Println(dat)
  13339. } else {
  13340. fmt.Println(err)
  13341. }
  13342. userJSONBytes, _ := json.Marshal(dat)
  13343. var res Result90100
  13344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13345. utils.ErrorLog("解析失败:%v", err)
  13346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13347. return
  13348. }
  13349. if res.Infcode != 0 {
  13350. c.ServeSuccessJSON(map[string]interface{}{
  13351. "failed_code": -10,
  13352. "msg": res.ErrMsg,
  13353. })
  13354. return
  13355. } else {
  13356. fmt.Println(res)
  13357. }
  13358. }
  13359. func (c *HisApiController) CheckCardPWD() {
  13360. card_pwd := c.GetString("card_pwd")
  13361. his_patient_id, _ := c.GetInt64("his_patient_id")
  13362. admin_user_id, _ := c.GetInt64("admin_user_id")
  13363. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13365. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13366. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13367. bas := strings.Split(psn.CardInfo, "|")
  13368. basNumber := bas[2]
  13369. if psn.InsuplcAdmdvs[:4] == "4403" {
  13370. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13371. var dat map[string]interface{}
  13372. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13373. fmt.Println(dat)
  13374. } else {
  13375. fmt.Println(err)
  13376. }
  13377. userJSONBytes, _ := json.Marshal(dat)
  13378. var res Result90991
  13379. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13380. utils.ErrorLog("解析失败:%v", err)
  13381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13382. return
  13383. }
  13384. if res.Infcode != 0 {
  13385. c.ServeSuccessJSON(map[string]interface{}{
  13386. "failed_code": -10,
  13387. "msg": res.ErrMsg,
  13388. })
  13389. return
  13390. } else {
  13391. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13392. var msg string
  13393. switch res.Output.Result.CardStat {
  13394. case "00":
  13395. msg = "未激活"
  13396. break
  13397. case "10":
  13398. msg = "激活"
  13399. break
  13400. case "20":
  13401. msg = "窗口挂失"
  13402. break
  13403. case "21":
  13404. msg = "电话挂失"
  13405. break
  13406. case "22":
  13407. msg = "单位网上申报挂失"
  13408. break
  13409. case "23":
  13410. msg = "保健办挂失"
  13411. break
  13412. case "24":
  13413. msg = "个人网上挂失"
  13414. break
  13415. case "25":
  13416. msg = "网上服务大厅挂失"
  13417. break
  13418. case "30":
  13419. msg = "注销"
  13420. break
  13421. case "40":
  13422. msg = "回收"
  13423. break
  13424. case "99":
  13425. msg = "制卡中(无效卡)"
  13426. break
  13427. }
  13428. c.ServeSuccessJSON(map[string]interface{}{
  13429. "failed_code": -10,
  13430. "msg": msg,
  13431. })
  13432. return
  13433. } else {
  13434. c.ServeSuccessJSON(map[string]interface{}{
  13435. "msg": "校验成功",
  13436. })
  13437. return
  13438. }
  13439. }
  13440. } else {
  13441. c.ServeSuccessJSON(map[string]interface{}{
  13442. "msg": "校验成功",
  13443. })
  13444. return
  13445. }
  13446. }
  13447. func (c *HisApiController) CheckCardPWDTwo() {
  13448. //card_pwd := c.GetString("card_pwd")
  13449. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13450. admin_user_id, _ := c.GetInt64("admin_user_id")
  13451. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13453. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13454. var dat map[string]interface{}
  13455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13456. fmt.Println(dat)
  13457. } else {
  13458. fmt.Println(err)
  13459. }
  13460. userJSONBytes, _ := json.Marshal(dat)
  13461. var res Result90991
  13462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13463. utils.ErrorLog("解析失败:%v", err)
  13464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13465. return
  13466. }
  13467. if res.Infcode != 0 {
  13468. c.ServeSuccessJSON(map[string]interface{}{
  13469. "failed_code": -10,
  13470. "msg": res.ErrMsg,
  13471. })
  13472. return
  13473. } else {
  13474. if res.Output.Result.SscnoCheckStat == "0" {
  13475. var msg string
  13476. switch res.Output.Result.CardStat {
  13477. case "00":
  13478. msg = "未激活"
  13479. break
  13480. case "10":
  13481. msg = "激活"
  13482. break
  13483. case "20":
  13484. msg = "窗口挂失"
  13485. break
  13486. case "21":
  13487. msg = "电话挂失"
  13488. break
  13489. case "22":
  13490. msg = "单位网上申报挂失"
  13491. break
  13492. case "23":
  13493. msg = "保健办挂失"
  13494. break
  13495. case "24":
  13496. msg = "个人网上挂失"
  13497. break
  13498. case "25":
  13499. msg = "网上服务大厅挂失"
  13500. break
  13501. case "30":
  13502. msg = "注销"
  13503. break
  13504. case "40":
  13505. msg = "回收"
  13506. break
  13507. case "99":
  13508. msg = "制卡中(无效卡)"
  13509. break
  13510. }
  13511. c.ServeSuccessJSON(map[string]interface{}{
  13512. "failed_code": -10,
  13513. "msg": msg,
  13514. })
  13515. return
  13516. } else {
  13517. c.ServeSuccessJSON(map[string]interface{}{
  13518. "msg": "校验成功",
  13519. })
  13520. return
  13521. }
  13522. }
  13523. }
  13524. type ELeCertData struct {
  13525. Data struct {
  13526. Extra string `json:"extra"`
  13527. IDNo string `json:"idNo"`
  13528. IDType string `json:"idType"`
  13529. EcToken string `json:"ecToken"`
  13530. InsuOrg string `json:"insuOrg"`
  13531. UserName string `json:"userName"`
  13532. EcIndexNo string `json:"ecIndexNo"`
  13533. Gender string `json:"gender"`
  13534. Birthday string `json:"birthday"`
  13535. Nationality string `json:"nationality"`
  13536. Email string `json:"email"`
  13537. } `json:"OutData"`
  13538. }
  13539. func (c *HisApiController) ReadCard() {
  13540. id_card_type, _ := c.GetInt64("id_card_type")
  13541. admin_user_id, _ := c.GetInt64("admin_user_id")
  13542. certificates, _ := c.GetInt64("certificates")
  13543. //
  13544. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13545. id_card_no := c.GetString("id_card_no")
  13546. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13547. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13549. switch id_card_type {
  13550. case 1:
  13551. if miConfig.MdtrtareaAdmvs == "421300" {
  13552. var res ResultTwo
  13553. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13554. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13555. "&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)
  13556. resp, requestErr := http.Get(api)
  13557. if requestErr != nil {
  13558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13559. return
  13560. }
  13561. body, ioErr := ioutil.ReadAll(resp.Body)
  13562. if ioErr != nil {
  13563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13565. return
  13566. }
  13567. var respJSON map[string]interface{}
  13568. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13571. return
  13572. }
  13573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13574. result, _ := json.Marshal(respJSON)
  13575. fmt.Println("log")
  13576. fmt.Println(string(result))
  13577. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13578. utils.ErrorLog("解析失败:%v", err)
  13579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13580. return
  13581. }
  13582. if res.Infcode == 0 {
  13583. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13584. if err == gorm.ErrRecordNotFound {
  13585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13586. return
  13587. } else if err != nil {
  13588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13589. return
  13590. } else {
  13591. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13592. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13593. infoStr := string(Iinfos)
  13594. idetinfoStr := string(Idetinfos)
  13595. var rf []*ResultFive
  13596. json.Unmarshal([]byte(infoStr), &rf)
  13597. var insutypes []*ResultFive
  13598. var insutype string
  13599. var is390 int = 0
  13600. var is310 int = 0
  13601. for _, item := range rf {
  13602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13603. insutypes = append(insutypes, item)
  13604. }
  13605. }
  13606. if len(insutypes) == 1 {
  13607. insutype = insutypes[0].Insutype
  13608. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13609. } else {
  13610. for _, i := range insutypes {
  13611. if i.Insutype == "390" {
  13612. is390 = 1
  13613. }
  13614. if i.Insutype == "310" {
  13615. is310 = 1
  13616. }
  13617. }
  13618. }
  13619. if is390 == 1 {
  13620. insutype = "390"
  13621. }
  13622. if is310 == 1 {
  13623. insutype = "310"
  13624. }
  13625. if len(insutypes) == 0 {
  13626. insutype = "390"
  13627. }
  13628. var insuplc_admdvs string
  13629. for _, item := range rf {
  13630. if item.Insutype == insutype {
  13631. insuplc_admdvs = item.InsuplcAdmdvs
  13632. }
  13633. }
  13634. if strings.Contains(insuplc_admdvs, "4213") {
  13635. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13636. }
  13637. psn := &models.HisPsn{
  13638. PsnNo: res.Output.Baseinfo.PsnNo,
  13639. PatientId: patient.ID,
  13640. Certno: res.Output.Baseinfo.Certno,
  13641. Gend: res.Output.Baseinfo.Gend,
  13642. Naty: res.Output.Baseinfo.Naty,
  13643. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13644. PsnName: res.Output.Baseinfo.PsnName,
  13645. Idetinfo: idetinfoStr,
  13646. Insuinfo: infoStr,
  13647. InsuplcAdmdvs: insuplc_admdvs,
  13648. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13649. }
  13650. service.CreateHisPsn(psn)
  13651. c.ServeSuccessJSON(map[string]interface{}{
  13652. "patient": patient,
  13653. "number": res.Output.Baseinfo.Certno,
  13654. })
  13655. }
  13656. } else {
  13657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13658. return
  13659. }
  13660. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13661. var res ResultTwo
  13662. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13663. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13664. "&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)
  13665. resp, requestErr := http.Get(api)
  13666. if requestErr != nil {
  13667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13668. return
  13669. }
  13670. body, ioErr := ioutil.ReadAll(resp.Body)
  13671. if ioErr != nil {
  13672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13674. return
  13675. }
  13676. var respJSON map[string]interface{}
  13677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13680. return
  13681. }
  13682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13683. result, _ := json.Marshal(respJSON)
  13684. fmt.Println("log")
  13685. fmt.Println(string(result))
  13686. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13687. utils.ErrorLog("解析失败:%v", err)
  13688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13689. return
  13690. }
  13691. if res.Infcode == 0 {
  13692. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13693. if err == gorm.ErrRecordNotFound {
  13694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13695. return
  13696. } else if err != nil {
  13697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13698. return
  13699. } else {
  13700. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13701. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13702. infoStr := string(Iinfos)
  13703. idetinfoStr := string(Idetinfos)
  13704. psn := &models.HisPsn{
  13705. PsnNo: res.Output.Baseinfo.PsnNo,
  13706. PatientId: patient.ID,
  13707. Certno: res.Output.Baseinfo.Certno,
  13708. Gend: res.Output.Baseinfo.Gend,
  13709. Naty: res.Output.Baseinfo.Naty,
  13710. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13711. PsnName: res.Output.Baseinfo.PsnName,
  13712. Idetinfo: idetinfoStr,
  13713. Insuinfo: infoStr,
  13714. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13715. }
  13716. service.CreateHisPsn(psn)
  13717. var rf []*ResultFive
  13718. json.Unmarshal([]byte(infoStr), &rf)
  13719. var insutypes []*ResultFive
  13720. var insutype string
  13721. var is390 int = 0
  13722. var is310 int = 0
  13723. for _, item := range rf {
  13724. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13725. insutypes = append(insutypes, item)
  13726. }
  13727. }
  13728. if len(insutypes) == 1 {
  13729. insutype = insutypes[0].Insutype
  13730. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13731. } else {
  13732. for _, i := range insutypes {
  13733. if i.Insutype == "390" {
  13734. is390 = 1
  13735. }
  13736. if i.Insutype == "310" {
  13737. is310 = 1
  13738. }
  13739. }
  13740. }
  13741. if is390 == 1 {
  13742. insutype = "390"
  13743. }
  13744. if is310 == 1 {
  13745. insutype = "310"
  13746. }
  13747. if len(insutypes) == 0 {
  13748. insutype = "310"
  13749. }
  13750. c.ServeSuccessJSON(map[string]interface{}{
  13751. "patient": patient,
  13752. "number": res.Output.Baseinfo.Certno,
  13753. "insutype": insutype,
  13754. })
  13755. }
  13756. } else {
  13757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13758. return
  13759. }
  13760. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13761. var res ResultTwo
  13762. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13763. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13764. "&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)
  13765. resp, requestErr := http.Get(api)
  13766. if requestErr != nil {
  13767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13768. return
  13769. }
  13770. body, ioErr := ioutil.ReadAll(resp.Body)
  13771. if ioErr != nil {
  13772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13774. return
  13775. }
  13776. var respJSON map[string]interface{}
  13777. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13780. return
  13781. }
  13782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13783. result, _ := json.Marshal(respJSON)
  13784. fmt.Println("log")
  13785. fmt.Println(string(result))
  13786. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13787. utils.ErrorLog("解析失败:%v", err)
  13788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13789. return
  13790. }
  13791. if res.Infcode == 0 {
  13792. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13793. if err == gorm.ErrRecordNotFound {
  13794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13795. return
  13796. } else if err != nil {
  13797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13798. return
  13799. } else {
  13800. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13801. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13802. infoStr := string(Iinfos)
  13803. idetinfoStr := string(Idetinfos)
  13804. var rf []*ResultFive
  13805. json.Unmarshal([]byte(infoStr), &rf)
  13806. var insutypes []*ResultFive
  13807. var insutype string
  13808. var is390 int = 0
  13809. var is310 int = 0
  13810. for _, item := range rf {
  13811. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13812. insutypes = append(insutypes, item)
  13813. }
  13814. }
  13815. if len(insutypes) == 1 {
  13816. insutype = insutypes[0].Insutype
  13817. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13818. } else {
  13819. for _, i := range insutypes {
  13820. if i.Insutype == "390" {
  13821. is390 = 1
  13822. }
  13823. if i.Insutype == "310" {
  13824. is310 = 1
  13825. }
  13826. }
  13827. }
  13828. if is390 == 1 {
  13829. insutype = "390"
  13830. }
  13831. if is310 == 1 {
  13832. insutype = "310"
  13833. }
  13834. if len(insutypes) == 0 {
  13835. insutype = "390"
  13836. }
  13837. var insuplc_admdvs string
  13838. for _, item := range rf {
  13839. if item.Insutype == insutype {
  13840. insuplc_admdvs = item.InsuplcAdmdvs
  13841. }
  13842. }
  13843. psn := &models.HisPsn{
  13844. PsnNo: res.Output.Baseinfo.PsnNo,
  13845. PatientId: patient.ID,
  13846. Certno: res.Output.Baseinfo.Certno,
  13847. Gend: res.Output.Baseinfo.Gend,
  13848. Naty: res.Output.Baseinfo.Naty,
  13849. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13850. PsnName: res.Output.Baseinfo.PsnName,
  13851. Idetinfo: idetinfoStr,
  13852. Insuinfo: infoStr,
  13853. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13854. InsuplcAdmdvs: insuplc_admdvs,
  13855. }
  13856. service.CreateHisPsn(psn)
  13857. for _, item := range rf {
  13858. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13859. insutypes = append(insutypes, item)
  13860. }
  13861. }
  13862. if len(insutypes) == 1 {
  13863. insutype = insutypes[0].Insutype
  13864. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13865. } else {
  13866. for _, i := range insutypes {
  13867. if i.Insutype == "390" {
  13868. is390 = 1
  13869. }
  13870. if i.Insutype == "310" {
  13871. is310 = 1
  13872. }
  13873. }
  13874. }
  13875. if is390 == 1 {
  13876. insutype = "390"
  13877. }
  13878. if is310 == 1 {
  13879. insutype = "310"
  13880. }
  13881. if len(insutypes) == 0 {
  13882. insutype = "310"
  13883. }
  13884. c.ServeSuccessJSON(map[string]interface{}{
  13885. "patient": patient,
  13886. "number": res.Output.Baseinfo.Certno,
  13887. "insutype": insutype,
  13888. })
  13889. }
  13890. } else {
  13891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13892. return
  13893. }
  13894. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13895. var res ResultTwo
  13896. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13897. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13898. "&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)
  13899. resp, requestErr := http.Get(api)
  13900. if requestErr != nil {
  13901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13902. return
  13903. }
  13904. body, ioErr := ioutil.ReadAll(resp.Body)
  13905. if ioErr != nil {
  13906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13908. return
  13909. }
  13910. var respJSON map[string]interface{}
  13911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13914. return
  13915. }
  13916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13917. result, _ := json.Marshal(respJSON)
  13918. fmt.Println("log")
  13919. fmt.Println(string(result))
  13920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13921. utils.ErrorLog("解析失败:%v", err)
  13922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13923. return
  13924. }
  13925. if res.Infcode == 0 {
  13926. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13927. if err == gorm.ErrRecordNotFound {
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13929. return
  13930. } else if err != nil {
  13931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13932. return
  13933. } else {
  13934. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13935. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13936. infoStr := string(Iinfos)
  13937. idetinfoStr := string(Idetinfos)
  13938. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13939. psn := &models.HisPsn{
  13940. PsnNo: res.Output.Baseinfo.PsnNo,
  13941. PatientId: patient.ID,
  13942. Certno: res.Output.Baseinfo.Certno,
  13943. Brdy: b,
  13944. Age: float64(age),
  13945. Gend: res.Output.Baseinfo.Gend,
  13946. Naty: res.Output.Baseinfo.Naty,
  13947. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13948. PsnName: res.Output.Baseinfo.PsnName,
  13949. Idetinfo: idetinfoStr,
  13950. Insuinfo: infoStr,
  13951. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13952. }
  13953. service.CreateHisPsn(psn)
  13954. var rf []*ResultFive
  13955. json.Unmarshal([]byte(infoStr), &rf)
  13956. var insutypes []*ResultFive
  13957. var insutype string
  13958. var is390 int = 0
  13959. var is310 int = 0
  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. c.ServeSuccessJSON(map[string]interface{}{
  13988. "patient": patient,
  13989. "number": res.Output.Baseinfo.Certno,
  13990. "insutype": insutype,
  13991. })
  13992. }
  13993. } else {
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13995. return
  13996. }
  13997. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13998. var api string
  13999. if miConfig.MdtrtareaAdmvs == "320830" {
  14000. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14001. "&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
  14002. fmt.Println(api)
  14003. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14004. 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 +
  14005. "&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
  14006. fmt.Println(api)
  14007. } else {
  14008. 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 +
  14009. "&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)
  14010. }
  14011. resp, requestErr := http.Get(api)
  14012. if requestErr != nil {
  14013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14014. return
  14015. }
  14016. body, ioErr := ioutil.ReadAll(resp.Body)
  14017. if ioErr != nil {
  14018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14020. return
  14021. }
  14022. var respJSON map[string]interface{}
  14023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14026. return
  14027. }
  14028. var status string
  14029. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14030. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14031. //console.log()
  14032. fmt.Println("type===")
  14033. fmt.Println(card_type)
  14034. var token string
  14035. var res ResultTwo //1101结果
  14036. var res10265 ResultTwo10265 //1101结果
  14037. var card_info string //卡信息
  14038. var busi_card_info string
  14039. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14040. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14041. if status == "0" { //读卡成功
  14042. if card_type == "1" {
  14043. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14044. result, _ := json.Marshal(respJSON)
  14045. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14046. utils.ErrorLog("解析失败:%v", err)
  14047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14048. return
  14049. }
  14050. res.ErrMsg = res10265.ErrMsg
  14051. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14052. res.Infcode = infocode
  14053. res.Output = res10265.Output
  14054. res.InfRefmsgid = res10265.InfRefmsgid
  14055. } else {
  14056. //var card_info string //卡信息
  14057. //var busi_card_info string
  14058. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14059. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14060. //fmt.Println(card_info)
  14061. //fmt.Println(busi_card_info)
  14062. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14063. result, _ := json.Marshal(respJSON)
  14064. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14065. utils.ErrorLog("解析失败:%v", err)
  14066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14067. return
  14068. }
  14069. res.ErrMsg = res10265.ErrMsg
  14070. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14071. res.Infcode = infocode
  14072. res.Output = res10265.Output
  14073. res.InfRefmsgid = res10265.InfRefmsgid
  14074. }
  14075. if res.Infcode == 0 {
  14076. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14077. if err == gorm.ErrRecordNotFound {
  14078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14079. return
  14080. } else if err != nil {
  14081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14082. return
  14083. } else {
  14084. if card_type == "1" {
  14085. bas := strings.Split(card_info, "|")
  14086. basNumber := bas[2]
  14087. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14088. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14089. infoStr := string(Iinfos)
  14090. idetinfoStr := string(Idetinfos)
  14091. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14092. psn := &models.HisPsn{
  14093. PsnNo: res.Output.Baseinfo.PsnNo,
  14094. PatientId: patient.ID,
  14095. Certno: res.Output.Baseinfo.Certno,
  14096. Brdy: b,
  14097. Age: float64(age),
  14098. Gend: res.Output.Baseinfo.Gend,
  14099. Naty: res.Output.Baseinfo.Naty,
  14100. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14101. PsnName: res.Output.Baseinfo.PsnName,
  14102. Idetinfo: idetinfoStr,
  14103. Insuinfo: infoStr,
  14104. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14105. CardInfo: card_info,
  14106. VerifyNumber: busi_card_info,
  14107. }
  14108. service.CreateHisPsn(psn)
  14109. var rf []*ResultFive
  14110. json.Unmarshal([]byte(infoStr), &rf)
  14111. var insutypes []*ResultFive
  14112. var insutype string
  14113. var is390 int = 0
  14114. var is310 int = 0
  14115. for _, item := range rf {
  14116. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14117. insutypes = append(insutypes, item)
  14118. }
  14119. }
  14120. if len(insutypes) == 1 {
  14121. insutype = insutypes[0].Insutype
  14122. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14123. } else {
  14124. for _, i := range insutypes {
  14125. if i.Insutype == "390" {
  14126. is390 = 1
  14127. }
  14128. if i.Insutype == "310" {
  14129. is310 = 1
  14130. }
  14131. }
  14132. }
  14133. if is390 == 1 {
  14134. insutype = "390"
  14135. }
  14136. if is310 == 1 {
  14137. insutype = "310"
  14138. }
  14139. if len(insutypes) == 0 {
  14140. insutype = "310"
  14141. }
  14142. c.ServeSuccessJSON(map[string]interface{}{
  14143. "patient": patient,
  14144. "number": basNumber,
  14145. "insutype": insutype,
  14146. })
  14147. } else {
  14148. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14149. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14150. infoStr := string(Iinfos)
  14151. idetinfoStr := string(Idetinfos)
  14152. psn := &models.HisPsn{
  14153. PsnNo: res.Output.Baseinfo.PsnNo,
  14154. PatientId: patient.ID,
  14155. Certno: res.Output.Baseinfo.Certno,
  14156. Gend: res.Output.Baseinfo.Gend,
  14157. Naty: res.Output.Baseinfo.Naty,
  14158. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14159. PsnName: res.Output.Baseinfo.PsnName,
  14160. Idetinfo: idetinfoStr,
  14161. Insuinfo: infoStr,
  14162. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14163. CardInfo: card_info,
  14164. VerifyNumber: token,
  14165. }
  14166. service.CreateHisPsn(psn)
  14167. c.ServeSuccessJSON(map[string]interface{}{
  14168. "patient": patient,
  14169. "number": token,
  14170. })
  14171. }
  14172. }
  14173. } else {
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14175. return
  14176. }
  14177. } else { //读卡失败
  14178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14179. return
  14180. }
  14181. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14182. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14183. cardnum = DeleteExtraSpaceTwo(cardnum)
  14184. cardCode = DeleteExtraSpaceTwo(cardCode)
  14185. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14186. name = DeleteExtraSpaceTwo(name)
  14187. errmsg = DeleteExtraSpaceTwo(errmsg)
  14188. cardnum = Remove0000(cardnum)
  14189. cardCode = Remove0000(cardCode)
  14190. id_card_no = Remove0000(id_card_no)
  14191. name = Remove0000(name)
  14192. errmsg = Remove0000(errmsg)
  14193. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14194. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14195. //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)
  14196. //fmt.Println(result2)
  14197. //fmt.Println(requestLog2)
  14198. //fmt.Println(errMsgLog2)
  14199. 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)
  14200. saveLog(result, requestLog, "1101", "获取人员信息")
  14201. fmt.Println(errMsgLog)
  14202. if len(errMsgLog) > 0 {
  14203. } else {
  14204. var dat map[string]interface{}
  14205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14206. fmt.Println(dat)
  14207. } else {
  14208. fmt.Println(err)
  14209. }
  14210. userJSONBytes, _ := json.Marshal(dat)
  14211. var res ResultTwo
  14212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14213. utils.ErrorLog("解析失败:%v", err)
  14214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14215. return
  14216. }
  14217. res.ErrMsg = errMsgLog
  14218. if res.Infcode == 0 {
  14219. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14220. if err == gorm.ErrRecordNotFound {
  14221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14222. return
  14223. } else if err != nil {
  14224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14225. return
  14226. } else {
  14227. fmt.Println(res)
  14228. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14229. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14230. infoStr := string(Iinfos)
  14231. idetinfoStr := string(Idetinfos)
  14232. var rf []*ResultFive
  14233. json.Unmarshal([]byte(infoStr), &rf)
  14234. var insutypes []*ResultFive
  14235. var insutype string
  14236. var is390 int = 0
  14237. var is310 int = 0
  14238. for _, item := range rf {
  14239. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14240. insutypes = append(insutypes, item)
  14241. }
  14242. }
  14243. if len(insutypes) == 1 {
  14244. insutype = insutypes[0].Insutype
  14245. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14246. } else {
  14247. for _, i := range insutypes {
  14248. if i.Insutype == "390" {
  14249. is390 = 1
  14250. }
  14251. if i.Insutype == "310" {
  14252. is310 = 1
  14253. }
  14254. }
  14255. }
  14256. if is390 == 1 {
  14257. insutype = "390"
  14258. }
  14259. if is310 == 1 {
  14260. insutype = "310"
  14261. }
  14262. if len(insutypes) == 0 {
  14263. insutype = "390"
  14264. }
  14265. var insuplc_admdvs string
  14266. for _, item := range rf {
  14267. if item.Insutype == insutype {
  14268. insuplc_admdvs = item.InsuplcAdmdvs
  14269. }
  14270. }
  14271. psn := &models.HisPsn{
  14272. PsnNo: res.Output.Baseinfo.PsnNo,
  14273. PatientId: patient.ID,
  14274. Certno: res.Output.Baseinfo.Certno,
  14275. Gend: res.Output.Baseinfo.Gend,
  14276. Naty: res.Output.Baseinfo.Naty,
  14277. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14278. PsnName: res.Output.Baseinfo.PsnName,
  14279. Idetinfo: idetinfoStr,
  14280. Insuinfo: infoStr,
  14281. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14282. CardInfo: basStr,
  14283. VerifyNumber: "",
  14284. InsuplcAdmdvs: insuplc_admdvs,
  14285. }
  14286. service.CreateHisPsn(psn)
  14287. c.ServeSuccessJSON(map[string]interface{}{
  14288. "patient": patient,
  14289. "number": cardnum,
  14290. "insutype": insutype,
  14291. })
  14292. }
  14293. } else {
  14294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14295. return
  14296. }
  14297. }
  14298. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14299. fmt.Println(initFlag)
  14300. fmt.Println("initFlag")
  14301. if initFlag == 0 {
  14302. c.TestGetJiangXiBasBaseInit()
  14303. }
  14304. basStr := c.GetBasBaseInfo()
  14305. if len(basStr) == 0 {
  14306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14307. return
  14308. }
  14309. fmt.Println(basStr)
  14310. bas := strings.Split(basStr, "|")
  14311. basNumber := bas[1]
  14312. fmt.Println(basNumber)
  14313. card := bas[2]
  14314. card_sn := bas[3]
  14315. fmt.Println(card_sn)
  14316. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14317. result, _ := service.Jxyb11012(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, card)
  14318. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14319. var dat map[string]interface{}
  14320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14321. fmt.Println(dat)
  14322. } else {
  14323. fmt.Println(err)
  14324. }
  14325. userJSONBytes, _ := json.Marshal(dat)
  14326. var res ResultTwo
  14327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14328. utils.ErrorLog("解析失败:%v", err)
  14329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14330. return
  14331. }
  14332. if res.Infcode == 0 {
  14333. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14334. if err == gorm.ErrRecordNotFound {
  14335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14336. return
  14337. } else if err != nil {
  14338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14339. return
  14340. } else {
  14341. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14342. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14343. infoStr := string(Iinfos)
  14344. idetinfoStr := string(Idetinfos)
  14345. var rf []*ResultFive
  14346. json.Unmarshal([]byte(infoStr), &rf)
  14347. var insutypes []*ResultFive
  14348. var insutype string
  14349. var is390 int = 0
  14350. var is310 int = 0
  14351. var insuplc_admdvs string
  14352. for _, item := range rf {
  14353. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14354. insutypes = append(insutypes, item)
  14355. }
  14356. }
  14357. if len(insutypes) == 1 {
  14358. insutype = insutypes[0].Insutype
  14359. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14360. } else {
  14361. for _, i := range insutypes {
  14362. if i.Insutype == "390" {
  14363. is390 = 1
  14364. }
  14365. if i.Insutype == "310" {
  14366. is310 = 1
  14367. }
  14368. }
  14369. }
  14370. if is390 == 1 {
  14371. insutype = "390"
  14372. }
  14373. if is310 == 1 {
  14374. insutype = "310"
  14375. }
  14376. if len(insutypes) == 0 {
  14377. insutype = "310"
  14378. }
  14379. for _, item := range rf {
  14380. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14381. insuplc_admdvs = item.InsuplcAdmdvs
  14382. }
  14383. }
  14384. psn := &models.HisPsn{
  14385. PsnNo: res.Output.Baseinfo.PsnNo,
  14386. PatientId: patient.ID,
  14387. Certno: res.Output.Baseinfo.Certno,
  14388. Gend: res.Output.Baseinfo.Gend,
  14389. Naty: res.Output.Baseinfo.Naty,
  14390. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14391. PsnName: res.Output.Baseinfo.PsnName,
  14392. Idetinfo: idetinfoStr,
  14393. Insuinfo: infoStr,
  14394. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14395. CardInfo: basStr,
  14396. InsuplcAdmdvs: insuplc_admdvs,
  14397. VerifyNumber: "",
  14398. }
  14399. service.CreateHisPsn(psn)
  14400. c.ServeSuccessJSON(map[string]interface{}{
  14401. "patient": patient,
  14402. "number": basNumber,
  14403. "insutype": insutype,
  14404. })
  14405. }
  14406. } else {
  14407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14408. return
  14409. }
  14410. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14411. basStr := c.GetBasBaseInfo22222()
  14412. fmt.Println(basStr)
  14413. if len(basStr) == 0 {
  14414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14415. return
  14416. }
  14417. fmt.Println(basStr)
  14418. bas := strings.Split(basStr, "|")
  14419. basNumber := bas[2] //卡号
  14420. card_sn := bas[3] //
  14421. id_card_No := bas[1] //卡号
  14422. fmt.Println(basNumber)
  14423. fmt.Println(card_sn)
  14424. fmt.Println(id_card_No)
  14425. var patient service.Patients
  14426. if len(id_card_No) == 0 {
  14427. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14428. } else {
  14429. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14430. }
  14431. 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)
  14432. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14433. var dat map[string]interface{}
  14434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14435. fmt.Println(dat)
  14436. } else {
  14437. fmt.Println(err)
  14438. }
  14439. userJSONBytes, _ := json.Marshal(dat)
  14440. var res ResultTwo
  14441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14442. utils.ErrorLog("解析失败:%v", err)
  14443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14444. return
  14445. }
  14446. if res.Infcode == 0 {
  14447. var pateint2 service.Patients
  14448. var err error
  14449. if len(id_card_No) == 0 {
  14450. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14451. } else {
  14452. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14453. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14454. }
  14455. if err == gorm.ErrRecordNotFound {
  14456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14457. return
  14458. } else if err != nil {
  14459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14460. return
  14461. } else {
  14462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14463. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14464. infoStr := string(Iinfos)
  14465. idetinfoStr := string(Idetinfos)
  14466. var rf []*ResultFive
  14467. json.Unmarshal([]byte(infoStr), &rf)
  14468. var insutypes []*ResultFive
  14469. var insutype string
  14470. var is390 int = 0
  14471. var is310 int = 0
  14472. var insuplc_admdvs string
  14473. for _, item := range rf {
  14474. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14475. insutypes = append(insutypes, item)
  14476. }
  14477. }
  14478. if len(insutypes) == 1 {
  14479. insutype = insutypes[0].Insutype
  14480. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14481. } else {
  14482. for _, i := range insutypes {
  14483. if i.Insutype == "390" {
  14484. is390 = 1
  14485. }
  14486. if i.Insutype == "310" {
  14487. is310 = 1
  14488. }
  14489. }
  14490. }
  14491. if is390 == 1 {
  14492. insutype = "390"
  14493. }
  14494. if is310 == 1 {
  14495. insutype = "310"
  14496. }
  14497. if len(insutypes) == 0 {
  14498. insutype = "310"
  14499. }
  14500. for _, item := range rf {
  14501. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14502. insuplc_admdvs = item.InsuplcAdmdvs
  14503. }
  14504. }
  14505. psn := &models.HisPsn{
  14506. PsnNo: res.Output.Baseinfo.PsnNo,
  14507. PatientId: pateint2.ID,
  14508. Certno: res.Output.Baseinfo.Certno,
  14509. Gend: res.Output.Baseinfo.Gend,
  14510. Naty: res.Output.Baseinfo.Naty,
  14511. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14512. PsnName: res.Output.Baseinfo.PsnName,
  14513. Idetinfo: idetinfoStr,
  14514. Insuinfo: infoStr,
  14515. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14516. CardInfo: basStr,
  14517. InsuplcAdmdvs: insuplc_admdvs,
  14518. VerifyNumber: "",
  14519. }
  14520. service.CreateHisPsn(psn)
  14521. c.ServeSuccessJSON(map[string]interface{}{
  14522. "patient": patient,
  14523. "number": basNumber,
  14524. "insutype": insutype,
  14525. })
  14526. }
  14527. } else {
  14528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14529. return
  14530. }
  14531. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14532. fmt.Println(initFlag)
  14533. fmt.Println("initFlag")
  14534. if initFlag == 0 {
  14535. c.TestGetJiangXiBasBaseInittwo()
  14536. }
  14537. basStr := c.GetBasBaseInfo()
  14538. if len(basStr) == 0 {
  14539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14540. return
  14541. }
  14542. fmt.Println(basStr)
  14543. bas := strings.Split(basStr, "|")
  14544. basNumber := bas[1]
  14545. fmt.Println(basNumber)
  14546. card_sn := bas[3]
  14547. fmt.Println(card_sn)
  14548. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14549. 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)
  14550. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14551. var dat map[string]interface{}
  14552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14553. fmt.Println(dat)
  14554. } else {
  14555. fmt.Println(err)
  14556. }
  14557. userJSONBytes, _ := json.Marshal(dat)
  14558. var res ResultTwo
  14559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14560. utils.ErrorLog("解析失败:%v", err)
  14561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14562. return
  14563. }
  14564. if res.Infcode == 0 {
  14565. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14566. if err == gorm.ErrRecordNotFound {
  14567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14568. return
  14569. } else if err != nil {
  14570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14571. return
  14572. } else {
  14573. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14574. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14575. infoStr := string(Iinfos)
  14576. idetinfoStr := string(Idetinfos)
  14577. var rf []*ResultFive
  14578. json.Unmarshal([]byte(infoStr), &rf)
  14579. var insutypes []*ResultFive
  14580. var insutype string
  14581. var is390 int = 0
  14582. var is310 int = 0
  14583. var insuplc_admdvs string
  14584. for _, item := range rf {
  14585. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14586. insutypes = append(insutypes, item)
  14587. }
  14588. }
  14589. if len(insutypes) == 1 {
  14590. insutype = insutypes[0].Insutype
  14591. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14592. } else {
  14593. for _, i := range insutypes {
  14594. if i.Insutype == "390" {
  14595. is390 = 1
  14596. }
  14597. if i.Insutype == "310" {
  14598. is310 = 1
  14599. }
  14600. }
  14601. }
  14602. if is390 == 1 {
  14603. insutype = "390"
  14604. }
  14605. if is310 == 1 {
  14606. insutype = "310"
  14607. }
  14608. if len(insutypes) == 0 {
  14609. insutype = "310"
  14610. }
  14611. for _, item := range rf {
  14612. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14613. insuplc_admdvs = item.InsuplcAdmdvs
  14614. }
  14615. }
  14616. psn := &models.HisPsn{
  14617. PsnNo: res.Output.Baseinfo.PsnNo,
  14618. PatientId: patient.ID,
  14619. Certno: res.Output.Baseinfo.Certno,
  14620. Gend: res.Output.Baseinfo.Gend,
  14621. Naty: res.Output.Baseinfo.Naty,
  14622. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14623. PsnName: res.Output.Baseinfo.PsnName,
  14624. Idetinfo: idetinfoStr,
  14625. Insuinfo: infoStr,
  14626. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14627. CardInfo: basStr,
  14628. InsuplcAdmdvs: insuplc_admdvs,
  14629. VerifyNumber: "",
  14630. }
  14631. service.CreateHisPsn(psn)
  14632. c.ServeSuccessJSON(map[string]interface{}{
  14633. "patient": patient,
  14634. "number": basNumber,
  14635. "insutype": insutype,
  14636. })
  14637. }
  14638. } else {
  14639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14640. return
  14641. }
  14642. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14643. fmt.Println(initFlag)
  14644. fmt.Println("initFlag")
  14645. if initFlag == 0 {
  14646. c.TestGetHnBasBaseInit()
  14647. }
  14648. basStr := c.GetBasBaseInfo()
  14649. if len(basStr) == 0 {
  14650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14651. return
  14652. }
  14653. fmt.Println(basStr)
  14654. bas := strings.Split(basStr, "|")
  14655. basNumber := bas[1]
  14656. fmt.Println(basNumber)
  14657. card_sn := bas[3]
  14658. card_no := bas[2]
  14659. fmt.Println(card_sn)
  14660. name := bas[4]
  14661. name = ConvertToString(name, "gbk", "utf-8")
  14662. 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)
  14663. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14664. var dat map[string]interface{}
  14665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14666. fmt.Println(dat)
  14667. } else {
  14668. fmt.Println(err)
  14669. }
  14670. userJSONBytes, _ := json.Marshal(dat)
  14671. var res ResultTwo
  14672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14673. utils.ErrorLog("解析失败:%v", err)
  14674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14675. return
  14676. }
  14677. if res.Infcode == 0 {
  14678. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14679. if err == gorm.ErrRecordNotFound {
  14680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14681. return
  14682. } else if err != nil {
  14683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14684. return
  14685. } else {
  14686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14688. infoStr := string(Iinfos)
  14689. idetinfoStr := string(Idetinfos)
  14690. psn := &models.HisPsn{
  14691. PsnNo: res.Output.Baseinfo.PsnNo,
  14692. PatientId: patient.ID,
  14693. Certno: res.Output.Baseinfo.Certno,
  14694. Gend: res.Output.Baseinfo.Gend,
  14695. Naty: res.Output.Baseinfo.Naty,
  14696. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14697. PsnName: res.Output.Baseinfo.PsnName,
  14698. Idetinfo: idetinfoStr,
  14699. Insuinfo: infoStr,
  14700. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14701. CardInfo: basStr,
  14702. VerifyNumber: "",
  14703. }
  14704. service.CreateHisPsn(psn)
  14705. var rf []*ResultFive
  14706. json.Unmarshal([]byte(infoStr), &rf)
  14707. var insutypes []*ResultFive
  14708. var insutype string
  14709. var is390 int = 0
  14710. var is310 int = 0
  14711. for _, item := range rf {
  14712. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14713. insutypes = append(insutypes, item)
  14714. }
  14715. }
  14716. if len(insutypes) == 1 {
  14717. insutype = insutypes[0].Insutype
  14718. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14719. } else {
  14720. for _, i := range insutypes {
  14721. if i.Insutype == "390" {
  14722. is390 = 1
  14723. }
  14724. if i.Insutype == "310" {
  14725. is310 = 1
  14726. }
  14727. }
  14728. }
  14729. if is390 == 1 {
  14730. insutype = "390"
  14731. }
  14732. if is310 == 1 {
  14733. insutype = "310"
  14734. }
  14735. if len(insutypes) == 0 {
  14736. insutype = "310"
  14737. }
  14738. c.ServeSuccessJSON(map[string]interface{}{
  14739. "patient": patient,
  14740. "number": basNumber,
  14741. "insutype": insutype,
  14742. })
  14743. }
  14744. } else {
  14745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14746. return
  14747. }
  14748. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14749. var api string
  14750. 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 +
  14751. "&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
  14752. fmt.Println(api)
  14753. resp, requestErr := http.Get(api)
  14754. if requestErr != nil {
  14755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14756. return
  14757. }
  14758. body, ioErr := ioutil.ReadAll(resp.Body)
  14759. if ioErr != nil {
  14760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14762. return
  14763. }
  14764. var respJSON map[string]interface{}
  14765. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14768. return
  14769. }
  14770. var res ResultTwo //1101结果
  14771. var res10265 ResultTwo10265 //1101结果
  14772. var card_info string //卡信息
  14773. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14774. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14775. result, _ := json.Marshal(respJSON)
  14776. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14777. utils.ErrorLog("解析失败:%v", err)
  14778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14779. return
  14780. }
  14781. res.ErrMsg = res10265.ErrMsg
  14782. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14783. res.Infcode = infocode
  14784. res.Output = res10265.Output
  14785. res.InfRefmsgid = res10265.InfRefmsgid
  14786. if res.Infcode == 0 {
  14787. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14788. if err == gorm.ErrRecordNotFound {
  14789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14790. return
  14791. } else if err != nil {
  14792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14793. return
  14794. } else {
  14795. bas := strings.Split(card_info, "|")
  14796. basNumber := bas[2]
  14797. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14798. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14799. infoStr := string(Iinfos)
  14800. idetinfoStr := string(Idetinfos)
  14801. psn := &models.HisPsn{
  14802. PsnNo: res.Output.Baseinfo.PsnNo,
  14803. PatientId: patient.ID,
  14804. Certno: res.Output.Baseinfo.Certno,
  14805. Gend: res.Output.Baseinfo.Gend,
  14806. Naty: res.Output.Baseinfo.Naty,
  14807. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14808. PsnName: res.Output.Baseinfo.PsnName,
  14809. Idetinfo: idetinfoStr,
  14810. Insuinfo: infoStr,
  14811. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14812. CardInfo: card_info,
  14813. VerifyNumber: token,
  14814. }
  14815. service.CreateHisPsn(psn)
  14816. var rf []*ResultFive
  14817. json.Unmarshal([]byte(infoStr), &rf)
  14818. var insutypes []*ResultFive
  14819. var insutype string
  14820. var is390 int = 0
  14821. var is310 int = 0
  14822. for _, item := range rf {
  14823. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14824. insutypes = append(insutypes, item)
  14825. }
  14826. }
  14827. if len(insutypes) == 1 {
  14828. insutype = insutypes[0].Insutype
  14829. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14830. } else {
  14831. for _, i := range insutypes {
  14832. if i.Insutype == "390" {
  14833. is390 = 1
  14834. }
  14835. if i.Insutype == "310" {
  14836. is310 = 1
  14837. }
  14838. }
  14839. }
  14840. if is390 == 1 {
  14841. insutype = "390"
  14842. }
  14843. if is310 == 1 {
  14844. insutype = "310"
  14845. }
  14846. if len(insutypes) == 0 {
  14847. insutype = "310"
  14848. }
  14849. c.ServeSuccessJSON(map[string]interface{}{
  14850. "patient": patient,
  14851. "number": basNumber,
  14852. "insutype": insutype,
  14853. })
  14854. }
  14855. } else {
  14856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14857. return
  14858. }
  14859. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14860. res := c.GetoleInfo()
  14861. if res.Infcode == 0 {
  14862. var result string
  14863. if res.Output.MdtrtCertType == "01" {
  14864. 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)
  14865. } else if res.Output.MdtrtCertType == "02" {
  14866. 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)
  14867. } else if res.Output.MdtrtCertType == "03" {
  14868. 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)
  14869. }
  14870. var dat map[string]interface{}
  14871. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14872. fmt.Println(dat)
  14873. } else {
  14874. fmt.Println(err)
  14875. }
  14876. userJSONBytes, _ := json.Marshal(dat)
  14877. var res2 ResultTwo
  14878. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14879. utils.ErrorLog("解析失败:%v", err)
  14880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14881. return
  14882. }
  14883. if res2.Infcode == 0 {
  14884. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14885. if err == gorm.ErrRecordNotFound {
  14886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14887. return
  14888. } else if err != nil {
  14889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14890. return
  14891. } else {
  14892. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14893. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14894. infoStr := string(Iinfos)
  14895. idetinfoStr := string(Idetinfos)
  14896. var rf []*ResultFive
  14897. json.Unmarshal([]byte(infoStr), &rf)
  14898. var insutypes []*ResultFive
  14899. var insutype string
  14900. var is390 int = 0
  14901. var is310 int = 0
  14902. //var insuplc_admdvs string
  14903. for _, item := range rf {
  14904. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14905. insutypes = append(insutypes, item)
  14906. }
  14907. }
  14908. if len(insutypes) == 1 {
  14909. insutype = insutypes[0].Insutype
  14910. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14911. } else {
  14912. for _, i := range insutypes {
  14913. if i.Insutype == "390" {
  14914. is390 = 1
  14915. }
  14916. if i.Insutype == "310" {
  14917. is310 = 1
  14918. }
  14919. }
  14920. }
  14921. if is390 == 1 {
  14922. insutype = "390"
  14923. }
  14924. if is310 == 1 {
  14925. insutype = "310"
  14926. }
  14927. if len(insutypes) == 0 {
  14928. insutype = "310"
  14929. }
  14930. psn := &models.HisPsn{
  14931. PsnNo: res2.Output.Baseinfo.PsnNo,
  14932. PatientId: patient.ID,
  14933. Certno: res2.Output.Baseinfo.Certno,
  14934. Gend: res2.Output.Baseinfo.Gend,
  14935. Naty: res2.Output.Baseinfo.Naty,
  14936. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14937. PsnName: res2.Output.Baseinfo.PsnName,
  14938. Idetinfo: idetinfoStr,
  14939. Insuinfo: infoStr,
  14940. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14941. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14942. VerifyNumber: res.Output.EcToken,
  14943. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14944. }
  14945. if res.Output.MdtrtCertType == "01" {
  14946. psn.VerifyNumber = res.Output.EcToken
  14947. //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)
  14948. } else if res.Output.MdtrtCertType == "02" {
  14949. psn.VerifyNumber = res.Output.MdtrtCertNo
  14950. //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)
  14951. } else if res.Output.MdtrtCertType == "03" {
  14952. psn.VerifyNumber = res.Output.MdtrtCertNo
  14953. //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)
  14954. }
  14955. var balc float64
  14956. for _, item := range rf {
  14957. if item.Insutype == insutype {
  14958. balc = item.Balc
  14959. }
  14960. }
  14961. service.CreateHisPsn(psn)
  14962. c.ServeSuccessJSON(map[string]interface{}{
  14963. "patient": patient,
  14964. "number": res.Output.CardNo,
  14965. "insutype": insutype,
  14966. "blac": balc,
  14967. "desc": idetinfoStr,
  14968. })
  14969. }
  14970. } else {
  14971. c.ServeSuccessJSON(map[string]interface{}{
  14972. "failed_code": -10,
  14973. "msg": res2.ErrMsg,
  14974. })
  14975. }
  14976. } else {
  14977. c.ServeSuccessJSON(map[string]interface{}{
  14978. "failed_code": -10,
  14979. "msg": res.ErrMsg,
  14980. })
  14981. }
  14982. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14983. var api string
  14984. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14985. "&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
  14986. fmt.Println(api)
  14987. resp, requestErr := http.Get(api)
  14988. if requestErr != nil {
  14989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14990. return
  14991. }
  14992. body, ioErr := ioutil.ReadAll(resp.Body)
  14993. if ioErr != nil {
  14994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14996. return
  14997. }
  14998. var respJSON map[string]interface{}
  14999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15002. return
  15003. }
  15004. var status string
  15005. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15006. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15007. //console.log()
  15008. fmt.Println("type===")
  15009. fmt.Println(card_type)
  15010. var token string
  15011. var res ResultTwo //1101结果
  15012. //var res10265 ResultTwoesultTwo10265 //1101结果
  15013. var card_info string //卡信息
  15014. var busi_card_info string
  15015. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15016. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15017. if status == "0" { //读卡成功
  15018. if card_type == "1" {
  15019. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15020. result, _ := json.Marshal(respJSON)
  15021. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15022. utils.ErrorLog("解析失败:%v", err)
  15023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15024. return
  15025. }
  15026. } else {
  15027. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15028. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15029. result, _ := json.Marshal(respJSON)
  15030. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15031. utils.ErrorLog("解析失败:%v", err)
  15032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15033. return
  15034. }
  15035. }
  15036. if res.Infcode == 0 {
  15037. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15038. if err == gorm.ErrRecordNotFound {
  15039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15040. return
  15041. } else if err != nil {
  15042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15043. return
  15044. } else {
  15045. if card_type == "1" {
  15046. bas := strings.Split(card_info, "|")
  15047. basNumber := bas[2]
  15048. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15049. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15050. infoStr := string(Iinfos)
  15051. idetinfoStr := string(Idetinfos)
  15052. psn := &models.HisPsn{
  15053. PsnNo: res.Output.Baseinfo.PsnNo,
  15054. PatientId: patient.ID,
  15055. Certno: res.Output.Baseinfo.Certno,
  15056. Gend: res.Output.Baseinfo.Gend,
  15057. Naty: res.Output.Baseinfo.Naty,
  15058. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15059. PsnName: res.Output.Baseinfo.PsnName,
  15060. Idetinfo: idetinfoStr,
  15061. Insuinfo: infoStr,
  15062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15063. CardInfo: card_info,
  15064. VerifyNumber: busi_card_info,
  15065. }
  15066. service.CreateHisPsn(psn)
  15067. var rf []*ResultFive
  15068. json.Unmarshal([]byte(infoStr), &rf)
  15069. var insutypes []*ResultFive
  15070. var insutype string
  15071. var is390 int = 0
  15072. var is310 int = 0
  15073. for _, item := range rf {
  15074. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15075. insutypes = append(insutypes, item)
  15076. }
  15077. }
  15078. if len(insutypes) == 1 {
  15079. insutype = insutypes[0].Insutype
  15080. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15081. } else {
  15082. for _, i := range insutypes {
  15083. if i.Insutype == "390" {
  15084. is390 = 1
  15085. }
  15086. if i.Insutype == "310" {
  15087. is310 = 1
  15088. }
  15089. }
  15090. }
  15091. if is390 == 1 {
  15092. insutype = "390"
  15093. }
  15094. if is310 == 1 {
  15095. insutype = "310"
  15096. }
  15097. if len(insutypes) == 0 {
  15098. insutype = "310"
  15099. }
  15100. c.ServeSuccessJSON(map[string]interface{}{
  15101. "patient": patient,
  15102. "number": basNumber,
  15103. "insutype": insutype,
  15104. })
  15105. } else {
  15106. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15107. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15108. infoStr := string(Iinfos)
  15109. idetinfoStr := string(Idetinfos)
  15110. psn := &models.HisPsn{
  15111. PsnNo: res.Output.Baseinfo.PsnNo,
  15112. PatientId: patient.ID,
  15113. Certno: res.Output.Baseinfo.Certno,
  15114. Gend: res.Output.Baseinfo.Gend,
  15115. Naty: res.Output.Baseinfo.Naty,
  15116. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15117. PsnName: res.Output.Baseinfo.PsnName,
  15118. Idetinfo: idetinfoStr,
  15119. Insuinfo: infoStr,
  15120. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15121. CardInfo: card_info,
  15122. VerifyNumber: token,
  15123. }
  15124. service.CreateHisPsn(psn)
  15125. c.ServeSuccessJSON(map[string]interface{}{
  15126. "patient": patient,
  15127. "number": token,
  15128. })
  15129. }
  15130. }
  15131. } else {
  15132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15133. return
  15134. }
  15135. } else { //读卡失败
  15136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15137. return
  15138. }
  15139. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15140. var api string
  15141. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15142. "&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
  15143. fmt.Println(api)
  15144. resp, requestErr := http.Get(api)
  15145. if requestErr != nil {
  15146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15147. return
  15148. }
  15149. body, ioErr := ioutil.ReadAll(resp.Body)
  15150. if ioErr != nil {
  15151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15153. return
  15154. }
  15155. var respJSON map[string]interface{}
  15156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15159. return
  15160. }
  15161. var status string
  15162. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15163. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15164. //console.log()
  15165. fmt.Println("type===")
  15166. fmt.Println(card_type)
  15167. var token string
  15168. var res ResultTwo //1101结果
  15169. //var res10265 ResultTwoesultTwo10265 //1101结果
  15170. var card_info string //卡信息
  15171. //var busi_card_info string
  15172. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15173. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15174. if status == "0" { //读卡成功
  15175. if card_type == "1" {
  15176. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15177. result, _ := json.Marshal(respJSON)
  15178. fmt.Println(result)
  15179. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15180. utils.ErrorLog("解析失败:%v", err)
  15181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15182. return
  15183. }
  15184. fmt.Println(res)
  15185. } else {
  15186. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15187. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15188. result, _ := json.Marshal(respJSON)
  15189. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15190. utils.ErrorLog("解析失败:%v", err)
  15191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15192. return
  15193. }
  15194. }
  15195. if res.Infcode == 0 {
  15196. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15197. if err == gorm.ErrRecordNotFound {
  15198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15199. return
  15200. } else if err != nil {
  15201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15202. return
  15203. } else {
  15204. if card_type == "1" {
  15205. bas := strings.Split(card_info, "|")
  15206. basNumber := bas[2]
  15207. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15208. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15209. infoStr := string(Iinfos)
  15210. idetinfoStr := string(Idetinfos)
  15211. psn := &models.HisPsn{
  15212. PsnNo: res.Output.Baseinfo.PsnNo,
  15213. PatientId: patient.ID,
  15214. Certno: res.Output.Baseinfo.Certno,
  15215. Gend: res.Output.Baseinfo.Gend,
  15216. Naty: res.Output.Baseinfo.Naty,
  15217. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15218. PsnName: res.Output.Baseinfo.PsnName,
  15219. Idetinfo: idetinfoStr,
  15220. Insuinfo: infoStr,
  15221. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15222. CardInfo: card_info,
  15223. //VerifyNumber: busi_card_info,
  15224. }
  15225. service.CreateHisPsn(psn)
  15226. var rf []*ResultFive
  15227. json.Unmarshal([]byte(infoStr), &rf)
  15228. var insutypes []*ResultFive
  15229. var insutype string
  15230. var is390 int = 0
  15231. var is310 int = 0
  15232. for _, item := range rf {
  15233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15234. insutypes = append(insutypes, item)
  15235. }
  15236. }
  15237. if len(insutypes) == 1 {
  15238. insutype = insutypes[0].Insutype
  15239. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15240. } else {
  15241. for _, i := range insutypes {
  15242. if i.Insutype == "390" {
  15243. is390 = 1
  15244. }
  15245. if i.Insutype == "310" {
  15246. is310 = 1
  15247. }
  15248. }
  15249. }
  15250. if is390 == 1 {
  15251. insutype = "390"
  15252. }
  15253. if is310 == 1 {
  15254. insutype = "310"
  15255. }
  15256. if len(insutypes) == 0 {
  15257. insutype = "310"
  15258. }
  15259. c.ServeSuccessJSON(map[string]interface{}{
  15260. "patient": patient,
  15261. "number": basNumber,
  15262. "insutype": insutype,
  15263. })
  15264. } else {
  15265. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15266. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15267. infoStr := string(Iinfos)
  15268. idetinfoStr := string(Idetinfos)
  15269. psn := &models.HisPsn{
  15270. PsnNo: res.Output.Baseinfo.PsnNo,
  15271. PatientId: patient.ID,
  15272. Certno: res.Output.Baseinfo.Certno,
  15273. Gend: res.Output.Baseinfo.Gend,
  15274. Naty: res.Output.Baseinfo.Naty,
  15275. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15276. PsnName: res.Output.Baseinfo.PsnName,
  15277. Idetinfo: idetinfoStr,
  15278. Insuinfo: infoStr,
  15279. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15280. CardInfo: card_info,
  15281. VerifyNumber: token,
  15282. }
  15283. service.CreateHisPsn(psn)
  15284. c.ServeSuccessJSON(map[string]interface{}{
  15285. "patient": patient,
  15286. "number": token,
  15287. })
  15288. }
  15289. }
  15290. } else {
  15291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15292. return
  15293. }
  15294. } else { //读卡失败
  15295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15296. return
  15297. }
  15298. } else {
  15299. if initFlag == 0 {
  15300. c.TestGetBasBaseInit()
  15301. }
  15302. basStr := c.GetBasBaseInfo()
  15303. if len(basStr) == 0 {
  15304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15305. return
  15306. }
  15307. fmt.Println(basStr)
  15308. bas := strings.Split(basStr, "|")
  15309. basNumber := bas[1]
  15310. fmt.Println(basNumber)
  15311. card_sn := bas[3]
  15312. fmt.Println(card_sn)
  15313. cardNumber := bas[2]
  15314. fmt.Println(cardNumber)
  15315. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15316. var result string
  15317. if bas[0][:2] == "44" {
  15318. 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)
  15319. } else {
  15320. 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)
  15321. }
  15322. var dat map[string]interface{}
  15323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15324. fmt.Println(dat)
  15325. } else {
  15326. fmt.Println(err)
  15327. }
  15328. userJSONBytes, _ := json.Marshal(dat)
  15329. var res ResultTwo
  15330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15331. utils.ErrorLog("解析失败:%v", err)
  15332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15333. return
  15334. }
  15335. if res.Infcode == 0 {
  15336. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15337. if err == gorm.ErrRecordNotFound {
  15338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15339. return
  15340. } else if err != nil {
  15341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15342. return
  15343. } else {
  15344. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15345. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15346. infoStr := string(Iinfos)
  15347. idetinfoStr := string(Idetinfos)
  15348. var rf []*ResultFive
  15349. json.Unmarshal([]byte(infoStr), &rf)
  15350. var insutypes []*ResultFive
  15351. var insutype string
  15352. var is390 int = 0
  15353. var is310 int = 0
  15354. var insuplc_admdvs string
  15355. for _, item := range rf {
  15356. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15357. insutypes = append(insutypes, item)
  15358. }
  15359. }
  15360. if len(insutypes) == 1 {
  15361. insutype = insutypes[0].Insutype
  15362. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15363. } else {
  15364. for _, i := range insutypes {
  15365. if i.Insutype == "390" {
  15366. is390 = 1
  15367. }
  15368. if i.Insutype == "310" {
  15369. is310 = 1
  15370. }
  15371. }
  15372. }
  15373. if is390 == 1 {
  15374. insutype = "390"
  15375. }
  15376. if is310 == 1 {
  15377. insutype = "310"
  15378. }
  15379. if len(insutypes) == 0 {
  15380. insutype = "310"
  15381. }
  15382. for _, item := range rf {
  15383. if item.Insutype == insutype {
  15384. insuplc_admdvs = item.InsuplcAdmdvs
  15385. }
  15386. }
  15387. psn := &models.HisPsn{
  15388. PsnNo: res.Output.Baseinfo.PsnNo,
  15389. PatientId: patient.ID,
  15390. Certno: res.Output.Baseinfo.Certno,
  15391. Gend: res.Output.Baseinfo.Gend,
  15392. Naty: res.Output.Baseinfo.Naty,
  15393. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15394. PsnName: res.Output.Baseinfo.PsnName,
  15395. Idetinfo: idetinfoStr,
  15396. Insuinfo: infoStr,
  15397. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15398. CardInfo: basStr,
  15399. VerifyNumber: "",
  15400. InsuplcAdmdvs: insuplc_admdvs,
  15401. }
  15402. service.CreateHisPsn(psn)
  15403. c.ServeSuccessJSON(map[string]interface{}{
  15404. "patient": patient,
  15405. "insutype": insutype,
  15406. "number": basNumber,
  15407. })
  15408. }
  15409. } else {
  15410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15411. return
  15412. }
  15413. break
  15414. }
  15415. case 2:
  15416. if miConfig.MdtrtareaAdmvs == "430800" {
  15417. if initFlag == 0 {
  15418. c.TestGetHnBasBaseInit()
  15419. }
  15420. SFZStr := c.GetSFZBaseInfo()
  15421. if len(SFZStr) == 0 {
  15422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15423. return
  15424. }
  15425. fmt.Println(SFZStr)
  15426. id_card_str := strings.Split(SFZStr, "^")
  15427. card_no := id_card_str[0]
  15428. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15429. //name := id_card_str[1]
  15430. //name = ConvertToString(name, "gbk", "utf-8")
  15431. 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)
  15432. var dat map[string]interface{}
  15433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15434. fmt.Println(dat)
  15435. } else {
  15436. fmt.Println(err)
  15437. }
  15438. userJSONBytes, _ := json.Marshal(dat)
  15439. var res ResultTwo
  15440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15441. utils.ErrorLog("解析失败:%v", err)
  15442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15443. return
  15444. }
  15445. if res.Infcode == 0 {
  15446. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15447. if err == gorm.ErrRecordNotFound {
  15448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15449. return
  15450. } else if err != nil {
  15451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15452. return
  15453. } else {
  15454. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15455. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15456. infoStr := string(Iinfos)
  15457. idetinfoStr := string(Idetinfos)
  15458. var rf []*ResultFive
  15459. json.Unmarshal([]byte(infoStr), &rf)
  15460. var insutypes []*ResultFive
  15461. var insutype string
  15462. var is390 int = 0
  15463. var is310 int = 0
  15464. for _, item := range rf {
  15465. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15466. insutypes = append(insutypes, item)
  15467. }
  15468. }
  15469. if len(insutypes) == 1 {
  15470. insutype = insutypes[0].Insutype
  15471. } else {
  15472. for _, i := range insutypes {
  15473. if i.Insutype == "390" {
  15474. is390 = 1
  15475. }
  15476. if i.Insutype == "310" {
  15477. is310 = 1
  15478. }
  15479. }
  15480. }
  15481. if is390 == 1 {
  15482. insutype = "390"
  15483. }
  15484. if is310 == 1 {
  15485. insutype = "310"
  15486. }
  15487. if len(insutypes) == 0 {
  15488. insutype = "310"
  15489. }
  15490. var InsuplcAdmdvs string
  15491. for _, item := range rf {
  15492. if item.Insutype == insutype {
  15493. InsuplcAdmdvs = item.InsuplcAdmdvs
  15494. }
  15495. }
  15496. psn := &models.HisPsn{
  15497. PsnNo: res.Output.Baseinfo.PsnNo,
  15498. PatientId: patient.ID,
  15499. Certno: res.Output.Baseinfo.Certno,
  15500. Gend: res.Output.Baseinfo.Gend,
  15501. Naty: res.Output.Baseinfo.Naty,
  15502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15503. PsnName: res.Output.Baseinfo.PsnName,
  15504. Idetinfo: idetinfoStr,
  15505. Insuinfo: infoStr,
  15506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15507. CardInfo: SFZStr,
  15508. VerifyNumber: "",
  15509. InsuplcAdmdvs: InsuplcAdmdvs,
  15510. }
  15511. service.CreateHisPsn(psn)
  15512. c.ServeSuccessJSON(map[string]interface{}{
  15513. "patient": patient,
  15514. "number": card_no,
  15515. "insutype": insutype,
  15516. })
  15517. }
  15518. } else {
  15519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15520. return
  15521. }
  15522. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15523. var res ResultTwo
  15524. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15525. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15526. "&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)
  15527. resp, requestErr := http.Get(api)
  15528. if requestErr != nil {
  15529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15530. return
  15531. }
  15532. body, ioErr := ioutil.ReadAll(resp.Body)
  15533. if ioErr != nil {
  15534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15536. return
  15537. }
  15538. var respJSON map[string]interface{}
  15539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15542. return
  15543. }
  15544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15545. result, _ := json.Marshal(respJSON)
  15546. fmt.Println("log")
  15547. fmt.Println(string(result))
  15548. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15549. utils.ErrorLog("解析失败:%v", err)
  15550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15551. return
  15552. }
  15553. if res.Infcode == 0 {
  15554. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15555. if err == gorm.ErrRecordNotFound {
  15556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15557. return
  15558. } else if err != nil {
  15559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15560. return
  15561. } else {
  15562. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15563. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15564. infoStr := string(Iinfos)
  15565. idetinfoStr := string(Idetinfos)
  15566. psn := &models.HisPsn{
  15567. PsnNo: res.Output.Baseinfo.PsnNo,
  15568. PatientId: patient.ID,
  15569. Certno: res.Output.Baseinfo.Certno,
  15570. Gend: res.Output.Baseinfo.Gend,
  15571. Naty: res.Output.Baseinfo.Naty,
  15572. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15573. PsnName: res.Output.Baseinfo.PsnName,
  15574. Idetinfo: idetinfoStr,
  15575. Insuinfo: infoStr,
  15576. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15577. }
  15578. service.CreateHisPsn(psn)
  15579. c.ServeSuccessJSON(map[string]interface{}{
  15580. "patient": patient,
  15581. "number": res.Output.Baseinfo.Certno,
  15582. })
  15583. }
  15584. } else {
  15585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15586. return
  15587. }
  15588. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15589. var res ResultTwo
  15590. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15591. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15592. "&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)
  15593. resp, requestErr := http.Get(api)
  15594. if requestErr != nil {
  15595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15596. return
  15597. }
  15598. body, ioErr := ioutil.ReadAll(resp.Body)
  15599. if ioErr != nil {
  15600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15602. return
  15603. }
  15604. var respJSON map[string]interface{}
  15605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15608. return
  15609. }
  15610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15611. result, _ := json.Marshal(respJSON)
  15612. fmt.Println("log")
  15613. fmt.Println(string(result))
  15614. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15615. utils.ErrorLog("解析失败:%v", err)
  15616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15617. return
  15618. }
  15619. if res.Infcode == 0 {
  15620. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15621. if err == gorm.ErrRecordNotFound {
  15622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15623. return
  15624. } else if err != nil {
  15625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15626. return
  15627. } else {
  15628. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15629. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15630. infoStr := string(Iinfos)
  15631. idetinfoStr := string(Idetinfos)
  15632. psn := &models.HisPsn{
  15633. PsnNo: res.Output.Baseinfo.PsnNo,
  15634. PatientId: patient.ID,
  15635. Certno: res.Output.Baseinfo.Certno,
  15636. Gend: res.Output.Baseinfo.Gend,
  15637. Naty: res.Output.Baseinfo.Naty,
  15638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15639. PsnName: res.Output.Baseinfo.PsnName,
  15640. Idetinfo: idetinfoStr,
  15641. Insuinfo: infoStr,
  15642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15643. }
  15644. service.CreateHisPsn(psn)
  15645. c.ServeSuccessJSON(map[string]interface{}{
  15646. "patient": patient,
  15647. "number": res.Output.Baseinfo.Certno,
  15648. })
  15649. }
  15650. } else {
  15651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15652. return
  15653. }
  15654. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15655. var res ResultTwo
  15656. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15657. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15658. "&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)
  15659. resp, requestErr := http.Get(api)
  15660. if requestErr != nil {
  15661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15662. return
  15663. }
  15664. body, ioErr := ioutil.ReadAll(resp.Body)
  15665. if ioErr != nil {
  15666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15668. return
  15669. }
  15670. var respJSON map[string]interface{}
  15671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15674. return
  15675. }
  15676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15677. result, _ := json.Marshal(respJSON)
  15678. fmt.Println("log")
  15679. fmt.Println(string(result))
  15680. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15681. utils.ErrorLog("解析失败:%v", err)
  15682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15683. return
  15684. }
  15685. if res.Infcode == 0 {
  15686. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15687. if err == gorm.ErrRecordNotFound {
  15688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15689. return
  15690. } else if err != nil {
  15691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15692. return
  15693. } else {
  15694. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15695. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15696. infoStr := string(Iinfos)
  15697. idetinfoStr := string(Idetinfos)
  15698. var rf []*ResultFive
  15699. json.Unmarshal([]byte(infoStr), &rf)
  15700. var insutypes []*ResultFive
  15701. var insutype string
  15702. var is390 int = 0
  15703. var is310 int = 0
  15704. for _, item := range rf {
  15705. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15706. insutypes = append(insutypes, item)
  15707. }
  15708. }
  15709. if len(insutypes) == 1 {
  15710. insutype = insutypes[0].Insutype
  15711. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15712. } else {
  15713. for _, i := range insutypes {
  15714. if i.Insutype == "390" {
  15715. is390 = 1
  15716. }
  15717. if i.Insutype == "310" {
  15718. is310 = 1
  15719. }
  15720. }
  15721. }
  15722. if is390 == 1 {
  15723. insutype = "390"
  15724. }
  15725. if is310 == 1 {
  15726. insutype = "310"
  15727. }
  15728. if len(insutypes) == 0 {
  15729. insutype = "390"
  15730. }
  15731. var insuplc_admdvs string
  15732. for _, item := range rf {
  15733. if item.Insutype == insutype {
  15734. insuplc_admdvs = item.InsuplcAdmdvs
  15735. }
  15736. }
  15737. psn := &models.HisPsn{
  15738. PsnNo: res.Output.Baseinfo.PsnNo,
  15739. PatientId: patient.ID,
  15740. Certno: res.Output.Baseinfo.Certno,
  15741. Gend: res.Output.Baseinfo.Gend,
  15742. Naty: res.Output.Baseinfo.Naty,
  15743. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15744. PsnName: res.Output.Baseinfo.PsnName,
  15745. Idetinfo: idetinfoStr,
  15746. Insuinfo: infoStr,
  15747. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15748. InsuplcAdmdvs: insuplc_admdvs,
  15749. }
  15750. service.CreateHisPsn(psn)
  15751. c.ServeSuccessJSON(map[string]interface{}{
  15752. "patient": patient,
  15753. "number": res.Output.Baseinfo.Certno,
  15754. })
  15755. }
  15756. } else {
  15757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15758. return
  15759. }
  15760. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15761. res := c.GetoleInfo()
  15762. if res.Infcode == 0 {
  15763. var result string
  15764. if res.Output.MdtrtCertType == "01" {
  15765. 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)
  15766. } else if res.Output.MdtrtCertType == "02" {
  15767. 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)
  15768. } else if res.Output.MdtrtCertType == "03" {
  15769. 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)
  15770. }
  15771. var dat map[string]interface{}
  15772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15773. fmt.Println(dat)
  15774. } else {
  15775. fmt.Println(err)
  15776. }
  15777. userJSONBytes, _ := json.Marshal(dat)
  15778. var res2 ResultTwo
  15779. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15780. utils.ErrorLog("解析失败:%v", err)
  15781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15782. return
  15783. }
  15784. if res2.Infcode == 0 {
  15785. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15786. if err == gorm.ErrRecordNotFound {
  15787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15788. return
  15789. } else if err != nil {
  15790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15791. return
  15792. } else {
  15793. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15794. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15795. infoStr := string(Iinfos)
  15796. idetinfoStr := string(Idetinfos)
  15797. var rf []*ResultFive
  15798. json.Unmarshal([]byte(infoStr), &rf)
  15799. var insutypes []*ResultFive
  15800. var insutype string
  15801. var is390 int = 0
  15802. var is310 int = 0
  15803. //var insuplc_admdvs string
  15804. for _, item := range rf {
  15805. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15806. insutypes = append(insutypes, item)
  15807. }
  15808. }
  15809. if len(insutypes) == 1 {
  15810. insutype = insutypes[0].Insutype
  15811. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15812. } else {
  15813. for _, i := range insutypes {
  15814. if i.Insutype == "390" {
  15815. is390 = 1
  15816. }
  15817. if i.Insutype == "310" {
  15818. is310 = 1
  15819. }
  15820. }
  15821. }
  15822. if is390 == 1 {
  15823. insutype = "390"
  15824. }
  15825. if is310 == 1 {
  15826. insutype = "310"
  15827. }
  15828. if len(insutypes) == 0 {
  15829. insutype = "310"
  15830. }
  15831. psn := &models.HisPsn{
  15832. PsnNo: res2.Output.Baseinfo.PsnNo,
  15833. PatientId: patient.ID,
  15834. //Brdy: res2.Output.Baseinfo.Brdy,
  15835. Certno: res2.Output.Baseinfo.Certno,
  15836. Gend: res2.Output.Baseinfo.Gend,
  15837. Naty: res2.Output.Baseinfo.Naty,
  15838. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15839. PsnName: res2.Output.Baseinfo.PsnName,
  15840. Idetinfo: idetinfoStr,
  15841. Insuinfo: infoStr,
  15842. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15843. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15844. VerifyNumber: res.Output.EcToken,
  15845. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15846. }
  15847. service.CreateHisPsn(psn)
  15848. var balc float64
  15849. for _, item := range rf {
  15850. if item.Insutype == insutype {
  15851. balc = item.Balc
  15852. }
  15853. }
  15854. c.ServeSuccessJSON(map[string]interface{}{
  15855. "patient": patient,
  15856. "number": res.Output.CardNo,
  15857. "insutype": insutype,
  15858. "blac": balc,
  15859. "desc": idetinfoStr,
  15860. })
  15861. }
  15862. } else {
  15863. c.ServeSuccessJSON(map[string]interface{}{
  15864. "failed_code": -10,
  15865. "msg": res2.ErrMsg,
  15866. })
  15867. }
  15868. } else {
  15869. c.ServeSuccessJSON(map[string]interface{}{
  15870. "failed_code": -10,
  15871. "msg": res.ErrMsg,
  15872. })
  15873. }
  15874. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15875. var insuplc_admdvs string
  15876. if len(patient.InsuplcAdmdvs) > 0 {
  15877. insuplc_admdvs = patient.InsuplcAdmdvs
  15878. } else {
  15879. if len(insuplc_admdvs_str) > 0 {
  15880. insuplc_admdvs = insuplc_admdvs_str
  15881. } else {
  15882. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15883. }
  15884. }
  15885. //请求内网数据
  15886. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15887. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15888. "&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=" + ""
  15889. resp, requestErr := http.Get(api)
  15890. if requestErr != nil {
  15891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15892. return
  15893. }
  15894. body, ioErr := ioutil.ReadAll(resp.Body)
  15895. if ioErr != nil {
  15896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15898. return
  15899. }
  15900. var respJSON map[string]interface{}
  15901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15904. return
  15905. }
  15906. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15907. if status == "0" {
  15908. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15909. c.ServeSuccessJSON(map[string]interface{}{
  15910. "failed_code": -10,
  15911. "msg": err_msg,
  15912. })
  15913. return
  15914. }
  15915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15916. var res ResultTwo
  15917. result, _ := json.Marshal(respJSON)
  15918. fmt.Println("log")
  15919. fmt.Println(string(result))
  15920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15921. utils.ErrorLog("解析失败:%v", err)
  15922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15923. return
  15924. }
  15925. if res.Infcode == 0 {
  15926. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15927. if err == gorm.ErrRecordNotFound {
  15928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15929. return
  15930. } else if err != nil {
  15931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15932. return
  15933. } else {
  15934. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15935. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15936. infoStr := string(Iinfos)
  15937. idetinfoStr := string(Idetinfos)
  15938. psn := &models.HisPsn{
  15939. PsnNo: res.Output.Baseinfo.PsnNo,
  15940. PatientId: patient.ID,
  15941. Certno: res.Output.Baseinfo.Certno,
  15942. Gend: res.Output.Baseinfo.Gend,
  15943. Naty: res.Output.Baseinfo.Naty,
  15944. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15945. PsnName: res.Output.Baseinfo.PsnName,
  15946. Idetinfo: idetinfoStr,
  15947. Insuinfo: infoStr,
  15948. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15949. }
  15950. service.CreateHisPsn(psn)
  15951. var rf []*ResultFive
  15952. json.Unmarshal([]byte(infoStr), &rf)
  15953. var insutypes []*ResultFive
  15954. var is390 int = 0
  15955. var is310 int = 0
  15956. var insutype string
  15957. for _, item := range rf {
  15958. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15959. insutypes = append(insutypes, item)
  15960. }
  15961. }
  15962. if len(insutypes) == 1 {
  15963. insutype = insutypes[0].Insutype
  15964. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15965. } else {
  15966. for _, i := range insutypes {
  15967. if i.Insutype == "390" {
  15968. is390 = 1
  15969. }
  15970. if i.Insutype == "310" {
  15971. is310 = 1
  15972. }
  15973. }
  15974. }
  15975. if is390 == 1 {
  15976. insutype = "390"
  15977. }
  15978. if is310 == 1 {
  15979. insutype = "310"
  15980. }
  15981. if len(insutypes) == 0 {
  15982. insutype = "390"
  15983. }
  15984. c.ServeSuccessJSON(map[string]interface{}{
  15985. "patient": patient,
  15986. "insutype": insutype,
  15987. "number": res.Output.Baseinfo.Certno,
  15988. "info": res,
  15989. })
  15990. }
  15991. } else {
  15992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15993. return
  15994. }
  15995. } else {
  15996. SFZStr := c.GetSFZBaseInfo()
  15997. id_card_str := strings.Split(SFZStr, "^")
  15998. id_card_number := id_card_str[0]
  15999. card_sn := ""
  16000. 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)
  16001. var dat map[string]interface{}
  16002. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16003. fmt.Println(dat)
  16004. } else {
  16005. fmt.Println(err)
  16006. }
  16007. userJSONBytes, _ := json.Marshal(dat)
  16008. var res ResultTwo
  16009. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16010. utils.ErrorLog("解析失败:%v", err)
  16011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16012. return
  16013. }
  16014. if res.Infcode == 0 {
  16015. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16016. if err == gorm.ErrRecordNotFound {
  16017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16018. return
  16019. } else if err != nil {
  16020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16021. return
  16022. } else {
  16023. c.ServeSuccessJSON(map[string]interface{}{
  16024. "patient": patient,
  16025. "number": id_card_number,
  16026. })
  16027. }
  16028. } else {
  16029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16030. return
  16031. }
  16032. }
  16033. break
  16034. case 3:
  16035. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16036. var api string
  16037. if miConfig.MdtrtareaAdmvs == "320830" {
  16038. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16039. "&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
  16040. fmt.Println(api)
  16041. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16042. 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 +
  16043. "&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
  16044. fmt.Println(api)
  16045. } else {
  16046. 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 +
  16047. "&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)
  16048. }
  16049. resp, requestErr := http.Get(api)
  16050. if requestErr != nil {
  16051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16052. return
  16053. }
  16054. body, ioErr := ioutil.ReadAll(resp.Body)
  16055. if ioErr != nil {
  16056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16058. return
  16059. }
  16060. var respJSON map[string]interface{}
  16061. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16064. return
  16065. }
  16066. var status string
  16067. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16068. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16069. var token string
  16070. var res ResultTwo //1101结果
  16071. var res10265 ResultTwo10265 //1101结果
  16072. var card_info string //卡信息
  16073. var busi_card_info string
  16074. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16075. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16076. if status == "0" { //读卡成功
  16077. if card_type == "1" {
  16078. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16079. result, _ := json.Marshal(respJSON)
  16080. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16081. utils.ErrorLog("解析失败:%v", err)
  16082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16083. return
  16084. }
  16085. res.ErrMsg = res10265.ErrMsg
  16086. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16087. res.Infcode = infocode
  16088. res.Output = res10265.Output
  16089. res.InfRefmsgid = res10265.InfRefmsgid
  16090. } else {
  16091. //var card_info string //卡信息
  16092. //var busi_card_info string
  16093. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16094. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16095. //fmt.Println(card_info)
  16096. //fmt.Println(busi_card_info)
  16097. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16098. result, _ := json.Marshal(respJSON)
  16099. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16100. utils.ErrorLog("解析失败:%v", err)
  16101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16102. return
  16103. }
  16104. res.ErrMsg = res10265.ErrMsg
  16105. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16106. res.Infcode = infocode
  16107. res.Output = res10265.Output
  16108. res.InfRefmsgid = res10265.InfRefmsgid
  16109. }
  16110. if res.Infcode == 0 {
  16111. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16112. if err == gorm.ErrRecordNotFound {
  16113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16114. return
  16115. } else if err != nil {
  16116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16117. return
  16118. } else {
  16119. if card_type == "1" {
  16120. bas := strings.Split(card_info, "|")
  16121. basNumber := bas[2]
  16122. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16123. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16124. infoStr := string(Iinfos)
  16125. idetinfoStr := string(Idetinfos)
  16126. psn := &models.HisPsn{
  16127. PsnNo: res.Output.Baseinfo.PsnNo,
  16128. PatientId: patient.ID,
  16129. Certno: res.Output.Baseinfo.Certno,
  16130. //Brdy: res.Output.Baseinfo.Brdy,
  16131. Gend: res.Output.Baseinfo.Gend,
  16132. Naty: res.Output.Baseinfo.Naty,
  16133. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16134. PsnName: res.Output.Baseinfo.PsnName,
  16135. Idetinfo: idetinfoStr,
  16136. Insuinfo: infoStr,
  16137. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16138. CardInfo: card_info,
  16139. VerifyNumber: busi_card_info,
  16140. }
  16141. service.CreateHisPsn(psn)
  16142. c.ServeSuccessJSON(map[string]interface{}{
  16143. "patient": patient,
  16144. "number": basNumber,
  16145. })
  16146. } else {
  16147. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16148. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16149. infoStr := string(Iinfos)
  16150. idetinfoStr := string(Idetinfos)
  16151. psn := &models.HisPsn{
  16152. PsnNo: res.Output.Baseinfo.PsnNo,
  16153. PatientId: patient.ID,
  16154. Certno: res.Output.Baseinfo.Certno,
  16155. Gend: res.Output.Baseinfo.Gend,
  16156. Naty: res.Output.Baseinfo.Naty,
  16157. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16158. PsnName: res.Output.Baseinfo.PsnName,
  16159. Idetinfo: idetinfoStr,
  16160. Insuinfo: infoStr,
  16161. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16162. CardInfo: card_info,
  16163. VerifyNumber: token,
  16164. }
  16165. service.CreateHisPsn(psn)
  16166. var rf []*ResultFive
  16167. json.Unmarshal([]byte(infoStr), &rf)
  16168. var insutypes []*ResultFive
  16169. var insutype string
  16170. var is390 int = 0
  16171. var is310 int = 0
  16172. for _, item := range rf {
  16173. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16174. insutypes = append(insutypes, item)
  16175. }
  16176. }
  16177. if len(insutypes) == 1 {
  16178. insutype = insutypes[0].Insutype
  16179. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16180. } else {
  16181. for _, i := range insutypes {
  16182. if i.Insutype == "390" {
  16183. is390 = 1
  16184. }
  16185. if i.Insutype == "310" {
  16186. is310 = 1
  16187. }
  16188. }
  16189. }
  16190. if is390 == 1 {
  16191. insutype = "390"
  16192. }
  16193. if is310 == 1 {
  16194. insutype = "310"
  16195. }
  16196. if len(insutypes) == 0 {
  16197. insutype = "310"
  16198. }
  16199. c.ServeSuccessJSON(map[string]interface{}{
  16200. "patient": patient,
  16201. "number": token,
  16202. "insutype": insutype,
  16203. })
  16204. }
  16205. }
  16206. } else {
  16207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16208. return
  16209. }
  16210. } else { //读卡失败
  16211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16212. return
  16213. }
  16214. }
  16215. break
  16216. case 4:
  16217. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16218. var api string
  16219. if miConfig.MdtrtareaAdmvs == "320830" {
  16220. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16221. "&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
  16222. fmt.Println(api)
  16223. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16224. 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 +
  16225. "&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
  16226. fmt.Println(api)
  16227. } else {
  16228. 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 +
  16229. "&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)
  16230. }
  16231. resp, requestErr := http.Get(api)
  16232. if requestErr != nil {
  16233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16234. return
  16235. }
  16236. body, ioErr := ioutil.ReadAll(resp.Body)
  16237. if ioErr != nil {
  16238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16240. return
  16241. }
  16242. var respJSON map[string]interface{}
  16243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16246. return
  16247. }
  16248. var status string
  16249. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16250. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16251. var token string
  16252. var res ResultTwo //1101结果
  16253. var res10265 ResultTwo10265 //1101结果
  16254. if status == "0" { //读卡成功
  16255. var card_info string //卡信息
  16256. var busi_card_info string
  16257. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16258. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16259. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16260. fmt.Println(card_info)
  16261. fmt.Println(busi_card_info)
  16262. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16263. result, _ := json.Marshal(respJSON)
  16264. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16265. utils.ErrorLog("解析失败:%v", err)
  16266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16267. return
  16268. }
  16269. res.ErrMsg = res10265.ErrMsg
  16270. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16271. res.Infcode = infocode
  16272. res.Output = res10265.Output
  16273. res.InfRefmsgid = res10265.InfRefmsgid
  16274. if res.Infcode == 0 {
  16275. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16276. if err == gorm.ErrRecordNotFound {
  16277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16278. return
  16279. } else if err != nil {
  16280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16281. return
  16282. } else {
  16283. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16284. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16285. infoStr := string(Iinfos)
  16286. idetinfoStr := string(Idetinfos)
  16287. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16288. psn := &models.HisPsn{
  16289. PsnNo: res.Output.Baseinfo.PsnNo,
  16290. PatientId: patient.ID,
  16291. Certno: res.Output.Baseinfo.Certno,
  16292. Brdy: b,
  16293. Age: float64(age),
  16294. //Brdy: res.Output.Baseinfo.Brdy,
  16295. Gend: res.Output.Baseinfo.Gend,
  16296. Naty: res.Output.Baseinfo.Naty,
  16297. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16298. PsnName: res.Output.Baseinfo.PsnName,
  16299. Idetinfo: idetinfoStr,
  16300. Insuinfo: infoStr,
  16301. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16302. CardInfo: card_info,
  16303. VerifyNumber: token,
  16304. }
  16305. var rf []*ResultFive
  16306. json.Unmarshal([]byte(infoStr), &rf)
  16307. var insutypes []*ResultFive
  16308. var insutype string
  16309. var is390 int = 0
  16310. var is310 int = 0
  16311. for _, item := range rf {
  16312. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16313. insutypes = append(insutypes, item)
  16314. }
  16315. }
  16316. if len(insutypes) == 1 {
  16317. insutype = insutypes[0].Insutype
  16318. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16319. } else {
  16320. for _, i := range insutypes {
  16321. if i.Insutype == "390" {
  16322. is390 = 1
  16323. }
  16324. if i.Insutype == "310" {
  16325. is310 = 1
  16326. }
  16327. }
  16328. }
  16329. if is390 == 1 {
  16330. insutype = "390"
  16331. }
  16332. if is310 == 1 {
  16333. insutype = "310"
  16334. }
  16335. if len(insutypes) == 0 {
  16336. insutype = "310"
  16337. }
  16338. service.CreateHisPsn(psn)
  16339. c.ServeSuccessJSON(map[string]interface{}{
  16340. "patient": patient,
  16341. "number": token,
  16342. "insutype": insutype,
  16343. })
  16344. }
  16345. } else {
  16346. c.ServeSuccessJSON(map[string]interface{}{
  16347. "failed_code": -10,
  16348. "msg": res.ErrMsg,
  16349. })
  16350. }
  16351. } else { //读卡失败
  16352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16353. return
  16354. }
  16355. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16356. var api string
  16357. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16358. "&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
  16359. resp, requestErr := http.Get(api)
  16360. if requestErr != nil {
  16361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16362. return
  16363. }
  16364. body, ioErr := ioutil.ReadAll(resp.Body)
  16365. if ioErr != nil {
  16366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16368. return
  16369. }
  16370. var respJSON map[string]interface{}
  16371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16374. return
  16375. }
  16376. var status string
  16377. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16378. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16379. var token string
  16380. var res ResultTwo //1101结果
  16381. if status == "1" { //读卡成功
  16382. var card_info string //卡信息
  16383. var busi_card_info string
  16384. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16385. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16386. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16387. fmt.Println(card_info)
  16388. fmt.Println(busi_card_info)
  16389. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16390. result, _ := json.Marshal(respJSON)
  16391. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16392. utils.ErrorLog("解析失败:%v", err)
  16393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16394. return
  16395. }
  16396. if res.Infcode == 0 {
  16397. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16398. if err == gorm.ErrRecordNotFound {
  16399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16400. return
  16401. } else if err != nil {
  16402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16403. return
  16404. } else {
  16405. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16406. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16407. infoStr := string(Iinfos)
  16408. idetinfoStr := string(Idetinfos)
  16409. psn := &models.HisPsn{
  16410. PsnNo: res.Output.Baseinfo.PsnNo,
  16411. PatientId: patient.ID,
  16412. Certno: res.Output.Baseinfo.Certno,
  16413. Gend: res.Output.Baseinfo.Gend,
  16414. Naty: res.Output.Baseinfo.Naty,
  16415. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16416. PsnName: res.Output.Baseinfo.PsnName,
  16417. Idetinfo: idetinfoStr,
  16418. Insuinfo: infoStr,
  16419. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16420. CardInfo: card_info,
  16421. VerifyNumber: token,
  16422. }
  16423. var rf []*ResultFive
  16424. json.Unmarshal([]byte(infoStr), &rf)
  16425. var insutypes []*ResultFive
  16426. var insutype string
  16427. var is390 int = 0
  16428. var is310 int = 0
  16429. for _, item := range rf {
  16430. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16431. insutypes = append(insutypes, item)
  16432. }
  16433. }
  16434. if len(insutypes) == 1 {
  16435. insutype = insutypes[0].Insutype
  16436. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16437. } else {
  16438. for _, i := range insutypes {
  16439. if i.Insutype == "390" {
  16440. is390 = 1
  16441. }
  16442. if i.Insutype == "310" {
  16443. is310 = 1
  16444. }
  16445. }
  16446. }
  16447. if is390 == 1 {
  16448. insutype = "390"
  16449. }
  16450. if is310 == 1 {
  16451. insutype = "310"
  16452. }
  16453. if len(insutypes) == 0 {
  16454. insutype = "310"
  16455. }
  16456. service.CreateHisPsn(psn)
  16457. c.ServeSuccessJSON(map[string]interface{}{
  16458. "patient": patient,
  16459. "number": token,
  16460. "insutype": insutype,
  16461. })
  16462. }
  16463. } else {
  16464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16465. return
  16466. }
  16467. } else { //读卡失败
  16468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16469. return
  16470. }
  16471. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16472. var api string
  16473. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16474. "&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
  16475. resp, requestErr := http.Get(api)
  16476. if requestErr != nil {
  16477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16478. return
  16479. }
  16480. body, ioErr := ioutil.ReadAll(resp.Body)
  16481. if ioErr != nil {
  16482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16484. return
  16485. }
  16486. var respJSON map[string]interface{}
  16487. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16490. return
  16491. }
  16492. var status string
  16493. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16494. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16495. var token string
  16496. var res ResultTwo //1101结果
  16497. if status == "1" { //读卡成功
  16498. var card_info string //卡信息
  16499. var busi_card_info string
  16500. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16501. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16502. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16503. fmt.Println(card_info)
  16504. fmt.Println(busi_card_info)
  16505. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16506. result, _ := json.Marshal(respJSON)
  16507. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16508. utils.ErrorLog("解析失败:%v", err)
  16509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16510. return
  16511. }
  16512. if res.Infcode == 0 {
  16513. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16514. if err == gorm.ErrRecordNotFound {
  16515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16516. return
  16517. } else if err != nil {
  16518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16519. return
  16520. } else {
  16521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16523. infoStr := string(Iinfos)
  16524. idetinfoStr := string(Idetinfos)
  16525. psn := &models.HisPsn{
  16526. PsnNo: res.Output.Baseinfo.PsnNo,
  16527. PatientId: patient.ID,
  16528. Certno: res.Output.Baseinfo.Certno,
  16529. Gend: res.Output.Baseinfo.Gend,
  16530. Naty: res.Output.Baseinfo.Naty,
  16531. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16532. PsnName: res.Output.Baseinfo.PsnName,
  16533. Idetinfo: idetinfoStr,
  16534. Insuinfo: infoStr,
  16535. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16536. CardInfo: card_info,
  16537. VerifyNumber: token,
  16538. }
  16539. var rf []*ResultFive
  16540. json.Unmarshal([]byte(infoStr), &rf)
  16541. var insutypes []*ResultFive
  16542. var insutype string
  16543. var is390 int = 0
  16544. var is310 int = 0
  16545. for _, item := range rf {
  16546. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16547. insutypes = append(insutypes, item)
  16548. }
  16549. }
  16550. if len(insutypes) == 1 {
  16551. insutype = insutypes[0].Insutype
  16552. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16553. } else {
  16554. for _, i := range insutypes {
  16555. if i.Insutype == "390" {
  16556. is390 = 1
  16557. }
  16558. if i.Insutype == "310" {
  16559. is310 = 1
  16560. }
  16561. }
  16562. }
  16563. if is390 == 1 {
  16564. insutype = "390"
  16565. }
  16566. if is310 == 1 {
  16567. insutype = "310"
  16568. }
  16569. if len(insutypes) == 0 {
  16570. insutype = "390"
  16571. }
  16572. service.CreateHisPsn(psn)
  16573. c.ServeSuccessJSON(map[string]interface{}{
  16574. "patient": patient,
  16575. "number": token,
  16576. "insutype": insutype,
  16577. })
  16578. }
  16579. } else {
  16580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16581. return
  16582. }
  16583. } else { //读卡失败
  16584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16585. return
  16586. }
  16587. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16588. //idNo := c.GetString("idNo")
  16589. //userName := c.GetString("userName")
  16590. //ecToken := c.GetString("ecToken")
  16591. //insuOrg := c.GetString("insuOrg")
  16592. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16593. utils.ErrorLog("解析失败:%v", json_result)
  16594. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16595. type ELeData struct {
  16596. Data struct {
  16597. IdNo string `json:"idNo"`
  16598. IdType string `json:"idType"`
  16599. UserName string `json:"userName"`
  16600. EcToken string `json:"ecToken"`
  16601. InsuOrg string `json:"insuOrg"`
  16602. Gender string `json:"gender"`
  16603. Birthday string `json:"birthday"`
  16604. Nationality string `json:"nationality"`
  16605. Email string `json:"email"`
  16606. Extra string `json:"extra"`
  16607. } `json:"data"`
  16608. Code int `json:"code"`
  16609. Message string `json:"message"`
  16610. }
  16611. var ele ELeData
  16612. err := json.Unmarshal([]byte(json_result), &ele)
  16613. if err != nil {
  16614. utils.ErrorLog("解析失败:%v", err)
  16615. }
  16616. token := ele.Data.EcToken
  16617. token = Remove0000(token)
  16618. 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)
  16619. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16620. var res ResultTwo
  16621. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16622. utils.ErrorLog("解析失败:%v", err)
  16623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16624. return
  16625. }
  16626. if res.Infcode == 0 {
  16627. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16628. if err == gorm.ErrRecordNotFound {
  16629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16630. return
  16631. } else if err != nil {
  16632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16633. return
  16634. } else {
  16635. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16636. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16637. infoStr := string(Iinfos)
  16638. idetinfoStr := string(Idetinfos)
  16639. psn := &models.HisPsn{
  16640. PsnNo: res.Output.Baseinfo.PsnNo,
  16641. PatientId: patient.ID,
  16642. Certno: res.Output.Baseinfo.Certno,
  16643. Gend: res.Output.Baseinfo.Gend,
  16644. Naty: res.Output.Baseinfo.Naty,
  16645. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16646. PsnName: res.Output.Baseinfo.PsnName,
  16647. Idetinfo: idetinfoStr,
  16648. Insuinfo: infoStr,
  16649. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16650. CardInfo: "",
  16651. Stage: "1",
  16652. VerifyNumber: token,
  16653. InsuplcAdmdvs: ele.Data.InsuOrg,
  16654. }
  16655. service.CreateHisPsn(psn)
  16656. var rf []*ResultFive
  16657. json.Unmarshal([]byte(infoStr), &rf)
  16658. var insutypes []*ResultFive
  16659. var insutype string
  16660. var is390 int = 0
  16661. var is310 int = 0
  16662. for _, item := range rf {
  16663. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16664. insutypes = append(insutypes, item)
  16665. }
  16666. }
  16667. if len(insutypes) == 1 {
  16668. insutype = insutypes[0].Insutype
  16669. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16670. } else {
  16671. for _, i := range insutypes {
  16672. if i.Insutype == "390" {
  16673. is390 = 1
  16674. }
  16675. if i.Insutype == "310" {
  16676. is310 = 1
  16677. }
  16678. }
  16679. }
  16680. if is390 == 1 {
  16681. insutype = "390"
  16682. }
  16683. if is310 == 1 {
  16684. insutype = "310"
  16685. }
  16686. if len(insutypes) == 0 {
  16687. insutype = "310"
  16688. }
  16689. c.ServeSuccessJSON(map[string]interface{}{
  16690. "patient": patient,
  16691. "number": token,
  16692. "insutype": insutype,
  16693. })
  16694. }
  16695. } else {
  16696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16697. return
  16698. }
  16699. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16700. //if initFlag == 0 {
  16701. //c.TestGetJiangXiBasBaseInit()
  16702. //}
  16703. //if initEleFlag == 0 {
  16704. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16705. //}
  16706. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16707. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16708. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16709. type ELeData struct {
  16710. Data struct {
  16711. IdNo string `json:"idNo"`
  16712. IdType string `json:"idType"`
  16713. UserName string `json:"userName"`
  16714. EcToken string `json:"ecToken"`
  16715. InsuOrg string `json:"insuOrg"`
  16716. Gender string `json:"gender"`
  16717. Birthday string `json:"birthday"`
  16718. Nationality string `json:"nationality"`
  16719. Email string `json:"email"`
  16720. Extra string `json:"extra"`
  16721. } `json:"data"`
  16722. Code int `json:"code"`
  16723. Message string `json:"message"`
  16724. }
  16725. var ele ELeData
  16726. err := json.Unmarshal([]byte(result), &ele)
  16727. if err != nil {
  16728. utils.ErrorLog("解析失败:%v", err)
  16729. }
  16730. token := ele.Data.EcToken
  16731. token = Remove0000(token)
  16732. 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)
  16733. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16734. var res ResultTwo
  16735. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16736. utils.ErrorLog("解析失败:%v", err)
  16737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16738. return
  16739. }
  16740. if res.Infcode == 0 {
  16741. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16742. if err == gorm.ErrRecordNotFound {
  16743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16744. return
  16745. } else if err != nil {
  16746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16747. return
  16748. } else {
  16749. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16750. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16751. infoStr := string(Iinfos)
  16752. idetinfoStr := string(Idetinfos)
  16753. psn := &models.HisPsn{
  16754. PsnNo: res.Output.Baseinfo.PsnNo,
  16755. PatientId: patient.ID,
  16756. Certno: res.Output.Baseinfo.Certno,
  16757. Gend: res.Output.Baseinfo.Gend,
  16758. Naty: res.Output.Baseinfo.Naty,
  16759. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16760. PsnName: res.Output.Baseinfo.PsnName,
  16761. Idetinfo: idetinfoStr,
  16762. Insuinfo: infoStr,
  16763. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16764. CardInfo: "",
  16765. VerifyNumber: token,
  16766. InsuplcAdmdvs: ele.Data.InsuOrg,
  16767. }
  16768. service.CreateHisPsn(psn)
  16769. var rf []*ResultFive
  16770. json.Unmarshal([]byte(infoStr), &rf)
  16771. var insutypes []*ResultFive
  16772. var insutype string
  16773. var is390 int = 0
  16774. var is310 int = 0
  16775. for _, item := range rf {
  16776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16777. insutypes = append(insutypes, item)
  16778. }
  16779. }
  16780. if len(insutypes) == 1 {
  16781. insutype = insutypes[0].Insutype
  16782. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16783. } else {
  16784. for _, i := range insutypes {
  16785. if i.Insutype == "390" {
  16786. is390 = 1
  16787. }
  16788. if i.Insutype == "310" {
  16789. is310 = 1
  16790. }
  16791. }
  16792. }
  16793. if is390 == 1 {
  16794. insutype = "390"
  16795. }
  16796. if is310 == 1 {
  16797. insutype = "310"
  16798. }
  16799. if len(insutypes) == 0 {
  16800. insutype = "310"
  16801. }
  16802. c.ServeSuccessJSON(map[string]interface{}{
  16803. "patient": patient,
  16804. "number": token,
  16805. "insutype": insutype,
  16806. })
  16807. }
  16808. } else {
  16809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16810. return
  16811. }
  16812. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16813. //if initFlag == 0 {
  16814. //c.TestGetJiangXiBasBaseInit()
  16815. //}
  16816. //if initEleFlag == 0 {
  16817. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16818. //}
  16819. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16820. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16821. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16822. type ELeData struct {
  16823. Data struct {
  16824. IdNo string `json:"idNo"`
  16825. IdType string `json:"idType"`
  16826. UserName string `json:"userName"`
  16827. EcToken string `json:"ecToken"`
  16828. InsuOrg string `json:"insuOrg"`
  16829. Gender string `json:"gender"`
  16830. Birthday string `json:"birthday"`
  16831. Nationality string `json:"nationality"`
  16832. Email string `json:"email"`
  16833. Extra string `json:"extra"`
  16834. } `json:"data"`
  16835. Code int `json:"code"`
  16836. Message string `json:"message"`
  16837. }
  16838. var ele ELeData
  16839. err := json.Unmarshal([]byte(result), &ele)
  16840. if err != nil {
  16841. utils.ErrorLog("解析失败:%v", err)
  16842. }
  16843. token := ele.Data.EcToken
  16844. token = Remove0000(token)
  16845. 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)
  16846. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16847. var res ResultTwo
  16848. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16849. utils.ErrorLog("解析失败:%v", err)
  16850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16851. return
  16852. }
  16853. if res.Infcode == 0 {
  16854. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16855. if err == gorm.ErrRecordNotFound {
  16856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16857. return
  16858. } else if err != nil {
  16859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16860. return
  16861. } else {
  16862. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16863. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16864. infoStr := string(Iinfos)
  16865. idetinfoStr := string(Idetinfos)
  16866. psn := &models.HisPsn{
  16867. PsnNo: res.Output.Baseinfo.PsnNo,
  16868. PatientId: patient.ID,
  16869. Certno: res.Output.Baseinfo.Certno,
  16870. Gend: res.Output.Baseinfo.Gend,
  16871. Naty: res.Output.Baseinfo.Naty,
  16872. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16873. PsnName: res.Output.Baseinfo.PsnName,
  16874. Idetinfo: idetinfoStr,
  16875. Insuinfo: infoStr,
  16876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16877. CardInfo: "",
  16878. VerifyNumber: token,
  16879. InsuplcAdmdvs: ele.Data.InsuOrg,
  16880. }
  16881. service.CreateHisPsn(psn)
  16882. var rf []*ResultFive
  16883. json.Unmarshal([]byte(infoStr), &rf)
  16884. var insutypes []*ResultFive
  16885. var insutype string
  16886. var is390 int = 0
  16887. var is310 int = 0
  16888. for _, item := range rf {
  16889. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16890. insutypes = append(insutypes, item)
  16891. }
  16892. }
  16893. if len(insutypes) == 1 {
  16894. insutype = insutypes[0].Insutype
  16895. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16896. } else {
  16897. for _, i := range insutypes {
  16898. if i.Insutype == "390" {
  16899. is390 = 1
  16900. }
  16901. if i.Insutype == "310" {
  16902. is310 = 1
  16903. }
  16904. }
  16905. }
  16906. if is390 == 1 {
  16907. insutype = "390"
  16908. }
  16909. if is310 == 1 {
  16910. insutype = "310"
  16911. }
  16912. if len(insutypes) == 0 {
  16913. insutype = "310"
  16914. }
  16915. c.ServeSuccessJSON(map[string]interface{}{
  16916. "patient": patient,
  16917. "number": token,
  16918. "insutype": insutype,
  16919. })
  16920. }
  16921. } else {
  16922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16923. return
  16924. }
  16925. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16926. //if initFlag == 0 {
  16927. //c.TestGetJiangXiBasBaseInit()
  16928. //}
  16929. //if initEleFlag == 0 {
  16930. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16931. //}
  16932. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16933. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16934. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16935. type ELeData struct {
  16936. Data struct {
  16937. IdNo string `json:"idNo"`
  16938. IdType string `json:"idType"`
  16939. UserName string `json:"userName"`
  16940. EcToken string `json:"ecToken"`
  16941. InsuOrg string `json:"insuOrg"`
  16942. Gender string `json:"gender"`
  16943. Birthday string `json:"birthday"`
  16944. Nationality string `json:"nationality"`
  16945. Email string `json:"email"`
  16946. Extra string `json:"extra"`
  16947. } `json:"data"`
  16948. Code int `json:"code"`
  16949. Message string `json:"message"`
  16950. }
  16951. var ele ELeData
  16952. err := json.Unmarshal([]byte(result), &ele)
  16953. if err != nil {
  16954. utils.ErrorLog("解析失败:%v", err)
  16955. }
  16956. token := ele.Data.EcToken
  16957. token = Remove0000(token)
  16958. 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)
  16959. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16960. var res ResultTwo
  16961. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16962. utils.ErrorLog("解析失败:%v", err)
  16963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16964. return
  16965. }
  16966. if res.Infcode == 0 {
  16967. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16968. if err == gorm.ErrRecordNotFound {
  16969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16970. return
  16971. } else if err != nil {
  16972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16973. return
  16974. } else {
  16975. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16976. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16977. infoStr := string(Iinfos)
  16978. idetinfoStr := string(Idetinfos)
  16979. psn := &models.HisPsn{
  16980. PsnNo: res.Output.Baseinfo.PsnNo,
  16981. PatientId: patient.ID,
  16982. Certno: res.Output.Baseinfo.Certno,
  16983. Gend: res.Output.Baseinfo.Gend,
  16984. Naty: res.Output.Baseinfo.Naty,
  16985. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16986. PsnName: res.Output.Baseinfo.PsnName,
  16987. Idetinfo: idetinfoStr,
  16988. Insuinfo: infoStr,
  16989. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16990. CardInfo: "",
  16991. VerifyNumber: token,
  16992. InsuplcAdmdvs: ele.Data.InsuOrg,
  16993. }
  16994. service.CreateHisPsn(psn)
  16995. var rf []*ResultFive
  16996. json.Unmarshal([]byte(infoStr), &rf)
  16997. var insutypes []*ResultFive
  16998. var insutype string
  16999. var is390 int = 0
  17000. var is310 int = 0
  17001. for _, item := range rf {
  17002. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17003. insutypes = append(insutypes, item)
  17004. }
  17005. }
  17006. if len(insutypes) == 1 {
  17007. insutype = insutypes[0].Insutype
  17008. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17009. } else {
  17010. for _, i := range insutypes {
  17011. if i.Insutype == "390" {
  17012. is390 = 1
  17013. }
  17014. if i.Insutype == "310" {
  17015. is310 = 1
  17016. }
  17017. }
  17018. }
  17019. if is390 == 1 {
  17020. insutype = "390"
  17021. }
  17022. if is310 == 1 {
  17023. insutype = "310"
  17024. }
  17025. if len(insutypes) == 0 {
  17026. insutype = "310"
  17027. }
  17028. c.ServeSuccessJSON(map[string]interface{}{
  17029. "patient": patient,
  17030. "number": token,
  17031. "insutype": insutype,
  17032. })
  17033. }
  17034. } else {
  17035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17036. return
  17037. }
  17038. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17039. //if initFlag == 0 {
  17040. c.TestGetJiangXiBasBaseInit()
  17041. //}
  17042. //if initEleFlag == 0 {
  17043. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17044. //}
  17045. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17046. type ELeData struct {
  17047. Data struct {
  17048. IdNo string `json:"idNo"`
  17049. IdType string `json:"idType"`
  17050. UserName string `json:"userName"`
  17051. EcToken string `json:"ecToken"`
  17052. InsuOrg string `json:"insuOrg"`
  17053. Gender string `json:"gender"`
  17054. Birthday string `json:"birthday"`
  17055. Nationality string `json:"nationality"`
  17056. Email string `json:"email"`
  17057. Extra string `json:"extra"`
  17058. } `json:"data"`
  17059. Code int `json:"code"`
  17060. Message string `json:"message"`
  17061. }
  17062. var ele ELeData
  17063. err := json.Unmarshal([]byte(json_result), &ele)
  17064. if err != nil {
  17065. utils.ErrorLog("解析失败:%v", err)
  17066. }
  17067. token := ele.Data.EcToken
  17068. token = Remove0000(token)
  17069. 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)
  17070. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17071. var res ResultTwo
  17072. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17073. utils.ErrorLog("解析失败:%v", err)
  17074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17075. return
  17076. }
  17077. if res.Infcode == 0 {
  17078. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17079. if err == gorm.ErrRecordNotFound {
  17080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17081. return
  17082. } else if err != nil {
  17083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17084. return
  17085. } else {
  17086. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17087. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17088. infoStr := string(Iinfos)
  17089. idetinfoStr := string(Idetinfos)
  17090. psn := &models.HisPsn{
  17091. PsnNo: res.Output.Baseinfo.PsnNo,
  17092. PatientId: patient.ID,
  17093. Certno: res.Output.Baseinfo.Certno,
  17094. Gend: res.Output.Baseinfo.Gend,
  17095. Naty: res.Output.Baseinfo.Naty,
  17096. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17097. PsnName: res.Output.Baseinfo.PsnName,
  17098. Idetinfo: idetinfoStr,
  17099. Insuinfo: infoStr,
  17100. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17101. CardInfo: "",
  17102. VerifyNumber: token,
  17103. }
  17104. service.CreateHisPsn(psn)
  17105. var rf []*ResultFive
  17106. json.Unmarshal([]byte(infoStr), &rf)
  17107. var insutypes []*ResultFive
  17108. var insutype string
  17109. var is390 int = 0
  17110. var is310 int = 0
  17111. for _, item := range rf {
  17112. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17113. insutypes = append(insutypes, item)
  17114. }
  17115. }
  17116. if len(insutypes) == 1 {
  17117. insutype = insutypes[0].Insutype
  17118. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17119. } else {
  17120. for _, i := range insutypes {
  17121. if i.Insutype == "390" {
  17122. is390 = 1
  17123. }
  17124. if i.Insutype == "310" {
  17125. is310 = 1
  17126. }
  17127. }
  17128. }
  17129. if is390 == 1 {
  17130. insutype = "390"
  17131. }
  17132. if is310 == 1 {
  17133. insutype = "310"
  17134. }
  17135. if len(insutypes) == 0 {
  17136. insutype = "310"
  17137. }
  17138. c.ServeSuccessJSON(map[string]interface{}{
  17139. "patient": patient,
  17140. "number": token,
  17141. "insutype": insutype,
  17142. })
  17143. }
  17144. } else {
  17145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17146. return
  17147. }
  17148. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17149. type ELeData struct {
  17150. Code string `json:"code"`
  17151. Data struct {
  17152. Aac002 string `json:"aac002"`
  17153. Aaz500 string `json:"aaz500"`
  17154. ActCardNo string `json:"actCardNo"`
  17155. Bab520 string `json:"bab520"`
  17156. Bkz543 string `json:"bkz543"`
  17157. BusinessType string `json:"businessType"`
  17158. CertfCodg string `json:"certfCodg"`
  17159. EcIndexNo string `json:"ecIndexNo"`
  17160. EcToken string `json:"ecToken"`
  17161. ID0000 string `json:"id0000"`
  17162. IDNo string `json:"idNo"`
  17163. IDType string `json:"idType"`
  17164. Idcode string `json:"idcode"`
  17165. IdentityToken string `json:"identity_token"`
  17166. InsuOrg string `json:"insuOrg"`
  17167. OfficeID string `json:"officeId"`
  17168. OfficeName string `json:"officeName"`
  17169. OperatorID string `json:"operatorId"`
  17170. OperatorName string `json:"operatorName"`
  17171. OrgID string `json:"orgId"`
  17172. UserName string `json:"userName"`
  17173. } `json:"data"`
  17174. Infno interface{} `json:"infno"`
  17175. Message string `json:"message"`
  17176. OrgID string `json:"orgId"`
  17177. TransType string `json:"transType"`
  17178. }
  17179. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17180. outPutInfo = Remove0000(outPutInfo)
  17181. if len(outPutInfo) > 0 {
  17182. var ele ELeData
  17183. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17184. if err != nil {
  17185. utils.ErrorLog("解析失败:%v", err)
  17186. }
  17187. token := ele.Data.EcToken
  17188. fmt.Println(inputInfo)
  17189. fmt.Println(outPutInfo)
  17190. 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)
  17191. saveLog(result, requestLog, "1101", "获取人员信息")
  17192. var dat map[string]interface{}
  17193. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17194. fmt.Println(dat)
  17195. } else {
  17196. fmt.Println(err)
  17197. }
  17198. userJSONBytes, _ := json.Marshal(dat)
  17199. var res ResultTwo
  17200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17201. utils.ErrorLog("解析失败:%v", err)
  17202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17203. return
  17204. }
  17205. res.ErrMsg = errMsgLog
  17206. if res.Infcode == 0 {
  17207. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17208. if err == gorm.ErrRecordNotFound {
  17209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17210. return
  17211. } else if err != nil {
  17212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17213. return
  17214. } else {
  17215. fmt.Println(res)
  17216. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17217. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17218. infoStr := string(Iinfos)
  17219. idetinfoStr := string(Idetinfos)
  17220. psn := &models.HisPsn{
  17221. PsnNo: res.Output.Baseinfo.PsnNo,
  17222. PatientId: patient.ID,
  17223. Certno: res.Output.Baseinfo.Certno,
  17224. Gend: res.Output.Baseinfo.Gend,
  17225. Naty: res.Output.Baseinfo.Naty,
  17226. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17227. PsnName: res.Output.Baseinfo.PsnName,
  17228. Idetinfo: idetinfoStr,
  17229. Insuinfo: infoStr,
  17230. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17231. CardInfo: outPutInfo,
  17232. VerifyNumber: token,
  17233. InsuplcAdmdvs: ele.Data.InsuOrg,
  17234. }
  17235. service.CreateHisPsn(psn)
  17236. var rf []*ResultFive
  17237. json.Unmarshal([]byte(infoStr), &rf)
  17238. var insutypes []*ResultFive
  17239. var insutype string
  17240. var is390 int = 0
  17241. var is310 int = 0
  17242. for _, item := range rf {
  17243. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17244. insutypes = append(insutypes, item)
  17245. }
  17246. }
  17247. if len(insutypes) == 1 {
  17248. insutype = insutypes[0].Insutype
  17249. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17250. } else {
  17251. for _, i := range insutypes {
  17252. if i.Insutype == "390" {
  17253. is390 = 1
  17254. }
  17255. if i.Insutype == "310" {
  17256. is310 = 1
  17257. }
  17258. }
  17259. }
  17260. if is390 == 1 {
  17261. insutype = "390"
  17262. }
  17263. if is310 == 1 {
  17264. insutype = "310"
  17265. }
  17266. if len(insutypes) == 0 {
  17267. insutype = "310"
  17268. }
  17269. c.ServeSuccessJSON(map[string]interface{}{
  17270. "patient": patient,
  17271. "number": token,
  17272. "insutype": insutype,
  17273. })
  17274. }
  17275. } else {
  17276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17277. return
  17278. }
  17279. }
  17280. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17281. var api string
  17282. 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 +
  17283. "&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
  17284. resp, requestErr := http.Get(api)
  17285. if requestErr != nil {
  17286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17287. return
  17288. }
  17289. body, ioErr := ioutil.ReadAll(resp.Body)
  17290. if ioErr != nil {
  17291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17293. return
  17294. }
  17295. var respJSON map[string]interface{}
  17296. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17299. return
  17300. }
  17301. var status string
  17302. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17303. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17304. var token string
  17305. var res ResultTwo //1101结果
  17306. var res10265 ResultTwo10265 //1101结果
  17307. if status == "0" { //读卡成功
  17308. var card_info string //卡信息
  17309. var busi_card_info string
  17310. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17311. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17312. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17313. fmt.Println(card_info)
  17314. fmt.Println(busi_card_info)
  17315. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17316. result, _ := json.Marshal(respJSON)
  17317. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17318. utils.ErrorLog("解析失败:%v", err)
  17319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17320. return
  17321. }
  17322. res.ErrMsg = res10265.ErrMsg
  17323. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17324. res.Infcode = infocode
  17325. res.Output = res10265.Output
  17326. res.InfRefmsgid = res10265.InfRefmsgid
  17327. if res.Infcode == 0 {
  17328. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17329. if err == gorm.ErrRecordNotFound {
  17330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17331. return
  17332. } else if err != nil {
  17333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17334. return
  17335. } else {
  17336. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17337. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17338. infoStr := string(Iinfos)
  17339. idetinfoStr := string(Idetinfos)
  17340. psn := &models.HisPsn{
  17341. PsnNo: res.Output.Baseinfo.PsnNo,
  17342. PatientId: patient.ID,
  17343. Certno: res.Output.Baseinfo.Certno,
  17344. Gend: res.Output.Baseinfo.Gend,
  17345. Naty: res.Output.Baseinfo.Naty,
  17346. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17347. PsnName: res.Output.Baseinfo.PsnName,
  17348. Idetinfo: idetinfoStr,
  17349. Insuinfo: infoStr,
  17350. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17351. CardInfo: card_info,
  17352. VerifyNumber: token,
  17353. }
  17354. var rf []*ResultFive
  17355. json.Unmarshal([]byte(infoStr), &rf)
  17356. var insutypes []*ResultFive
  17357. var insutype string
  17358. var is390 int = 0
  17359. var is310 int = 0
  17360. for _, item := range rf {
  17361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17362. insutypes = append(insutypes, item)
  17363. }
  17364. }
  17365. if len(insutypes) == 1 {
  17366. insutype = insutypes[0].Insutype
  17367. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17368. } else {
  17369. for _, i := range insutypes {
  17370. if i.Insutype == "390" {
  17371. is390 = 1
  17372. }
  17373. if i.Insutype == "310" {
  17374. is310 = 1
  17375. }
  17376. }
  17377. }
  17378. if is390 == 1 {
  17379. insutype = "390"
  17380. }
  17381. if is310 == 1 {
  17382. insutype = "310"
  17383. }
  17384. if len(insutypes) == 0 {
  17385. insutype = "310"
  17386. }
  17387. service.CreateHisPsn(psn)
  17388. c.ServeSuccessJSON(map[string]interface{}{
  17389. "patient": patient,
  17390. "number": token,
  17391. "insutype": insutype,
  17392. })
  17393. }
  17394. } else {
  17395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17396. return
  17397. }
  17398. } else { //读卡失败
  17399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17400. return
  17401. }
  17402. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17403. res := c.GetoleInfo()
  17404. if res.Infcode == 0 {
  17405. var result string
  17406. if res.Output.MdtrtCertType == "01" {
  17407. 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)
  17408. } else if res.Output.MdtrtCertType == "02" {
  17409. 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)
  17410. } else if res.Output.MdtrtCertType == "03" {
  17411. 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)
  17412. }
  17413. var dat map[string]interface{}
  17414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17415. fmt.Println(dat)
  17416. } else {
  17417. fmt.Println(err)
  17418. }
  17419. userJSONBytes, _ := json.Marshal(dat)
  17420. var res2 ResultTwo
  17421. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17422. utils.ErrorLog("解析失败:%v", err)
  17423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17424. return
  17425. }
  17426. if res2.Infcode == 0 {
  17427. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17428. if err == gorm.ErrRecordNotFound {
  17429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17430. return
  17431. } else if err != nil {
  17432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17433. return
  17434. } else {
  17435. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17436. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17437. infoStr := string(Iinfos)
  17438. idetinfoStr := string(Idetinfos)
  17439. var rf []*ResultFive
  17440. json.Unmarshal([]byte(infoStr), &rf)
  17441. var insutypes []*ResultFive
  17442. var insutype string
  17443. var is390 int = 0
  17444. var is310 int = 0
  17445. //var insuplc_admdvs string
  17446. for _, item := range rf {
  17447. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17448. insutypes = append(insutypes, item)
  17449. }
  17450. }
  17451. if len(insutypes) == 1 {
  17452. insutype = insutypes[0].Insutype
  17453. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17454. } else {
  17455. for _, i := range insutypes {
  17456. if i.Insutype == "390" {
  17457. is390 = 1
  17458. }
  17459. if i.Insutype == "310" {
  17460. is310 = 1
  17461. }
  17462. }
  17463. }
  17464. if is390 == 1 {
  17465. insutype = "390"
  17466. }
  17467. if is310 == 1 {
  17468. insutype = "310"
  17469. }
  17470. if len(insutypes) == 0 {
  17471. insutype = "310"
  17472. }
  17473. psn := &models.HisPsn{
  17474. PsnNo: res2.Output.Baseinfo.PsnNo,
  17475. PatientId: patient.ID,
  17476. Certno: res2.Output.Baseinfo.Certno,
  17477. Gend: res2.Output.Baseinfo.Gend,
  17478. Naty: res2.Output.Baseinfo.Naty,
  17479. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17480. PsnName: res2.Output.Baseinfo.PsnName,
  17481. Idetinfo: idetinfoStr,
  17482. Insuinfo: infoStr,
  17483. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17484. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17485. VerifyNumber: res.Output.EcToken,
  17486. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17487. }
  17488. if res.Output.MdtrtCertType == "01" {
  17489. psn.VerifyNumber = res.Output.EcToken
  17490. //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)
  17491. } else if res.Output.MdtrtCertType == "02" {
  17492. psn.VerifyNumber = res.Output.CardNo
  17493. //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)
  17494. } else if res.Output.MdtrtCertType == "03" {
  17495. psn.VerifyNumber = res.Output.MdtrtCertNo
  17496. //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)
  17497. }
  17498. service.CreateHisPsn(psn)
  17499. var balc float64
  17500. for _, item := range rf {
  17501. if item.Insutype == insutype {
  17502. balc = item.Balc
  17503. }
  17504. }
  17505. c.ServeSuccessJSON(map[string]interface{}{
  17506. "patient": patient,
  17507. "number": res.Output.CardNo,
  17508. "insutype": insutype,
  17509. "blac": balc,
  17510. "desc": idetinfoStr,
  17511. })
  17512. }
  17513. } else {
  17514. c.ServeSuccessJSON(map[string]interface{}{
  17515. "failed_code": -10,
  17516. "msg": res2.ErrMsg,
  17517. })
  17518. }
  17519. } else {
  17520. c.ServeSuccessJSON(map[string]interface{}{
  17521. "failed_code": -10,
  17522. "msg": res.ErrMsg,
  17523. })
  17524. }
  17525. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17526. var res ResultTwo
  17527. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17528. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17529. "&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)
  17530. resp, requestErr := http.Get(api)
  17531. if requestErr != nil {
  17532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17533. return
  17534. }
  17535. body, ioErr := ioutil.ReadAll(resp.Body)
  17536. if ioErr != nil {
  17537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17539. return
  17540. }
  17541. var respJSON map[string]interface{}
  17542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17545. return
  17546. }
  17547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17548. result, _ := json.Marshal(respJSON)
  17549. fmt.Println("log")
  17550. fmt.Println(string(result))
  17551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17552. utils.ErrorLog("解析失败:%v", err)
  17553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17554. return
  17555. }
  17556. if res.Infcode == 0 {
  17557. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17558. if err == gorm.ErrRecordNotFound {
  17559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17560. return
  17561. } else if err != nil {
  17562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17563. return
  17564. } else {
  17565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17567. infoStr := string(Iinfos)
  17568. idetinfoStr := string(Idetinfos)
  17569. var rf []*ResultFive
  17570. json.Unmarshal([]byte(infoStr), &rf)
  17571. var insutypes []*ResultFive
  17572. var insutype string
  17573. var is390 int = 0
  17574. var is310 int = 0
  17575. for _, item := range rf {
  17576. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17577. insutypes = append(insutypes, item)
  17578. }
  17579. }
  17580. if len(insutypes) == 1 {
  17581. insutype = insutypes[0].Insutype
  17582. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17583. } else {
  17584. for _, i := range insutypes {
  17585. if i.Insutype == "390" {
  17586. is390 = 1
  17587. }
  17588. if i.Insutype == "310" {
  17589. is310 = 1
  17590. }
  17591. }
  17592. }
  17593. if is390 == 1 {
  17594. insutype = "390"
  17595. }
  17596. if is310 == 1 {
  17597. insutype = "310"
  17598. }
  17599. if len(insutypes) == 0 {
  17600. insutype = "390"
  17601. }
  17602. var insuplc_admdvs string
  17603. for _, item := range rf {
  17604. if item.Insutype == insutype {
  17605. insuplc_admdvs = item.InsuplcAdmdvs
  17606. }
  17607. }
  17608. psn := &models.HisPsn{
  17609. PsnNo: res.Output.Baseinfo.PsnNo,
  17610. PatientId: patient.ID,
  17611. Certno: res.Output.Baseinfo.Certno,
  17612. Gend: res.Output.Baseinfo.Gend,
  17613. Naty: res.Output.Baseinfo.Naty,
  17614. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17615. PsnName: res.Output.Baseinfo.PsnName,
  17616. Idetinfo: idetinfoStr,
  17617. Insuinfo: infoStr,
  17618. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17619. InsuplcAdmdvs: insuplc_admdvs,
  17620. }
  17621. service.CreateHisPsn(psn)
  17622. c.ServeSuccessJSON(map[string]interface{}{
  17623. "patient": patient,
  17624. "number": res.Output.Baseinfo.Certno,
  17625. })
  17626. }
  17627. } else {
  17628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17629. return
  17630. }
  17631. } else {
  17632. type ELeData struct {
  17633. Code string `json:"code"`
  17634. Data struct {
  17635. Aac002 string `json:"aac002"`
  17636. Aaz500 string `json:"aaz500"`
  17637. ActCardNo string `json:"actCardNo"`
  17638. Bab520 string `json:"bab520"`
  17639. Bkz543 string `json:"bkz543"`
  17640. BusinessType string `json:"businessType"`
  17641. CertfCodg string `json:"certfCodg"`
  17642. EcIndexNo string `json:"ecIndexNo"`
  17643. EcToken string `json:"ecToken"`
  17644. ID0000 string `json:"id0000"`
  17645. IDNo string `json:"idNo"`
  17646. IDType string `json:"idType"`
  17647. Idcode string `json:"idcode"`
  17648. IdentityToken string `json:"identity_token"`
  17649. InsuOrg string `json:"insuOrg"`
  17650. OfficeID string `json:"officeId"`
  17651. OfficeName string `json:"officeName"`
  17652. OperatorID string `json:"operatorId"`
  17653. OperatorName string `json:"operatorName"`
  17654. OrgID string `json:"orgId"`
  17655. UserName string `json:"userName"`
  17656. } `json:"data"`
  17657. Infno interface{} `json:"infno"`
  17658. Message string `json:"message"`
  17659. OrgID string `json:"orgId"`
  17660. TransType string `json:"transType"`
  17661. }
  17662. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17663. fmt.Println(result)
  17664. outPutInfo := Remove0000(result)
  17665. fmt.Println(outPutInfo)
  17666. if len(outPutInfo) > 0 {
  17667. var ele ELeData
  17668. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17669. if err != nil {
  17670. utils.ErrorLog("解析失败:%v", err)
  17671. }
  17672. token := ele.Data.EcToken
  17673. fmt.Println(outPutInfo)
  17674. 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)
  17675. saveLog(result, requestLog, "1101", "获取人员信息")
  17676. var dat map[string]interface{}
  17677. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17678. fmt.Println(dat)
  17679. } else {
  17680. fmt.Println(err)
  17681. }
  17682. userJSONBytes, _ := json.Marshal(dat)
  17683. var res ResultTwo
  17684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17685. utils.ErrorLog("解析失败:%v", err)
  17686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17687. return
  17688. }
  17689. if res.Infcode == 0 {
  17690. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17691. if err == gorm.ErrRecordNotFound {
  17692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17693. return
  17694. } else if err != nil {
  17695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17696. return
  17697. } else {
  17698. fmt.Println(res)
  17699. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17700. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17701. infoStr := string(Iinfos)
  17702. idetinfoStr := string(Idetinfos)
  17703. psn := &models.HisPsn{
  17704. PsnNo: res.Output.Baseinfo.PsnNo,
  17705. PatientId: patient.ID,
  17706. Certno: res.Output.Baseinfo.Certno,
  17707. Gend: res.Output.Baseinfo.Gend,
  17708. Naty: res.Output.Baseinfo.Naty,
  17709. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17710. PsnName: res.Output.Baseinfo.PsnName,
  17711. Idetinfo: idetinfoStr,
  17712. Insuinfo: infoStr,
  17713. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17714. CardInfo: outPutInfo,
  17715. VerifyNumber: token,
  17716. InsuplcAdmdvs: ele.Data.InsuOrg,
  17717. }
  17718. service.CreateHisPsn(psn)
  17719. var rf []*ResultFive
  17720. json.Unmarshal([]byte(infoStr), &rf)
  17721. var insutypes []*ResultFive
  17722. var insutype string
  17723. var is390 int = 0
  17724. var is310 int = 0
  17725. for _, item := range rf {
  17726. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17727. insutypes = append(insutypes, item)
  17728. }
  17729. }
  17730. if len(insutypes) == 1 {
  17731. insutype = insutypes[0].Insutype
  17732. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17733. } else {
  17734. for _, i := range insutypes {
  17735. if i.Insutype == "390" {
  17736. is390 = 1
  17737. }
  17738. if i.Insutype == "310" {
  17739. is310 = 1
  17740. }
  17741. }
  17742. }
  17743. if is390 == 1 {
  17744. insutype = "390"
  17745. }
  17746. if is310 == 1 {
  17747. insutype = "310"
  17748. }
  17749. if len(insutypes) == 0 {
  17750. insutype = "310"
  17751. }
  17752. c.ServeSuccessJSON(map[string]interface{}{
  17753. "patient": patient,
  17754. "number": token,
  17755. "insutype": insutype,
  17756. })
  17757. }
  17758. } else {
  17759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17760. return
  17761. }
  17762. }
  17763. //fmt.Println(result)
  17764. //
  17765. //if initFlag == 0 {
  17766. // c.TestGetBasBaseInit()
  17767. //}
  17768. //token := c.GetEleBaseInfo()
  17769. //
  17770. //token = Remove0000(token)
  17771. //
  17772. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17773. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17774. ////
  17775. //var res ResultTwo
  17776. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17777. // utils.ErrorLog("解析失败:%v", err)
  17778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17779. // return
  17780. //}
  17781. //
  17782. //if res.Infcode == 0 {
  17783. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17784. // if err == gorm.ErrRecordNotFound {
  17785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17786. // return
  17787. // } else if err != nil {
  17788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17789. // return
  17790. //
  17791. // } else {
  17792. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17793. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17794. // infoStr := string(Iinfos)
  17795. // idetinfoStr := string(Idetinfos)
  17796. //
  17797. //
  17798. //
  17799. //
  17800. // var rf []*ResultFive
  17801. // json.Unmarshal([]byte(infoStr), &rf)
  17802. //
  17803. // var insutypes []*ResultFive
  17804. // var insutype string
  17805. // var is390 int = 0
  17806. // var is310 int = 0
  17807. // var insuplc_admdvs string
  17808. //
  17809. // for _, item := range rf {
  17810. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17811. // insutypes = append(insutypes, item)
  17812. // }
  17813. // }
  17814. //
  17815. // if len(insutypes) == 1 {
  17816. // insutype = insutypes[0].Insutype
  17817. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17818. // } else {
  17819. // for _, i := range insutypes {
  17820. // if i.Insutype == "390" {
  17821. // is390 = 1
  17822. // }
  17823. //
  17824. // if i.Insutype == "310" {
  17825. // is310 = 1
  17826. // }
  17827. // }
  17828. // }
  17829. // if is390 == 1 {
  17830. // insutype = "390"
  17831. // }
  17832. //
  17833. // if is310 == 1 {
  17834. // insutype = "310"
  17835. // }
  17836. // if len(insutypes) == 0 {
  17837. // insutype = "310"
  17838. // }
  17839. // for _, item := range rf {
  17840. // if item.Insutype == insutype {
  17841. // insuplc_admdvs = item.InsuplcAdmdvs
  17842. // }
  17843. // }
  17844. // psn := &models.HisPsn{
  17845. // PsnNo: res.Output.Baseinfo.PsnNo,
  17846. // Age: res.Output.Baseinfo.Age,
  17847. // PatientId: patient.ID,
  17848. // Certno: res.Output.Baseinfo.Certno,
  17849. // Brdy: res.Output.Baseinfo.Brdy,
  17850. // Gend: res.Output.Baseinfo.Gend,
  17851. // Naty: res.Output.Baseinfo.Naty,
  17852. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17853. // PsnName: res.Output.Baseinfo.PsnName,
  17854. // Idetinfo: idetinfoStr,
  17855. // Insuinfo: infoStr,
  17856. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17857. // CardInfo: "",
  17858. // VerifyNumber: token,
  17859. // InsuplcAdmdvs: insuplc_admdvs,
  17860. // }
  17861. // service.CreateHisPsn(psn)
  17862. //
  17863. // c.ServeSuccessJSON(map[string]interface{}{
  17864. // "patient": patient,
  17865. // "number": token,
  17866. // })
  17867. // }
  17868. //} else {
  17869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17870. // return
  17871. //}
  17872. }
  17873. break
  17874. case 5:
  17875. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  17876. var api string
  17877. if miConfig.MdtrtareaAdmvs == "320830" {
  17878. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17879. "&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
  17880. fmt.Println(api)
  17881. } else if miConfig.MdtrtareaAdmvs == "320921" {
  17882. 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 +
  17883. "&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
  17884. fmt.Println(api)
  17885. } else {
  17886. 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 +
  17887. "&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)
  17888. }
  17889. resp, requestErr := http.Get(api)
  17890. if requestErr != nil {
  17891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17892. return
  17893. }
  17894. body, ioErr := ioutil.ReadAll(resp.Body)
  17895. if ioErr != nil {
  17896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17898. return
  17899. }
  17900. var respJSON map[string]interface{}
  17901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17904. return
  17905. }
  17906. var status string
  17907. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17908. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17909. var token string
  17910. var res ResultTwo //1101结果
  17911. var res10265 ResultTwo10265 //1101结果
  17912. if status == "0" { //读卡成功
  17913. var card_info string //卡信息
  17914. //var busi_card_info string
  17915. var auth_info string
  17916. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17917. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17918. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17919. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17920. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17921. result, _ := json.Marshal(respJSON)
  17922. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17923. utils.ErrorLog("解析失败:%v", err)
  17924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17925. return
  17926. }
  17927. res.ErrMsg = res10265.ErrMsg
  17928. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17929. res.Infcode = infocode
  17930. res.Output = res10265.Output
  17931. res.InfRefmsgid = res10265.InfRefmsgid
  17932. if res.Infcode == 0 {
  17933. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17934. if err == gorm.ErrRecordNotFound {
  17935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17936. return
  17937. } else if err != nil {
  17938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17939. return
  17940. } else {
  17941. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17942. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17943. infoStr := string(Iinfos)
  17944. idetinfoStr := string(Idetinfos)
  17945. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17946. psn := &models.HisPsn{
  17947. PsnNo: res.Output.Baseinfo.PsnNo,
  17948. PatientId: patient.ID,
  17949. Certno: res.Output.Baseinfo.Certno,
  17950. Gend: res.Output.Baseinfo.Gend,
  17951. Brdy: b,
  17952. Age: float64(age),
  17953. Naty: res.Output.Baseinfo.Naty,
  17954. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17955. PsnName: res.Output.Baseinfo.PsnName,
  17956. Idetinfo: idetinfoStr,
  17957. Insuinfo: infoStr,
  17958. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17959. CardInfo: card_info,
  17960. VerifyNumber: token,
  17961. AuthInfo: auth_info,
  17962. }
  17963. var rf []*ResultFive
  17964. json.Unmarshal([]byte(infoStr), &rf)
  17965. var insutypes []*ResultFive
  17966. var insutype string
  17967. var is390 int = 0
  17968. var is310 int = 0
  17969. for _, item := range rf {
  17970. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17971. insutypes = append(insutypes, item)
  17972. }
  17973. }
  17974. if len(insutypes) == 1 {
  17975. insutype = insutypes[0].Insutype
  17976. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17977. } else {
  17978. for _, i := range insutypes {
  17979. if i.Insutype == "390" {
  17980. is390 = 1
  17981. }
  17982. if i.Insutype == "310" {
  17983. is310 = 1
  17984. }
  17985. }
  17986. }
  17987. if is390 == 1 {
  17988. insutype = "390"
  17989. }
  17990. if is310 == 1 {
  17991. insutype = "310"
  17992. }
  17993. if len(insutypes) == 0 {
  17994. insutype = "310"
  17995. }
  17996. service.CreateHisPsn(psn)
  17997. c.ServeSuccessJSON(map[string]interface{}{
  17998. "patient": patient,
  17999. "number": token,
  18000. "insutype": insutype,
  18001. })
  18002. }
  18003. } else {
  18004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18005. return
  18006. }
  18007. } else { //读卡失败
  18008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18009. return
  18010. }
  18011. }
  18012. break
  18013. }
  18014. }
  18015. var initFlag int64 = 0
  18016. var initEleFlag int64 = 0
  18017. func (c *HisApiController) TestGetBasBaseInit() {
  18018. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18019. Iinit := DllDef.MustFindProc("Init")
  18020. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18021. url := ""
  18022. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18023. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18024. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18025. url = ""
  18026. } else {
  18027. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18028. }
  18029. fmt.Println("SSCard的报错原因:", url)
  18030. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18031. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18032. if ret != 0 {
  18033. fmt.Println("SSCard的报错原因:", err)
  18034. fmt.Println("SSCard的运算结果为:", ret)
  18035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18036. return
  18037. }
  18038. result := int(ret)
  18039. fmt.Println("SSCard的运算结果为1:", result)
  18040. initFlag = 1
  18041. return
  18042. }
  18043. func (c *HisApiController) HandleJiangXiReadCard() {
  18044. fmt.Println("~~~~~~")
  18045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18046. admin_user_id, _ := c.GetInt64("admin_user_id")
  18047. id_card_type, _ := c.GetInt64("id_card_type")
  18048. //certificates, _ := c.GetInt64("certificates")
  18049. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18050. if initFlag == 0 {
  18051. c.TestGetJiangXiBasBaseInit()
  18052. }
  18053. basStr := c.GetBasBaseInfo()
  18054. if len(basStr) == 0 {
  18055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18056. return
  18057. }
  18058. fmt.Println(basStr)
  18059. bas := strings.Split(basStr, "|")
  18060. basNumber := bas[1]
  18061. fmt.Println(basNumber)
  18062. card_sn := bas[3]
  18063. fmt.Println(card_sn)
  18064. 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, "")
  18065. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18066. var dat map[string]interface{}
  18067. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18068. fmt.Println(dat)
  18069. } else {
  18070. fmt.Println(err)
  18071. }
  18072. userJSONBytes, _ := json.Marshal(dat)
  18073. var res ResultTwo
  18074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18075. utils.ErrorLog("解析失败:%v", err)
  18076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18077. return
  18078. }
  18079. if res.Infcode == 0 {
  18080. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18081. if err == gorm.ErrRecordNotFound {
  18082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18083. return
  18084. } else if err != nil {
  18085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18086. return
  18087. } else {
  18088. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18089. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18090. infoStr := string(Iinfos)
  18091. idetinfoStr := string(Idetinfos)
  18092. psn := &models.HisPsn{
  18093. PsnNo: res.Output.Baseinfo.PsnNo,
  18094. PatientId: patient.ID,
  18095. Certno: res.Output.Baseinfo.Certno,
  18096. Gend: res.Output.Baseinfo.Gend,
  18097. Naty: res.Output.Baseinfo.Naty,
  18098. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18099. PsnName: res.Output.Baseinfo.PsnName,
  18100. Idetinfo: idetinfoStr,
  18101. Insuinfo: infoStr,
  18102. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18103. CardInfo: basStr,
  18104. VerifyNumber: "",
  18105. }
  18106. service.CreateHisPsn(psn)
  18107. c.ServeSuccessJSON(map[string]interface{}{
  18108. "patient": patient,
  18109. "number": basNumber,
  18110. })
  18111. }
  18112. } else {
  18113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18114. return
  18115. }
  18116. }
  18117. func (c *HisApiController) TestGetHnBasBaseInit() {
  18118. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18119. Iinit := DllDef.MustFindProc("Init")
  18120. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18121. //http://10.77.211.236/CSB/hsa-fsi-1303
  18122. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18123. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18124. // 调用 Init 函数
  18125. 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"))))
  18126. //if ret != 0 {
  18127. fmt.Println("SSCard的报错原因:", err)
  18128. fmt.Println("SSCard的运算结果为:", ret)
  18129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18130. // return
  18131. //}
  18132. result := int(ret)
  18133. fmt.Println("SSCard的运算结果为1:", result)
  18134. initFlag = 1
  18135. return
  18136. }
  18137. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18138. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18139. Iinit := DllDef.MustFindProc("Init")
  18140. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18141. //http://10.77.211.236/CSB/hsa-fsi-1303
  18142. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18143. if ret != 0 {
  18144. fmt.Println("SSCard的报错原因:", err)
  18145. fmt.Println("SSCard的运算结果为:", ret)
  18146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18147. return
  18148. }
  18149. result := int(ret)
  18150. fmt.Println("SSCard的运算结果为1:", result)
  18151. initFlag = 1
  18152. return
  18153. }
  18154. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18155. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18156. Iinit := DllDef.MustFindProc("Init")
  18157. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18158. //http://10.77.211.236/CSB/hsa-fsi-1303
  18159. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18160. if ret != 0 {
  18161. fmt.Println("SSCard的报错原因:", err)
  18162. fmt.Println("SSCard的运算结果为:", ret)
  18163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18164. return
  18165. }
  18166. result := int(ret)
  18167. fmt.Println("SSCard的运算结果为1:", result)
  18168. initFlag = 1
  18169. return
  18170. }
  18171. func (c *HisApiController) GetSFZBaseInfo() string {
  18172. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18173. readCard := DllDef.MustFindProc("ReadSFZ")
  18174. if readCard == nil {
  18175. fmt.Println("readcard is nil")
  18176. readCard = DllDef.MustFindProc("ReadSFZ")
  18177. }
  18178. str := make([]byte, 8096)
  18179. str1 := make([]byte, 8096)
  18180. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18181. fmt.Println(r)
  18182. return Remove0000(string(str))
  18183. }
  18184. func (c *HisApiController) GetEleBaseInfo() string {
  18185. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18186. readCard := DllDef.MustFindProc("GetQRBase")
  18187. fmt.Println(readCard)
  18188. if readCard == nil {
  18189. fmt.Println("readcard is nil")
  18190. readCard = DllDef.MustFindProc("GetQRBase")
  18191. }
  18192. str := make([]byte, 1024)
  18193. str1 := make([]byte, 1024)
  18194. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18195. fmt.Println(ret2)
  18196. fmt.Println(string(str1))
  18197. fmt.Println(string(str))
  18198. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18199. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18200. if ret2 != 0 {
  18201. return ""
  18202. }
  18203. return string(str)
  18204. }
  18205. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18206. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18207. readCard := DllDef.MustFindProc("NationEcTrans")
  18208. fmt.Println(readCard)
  18209. fmt.Println("!!!!!")
  18210. pBusiCardInfo := make([]byte, 2048)
  18211. input := make(map[string]interface{})
  18212. inputData := make(map[string]interface{})
  18213. inputData["orgId"] = code
  18214. inputData["businessType"] = "01101"
  18215. inputData["operatorId"] = "1"
  18216. inputData["operatorName"] = "admin"
  18217. inputData["officeId"] = "001"
  18218. inputData["officeName"] = "血透室"
  18219. inputData["deviceType"] = ""
  18220. input["data"] = inputData
  18221. input["orgId"] = code
  18222. input["transType"] = "ec.query"
  18223. bytesData, _ := json.Marshal(input)
  18224. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18225. fmt.Println(ret2)
  18226. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18227. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18228. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18229. }
  18230. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18231. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18232. readCard := DllDef.MustFindProc("NationEcTrans")
  18233. fmt.Println(readCard)
  18234. fmt.Println("!!!!!")
  18235. pBusiCardInfo := make([]byte, 2048)
  18236. input := make(map[string]interface{})
  18237. inputData := make(map[string]interface{})
  18238. inputData["orgId"] = code
  18239. inputData["businessType"] = "01101"
  18240. inputData["operatorId"] = "9"
  18241. inputData["operatorName"] = "admin"
  18242. inputData["officeId"] = "001"
  18243. inputData["officeName"] = "血透室"
  18244. inputData["deviceType"] = ""
  18245. input["data"] = inputData
  18246. input["orgId"] = code
  18247. input["transType"] = "ec.query"
  18248. bytesData, _ := json.Marshal(input)
  18249. 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])))
  18250. fmt.Println(ret2)
  18251. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18252. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18253. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18254. }
  18255. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18256. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18257. readCard := DllDef.MustFindProc("NationEcTrans")
  18258. fmt.Println(readCard)
  18259. fmt.Println("!!!!!")
  18260. pBusiCardInfo := make([]byte, 2048)
  18261. input := make(map[string]interface{})
  18262. inputData := make(map[string]interface{})
  18263. inputData["orgId"] = code
  18264. inputData["businessType"] = "01301"
  18265. inputData["operatorId"] = "9"
  18266. inputData["operatorName"] = "admin"
  18267. inputData["officeId"] = "001"
  18268. inputData["officeName"] = "血透室"
  18269. inputData["deviceType"] = ""
  18270. input["data"] = inputData
  18271. input["orgId"] = code
  18272. input["transType"] = "ec.query"
  18273. bytesData, _ := json.Marshal(input)
  18274. 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])))
  18275. fmt.Println(ret2)
  18276. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18277. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18278. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18279. }
  18280. func GetJxEleBaseInfo(org_id int64) string {
  18281. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18282. readCard := DllDef.MustFindProc("NationEcTrans")
  18283. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18284. if readCard == nil {
  18285. fmt.Println("readcard is nil")
  18286. readCard = DllDef.MustFindProc("NationEcTrans")
  18287. }
  18288. str1 := make([]byte, 1024)
  18289. data := make(map[string]interface{})
  18290. inputData := make(map[string]interface{})
  18291. inputData["orgId"] = miConfig.Code
  18292. inputData["businessType"] = "01101"
  18293. inputData["operatorId"] = "test001"
  18294. inputData["operatorName"] = "cn"
  18295. inputData["officeId"] = "32760"
  18296. inputData["officeName"] = "waike"
  18297. inputData["deviceType"] = ""
  18298. data["data"] = inputData
  18299. data["transType"] = "ec.query"
  18300. data["extra "] = ""
  18301. data["orgId"] = miConfig.Code
  18302. bytesData, _ := json.Marshal(data)
  18303. //bytesData, _ := json.Marshal(data)
  18304. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18305. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18306. fmt.Println(ret2)
  18307. fmt.Println(string(str1))
  18308. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18309. if ret2 != 0 {
  18310. return ""
  18311. }
  18312. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18313. }
  18314. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18315. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18316. // readCard := DllDef.MustFindProc("NationEcTrans")
  18317. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18318. //
  18319. // if readCard == nil {
  18320. // fmt.Println("readcard is nil")
  18321. // readCard = DllDef.MustFindProc("NationEcTrans")
  18322. // }
  18323. // str1 := make([]byte, 1024)
  18324. //
  18325. // data := make(map[string]interface{})
  18326. //
  18327. // inputData := make(map[string]interface{})
  18328. // inputData["orgId"] = miConfig.Code
  18329. // inputData["businessType"] = "01101"
  18330. // inputData["operatorId"] = "test001"
  18331. // inputData["operatorName"] = "cn"
  18332. // inputData["officeId"] = "32760"
  18333. // inputData["officeName"] = "waike"
  18334. // inputData["deviceType"] = ""
  18335. //
  18336. // data["data"] = inputData
  18337. // data["transType"] = "ec.query"
  18338. // data["extra "] = ""
  18339. // data["orgId"] = miConfig.Code
  18340. // bytesData, _ := json.Marshal(data)
  18341. // //bytesData, _ := json.Marshal(data)
  18342. //
  18343. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18344. //
  18345. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18346. // fmt.Println(ret2)
  18347. // fmt.Println(string(str1))
  18348. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18349. //
  18350. // if ret2 != 0 {
  18351. // return ""
  18352. // }
  18353. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18354. //}
  18355. func GetJxEleBaseInitInfo(org_id int64) string {
  18356. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18357. readCard := DllDef.MustFindProc("NationEcTrans")
  18358. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18359. if readCard == nil {
  18360. fmt.Println("readcard is nil")
  18361. readCard = DllDef.MustFindProc("NationEcTrans")
  18362. }
  18363. str1 := make([]byte, 2048)
  18364. data := make(map[string]interface{})
  18365. inputData := make(map[string]interface{})
  18366. inputData["orgId"] = miConfig.Code
  18367. inputData["businessType"] = "01101"
  18368. inputData["operatorId"] = "1"
  18369. inputData["operatorName"] = "huangchuang"
  18370. inputData["officeId"] = "101"
  18371. inputData["officeName"] = "xuetou"
  18372. inputData["deviceType"] = ""
  18373. data["data"] = inputData
  18374. data["transType"] = "ec.query"
  18375. data["orgId"] = miConfig.Code
  18376. bytesData, _ := json.Marshal(data)
  18377. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18378. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18379. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18380. fmt.Println(ret2)
  18381. fmt.Println(string(str1))
  18382. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18383. if ret2 != 0 {
  18384. return ""
  18385. }
  18386. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18387. initEleFlag = 1
  18388. }
  18389. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18390. }
  18391. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18392. // // 构建命令
  18393. // cmd := exec.Command("python", "b.py")
  18394. //
  18395. // // 执行命令并等待完成
  18396. // output, err := cmd.CombinedOutput()
  18397. // if err != nil {
  18398. // fmt.Println("Error executing Python script:", err)
  18399. // return
  18400. // }
  18401. //
  18402. // // 打印Python脚本的输出
  18403. // fmt.Println(string(output))
  18404. //}
  18405. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18406. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18407. readCard := DllDef.MustFindProc("gxyb_call")
  18408. if readCard == nil {
  18409. fmt.Println("readcard is nil")
  18410. readCard = DllDef.MustFindProc("gxyb_call")
  18411. }
  18412. str := make([]byte, 1024)
  18413. str1 := make([]byte, 1024)
  18414. //data := make(map[string]interface{})
  18415. currentTime := time.Now()
  18416. // 格式化时间为 "YYYYMMDDHH24MISS"
  18417. formattedTime := currentTime.Format("20060102150405")
  18418. inputData := make(map[string]interface{})
  18419. inputData2 := make(map[string]interface{})
  18420. inputData["transNo"] = "1401"
  18421. inputData["transType"] = "passwordCheck"
  18422. inputData["timestamp"] = formattedTime
  18423. inputData2["fixmedinsCode"] = code
  18424. inputData2["psnNo"] = ""
  18425. inputData["data"] = inputData2
  18426. jsonBytes, err := json.Marshal(inputData)
  18427. if err != nil {
  18428. fmt.Println("Error encoding map to JSON:", err)
  18429. }
  18430. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18431. fmt.Println(string(str1))
  18432. fmt.Println(string(str))
  18433. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18434. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18435. if ret2 != 0 {
  18436. return ""
  18437. }
  18438. return string(str)
  18439. }
  18440. func (c *HisApiController) GetoleInfo() Response {
  18441. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18442. defer ole.CoUninitialize()
  18443. // Replace with the ProgID or CLSID of your COM object
  18444. progID := "YinHai.XJ.Actual.Interface.New"
  18445. // Create COM object
  18446. unknown, err := oleutil.CreateObject(progID)
  18447. if err != nil {
  18448. fmt.Println("Unable to create COM object:", err)
  18449. }
  18450. defer unknown.Release()
  18451. // Query for the IDispatch interface
  18452. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18453. if err != nil {
  18454. fmt.Println("Unable to get IDispatch interface:", err)
  18455. }
  18456. defer dispatch.Release()
  18457. // Prepare parameters
  18458. transNo := "1401"
  18459. transType := "passwordCheck"
  18460. timestamp := time.Now().Unix()
  18461. fixmedinsCode := "H45072101171"
  18462. psnNo := ""
  18463. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18464. result2 := ""
  18465. // Call COM object's method using the IDispatch interface
  18466. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18467. fmt.Println(resulr)
  18468. fmt.Println(result2)
  18469. if err != nil {
  18470. fmt.Println("调用COM对象方法失败:", err)
  18471. }
  18472. var response Response
  18473. err2 := json.Unmarshal([]byte(result2), &response)
  18474. if err2 != nil {
  18475. fmt.Println("解析JSON失败:", err)
  18476. }
  18477. return response
  18478. }
  18479. func (c *HisApiController) GetBasBaseInfo() string {
  18480. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18481. readCard := DllDef.MustFindProc("ReadCardBas")
  18482. if readCard == nil {
  18483. fmt.Println("readcard is nil")
  18484. readCard = DllDef.MustFindProc("ReadCardBas")
  18485. }
  18486. str := make([]byte, 1024)
  18487. str1 := make([]byte, 1024)
  18488. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18489. fmt.Println(string(str1))
  18490. fmt.Println(string(str))
  18491. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18492. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18493. if ret2 != 0 {
  18494. return ""
  18495. }
  18496. return string(str)
  18497. }
  18498. type Program struct {
  18499. FunctionID string `xml:"function_id"`
  18500. CardInfo string `xml:"cardinfo"`
  18501. User string `xml:"user"`
  18502. }
  18503. func (c *HisApiController) GetBasBaseInfo1111() string {
  18504. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18505. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18506. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18507. if readCard == nil {
  18508. fmt.Println("readcard is nil")
  18509. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18510. }
  18511. if readCard2 == nil {
  18512. fmt.Println("readcard is nil")
  18513. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18514. }
  18515. str := make([]byte, 1024)
  18516. str1 := make([]byte, 1024)
  18517. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18518. str3 := make([]byte, 1024)
  18519. str4 := make([]byte, 1024)
  18520. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18521. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18522. //if err != nil {
  18523. // fmt.Println("Error opening file:", err)
  18524. //}
  18525. //defer file.Close()
  18526. //
  18527. //var lastProgram Program
  18528. //scanner := bufio.NewScanner(file)
  18529. //inProgram := false
  18530. //
  18531. //for scanner.Scan() {
  18532. // line := scanner.Text()
  18533. // if strings.Contains(line, "<program>") {
  18534. // inProgram = true
  18535. // programXML := "<program>"
  18536. // for scanner.Scan() {
  18537. // line = scanner.Text()
  18538. // programXML += line
  18539. // if strings.Contains(line, "</program>") {
  18540. // programXML += "</program>"
  18541. // break
  18542. // }
  18543. // }
  18544. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18545. // // 解析成功,更新最后的 Program
  18546. // }
  18547. // inProgram = false
  18548. // }
  18549. //}
  18550. //
  18551. // fmt.Println("Error reading file:", inProgram)
  18552. //
  18553. //if err := scanner.Err(); err != nil {
  18554. // fmt.Println("Error reading file:", err)
  18555. //}
  18556. // 输出最后一次的 Program
  18557. //fmt.Printf("最后一次的 <program>:\n")
  18558. //fmt.Printf("<program>\n")
  18559. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18560. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18561. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18562. //fmt.Printf("</program>\n")
  18563. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18564. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18565. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18566. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18567. return ConvertToString(string(str), "gbk", "utf-8")
  18568. }
  18569. func (c *HisApiController) GetBasBaseInfo22222() string {
  18570. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18571. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18572. if readCard == nil {
  18573. fmt.Println("readcard is nil")
  18574. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18575. }
  18576. str := make([]byte, 1024)
  18577. str1 := make([]byte, 1024)
  18578. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18579. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18580. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18581. //if err != nil {
  18582. // fmt.Println("Error opening file:", err)
  18583. //}
  18584. //defer file.Close()
  18585. //
  18586. //var lastProgram Program
  18587. //scanner := bufio.NewScanner(file)
  18588. //inProgram := false
  18589. //
  18590. //for scanner.Scan() {
  18591. // line := scanner.Text()
  18592. // if strings.Contains(line, "<program>") {
  18593. // inProgram = true
  18594. // programXML := "<program>"
  18595. // for scanner.Scan() {
  18596. // line = scanner.Text()
  18597. // programXML += line
  18598. // if strings.Contains(line, "</program>") {
  18599. // programXML += "</program>"
  18600. // break
  18601. // }
  18602. // }
  18603. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18604. // // 解析成功,更新最后的 Program
  18605. // }
  18606. // inProgram = false
  18607. // }
  18608. //}
  18609. //
  18610. // fmt.Println("Error reading file:", inProgram)
  18611. //
  18612. //if err := scanner.Err(); err != nil {
  18613. // fmt.Println("Error reading file:", err)
  18614. //}
  18615. // 输出最后一次的 Program
  18616. //fmt.Printf("最后一次的 <program>:\n")
  18617. //fmt.Printf("<program>\n")
  18618. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18619. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18620. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18621. //fmt.Printf("</program>\n")
  18622. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18623. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18624. return ConvertToString(string(str1), "gbk", "utf-8")
  18625. }
  18626. func (c *HisApiController) GetahBasBaseInfo() string {
  18627. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18628. readCard := DllDef.MustFindProc("iReadCardBas")
  18629. if readCard == nil {
  18630. fmt.Println("readcard is nil")
  18631. readCard = DllDef.MustFindProc("iReadCardBas")
  18632. }
  18633. //str := make([]byte, 1024)
  18634. str1 := make([]byte, 1024)
  18635. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18636. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18637. //if err != nil {
  18638. // fmt.Println("Error opening file:", err)
  18639. //}
  18640. //defer file.Close()
  18641. //
  18642. //var lastProgram Program
  18643. //scanner := bufio.NewScanner(file)
  18644. //inProgram := false
  18645. //
  18646. //for scanner.Scan() {
  18647. // line := scanner.Text()
  18648. // if strings.Contains(line, "<program>") {
  18649. // inProgram = true
  18650. // programXML := "<program>"
  18651. // for scanner.Scan() {
  18652. // line = scanner.Text()
  18653. // programXML += line
  18654. // if strings.Contains(line, "</program>") {
  18655. // programXML += "</program>"
  18656. // break
  18657. // }
  18658. // }
  18659. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18660. // // 解析成功,更新最后的 Program
  18661. // }
  18662. // inProgram = false
  18663. // }
  18664. //}
  18665. //
  18666. // fmt.Println("Error reading file:", inProgram)
  18667. //
  18668. //if err := scanner.Err(); err != nil {
  18669. // fmt.Println("Error reading file:", err)
  18670. //}
  18671. // 输出最后一次的 Program
  18672. //fmt.Printf("最后一次的 <program>:\n")
  18673. //fmt.Printf("<program>\n")
  18674. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18675. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18676. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18677. //fmt.Printf("</program>\n")
  18678. fmt.Println(string(str1))
  18679. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18680. if ret2 != 0 {
  18681. return ""
  18682. }
  18683. return string(str1)
  18684. }
  18685. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18686. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18687. readCard := DllDef.MustFindProc("read_cardinfo")
  18688. if readCard == nil {
  18689. fmt.Println("readcard is nil")
  18690. readCard = DllDef.MustFindProc("read_cardinfo")
  18691. }
  18692. str := make([]byte, 1024) //卡号
  18693. str1 := make([]byte, 1024) //卡识别码
  18694. str2 := make([]byte, 1024) //身份证号
  18695. str3 := make([]byte, 1024) //姓名
  18696. str4 := make([]byte, 1024) //错误信息
  18697. 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])))
  18698. fmt.Println(string(str1))
  18699. fmt.Println(string(str))
  18700. fmt.Println(string(str2))
  18701. fmt.Println(string(str3))
  18702. fmt.Println(string(str4))
  18703. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18704. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18705. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18706. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18707. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18708. if ret2 != 0 {
  18709. return "", "", "", "", ""
  18710. }
  18711. return string(str), string(str1), string(str2), string(str3), string(str4)
  18712. }
  18713. type CustomFundPay struct {
  18714. FundPayType string `json:"fund_pay_type"`
  18715. FundPayamt float64 `json:"fund_payamt"`
  18716. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18717. }
  18718. //func (c *HisApiController) GetBatchSettleList() {
  18719. // start_time_str := c.GetString("start_time")
  18720. // //end_time_str := c.GetString("end_time")
  18721. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18722. //
  18723. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18724. //
  18725. // for _, item := range orders {
  18726. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18727. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18728. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18729. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18730. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18731. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18732. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18733. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18734. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18735. //
  18736. // if order.ID == 0 {
  18737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18738. // return
  18739. // }
  18740. //
  18741. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18742. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18743. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18744. // //fmt.Println(count)
  18745. // //var zero string
  18746. // //number := count + 1
  18747. // //if number >= 1000 {
  18748. // // zero = "0000" + strconv.FormatInt(number, 10)
  18749. // //} else if number >= 10000 {
  18750. // // zero = "000" + strconv.FormatInt(number, 10)
  18751. // //} else if number >= 100000 {
  18752. // // zero = "00" + strconv.FormatInt(number, 10)
  18753. // //} else if number >= 1000000 {
  18754. // // zero = "0" + strconv.FormatInt(number, 10)
  18755. // //} else {
  18756. // // zero = strconv.FormatInt(number, 10)
  18757. // //}
  18758. // //fmt.Println(zero)
  18759. //
  18760. // struct4101 := service.Struct4101{
  18761. // PsnNo: order.PsnNo,
  18762. // MdtrtId: order.MdtrtId,
  18763. // SetlId: order.SetlId,
  18764. // PsnName: order.PsnName,
  18765. // Gend: order.Gend,
  18766. // Brdy: his.Brdy,
  18767. // Age: his.Age,
  18768. // Naty: order.Naty,
  18769. // PatnCertType: "01",
  18770. // Certno: order.Certno,
  18771. // Prfs: "90",
  18772. // ConerName: roles[0].UserName,
  18773. // PatnRlts: "99",
  18774. // ConerAddr: miConfig.OrgName,
  18775. // ConerTel: admin.Mobile,
  18776. // HiType: order.Insutype,
  18777. // Insuplc: miConfig.InsuplcAdmdvs,
  18778. // MaindiagFlag: "1",
  18779. // BillCode: order.SetlId,
  18780. // BillNo: order.SetlId,
  18781. // BizSn: order.Number,
  18782. // PsnSelfPay: order.PsnPartAmt,
  18783. // PsnOwnPay: order.PsnPartAmt,
  18784. // AcctPay: order.AcctPay,
  18785. // PsnCashpay: order.PsnCashPay,
  18786. // HiPaymtd: "1",
  18787. // Hsorg: miConfig.InsuplcAdmdvs,
  18788. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18789. // MedinsFillPsn: curRoles.UserName,
  18790. // MedinsFillDept: miConfig.OrgName,
  18791. // IptMedType: "2",
  18792. // }
  18793. // struct4101.SetlBegnDate = order.SetlTime
  18794. // struct4101.SetlEndDate = order.SetlTime
  18795. // time_arr := strings.Split(order.SetlTime, " ")
  18796. // struct4101.AdmTime = time_arr[0]
  18797. // struct4101.AdmEndTime = time_arr[0]
  18798. //
  18799. // var rf []CustomFundPay
  18800. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18801. //
  18802. // var tempFunPays []service.CustomStruct
  18803. // for _, item := range rf {
  18804. // var tempFunPay service.CustomStruct
  18805. // tempFunPay.FundPayamt = item.FundPayamt
  18806. // tempFunPay.FundPayType = item.FundPayType
  18807. // tempFunPays = append(tempFunPays, tempFunPay)
  18808. // }
  18809. // struct4101.CustomStruct = tempFunPays
  18810. //
  18811. // var tempDiaginfos []service.DiaginfoStructTwo
  18812. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18813. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18814. //
  18815. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18816. // var config []*models.HisXtDiagnoseConfig
  18817. // for _, item := range diagnosis_ids {
  18818. // id, _ := strconv.ParseInt(item, 10, 64)
  18819. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18820. // config = append(config, &diagnosisConfig)
  18821. // }
  18822. //
  18823. // for index, item := range config {
  18824. // if index == 0 {
  18825. // var tempDiaginfo service.DiaginfoStructTwo
  18826. // tempDiaginfo.DiagCode = item.CountryCode
  18827. // tempDiaginfo.DiagName = item.CountryContentName
  18828. // tempDiaginfo.DiagType = "1"
  18829. // tempDiaginfo.MaindiagFlag = "1"
  18830. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18831. // } else {
  18832. // var tempDiaginfo service.DiaginfoStructTwo
  18833. // tempDiaginfo.DiagCode = item.CountryCode
  18834. // tempDiaginfo.DiagName = item.CountryContentName
  18835. // tempDiaginfo.DiagType = "1"
  18836. // tempDiaginfo.MaindiagFlag = "0"
  18837. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18838. // }
  18839. // }
  18840. // struct4101.Diseinfo = tempDiaginfos
  18841. //
  18842. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18843. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18844. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18845. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18846. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18847. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18848. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18849. //
  18850. // var iteminfo service.IteminfoStruct
  18851. //
  18852. // var bedCostTotal float64 = 0 //床位总费
  18853. // var bedCostSelfTotal float64 = 0 //床位自费
  18854. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18855. //
  18856. // var operationCostTotal float64 = 0 //手术费
  18857. // var operationCostSelfTotal float64 = 0 //手术费
  18858. // var operationCostPartSelfTotal float64 = 0 //手术费
  18859. //
  18860. // var otherCostTotal float64 = 0 //其他费用
  18861. // var otherCostSelfTotal float64 = 0 //其他费用
  18862. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18863. //
  18864. // var materialCostTotal float64 = 0 //材料费
  18865. // var materialCostSelfTotal float64 = 0 //材料费
  18866. // var materialCostPartSelfTotal float64 = 0 //材料费
  18867. //
  18868. // var westernMedicineCostTotal float64 = 0 //西药费
  18869. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18870. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18871. //
  18872. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18873. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18874. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18875. //
  18876. // var checkCostTotal float64 = 0 //检查费
  18877. // var checkCostSelfTotal float64 = 0 //检查费
  18878. // var checkCostPartSelfTotal float64 = 0 //检查费
  18879. //
  18880. // var laboratoryCostTotal float64 = 0 //化验费
  18881. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18882. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18883. //
  18884. // var treatCostTotal float64 = 0 //治疗费用
  18885. // var treatCostSelfTotal float64 = 0 //治疗费用
  18886. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18887. //
  18888. // decimal.DivisionPrecision = 2
  18889. //
  18890. // var bed_fulamt_ownpay_amt float64 = 0
  18891. // var operation_fulamt_ownpay_amt float64 = 0
  18892. // var other_fulamt_ownpay_amt float64 = 0
  18893. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18894. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18895. // var check_fulamt_ownpay_amt float64 = 0
  18896. // var material_fulamt_ownpay_amt float64 = 0
  18897. // var laboratory_fulamt_ownpay_amt float64 = 0
  18898. // var treat_fulamt_ownpay_amt float64 = 0
  18899. //
  18900. // var bed_claa_sunmfee float64 = 0
  18901. // var bed_clab_amt float64 = 0
  18902. // var bed_other_amt float64 = 0
  18903. //
  18904. // var operation_claa_sunmfee float64 = 0
  18905. // var operation_clab_amt float64 = 0
  18906. // var operation_other_amt float64 = 0
  18907. //
  18908. // var other_claa_sunmfee float64 = 0
  18909. // var other_clab_amt float64 = 0
  18910. // var other_other_amt float64 = 0
  18911. //
  18912. // var westernMedicine_claa_sunmfee float64 = 0
  18913. // var westernMedicine_clab_amt float64 = 0
  18914. // var westernMedicine_other_amt float64 = 0
  18915. //
  18916. // var chineseTraditional_claa_sunmfee float64 = 0
  18917. // var chineseTraditional_clab_amt float64 = 0
  18918. // var chineseTraditional_other_amt float64 = 0
  18919. //
  18920. // var check_claa_sunmfee float64 = 0
  18921. // var check_clab_amt float64 = 0
  18922. // var check_other_amt float64 = 0
  18923. //
  18924. // var material_claa_sunmfee float64 = 0
  18925. // var material_clab_amt float64 = 0
  18926. // var material_other_amt float64 = 0
  18927. //
  18928. // var laboratory_claa_sunmfee float64 = 0
  18929. // var laboratory_clab_amt float64 = 0
  18930. // var laboratory_other_amt float64 = 0
  18931. //
  18932. // var treat_claa_sunmfee float64 = 0
  18933. // var treat_clab_amt float64 = 0
  18934. // var treat_other_amt float64 = 0
  18935. //
  18936. // for _, item := range order.HisOrderInfo {
  18937. // if item.MedChrgitmType == "01" { //床位费
  18938. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18939. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18940. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18941. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18942. // if item.ChrgitmLv == "1" {
  18943. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18944. // }
  18945. // if item.ChrgitmLv == "2" {
  18946. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18947. //
  18948. // }
  18949. // if item.ChrgitmLv == "3" {
  18950. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18951. // }
  18952. //
  18953. // }
  18954. //
  18955. // if item.MedChrgitmType == "03" { //检查费
  18956. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18957. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18958. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18959. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18960. // if item.ChrgitmLv == "1" {
  18961. //
  18962. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18963. //
  18964. // }
  18965. // if item.ChrgitmLv == "2" {
  18966. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18967. //
  18968. // }
  18969. // if item.ChrgitmLv == "3" {
  18970. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18971. // }
  18972. // }
  18973. //
  18974. // if item.MedChrgitmType == "04" { //化验费
  18975. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18976. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18977. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18978. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18979. // if item.ChrgitmLv == "1" {
  18980. //
  18981. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18982. //
  18983. // }
  18984. // if item.ChrgitmLv == "2" {
  18985. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18986. //
  18987. // }
  18988. // if item.ChrgitmLv == "3" {
  18989. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18990. // }
  18991. // }
  18992. //
  18993. // if item.MedChrgitmType == "05" { //治疗费
  18994. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18995. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18996. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18997. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18998. // if item.ChrgitmLv == "1" {
  18999. //
  19000. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19001. //
  19002. // }
  19003. // if item.ChrgitmLv == "2" {
  19004. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19005. //
  19006. // }
  19007. // if item.ChrgitmLv == "3" {
  19008. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19009. // }
  19010. // }
  19011. //
  19012. // if item.MedChrgitmType == "06" { //手术费
  19013. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19014. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19015. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19016. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19017. //
  19018. // if item.ChrgitmLv == "1" {
  19019. //
  19020. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19021. //
  19022. // }
  19023. // if item.ChrgitmLv == "2" {
  19024. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19025. //
  19026. // }
  19027. // if item.ChrgitmLv == "3" {
  19028. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19029. // }
  19030. // }
  19031. //
  19032. // if item.MedChrgitmType == "08" { //材料费
  19033. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19034. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19035. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19036. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19037. // if item.ChrgitmLv == "1" {
  19038. //
  19039. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19040. //
  19041. // }
  19042. // if item.ChrgitmLv == "2" {
  19043. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19044. //
  19045. // }
  19046. // if item.ChrgitmLv == "3" {
  19047. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19048. // }
  19049. // }
  19050. //
  19051. // if item.MedChrgitmType == "09" { //西药费
  19052. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19053. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19054. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19055. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19056. // if item.ChrgitmLv == "1" {
  19057. //
  19058. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19059. //
  19060. // }
  19061. // if item.ChrgitmLv == "2" {
  19062. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19063. //
  19064. // }
  19065. // if item.ChrgitmLv == "3" {
  19066. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19067. // }
  19068. // }
  19069. //
  19070. // if item.MedChrgitmType == "11" { //中成费
  19071. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19072. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19073. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19074. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19075. // if item.ChrgitmLv == "1" {
  19076. //
  19077. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19078. //
  19079. // }
  19080. // if item.ChrgitmLv == "2" {
  19081. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19082. //
  19083. // }
  19084. // if item.ChrgitmLv == "3" {
  19085. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19086. // }
  19087. // }
  19088. //
  19089. // if item.MedChrgitmType == "14" { //其他费
  19090. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19091. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19092. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19093. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19094. // if item.ChrgitmLv == "1" {
  19095. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19096. //
  19097. // }
  19098. // if item.ChrgitmLv == "2" {
  19099. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19100. //
  19101. // }
  19102. // if item.ChrgitmLv == "3" {
  19103. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19104. // }
  19105. // }
  19106. //
  19107. // }
  19108. //
  19109. // var iteminfoStructs []service.IteminfoStruct
  19110. //
  19111. // if bedCostTotal != 0 {
  19112. // iteminfo.MedChrgitm = "01"
  19113. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19114. // iteminfo.Amt = bedCostTotal
  19115. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19116. // iteminfo.ClabAmt = bed_clab_amt
  19117. // iteminfo.OthAmt = bed_other_amt
  19118. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19119. // }
  19120. //
  19121. // if checkCostTotal != 0 {
  19122. // iteminfo.MedChrgitm = "03"
  19123. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19124. // iteminfo.Amt = checkCostTotal
  19125. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19126. // iteminfo.ClabAmt = check_clab_amt
  19127. // iteminfo.OthAmt = check_other_amt
  19128. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19129. //
  19130. // }
  19131. //
  19132. // if laboratoryCostTotal != 0 {
  19133. // iteminfo.MedChrgitm = "04"
  19134. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19135. // iteminfo.Amt = laboratoryCostTotal
  19136. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19137. // iteminfo.ClabAmt = laboratory_clab_amt
  19138. // iteminfo.OthAmt = laboratory_other_amt
  19139. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19140. //
  19141. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19142. //
  19143. // }
  19144. //
  19145. // if treatCostTotal != 0 {
  19146. // iteminfo.MedChrgitm = "05"
  19147. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19148. // iteminfo.Amt = treatCostTotal
  19149. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19150. // iteminfo.ClabAmt = treat_clab_amt
  19151. // iteminfo.OthAmt = treat_other_amt
  19152. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19153. // //(struct4101.IteminfoStruct, iteminfo)
  19154. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19155. // }
  19156. //
  19157. // if operationCostTotal != 0 {
  19158. // iteminfo.MedChrgitm = "06"
  19159. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19160. // iteminfo.Amt = operationCostTotal
  19161. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19162. // iteminfo.ClabAmt = operation_clab_amt
  19163. // iteminfo.OthAmt = operation_other_amt
  19164. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19165. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19166. // }
  19167. //
  19168. // if materialCostTotal != 0 {
  19169. // iteminfo.MedChrgitm = "08"
  19170. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19171. // iteminfo.Amt = materialCostTotal
  19172. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19173. // iteminfo.ClabAmt = material_clab_amt
  19174. // iteminfo.OthAmt = material_other_amt
  19175. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19176. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19177. // }
  19178. //
  19179. // if westernMedicineCostTotal != 0 {
  19180. // iteminfo.MedChrgitm = "09"
  19181. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19182. // iteminfo.Amt = westernMedicineCostTotal
  19183. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19184. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19185. // iteminfo.OthAmt = westernMedicine_other_amt
  19186. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19187. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19188. //
  19189. // }
  19190. // if chineseTraditionalMedicineCostTotal != 0 {
  19191. // iteminfo.MedChrgitm = "11"
  19192. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19193. // iteminfo.Amt = westernMedicineCostTotal
  19194. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19195. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19196. // iteminfo.OthAmt = westernMedicine_other_amt
  19197. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19198. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19199. //
  19200. // }
  19201. // if otherCostTotal != 0 {
  19202. // iteminfo.MedChrgitm = "14"
  19203. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19204. // iteminfo.Amt = otherCostTotal
  19205. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19206. // iteminfo.ClabAmt = other_clab_amt
  19207. // iteminfo.OthAmt = other_other_amt
  19208. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19209. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19210. //
  19211. // }
  19212. // struct4101.IteminfoStruct = iteminfoStructs
  19213. // struct4101.Ntly = "中国"
  19214. // struct4101.AdmCaty = "A03.06"
  19215. //
  19216. // struct4101.DoctorName = doctor.UserName
  19217. // struct4101.DoctorCode = doctor.DoctorNumber
  19218. //
  19219. // var res ResultSeventeen
  19220. //
  19221. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19222. // struct4101.BillCode = order.Number
  19223. // struct4101.BillNo = order.SetlId
  19224. // var resOther ResultSeventeenOther
  19225. // var pp models.PublicParams
  19226. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19227. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19228. // pp.FixmedinsName = miConfig.OrgName
  19229. // pp.FixmedinsCode = miConfig.Code
  19230. // pp.RequestUrl = miConfig.Url
  19231. // pp.Cainfo = miConfig.Cainfo
  19232. // pp.SecretKey = miConfig.SecretKey
  19233. // pp.AccessKey = miConfig.AccessKey
  19234. // pp.OpterName = curRoles.UserName
  19235. //
  19236. // client := &http.Client{}
  19237. // var req *http.Request
  19238. // data := make(map[string]interface{})
  19239. // data["struct4101"] = struct4101
  19240. // data["pp"] = pp
  19241. // bytesData, _ := json.Marshal(data)
  19242. // if miConfig.MdtrtareaAdmvs == "320921" {
  19243. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19244. // } else {
  19245. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19246. // }
  19247. // resp, _ := client.Do(req)
  19248. // defer resp.Body.Close()
  19249. // body, ioErr := ioutil.ReadAll(resp.Body)
  19250. // if ioErr != nil {
  19251. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19253. // return
  19254. // }
  19255. // var respJSON map[string]interface{}
  19256. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19257. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19259. // return
  19260. // }
  19261. //
  19262. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19263. // userJSONBytes, _ := json.Marshal(respJSON)
  19264. // fmt.Println("log")
  19265. // fmt.Println(string(userJSONBytes))
  19266. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19267. // utils.ErrorLog("解析失败:%v", err)
  19268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19269. // return
  19270. // }
  19271. // res.InfRefmsgid = resOther.InfRefmsgid
  19272. // res.Output = resOther.Output
  19273. // res.ErrMsg = resOther.ErrMsg
  19274. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19275. // res.Infcode = infocode
  19276. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19277. //
  19278. // var pp models.PublicParams
  19279. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19280. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19281. // pp.FixmedinsName = miConfig.OrgName
  19282. // pp.FixmedinsCode = miConfig.Code
  19283. // pp.RequestUrl = miConfig.Url
  19284. // pp.Cainfo = miConfig.Cainfo
  19285. // pp.SecretKey = miConfig.SecretKey
  19286. // pp.AccessKey = miConfig.AccessKey
  19287. // pp.OpterName = curRoles.UserName
  19288. // result, _ := service.Jxyb4101(struct4101, pp)
  19289. // var dat map[string]interface{}
  19290. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19291. // fmt.Println(dat)
  19292. // } else {
  19293. // fmt.Println(err)
  19294. // }
  19295. // userJSONBytes, _ := json.Marshal(dat)
  19296. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19297. // utils.ErrorLog("解析失败:%v", err)
  19298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19299. // return
  19300. // }
  19301. //
  19302. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19303. // var pp models.PublicParams
  19304. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19305. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19306. // pp.FixmedinsName = miConfig.OrgName
  19307. // pp.FixmedinsCode = miConfig.Code
  19308. // pp.RequestUrl = miConfig.Url
  19309. // pp.Cainfo = miConfig.Cainfo
  19310. // pp.SecretKey = miConfig.SecretKey
  19311. // pp.AccessKey = miConfig.AccessKey
  19312. // pp.OpterName = curRoles.UserName
  19313. // result, _ := service.Hnyb4101(struct4101, pp)
  19314. // var dat map[string]interface{}
  19315. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19316. // fmt.Println(dat)
  19317. // } else {
  19318. // fmt.Println(err)
  19319. // }
  19320. // userJSONBytes, _ := json.Marshal(dat)
  19321. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19322. // utils.ErrorLog("解析失败:%v", err)
  19323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19324. // return
  19325. // }
  19326. //
  19327. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19328. // var resOther ResultSeventeenOther
  19329. //
  19330. // var pp models.PublicParams
  19331. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19332. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19333. // pp.FixmedinsName = miConfig.OrgName
  19334. // pp.FixmedinsCode = miConfig.Code
  19335. // pp.RequestUrl = miConfig.Url
  19336. // pp.Cainfo = miConfig.Cainfo
  19337. // pp.SecretKey = miConfig.SecretKey
  19338. // pp.AccessKey = miConfig.AccessKey
  19339. // pp.OpterName = curRoles.UserName
  19340. // client := &http.Client{}
  19341. // var req *http.Request
  19342. // data := make(map[string]interface{})
  19343. // data["struct4101"] = struct4101
  19344. // data["pp"] = pp
  19345. // bytesData, _ := json.Marshal(data)
  19346. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19347. // resp, _ := client.Do(req)
  19348. // defer resp.Body.Close()
  19349. // body, ioErr := ioutil.ReadAll(resp.Body)
  19350. // if ioErr != nil {
  19351. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19353. // return
  19354. // }
  19355. // var respJSON map[string]interface{}
  19356. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19357. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19359. // return
  19360. // }
  19361. //
  19362. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19363. // userJSONBytes, _ := json.Marshal(respJSON)
  19364. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19365. // utils.ErrorLog("解析失败:%v", err)
  19366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19367. // return
  19368. // }
  19369. // res.InfRefmsgid = resOther.InfRefmsgid
  19370. // res.Output = resOther.Output
  19371. // res.ErrMsg = resOther.ErrMsg
  19372. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19373. // res.Infcode = infocode
  19374. //
  19375. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19376. // var pp models.PublicParams
  19377. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19378. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19379. // pp.FixmedinsName = miConfig.OrgName
  19380. // pp.FixmedinsCode = miConfig.Code
  19381. // pp.RequestUrl = miConfig.Url
  19382. // pp.Cainfo = miConfig.Cainfo
  19383. // pp.SecretKey = miConfig.SecretKey
  19384. // pp.AccessKey = miConfig.AccessKey
  19385. // pp.OpterName = curRoles.UserName
  19386. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19387. // fmt.Println(requestLog)
  19388. // fmt.Println(errMsgLog)
  19389. //
  19390. // saveLog(result, requestLog, "4101a", "上传清单")
  19391. //
  19392. // var dat map[string]interface{}
  19393. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19394. // fmt.Println(dat)
  19395. // } else {
  19396. // fmt.Println(err)
  19397. // }
  19398. // userJSONBytes, _ := json.Marshal(dat)
  19399. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19400. // utils.ErrorLog("解析失败:%v", err)
  19401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19402. // return
  19403. // }
  19404. //
  19405. // } else {
  19406. //
  19407. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19408. // var dat map[string]interface{}
  19409. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19410. // fmt.Println(dat)
  19411. // } else {
  19412. // fmt.Println(err)
  19413. // }
  19414. // userJSONBytes, _ := json.Marshal(dat)
  19415. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19416. // utils.ErrorLog("解析失败:%v", err)
  19417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19418. // return
  19419. // }
  19420. // }
  19421. //
  19422. // if res.Infcode != 0 {
  19423. // adminUser := c.GetAdminUserInfo()
  19424. // errlog := &models.HisOrderError{
  19425. // UserOrgId: adminUser.CurrentOrgId,
  19426. // Ctime: time.Now().Unix(),
  19427. // Mtime: time.Now().Unix(),
  19428. // ErrMsg: res.ErrMsg,
  19429. // Status: 1,
  19430. // PatientId: order.ID,
  19431. // Stage: 10265,
  19432. // }
  19433. // service.CreateErrMsgLog(errlog)
  19434. // continue
  19435. // } else {
  19436. // //order.FaPiaoNumber = zero
  19437. // //order.FaPiaoCode = last_order.FaPiaoCode
  19438. // //service.UpdateOrder(order)
  19439. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19440. // Number: res.Output.SetlListId,
  19441. // Status: 1,
  19442. // Ctime: time.Now().Unix(),
  19443. // Mtime: time.Now().Unix(),
  19444. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19445. // IsUpload: 1,
  19446. // OrderId: order.ID,
  19447. // }
  19448. // service.CreateUploadRecord(hisFundSettleListResult)
  19449. // c.ServeSuccessJSON(map[string]interface{}{
  19450. // "msg": "上传成功",
  19451. // "result": hisFundSettleListResult,
  19452. // })
  19453. // continue
  19454. // }
  19455. // }
  19456. //}
  19457. func (c *HisApiController) GetbatchSettleList() {
  19458. //order_id, _ := c.GetInt64("order_id")
  19459. admin_user_id, _ := c.GetInt64("admin_user_id")
  19460. orders, _ := service.GetAllHisOrderTwo10485()
  19461. for _, item := range orders {
  19462. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19463. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19464. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19465. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19466. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19467. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19469. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19470. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19471. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19472. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19473. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19474. //fmt.Println(count)
  19475. //var zero string
  19476. //number := count + 1
  19477. //if number >= 1000 {
  19478. // zero = "0000" + strconv.FormatInt(number, 10)
  19479. //} else if number >= 10000 {
  19480. // zero = "000" + strconv.FormatInt(number, 10)
  19481. //} else if number >= 100000 {
  19482. // zero = "00" + strconv.FormatInt(number, 10)
  19483. //} else if number >= 1000000 {
  19484. // zero = "0" + strconv.FormatInt(number, 10)
  19485. //} else {
  19486. // zero = strconv.FormatInt(number, 10)
  19487. //}
  19488. //fmt.Println(zero)
  19489. struct4101 := service.Struct4101{
  19490. PsnNo: order.PsnNo,
  19491. MdtrtId: order.MdtrtId,
  19492. SetlId: order.SetlId,
  19493. PsnName: order.PsnName,
  19494. Gend: order.Gend,
  19495. Brdy: his.Brdy,
  19496. Age: his.Age,
  19497. Naty: order.Naty,
  19498. PatnCertType: "01",
  19499. Certno: order.Certno,
  19500. Prfs: "90",
  19501. ConerName: roles[0].UserName,
  19502. PatnRlts: "99",
  19503. ConerAddr: miConfig.OrgName,
  19504. ConerTel: admin.Mobile,
  19505. HiType: order.Insutype,
  19506. Insuplc: miConfig.InsuplcAdmdvs,
  19507. MaindiagFlag: "1",
  19508. BillCode: order.SetlId,
  19509. BillNo: order.SetlId,
  19510. BizSn: order.Number,
  19511. PsnSelfPay: order.PsnPartAmt,
  19512. PsnOwnPay: order.PsnPartAmt,
  19513. AcctPay: order.AcctPay,
  19514. PsnCashpay: order.PsnCashPay,
  19515. HiPaymtd: "1",
  19516. Hsorg: miConfig.InsuplcAdmdvs,
  19517. HsorgOpter: miConfig.InsuplcAdmdvs,
  19518. MedinsFillPsn: curRoles.UserName,
  19519. MedinsFillDept: miConfig.OrgName,
  19520. IptMedType: "2",
  19521. }
  19522. struct4101.SetlBegnDate = order.SetlTime
  19523. struct4101.SetlEndDate = order.SetlTime
  19524. time_arr := strings.Split(order.SetlTime, " ")
  19525. struct4101.AdmTime = time_arr[0]
  19526. struct4101.AdmEndTime = time_arr[0]
  19527. //var rf []CustomFundPay
  19528. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19529. //
  19530. //var tempFunPays []service.CustomStruct
  19531. //for _, item := range rf {
  19532. // var tempFunPay service.CustomStruct
  19533. // tempFunPay.FundPayamt = item.FundPayamt
  19534. // tempFunPay.FundPayType = item.FundPayType
  19535. // tempFunPays = append(tempFunPays, tempFunPay)
  19536. //}
  19537. //struct4101.CustomStruct = tempFunPays
  19538. var tempDiaginfos []service.DiaginfoStructTwo
  19539. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19540. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19541. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19542. var config []*models.HisXtDiagnoseConfig
  19543. for _, item := range diagnosis_ids {
  19544. id, _ := strconv.ParseInt(item, 10, 64)
  19545. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19546. config = append(config, &diagnosisConfig)
  19547. }
  19548. for index, item := range config {
  19549. if index == 0 {
  19550. var tempDiaginfo service.DiaginfoStructTwo
  19551. tempDiaginfo.DiagCode = item.CountryCode
  19552. tempDiaginfo.DiagName = item.CountryContentName
  19553. tempDiaginfo.DiagType = "1"
  19554. tempDiaginfo.MaindiagFlag = "1"
  19555. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19556. } else {
  19557. var tempDiaginfo service.DiaginfoStructTwo
  19558. tempDiaginfo.DiagCode = item.CountryCode
  19559. tempDiaginfo.DiagName = item.CountryContentName
  19560. tempDiaginfo.DiagType = "1"
  19561. tempDiaginfo.MaindiagFlag = "0"
  19562. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19563. }
  19564. }
  19565. struct4101.Diseinfo = tempDiaginfos
  19566. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19567. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19568. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19569. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19570. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19571. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19572. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19573. var iteminfo service.IteminfoStruct
  19574. var bedCostTotal float64 = 0 //床位总费
  19575. var bedCostSelfTotal float64 = 0 //床位自费
  19576. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19577. var operationCostTotal float64 = 0 //手术费
  19578. var operationCostSelfTotal float64 = 0 //手术费
  19579. var operationCostPartSelfTotal float64 = 0 //手术费
  19580. var otherCostTotal float64 = 0 //其他费用
  19581. var otherCostSelfTotal float64 = 0 //其他费用
  19582. var otherCostPartSelfTotal float64 = 0 //其他费用
  19583. var materialCostTotal float64 = 0 //材料费
  19584. var materialCostSelfTotal float64 = 0 //材料费
  19585. var materialCostPartSelfTotal float64 = 0 //材料费
  19586. var westernMedicineCostTotal float64 = 0 //西药费
  19587. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19588. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19589. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19590. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19591. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19592. var checkCostTotal float64 = 0 //检查费
  19593. var checkCostSelfTotal float64 = 0 //检查费
  19594. var checkCostPartSelfTotal float64 = 0 //检查费
  19595. var laboratoryCostTotal float64 = 0 //化验费
  19596. var laboratoryCostSelfTotal float64 = 0 //化验费
  19597. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19598. var treatCostTotal float64 = 0 //治疗费用
  19599. var treatCostSelfTotal float64 = 0 //治疗费用
  19600. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19601. decimal.DivisionPrecision = 2
  19602. var bed_fulamt_ownpay_amt float64 = 0
  19603. var operation_fulamt_ownpay_amt float64 = 0
  19604. var other_fulamt_ownpay_amt float64 = 0
  19605. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19606. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19607. var check_fulamt_ownpay_amt float64 = 0
  19608. var material_fulamt_ownpay_amt float64 = 0
  19609. var laboratory_fulamt_ownpay_amt float64 = 0
  19610. var treat_fulamt_ownpay_amt float64 = 0
  19611. var bed_claa_sunmfee float64 = 0
  19612. var bed_clab_amt float64 = 0
  19613. var bed_other_amt float64 = 0
  19614. var operation_claa_sunmfee float64 = 0
  19615. var operation_clab_amt float64 = 0
  19616. var operation_other_amt float64 = 0
  19617. var other_claa_sunmfee float64 = 0
  19618. var other_clab_amt float64 = 0
  19619. var other_other_amt float64 = 0
  19620. var westernMedicine_claa_sunmfee float64 = 0
  19621. var westernMedicine_clab_amt float64 = 0
  19622. var westernMedicine_other_amt float64 = 0
  19623. var chineseTraditional_claa_sunmfee float64 = 0
  19624. var chineseTraditional_clab_amt float64 = 0
  19625. var chineseTraditional_other_amt float64 = 0
  19626. var check_claa_sunmfee float64 = 0
  19627. var check_clab_amt float64 = 0
  19628. var check_other_amt float64 = 0
  19629. var material_claa_sunmfee float64 = 0
  19630. var material_clab_amt float64 = 0
  19631. var material_other_amt float64 = 0
  19632. var laboratory_claa_sunmfee float64 = 0
  19633. var laboratory_clab_amt float64 = 0
  19634. var laboratory_other_amt float64 = 0
  19635. var treat_claa_sunmfee float64 = 0
  19636. var treat_clab_amt float64 = 0
  19637. var treat_other_amt float64 = 0
  19638. for _, item := range order.HisOrderInfo {
  19639. if item.MedChrgitmType == "01" { //床位费
  19640. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19641. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19642. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19643. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19644. if item.ChrgitmLv == "1" {
  19645. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19646. }
  19647. if item.ChrgitmLv == "2" {
  19648. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19649. }
  19650. if item.ChrgitmLv == "3" {
  19651. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19652. }
  19653. }
  19654. if item.MedChrgitmType == "03" { //检查费
  19655. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19656. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19657. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19658. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19659. if item.ChrgitmLv == "1" {
  19660. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19661. }
  19662. if item.ChrgitmLv == "2" {
  19663. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19664. }
  19665. if item.ChrgitmLv == "3" {
  19666. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19667. }
  19668. }
  19669. if item.MedChrgitmType == "04" { //化验费
  19670. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19671. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19672. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19673. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19674. if item.ChrgitmLv == "1" {
  19675. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19676. }
  19677. if item.ChrgitmLv == "2" {
  19678. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19679. }
  19680. if item.ChrgitmLv == "3" {
  19681. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19682. }
  19683. }
  19684. if item.MedChrgitmType == "05" { //治疗费
  19685. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19686. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19687. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19688. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19689. if item.ChrgitmLv == "1" {
  19690. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19691. }
  19692. if item.ChrgitmLv == "2" {
  19693. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19694. }
  19695. if item.ChrgitmLv == "3" {
  19696. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19697. }
  19698. }
  19699. if item.MedChrgitmType == "06" { //手术费
  19700. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19701. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19702. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19703. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19704. if item.ChrgitmLv == "1" {
  19705. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19706. }
  19707. if item.ChrgitmLv == "2" {
  19708. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19709. }
  19710. if item.ChrgitmLv == "3" {
  19711. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19712. }
  19713. }
  19714. if item.MedChrgitmType == "08" { //材料费
  19715. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19716. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19717. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19718. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19719. if item.ChrgitmLv == "1" {
  19720. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19721. }
  19722. if item.ChrgitmLv == "2" {
  19723. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19724. }
  19725. if item.ChrgitmLv == "3" {
  19726. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19727. }
  19728. }
  19729. if item.MedChrgitmType == "09" { //西药费
  19730. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19731. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19732. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19733. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19734. if item.ChrgitmLv == "1" {
  19735. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19736. }
  19737. if item.ChrgitmLv == "2" {
  19738. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19739. }
  19740. if item.ChrgitmLv == "3" {
  19741. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19742. }
  19743. }
  19744. if item.MedChrgitmType == "11" { //中成费
  19745. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19746. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19747. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19748. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19749. if item.ChrgitmLv == "1" {
  19750. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19751. }
  19752. if item.ChrgitmLv == "2" {
  19753. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19754. }
  19755. if item.ChrgitmLv == "3" {
  19756. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19757. }
  19758. }
  19759. if item.MedChrgitmType == "14" { //其他费
  19760. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19761. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19762. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19763. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19764. if item.ChrgitmLv == "1" {
  19765. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19766. }
  19767. if item.ChrgitmLv == "2" {
  19768. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19769. }
  19770. if item.ChrgitmLv == "3" {
  19771. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19772. }
  19773. }
  19774. }
  19775. var iteminfoStructs []service.IteminfoStruct
  19776. if bedCostTotal != 0 {
  19777. iteminfo.MedChrgitm = "01"
  19778. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19779. iteminfo.Amt = bedCostTotal
  19780. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19781. iteminfo.ClabAmt = bed_clab_amt
  19782. iteminfo.OthAmt = bed_other_amt
  19783. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19784. }
  19785. if checkCostTotal != 0 {
  19786. iteminfo.MedChrgitm = "03"
  19787. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19788. iteminfo.Amt = checkCostTotal
  19789. iteminfo.ClaaSumfee = check_claa_sunmfee
  19790. iteminfo.ClabAmt = check_clab_amt
  19791. iteminfo.OthAmt = check_other_amt
  19792. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19793. }
  19794. if laboratoryCostTotal != 0 {
  19795. iteminfo.MedChrgitm = "04"
  19796. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19797. iteminfo.Amt = laboratoryCostTotal
  19798. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19799. iteminfo.ClabAmt = laboratory_clab_amt
  19800. iteminfo.OthAmt = laboratory_other_amt
  19801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19802. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19803. }
  19804. if treatCostTotal != 0 {
  19805. iteminfo.MedChrgitm = "05"
  19806. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19807. iteminfo.Amt = treatCostTotal
  19808. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19809. iteminfo.ClabAmt = treat_clab_amt
  19810. iteminfo.OthAmt = treat_other_amt
  19811. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19812. //(struct4101.IteminfoStruct, iteminfo)
  19813. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19814. }
  19815. if operationCostTotal != 0 {
  19816. iteminfo.MedChrgitm = "06"
  19817. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19818. iteminfo.Amt = operationCostTotal
  19819. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19820. iteminfo.ClabAmt = operation_clab_amt
  19821. iteminfo.OthAmt = operation_other_amt
  19822. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19823. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19824. }
  19825. if materialCostTotal != 0 {
  19826. iteminfo.MedChrgitm = "08"
  19827. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19828. iteminfo.Amt = materialCostTotal
  19829. iteminfo.ClaaSumfee = material_claa_sunmfee
  19830. iteminfo.ClabAmt = material_clab_amt
  19831. iteminfo.OthAmt = material_other_amt
  19832. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19833. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19834. }
  19835. if westernMedicineCostTotal != 0 {
  19836. iteminfo.MedChrgitm = "09"
  19837. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19838. iteminfo.Amt = westernMedicineCostTotal
  19839. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19840. iteminfo.ClabAmt = westernMedicine_clab_amt
  19841. iteminfo.OthAmt = westernMedicine_other_amt
  19842. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19843. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19844. }
  19845. if chineseTraditionalMedicineCostTotal != 0 {
  19846. iteminfo.MedChrgitm = "11"
  19847. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19848. iteminfo.Amt = westernMedicineCostTotal
  19849. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19850. iteminfo.ClabAmt = westernMedicine_clab_amt
  19851. iteminfo.OthAmt = westernMedicine_other_amt
  19852. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19853. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19854. }
  19855. if otherCostTotal != 0 {
  19856. iteminfo.MedChrgitm = "14"
  19857. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19858. iteminfo.Amt = otherCostTotal
  19859. iteminfo.ClaaSumfee = other_claa_sunmfee
  19860. iteminfo.ClabAmt = other_clab_amt
  19861. iteminfo.OthAmt = other_other_amt
  19862. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19863. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19864. }
  19865. struct4101.IteminfoStruct = iteminfoStructs
  19866. struct4101.Ntly = "中国"
  19867. struct4101.AdmCaty = "A03.06"
  19868. struct4101.DoctorName = doctor.UserName
  19869. struct4101.DoctorCode = doctor.DoctorNumber
  19870. var res ResultSeventeen
  19871. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  19872. struct4101.BillCode = order.Number
  19873. struct4101.BillNo = order.SetlId
  19874. var resOther ResultSeventeenOther
  19875. var pp models.PublicParams
  19876. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19877. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19878. pp.FixmedinsName = miConfig.OrgName
  19879. pp.FixmedinsCode = miConfig.Code
  19880. pp.RequestUrl = miConfig.Url
  19881. pp.Cainfo = miConfig.Cainfo
  19882. pp.SecretKey = miConfig.SecretKey
  19883. pp.AccessKey = miConfig.AccessKey
  19884. pp.OpterName = curRoles.UserName
  19885. client := &http.Client{}
  19886. var req *http.Request
  19887. data := make(map[string]interface{})
  19888. data["struct4101"] = struct4101
  19889. data["pp"] = pp
  19890. bytesData, _ := json.Marshal(data)
  19891. if miConfig.MdtrtareaAdmvs == "320830" {
  19892. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  19893. } else if miConfig.MdtrtareaAdmvs == "320921" {
  19894. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19895. } else {
  19896. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19897. }
  19898. resp, _ := client.Do(req)
  19899. defer resp.Body.Close()
  19900. body, ioErr := ioutil.ReadAll(resp.Body)
  19901. if ioErr != nil {
  19902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19904. return
  19905. }
  19906. var respJSON map[string]interface{}
  19907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19910. return
  19911. }
  19912. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19913. userJSONBytes, _ := json.Marshal(respJSON)
  19914. fmt.Println("log")
  19915. fmt.Println(string(userJSONBytes))
  19916. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19917. utils.ErrorLog("解析失败:%v", err)
  19918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19919. return
  19920. }
  19921. res.InfRefmsgid = resOther.InfRefmsgid
  19922. res.Output = resOther.Output
  19923. res.ErrMsg = resOther.ErrMsg
  19924. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19925. res.Infcode = infocode
  19926. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19927. var pp models.PublicParams
  19928. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19929. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19930. pp.FixmedinsName = miConfig.OrgName
  19931. pp.FixmedinsCode = miConfig.Code
  19932. pp.RequestUrl = miConfig.Url
  19933. pp.Cainfo = miConfig.Cainfo
  19934. pp.SecretKey = miConfig.SecretKey
  19935. pp.AccessKey = miConfig.AccessKey
  19936. pp.OpterName = curRoles.UserName
  19937. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19938. result, _ := service.Jxyb4101(struct4101, pp)
  19939. var dat map[string]interface{}
  19940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19941. fmt.Println(dat)
  19942. } else {
  19943. fmt.Println(err)
  19944. }
  19945. userJSONBytes, _ := json.Marshal(dat)
  19946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19947. utils.ErrorLog("解析失败:%v", err)
  19948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19949. return
  19950. }
  19951. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19952. var pp models.PublicParams
  19953. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19954. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19955. pp.FixmedinsName = miConfig.OrgName
  19956. pp.FixmedinsCode = miConfig.Code
  19957. pp.RequestUrl = miConfig.Url
  19958. pp.Cainfo = miConfig.Cainfo
  19959. pp.SecretKey = miConfig.SecretKey
  19960. pp.AccessKey = miConfig.AccessKey
  19961. pp.OpterName = curRoles.UserName
  19962. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19963. result, _ := service.Jxyb4101(struct4101, pp)
  19964. var dat map[string]interface{}
  19965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19966. fmt.Println(dat)
  19967. } else {
  19968. fmt.Println(err)
  19969. }
  19970. userJSONBytes, _ := json.Marshal(dat)
  19971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19972. utils.ErrorLog("解析失败:%v", err)
  19973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19974. return
  19975. }
  19976. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19977. var pp models.PublicParams
  19978. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19979. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19980. pp.FixmedinsName = miConfig.OrgName
  19981. pp.FixmedinsCode = miConfig.Code
  19982. pp.RequestUrl = miConfig.Url
  19983. pp.Cainfo = miConfig.Cainfo
  19984. pp.SecretKey = miConfig.SecretKey
  19985. pp.AccessKey = miConfig.AccessKey
  19986. pp.OpterName = curRoles.UserName
  19987. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19988. result, _ := service.Jxyb4101(struct4101, pp)
  19989. var dat map[string]interface{}
  19990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19991. fmt.Println(dat)
  19992. } else {
  19993. fmt.Println(err)
  19994. }
  19995. userJSONBytes, _ := json.Marshal(dat)
  19996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19997. utils.ErrorLog("解析失败:%v", err)
  19998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19999. return
  20000. }
  20001. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20002. var pp models.PublicParams
  20003. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20004. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20005. pp.FixmedinsName = miConfig.OrgName
  20006. pp.FixmedinsCode = miConfig.Code
  20007. pp.RequestUrl = miConfig.Url
  20008. pp.Cainfo = miConfig.Cainfo
  20009. pp.SecretKey = miConfig.SecretKey
  20010. pp.AccessKey = miConfig.AccessKey
  20011. pp.OpterName = curRoles.UserName
  20012. result, _ := service.Hnyb4101(struct4101, pp)
  20013. var dat map[string]interface{}
  20014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20015. fmt.Println(dat)
  20016. } else {
  20017. fmt.Println(err)
  20018. }
  20019. userJSONBytes, _ := json.Marshal(dat)
  20020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20021. utils.ErrorLog("解析失败:%v", err)
  20022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20023. return
  20024. }
  20025. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20026. var resOther ResultSeventeenOther
  20027. var pp models.PublicParams
  20028. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20029. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20030. pp.FixmedinsName = miConfig.OrgName
  20031. pp.FixmedinsCode = miConfig.Code
  20032. pp.RequestUrl = miConfig.Url
  20033. pp.Cainfo = miConfig.Cainfo
  20034. pp.SecretKey = miConfig.SecretKey
  20035. pp.AccessKey = miConfig.AccessKey
  20036. pp.OpterName = curRoles.UserName
  20037. client := &http.Client{}
  20038. var req *http.Request
  20039. data := make(map[string]interface{})
  20040. data["struct4101"] = struct4101
  20041. data["pp"] = pp
  20042. bytesData, _ := json.Marshal(data)
  20043. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20044. resp, _ := client.Do(req)
  20045. defer resp.Body.Close()
  20046. body, ioErr := ioutil.ReadAll(resp.Body)
  20047. if ioErr != nil {
  20048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20050. return
  20051. }
  20052. var respJSON map[string]interface{}
  20053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20056. return
  20057. }
  20058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20059. userJSONBytes, _ := json.Marshal(respJSON)
  20060. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20061. utils.ErrorLog("解析失败:%v", err)
  20062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20063. return
  20064. }
  20065. res.InfRefmsgid = resOther.InfRefmsgid
  20066. res.Output = resOther.Output
  20067. res.ErrMsg = resOther.ErrMsg
  20068. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20069. res.Infcode = infocode
  20070. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20071. var pp models.PublicParams
  20072. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20073. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20074. pp.FixmedinsName = miConfig.OrgName
  20075. pp.FixmedinsCode = miConfig.Code
  20076. pp.RequestUrl = miConfig.Url
  20077. pp.Cainfo = miConfig.Cainfo
  20078. pp.SecretKey = miConfig.SecretKey
  20079. pp.AccessKey = miConfig.AccessKey
  20080. pp.OpterName = curRoles.UserName
  20081. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20082. fmt.Println(requestLog)
  20083. fmt.Println(errMsgLog)
  20084. saveLog(result, requestLog, "4101a", "上传清单")
  20085. var dat map[string]interface{}
  20086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20087. fmt.Println(dat)
  20088. } else {
  20089. fmt.Println(err)
  20090. }
  20091. userJSONBytes, _ := json.Marshal(dat)
  20092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20093. utils.ErrorLog("解析失败:%v", err)
  20094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20095. return
  20096. }
  20097. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20098. var pp models.PublicParams
  20099. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20100. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20101. pp.FixmedinsName = miConfig.OrgName
  20102. pp.FixmedinsCode = miConfig.Code
  20103. pp.RequestUrl = miConfig.Url
  20104. pp.Cainfo = miConfig.Cainfo
  20105. pp.SecretKey = miConfig.SecretKey
  20106. pp.AccessKey = miConfig.AccessKey
  20107. pp.OpterName = curRoles.UserName
  20108. client := &http.Client{}
  20109. var req *http.Request
  20110. data := make(map[string]interface{})
  20111. data["struct4101"] = struct4101
  20112. data["pp"] = pp
  20113. bytesData, _ := json.Marshal(data)
  20114. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20115. resp, _ := client.Do(req)
  20116. defer resp.Body.Close()
  20117. body, ioErr := ioutil.ReadAll(resp.Body)
  20118. if ioErr != nil {
  20119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20121. return
  20122. }
  20123. var respJSON map[string]interface{}
  20124. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20127. return
  20128. }
  20129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20130. userJSONBytes, _ := json.Marshal(respJSON)
  20131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20132. utils.ErrorLog("解析失败:%v", err)
  20133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20134. return
  20135. }
  20136. } else {
  20137. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20138. var dat map[string]interface{}
  20139. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20140. fmt.Println(dat)
  20141. } else {
  20142. fmt.Println(err)
  20143. }
  20144. userJSONBytes, _ := json.Marshal(dat)
  20145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20146. utils.ErrorLog("解析失败:%v", err)
  20147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20148. return
  20149. }
  20150. }
  20151. if res.Infcode != 0 {
  20152. errlog := &models.HisOrderError{
  20153. UserOrgId: order.UserOrgId,
  20154. Ctime: time.Now().Unix(),
  20155. Mtime: time.Now().Unix(),
  20156. ErrMsg: res.ErrMsg + "解析失败",
  20157. Status: 1,
  20158. PatientId: order.ID,
  20159. Stage: 10485,
  20160. }
  20161. service.CreateErrMsgLog(errlog)
  20162. continue
  20163. //c.ServeSuccessJSON(map[string]interface{}{
  20164. // "failed_code": -10,
  20165. // "msg": res.ErrMsg,
  20166. //})
  20167. } else {
  20168. //order.FaPiaoNumber = zero
  20169. //order.FaPiaoCode = last_order.FaPiaoCode
  20170. //service.UpdateOrder(order)
  20171. hisFundSettleListResult := &models.HisFundSettleListResult{
  20172. Number: res.Output.SetlListId,
  20173. Status: 1,
  20174. Ctime: time.Now().Unix(),
  20175. Mtime: time.Now().Unix(),
  20176. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20177. IsUpload: 1,
  20178. OrderId: order.ID,
  20179. }
  20180. service.CreateUploadRecord(hisFundSettleListResult)
  20181. continue
  20182. }
  20183. }
  20184. }
  20185. func (c *HisApiController) GetSettleList() {
  20186. order_id, _ := c.GetInt64("order_id")
  20187. admin_user_id, _ := c.GetInt64("admin_user_id")
  20188. order, _ := service.GetHisOrderByIDTwo(order_id)
  20189. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20190. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20191. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20192. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20193. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20194. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20195. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20196. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20197. if order.ID == 0 {
  20198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20199. return
  20200. }
  20201. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20202. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20203. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20204. //fmt.Println(count)
  20205. //var zero string
  20206. //number := count + 1
  20207. //if number >= 1000 {
  20208. // zero = "0000" + strconv.FormatInt(number, 10)
  20209. //} else if number >= 10000 {
  20210. // zero = "000" + strconv.FormatInt(number, 10)
  20211. //} else if number >= 100000 {
  20212. // zero = "00" + strconv.FormatInt(number, 10)
  20213. //} else if number >= 1000000 {
  20214. // zero = "0" + strconv.FormatInt(number, 10)
  20215. //} else {
  20216. // zero = strconv.FormatInt(number, 10)
  20217. //}
  20218. //fmt.Println(zero)
  20219. struct4101 := service.Struct4101{
  20220. PsnNo: order.PsnNo,
  20221. MdtrtId: order.MdtrtId,
  20222. SetlId: order.SetlId,
  20223. PsnName: order.PsnName,
  20224. Gend: order.Gend,
  20225. Brdy: his.Brdy,
  20226. Age: his.Age,
  20227. Naty: order.Naty,
  20228. PatnCertType: "01",
  20229. Certno: order.Certno,
  20230. Prfs: "90",
  20231. ConerName: roles[0].UserName,
  20232. PatnRlts: "99",
  20233. ConerAddr: miConfig.OrgName,
  20234. ConerTel: admin.Mobile,
  20235. HiType: order.Insutype,
  20236. Insuplc: miConfig.InsuplcAdmdvs,
  20237. MaindiagFlag: "1",
  20238. BillCode: order.SetlId,
  20239. BillNo: order.SetlId,
  20240. BizSn: order.Number,
  20241. PsnSelfPay: order.PsnPartAmt,
  20242. PsnOwnPay: order.PsnPartAmt,
  20243. AcctPay: order.AcctPay,
  20244. PsnCashpay: order.PsnCashPay,
  20245. HiPaymtd: "1",
  20246. Hsorg: miConfig.InsuplcAdmdvs,
  20247. HsorgOpter: miConfig.InsuplcAdmdvs,
  20248. MedinsFillPsn: curRoles.UserName,
  20249. MedinsFillDept: miConfig.OrgName,
  20250. IptMedType: "2",
  20251. }
  20252. struct4101.SetlBegnDate = order.SetlTime
  20253. struct4101.SetlEndDate = order.SetlTime
  20254. time_arr := strings.Split(order.SetlTime, " ")
  20255. struct4101.AdmTime = time_arr[0]
  20256. struct4101.AdmEndTime = time_arr[0]
  20257. //
  20258. //var rf []CustomFundPay
  20259. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20260. //
  20261. //var tempFunPays []service.CustomStruct
  20262. //for _, item := range rf {
  20263. // var tempFunPay service.CustomStruct
  20264. // tempFunPay.FundPayamt = item.FundPayamt
  20265. // tempFunPay.FundPayType = item.FundPayType
  20266. // tempFunPays = append(tempFunPays, tempFunPay)
  20267. //}
  20268. //struct4101.CustomStruct = tempFunPays
  20269. var tempDiaginfos []service.DiaginfoStructTwo
  20270. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20271. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20272. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20273. var config []*models.HisXtDiagnoseConfig
  20274. for _, item := range diagnosis_ids {
  20275. id, _ := strconv.ParseInt(item, 10, 64)
  20276. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20277. config = append(config, &diagnosisConfig)
  20278. }
  20279. if miConfig.Code == "H15049901371" {
  20280. //for _, item := range config {
  20281. // if item.ID == 138 {
  20282. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20283. var tempDiaginfo service.DiaginfoStructTwo
  20284. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20285. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20286. tempDiaginfo.DiagType = "1"
  20287. tempDiaginfo.MaindiagFlag = "1"
  20288. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20289. //}
  20290. //}
  20291. for _, item := range config {
  20292. if item.ID != 138 {
  20293. var tempDiaginfo service.DiaginfoStructTwo
  20294. tempDiaginfo.DiagCode = item.CountryCode
  20295. tempDiaginfo.DiagName = item.CountryContentName
  20296. tempDiaginfo.DiagType = "1"
  20297. tempDiaginfo.MaindiagFlag = "0"
  20298. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20299. }
  20300. }
  20301. } else {
  20302. for index, item := range config {
  20303. if index == 0 {
  20304. var tempDiaginfo service.DiaginfoStructTwo
  20305. tempDiaginfo.DiagCode = item.CountryCode
  20306. tempDiaginfo.DiagName = item.CountryContentName
  20307. tempDiaginfo.DiagType = "1"
  20308. tempDiaginfo.MaindiagFlag = "1"
  20309. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20310. } else {
  20311. var tempDiaginfo service.DiaginfoStructTwo
  20312. tempDiaginfo.DiagCode = item.CountryCode
  20313. tempDiaginfo.DiagName = item.CountryContentName
  20314. tempDiaginfo.DiagType = "1"
  20315. tempDiaginfo.MaindiagFlag = "0"
  20316. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20317. }
  20318. }
  20319. }
  20320. struct4101.Diseinfo = tempDiaginfos
  20321. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20322. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20323. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20324. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20325. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20326. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20327. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20328. var iteminfo service.IteminfoStruct
  20329. var bedCostTotal float64 = 0 //床位总费
  20330. var bedCostSelfTotal float64 = 0 //床位自费
  20331. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20332. var operationCostTotal float64 = 0 //手术费
  20333. var operationCostSelfTotal float64 = 0 //手术费
  20334. var operationCostPartSelfTotal float64 = 0 //手术费
  20335. var otherCostTotal float64 = 0 //其他费用
  20336. var otherCostSelfTotal float64 = 0 //其他费用
  20337. var otherCostPartSelfTotal float64 = 0 //其他费用
  20338. var materialCostTotal float64 = 0 //材料费
  20339. var materialCostSelfTotal float64 = 0 //材料费
  20340. var materialCostPartSelfTotal float64 = 0 //材料费
  20341. var westernMedicineCostTotal float64 = 0 //西药费
  20342. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20343. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20344. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20345. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20346. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20347. var checkCostTotal float64 = 0 //检查费
  20348. var checkCostSelfTotal float64 = 0 //检查费
  20349. var checkCostPartSelfTotal float64 = 0 //检查费
  20350. var laboratoryCostTotal float64 = 0 //化验费
  20351. var laboratoryCostSelfTotal float64 = 0 //化验费
  20352. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20353. var treatCostTotal float64 = 0 //治疗费用
  20354. var treatCostSelfTotal float64 = 0 //治疗费用
  20355. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20356. decimal.DivisionPrecision = 2
  20357. var bed_fulamt_ownpay_amt float64 = 0
  20358. var operation_fulamt_ownpay_amt float64 = 0
  20359. var other_fulamt_ownpay_amt float64 = 0
  20360. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20361. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20362. var check_fulamt_ownpay_amt float64 = 0
  20363. var material_fulamt_ownpay_amt float64 = 0
  20364. var laboratory_fulamt_ownpay_amt float64 = 0
  20365. var treat_fulamt_ownpay_amt float64 = 0
  20366. var bed_claa_sunmfee float64 = 0
  20367. var bed_clab_amt float64 = 0
  20368. var bed_other_amt float64 = 0
  20369. var operation_claa_sunmfee float64 = 0
  20370. var operation_clab_amt float64 = 0
  20371. var operation_other_amt float64 = 0
  20372. var other_claa_sunmfee float64 = 0
  20373. var other_clab_amt float64 = 0
  20374. var other_other_amt float64 = 0
  20375. var westernMedicine_claa_sunmfee float64 = 0
  20376. var westernMedicine_clab_amt float64 = 0
  20377. var westernMedicine_other_amt float64 = 0
  20378. var chineseTraditional_claa_sunmfee float64 = 0
  20379. var chineseTraditional_clab_amt float64 = 0
  20380. var chineseTraditional_other_amt float64 = 0
  20381. var check_claa_sunmfee float64 = 0
  20382. var check_clab_amt float64 = 0
  20383. var check_other_amt float64 = 0
  20384. var material_claa_sunmfee float64 = 0
  20385. var material_clab_amt float64 = 0
  20386. var material_other_amt float64 = 0
  20387. var laboratory_claa_sunmfee float64 = 0
  20388. var laboratory_clab_amt float64 = 0
  20389. var laboratory_other_amt float64 = 0
  20390. var treat_claa_sunmfee float64 = 0
  20391. var treat_clab_amt float64 = 0
  20392. var treat_other_amt float64 = 0
  20393. for _, item := range order.HisOrderInfo {
  20394. if item.MedChrgitmType == "01" { //床位费
  20395. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20396. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20397. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20398. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20399. if item.ChrgitmLv == "1" {
  20400. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20401. }
  20402. if item.ChrgitmLv == "2" {
  20403. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20404. }
  20405. if item.ChrgitmLv == "3" {
  20406. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20407. }
  20408. }
  20409. if item.MedChrgitmType == "03" { //检查费
  20410. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20411. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20412. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20413. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20414. if item.ChrgitmLv == "1" {
  20415. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20416. }
  20417. if item.ChrgitmLv == "2" {
  20418. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20419. }
  20420. if item.ChrgitmLv == "3" {
  20421. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20422. }
  20423. }
  20424. if item.MedChrgitmType == "04" { //化验费
  20425. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20426. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20427. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20428. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20429. if item.ChrgitmLv == "1" {
  20430. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20431. }
  20432. if item.ChrgitmLv == "2" {
  20433. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20434. }
  20435. if item.ChrgitmLv == "3" {
  20436. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20437. }
  20438. }
  20439. if item.MedChrgitmType == "05" { //治疗费
  20440. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20441. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20442. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20443. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20444. if item.ChrgitmLv == "1" {
  20445. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20446. }
  20447. if item.ChrgitmLv == "2" {
  20448. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20449. }
  20450. if item.ChrgitmLv == "3" {
  20451. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20452. }
  20453. }
  20454. if item.MedChrgitmType == "06" { //手术费
  20455. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20456. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20457. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20458. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20459. if item.ChrgitmLv == "1" {
  20460. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20461. }
  20462. if item.ChrgitmLv == "2" {
  20463. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20464. }
  20465. if item.ChrgitmLv == "3" {
  20466. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20467. }
  20468. }
  20469. if item.MedChrgitmType == "08" { //材料费
  20470. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20471. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20472. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20473. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20474. if item.ChrgitmLv == "1" {
  20475. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20476. }
  20477. if item.ChrgitmLv == "2" {
  20478. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20479. }
  20480. if item.ChrgitmLv == "3" {
  20481. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20482. }
  20483. }
  20484. if item.MedChrgitmType == "09" { //西药费
  20485. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20486. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20487. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20488. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20489. if item.ChrgitmLv == "1" {
  20490. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20491. }
  20492. if item.ChrgitmLv == "2" {
  20493. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20494. }
  20495. if item.ChrgitmLv == "3" {
  20496. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20497. }
  20498. }
  20499. if item.MedChrgitmType == "11" { //中成费
  20500. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20501. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20502. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20503. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20504. if item.ChrgitmLv == "1" {
  20505. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20506. }
  20507. if item.ChrgitmLv == "2" {
  20508. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20509. }
  20510. if item.ChrgitmLv == "3" {
  20511. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20512. }
  20513. }
  20514. if item.MedChrgitmType == "14" { //其他费
  20515. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20516. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20517. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20518. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20519. if item.ChrgitmLv == "1" {
  20520. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20521. }
  20522. if item.ChrgitmLv == "2" {
  20523. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20524. }
  20525. if item.ChrgitmLv == "3" {
  20526. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20527. }
  20528. }
  20529. }
  20530. var iteminfoStructs []service.IteminfoStruct
  20531. if bedCostTotal != 0 {
  20532. iteminfo.MedChrgitm = "01"
  20533. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20534. iteminfo.Amt = bedCostTotal
  20535. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20536. iteminfo.ClabAmt = bed_clab_amt
  20537. iteminfo.OthAmt = bed_other_amt
  20538. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20539. }
  20540. if checkCostTotal != 0 {
  20541. iteminfo.MedChrgitm = "03"
  20542. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20543. iteminfo.Amt = checkCostTotal
  20544. iteminfo.ClaaSumfee = check_claa_sunmfee
  20545. iteminfo.ClabAmt = check_clab_amt
  20546. iteminfo.OthAmt = check_other_amt
  20547. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20548. }
  20549. if laboratoryCostTotal != 0 {
  20550. iteminfo.MedChrgitm = "04"
  20551. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20552. iteminfo.Amt = laboratoryCostTotal
  20553. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20554. iteminfo.ClabAmt = laboratory_clab_amt
  20555. iteminfo.OthAmt = laboratory_other_amt
  20556. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20557. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20558. }
  20559. if treatCostTotal != 0 {
  20560. iteminfo.MedChrgitm = "05"
  20561. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20562. iteminfo.Amt = treatCostTotal
  20563. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20564. iteminfo.ClabAmt = treat_clab_amt
  20565. iteminfo.OthAmt = treat_other_amt
  20566. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20567. //(struct4101.IteminfoStruct, iteminfo)
  20568. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20569. }
  20570. if operationCostTotal != 0 {
  20571. iteminfo.MedChrgitm = "06"
  20572. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20573. iteminfo.Amt = operationCostTotal
  20574. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20575. iteminfo.ClabAmt = operation_clab_amt
  20576. iteminfo.OthAmt = operation_other_amt
  20577. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20578. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20579. }
  20580. if materialCostTotal != 0 {
  20581. iteminfo.MedChrgitm = "08"
  20582. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20583. iteminfo.Amt = materialCostTotal
  20584. iteminfo.ClaaSumfee = material_claa_sunmfee
  20585. iteminfo.ClabAmt = material_clab_amt
  20586. iteminfo.OthAmt = material_other_amt
  20587. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20588. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20589. }
  20590. if westernMedicineCostTotal != 0 {
  20591. iteminfo.MedChrgitm = "09"
  20592. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20593. iteminfo.Amt = westernMedicineCostTotal
  20594. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20595. iteminfo.ClabAmt = westernMedicine_clab_amt
  20596. iteminfo.OthAmt = westernMedicine_other_amt
  20597. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20598. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20599. }
  20600. if chineseTraditionalMedicineCostTotal != 0 {
  20601. iteminfo.MedChrgitm = "11"
  20602. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20603. iteminfo.Amt = westernMedicineCostTotal
  20604. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20605. iteminfo.ClabAmt = westernMedicine_clab_amt
  20606. iteminfo.OthAmt = westernMedicine_other_amt
  20607. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20608. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20609. }
  20610. if otherCostTotal != 0 {
  20611. iteminfo.MedChrgitm = "14"
  20612. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20613. iteminfo.Amt = otherCostTotal
  20614. iteminfo.ClaaSumfee = other_claa_sunmfee
  20615. iteminfo.ClabAmt = other_clab_amt
  20616. iteminfo.OthAmt = other_other_amt
  20617. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20618. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20619. }
  20620. struct4101.IteminfoStruct = iteminfoStructs
  20621. struct4101.Ntly = "中国"
  20622. struct4101.AdmCaty = "A03.06"
  20623. struct4101.DoctorName = doctor.UserName
  20624. struct4101.DoctorCode = doctor.DoctorNumber
  20625. var res ResultSeventeen
  20626. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20627. struct4101.BillCode = order.Number
  20628. struct4101.BillNo = order.SetlId
  20629. var resOther ResultSeventeenOther
  20630. var pp models.PublicParams
  20631. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20632. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20633. pp.FixmedinsName = miConfig.OrgName
  20634. pp.FixmedinsCode = miConfig.Code
  20635. pp.RequestUrl = miConfig.Url
  20636. pp.Cainfo = miConfig.Cainfo
  20637. pp.SecretKey = miConfig.SecretKey
  20638. pp.AccessKey = miConfig.AccessKey
  20639. pp.OpterName = curRoles.UserName
  20640. client := &http.Client{}
  20641. var req *http.Request
  20642. data := make(map[string]interface{})
  20643. data["struct4101"] = struct4101
  20644. data["pp"] = pp
  20645. bytesData, _ := json.Marshal(data)
  20646. if miConfig.MdtrtareaAdmvs == "320830" {
  20647. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20648. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20649. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20650. } else {
  20651. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20652. }
  20653. resp, _ := client.Do(req)
  20654. defer resp.Body.Close()
  20655. body, ioErr := ioutil.ReadAll(resp.Body)
  20656. if ioErr != nil {
  20657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20659. return
  20660. }
  20661. var respJSON map[string]interface{}
  20662. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20665. return
  20666. }
  20667. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20668. userJSONBytes, _ := json.Marshal(respJSON)
  20669. fmt.Println("log")
  20670. fmt.Println(string(userJSONBytes))
  20671. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20672. utils.ErrorLog("解析失败:%v", err)
  20673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20674. return
  20675. }
  20676. res.InfRefmsgid = resOther.InfRefmsgid
  20677. res.Output = resOther.Output
  20678. res.ErrMsg = resOther.ErrMsg
  20679. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20680. res.Infcode = infocode
  20681. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20682. var pp models.PublicParams
  20683. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20684. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20685. pp.FixmedinsName = miConfig.OrgName
  20686. pp.FixmedinsCode = miConfig.Code
  20687. pp.RequestUrl = miConfig.Url
  20688. pp.Cainfo = miConfig.Cainfo
  20689. pp.SecretKey = miConfig.SecretKey
  20690. pp.AccessKey = miConfig.AccessKey
  20691. pp.OpterName = curRoles.UserName
  20692. result, _ := service.Jxyb4101(struct4101, pp)
  20693. var dat map[string]interface{}
  20694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20695. fmt.Println(dat)
  20696. } else {
  20697. fmt.Println(err)
  20698. }
  20699. userJSONBytes, _ := json.Marshal(dat)
  20700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20701. utils.ErrorLog("解析失败:%v", err)
  20702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20703. return
  20704. }
  20705. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20706. var pp models.PublicParams
  20707. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20708. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20709. pp.FixmedinsName = miConfig.OrgName
  20710. pp.FixmedinsCode = miConfig.Code
  20711. pp.RequestUrl = miConfig.Url
  20712. pp.Cainfo = miConfig.Cainfo
  20713. pp.SecretKey = miConfig.SecretKey
  20714. pp.AccessKey = miConfig.AccessKey
  20715. pp.OpterName = curRoles.UserName
  20716. result, _ := service.Jxyb4101(struct4101, pp)
  20717. var dat map[string]interface{}
  20718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20719. fmt.Println(dat)
  20720. } else {
  20721. fmt.Println(err)
  20722. }
  20723. userJSONBytes, _ := json.Marshal(dat)
  20724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20725. utils.ErrorLog("解析失败:%v", err)
  20726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20727. return
  20728. }
  20729. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20730. var pp models.PublicParams
  20731. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20732. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20733. pp.FixmedinsName = miConfig.OrgName
  20734. pp.FixmedinsCode = miConfig.Code
  20735. pp.RequestUrl = miConfig.Url
  20736. pp.Cainfo = miConfig.Cainfo
  20737. pp.SecretKey = miConfig.SecretKey
  20738. pp.AccessKey = miConfig.AccessKey
  20739. pp.OpterName = curRoles.UserName
  20740. result, _ := service.Jxyb4101(struct4101, pp)
  20741. var dat map[string]interface{}
  20742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20743. fmt.Println(dat)
  20744. } else {
  20745. fmt.Println(err)
  20746. }
  20747. userJSONBytes, _ := json.Marshal(dat)
  20748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20749. utils.ErrorLog("解析失败:%v", err)
  20750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20751. return
  20752. }
  20753. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20754. var pp models.PublicParams
  20755. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20756. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20757. pp.FixmedinsName = miConfig.OrgName
  20758. pp.FixmedinsCode = miConfig.Code
  20759. pp.RequestUrl = miConfig.Url
  20760. pp.Cainfo = miConfig.Cainfo
  20761. pp.SecretKey = miConfig.SecretKey
  20762. pp.AccessKey = miConfig.AccessKey
  20763. pp.OpterName = curRoles.UserName
  20764. result, _ := service.Hnyb4101(struct4101, pp)
  20765. var dat map[string]interface{}
  20766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20767. fmt.Println(dat)
  20768. } else {
  20769. fmt.Println(err)
  20770. }
  20771. userJSONBytes, _ := json.Marshal(dat)
  20772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20773. utils.ErrorLog("解析失败:%v", err)
  20774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20775. return
  20776. }
  20777. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20778. var resOther ResultSeventeenOther
  20779. var pp models.PublicParams
  20780. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20781. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20782. pp.FixmedinsName = miConfig.OrgName
  20783. pp.FixmedinsCode = miConfig.Code
  20784. pp.RequestUrl = miConfig.Url
  20785. pp.Cainfo = miConfig.Cainfo
  20786. pp.SecretKey = miConfig.SecretKey
  20787. pp.AccessKey = miConfig.AccessKey
  20788. pp.OpterName = curRoles.UserName
  20789. client := &http.Client{}
  20790. var req *http.Request
  20791. data := make(map[string]interface{})
  20792. data["struct4101"] = struct4101
  20793. data["pp"] = pp
  20794. bytesData, _ := json.Marshal(data)
  20795. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20796. resp, _ := client.Do(req)
  20797. defer resp.Body.Close()
  20798. body, ioErr := ioutil.ReadAll(resp.Body)
  20799. if ioErr != nil {
  20800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20802. return
  20803. }
  20804. var respJSON map[string]interface{}
  20805. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20808. return
  20809. }
  20810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20811. userJSONBytes, _ := json.Marshal(respJSON)
  20812. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20813. utils.ErrorLog("解析失败:%v", err)
  20814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20815. return
  20816. }
  20817. res.InfRefmsgid = resOther.InfRefmsgid
  20818. res.Output = resOther.Output
  20819. res.ErrMsg = resOther.ErrMsg
  20820. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20821. res.Infcode = infocode
  20822. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20823. var pp models.PublicParams
  20824. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20825. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20826. pp.FixmedinsName = miConfig.OrgName
  20827. pp.FixmedinsCode = miConfig.Code
  20828. pp.RequestUrl = miConfig.Url
  20829. pp.Cainfo = miConfig.Cainfo
  20830. pp.SecretKey = miConfig.SecretKey
  20831. pp.AccessKey = miConfig.AccessKey
  20832. pp.OpterName = curRoles.UserName
  20833. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20834. fmt.Println(requestLog)
  20835. fmt.Println(errMsgLog)
  20836. saveLog(result, requestLog, "4101a", "上传清单")
  20837. var dat map[string]interface{}
  20838. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20839. fmt.Println(dat)
  20840. } else {
  20841. fmt.Println(err)
  20842. }
  20843. userJSONBytes, _ := json.Marshal(dat)
  20844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20845. utils.ErrorLog("解析失败:%v", err)
  20846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20847. return
  20848. }
  20849. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20850. var pp models.PublicParams
  20851. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20852. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20853. pp.FixmedinsName = miConfig.OrgName
  20854. pp.FixmedinsCode = miConfig.Code
  20855. pp.RequestUrl = miConfig.Url
  20856. pp.Cainfo = miConfig.Cainfo
  20857. pp.SecretKey = miConfig.SecretKey
  20858. pp.AccessKey = miConfig.AccessKey
  20859. pp.OpterName = curRoles.UserName
  20860. client := &http.Client{}
  20861. var req *http.Request
  20862. data := make(map[string]interface{})
  20863. data["struct4101"] = struct4101
  20864. data["pp"] = pp
  20865. bytesData, _ := json.Marshal(data)
  20866. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20867. resp, _ := client.Do(req)
  20868. defer resp.Body.Close()
  20869. body, ioErr := ioutil.ReadAll(resp.Body)
  20870. if ioErr != nil {
  20871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20873. return
  20874. }
  20875. var respJSON map[string]interface{}
  20876. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20879. return
  20880. }
  20881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20882. userJSONBytes, _ := json.Marshal(respJSON)
  20883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20884. utils.ErrorLog("解析失败:%v", err)
  20885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20886. return
  20887. }
  20888. } else {
  20889. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20890. var dat map[string]interface{}
  20891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20892. fmt.Println(dat)
  20893. } else {
  20894. fmt.Println(err)
  20895. }
  20896. userJSONBytes, _ := json.Marshal(dat)
  20897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20898. utils.ErrorLog("解析失败:%v", err)
  20899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20900. return
  20901. }
  20902. }
  20903. if res.Infcode != 0 {
  20904. c.ServeSuccessJSON(map[string]interface{}{
  20905. "failed_code": -10,
  20906. "msg": res.ErrMsg,
  20907. })
  20908. return
  20909. } else {
  20910. //order.FaPiaoNumber = zero
  20911. //order.FaPiaoCode = last_order.FaPiaoCode
  20912. //service.UpdateOrder(order)
  20913. hisFundSettleListResult := &models.HisFundSettleListResult{
  20914. Number: res.Output.SetlListId,
  20915. Status: 1,
  20916. Ctime: time.Now().Unix(),
  20917. Mtime: time.Now().Unix(),
  20918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20919. IsUpload: 1,
  20920. OrderId: order_id,
  20921. }
  20922. service.CreateUploadRecord(hisFundSettleListResult)
  20923. c.ServeSuccessJSON(map[string]interface{}{
  20924. "msg": "上传成功",
  20925. "result": hisFundSettleListResult,
  20926. })
  20927. return
  20928. }
  20929. }
  20930. func (c *HisApiController) GetSettleListHospital() {
  20931. order_id, _ := c.GetInt64("order_id")
  20932. admin_user_id, _ := c.GetInt64("admin_user_id")
  20933. order, _ := service.GetHisOrderByIDTwo(order_id)
  20934. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20935. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20936. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20937. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20938. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20939. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20940. if order.ID == 0 {
  20941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20942. return
  20943. }
  20944. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20945. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20946. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20947. fmt.Println(count)
  20948. var zero string
  20949. number := count + 1
  20950. if number >= 1000 {
  20951. zero = "0000" + strconv.FormatInt(number, 10)
  20952. } else if number >= 10000 {
  20953. zero = "000" + strconv.FormatInt(number, 10)
  20954. } else if number >= 100000 {
  20955. zero = "00" + strconv.FormatInt(number, 10)
  20956. } else if number >= 1000000 {
  20957. zero = "0" + strconv.FormatInt(number, 10)
  20958. } else {
  20959. zero = strconv.FormatInt(number, 10)
  20960. }
  20961. fmt.Println(zero)
  20962. struct4101 := service.Struct4101{
  20963. PsnNo: order.PsnNo,
  20964. MdtrtId: order.MdtrtId,
  20965. SetlId: order.SetlId,
  20966. PsnName: order.PsnName,
  20967. Gend: order.Gend,
  20968. Brdy: his.Brdy,
  20969. Age: int64(order.Age),
  20970. Naty: order.Naty,
  20971. PatnCertType: "01",
  20972. Certno: order.Certno,
  20973. Prfs: "90",
  20974. ConerName: roles[0].UserName,
  20975. PatnRlts: "99",
  20976. ConerAddr: miConfig.OrgName,
  20977. ConerTel: admin.Mobile,
  20978. HiType: order.Insutype,
  20979. Insuplc: miConfig.InsuplcAdmdvs,
  20980. MaindiagFlag: "1",
  20981. BillCode: order.SetlId,
  20982. BillNo: order.SetlId,
  20983. BizSn: order.Number,
  20984. PsnSelfPay: order.PsnPartAmt,
  20985. PsnOwnPay: order.PsnPartAmt,
  20986. AcctPay: order.AcctPay,
  20987. PsnCashpay: order.PsnCashPay,
  20988. HiPaymtd: "1",
  20989. Hsorg: miConfig.InsuplcAdmdvs,
  20990. HsorgOpter: miConfig.InsuplcAdmdvs,
  20991. MedinsFillPsn: curRoles.UserName,
  20992. MedinsFillDept: depart.Name,
  20993. IptMedType: "2",
  20994. AdmTime: his.InHosptialTime,
  20995. AdmEndTime: his.OutHosptialTime,
  20996. }
  20997. struct4101.SetlBegnDate = order.SetlTime
  20998. struct4101.SetlEndDate = order.SetlTime
  20999. //var rf []CustomFundPay
  21000. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21001. //
  21002. //var tempFunPays []service.CustomStruct
  21003. //for _, item := range rf {
  21004. // var tempFunPay service.CustomStruct
  21005. // tempFunPay.FundPayamt = item.FundPayamt
  21006. // tempFunPay.FundPayType = item.FundPayType
  21007. // tempFunPays = append(tempFunPays, tempFunPay)
  21008. //}
  21009. //struct4101.CustomStruct = tempFunPays
  21010. var tempDiaginfos []service.DiaginfoStructTwo
  21011. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21012. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21013. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21014. //for _, item := range infos {
  21015. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21016. //}
  21017. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21018. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21019. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21020. fmt.Println(diagnosis_ids_arr)
  21021. if order.UserOrgId == 10210 {
  21022. var diagnosis_ids_arr_two []int64
  21023. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21024. var config []*models.HisXtDiagnoseConfig
  21025. for _, id := range diagnosis_ids_arr_two {
  21026. //id, _ := strconv.ParseInt(item, 10, 64)
  21027. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21028. if diagnosisConfig.ID > 0 {
  21029. config = append(config, &diagnosisConfig)
  21030. }
  21031. }
  21032. for index, item := range config {
  21033. if item.ID > 0 {
  21034. if index == 0 {
  21035. var tempDiaginfo service.DiaginfoStructTwo
  21036. tempDiaginfo.DiagCode = item.CountryCode
  21037. tempDiaginfo.DiagName = item.CountryContentName
  21038. tempDiaginfo.DiagType = "1"
  21039. tempDiaginfo.MaindiagFlag = "1"
  21040. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21041. } else {
  21042. var tempDiaginfo service.DiaginfoStructTwo
  21043. tempDiaginfo.DiagCode = item.CountryCode
  21044. tempDiaginfo.DiagName = item.CountryContentName
  21045. tempDiaginfo.DiagType = "1"
  21046. tempDiaginfo.MaindiagFlag = "0"
  21047. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21048. }
  21049. }
  21050. }
  21051. struct4101.Diseinfo = tempDiaginfos
  21052. } else {
  21053. var config []*models.HisXtDiagnoseConfig
  21054. for _, item := range diagnosis_ids_arr {
  21055. id, _ := strconv.ParseInt(item, 10, 64)
  21056. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21057. if diagnosisConfig.ID > 0 {
  21058. config = append(config, &diagnosisConfig)
  21059. }
  21060. }
  21061. for index, item := range config {
  21062. if item.ID > 0 {
  21063. if index == 0 {
  21064. var tempDiaginfo service.DiaginfoStructTwo
  21065. tempDiaginfo.DiagCode = item.CountryCode
  21066. tempDiaginfo.DiagName = item.CountryContentName
  21067. tempDiaginfo.DiagType = "1"
  21068. tempDiaginfo.MaindiagFlag = "1"
  21069. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21070. } else {
  21071. var tempDiaginfo service.DiaginfoStructTwo
  21072. tempDiaginfo.DiagCode = item.CountryCode
  21073. tempDiaginfo.DiagName = item.CountryContentName
  21074. tempDiaginfo.DiagType = "1"
  21075. tempDiaginfo.MaindiagFlag = "0"
  21076. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21077. }
  21078. }
  21079. }
  21080. struct4101.Diseinfo = tempDiaginfos
  21081. }
  21082. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21083. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21084. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21085. tempOpspdiseinfo2.OprnOprtCode = ""
  21086. tempOpspdiseinfo2.OprnOprtName = ""
  21087. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21088. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21089. var iteminfo service.IteminfoStruct
  21090. var bedCostTotal float64 = 0 //床位总费
  21091. var bedCostSelfTotal float64 = 0 //床位自费
  21092. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21093. var operationCostTotal float64 = 0 //手术费
  21094. var operationCostSelfTotal float64 = 0 //手术费
  21095. var operationCostPartSelfTotal float64 = 0 //手术费
  21096. var otherCostTotal float64 = 0 //其他费用
  21097. var otherCostSelfTotal float64 = 0 //其他费用
  21098. var otherCostPartSelfTotal float64 = 0 //其他费用
  21099. var materialCostTotal float64 = 0 //材料费
  21100. var materialCostSelfTotal float64 = 0 //材料费
  21101. var materialCostPartSelfTotal float64 = 0 //材料费
  21102. var westernMedicineCostTotal float64 = 0 //西药费
  21103. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21104. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21105. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21106. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21107. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21108. var checkCostTotal float64 = 0 //检查费
  21109. var checkCostSelfTotal float64 = 0 //检查费
  21110. var checkCostPartSelfTotal float64 = 0 //检查费
  21111. var laboratoryCostTotal float64 = 0 //化验费
  21112. var laboratoryCostSelfTotal float64 = 0 //化验费
  21113. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21114. var treatCostTotal float64 = 0 //治疗费用
  21115. var treatCostSelfTotal float64 = 0 //治疗费用
  21116. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21117. decimal.DivisionPrecision = 2
  21118. var bed_fulamt_ownpay_amt float64 = 0
  21119. var operation_fulamt_ownpay_amt float64 = 0
  21120. var other_fulamt_ownpay_amt float64 = 0
  21121. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21122. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21123. var check_fulamt_ownpay_amt float64 = 0
  21124. var material_fulamt_ownpay_amt float64 = 0
  21125. var laboratory_fulamt_ownpay_amt float64 = 0
  21126. var treat_fulamt_ownpay_amt float64 = 0
  21127. var bed_claa_sunmfee float64 = 0
  21128. var bed_clab_amt float64 = 0
  21129. var bed_other_amt float64 = 0
  21130. var operation_claa_sunmfee float64 = 0
  21131. var operation_clab_amt float64 = 0
  21132. var operation_other_amt float64 = 0
  21133. var other_claa_sunmfee float64 = 0
  21134. var other_clab_amt float64 = 0
  21135. var other_other_amt float64 = 0
  21136. var westernMedicine_claa_sunmfee float64 = 0
  21137. var westernMedicine_clab_amt float64 = 0
  21138. var westernMedicine_other_amt float64 = 0
  21139. var chineseTraditional_claa_sunmfee float64 = 0
  21140. var chineseTraditional_clab_amt float64 = 0
  21141. var chineseTraditional_other_amt float64 = 0
  21142. var check_claa_sunmfee float64 = 0
  21143. var check_clab_amt float64 = 0
  21144. var check_other_amt float64 = 0
  21145. var material_claa_sunmfee float64 = 0
  21146. var material_clab_amt float64 = 0
  21147. var material_other_amt float64 = 0
  21148. var laboratory_claa_sunmfee float64 = 0
  21149. var laboratory_clab_amt float64 = 0
  21150. var laboratory_other_amt float64 = 0
  21151. var treat_claa_sunmfee float64 = 0
  21152. var treat_clab_amt float64 = 0
  21153. var treat_other_amt float64 = 0
  21154. for _, item := range order.HisOrderInfo {
  21155. if item.MedChrgitmType == "01" { //床位费
  21156. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21157. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21158. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21159. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21160. if item.ChrgitmLv == "1" {
  21161. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21162. }
  21163. if item.ChrgitmLv == "2" {
  21164. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21165. }
  21166. if item.ChrgitmLv == "3" {
  21167. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21168. }
  21169. }
  21170. if item.MedChrgitmType == "03" { //检查费
  21171. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21172. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21173. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21174. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21175. if item.ChrgitmLv == "1" {
  21176. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21177. }
  21178. if item.ChrgitmLv == "2" {
  21179. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21180. }
  21181. if item.ChrgitmLv == "3" {
  21182. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21183. }
  21184. }
  21185. if item.MedChrgitmType == "04" { //化验费
  21186. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21187. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21188. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21189. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21190. if item.ChrgitmLv == "1" {
  21191. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21192. }
  21193. if item.ChrgitmLv == "2" {
  21194. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21195. }
  21196. if item.ChrgitmLv == "3" {
  21197. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21198. }
  21199. }
  21200. if item.MedChrgitmType == "05" { //治疗费
  21201. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21202. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21203. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21204. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21205. if item.ChrgitmLv == "1" {
  21206. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21207. }
  21208. if item.ChrgitmLv == "2" {
  21209. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21210. }
  21211. if item.ChrgitmLv == "3" {
  21212. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21213. }
  21214. }
  21215. if item.MedChrgitmType == "06" { //手术费
  21216. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21217. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21218. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21219. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21220. if item.ChrgitmLv == "1" {
  21221. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21222. }
  21223. if item.ChrgitmLv == "2" {
  21224. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21225. }
  21226. if item.ChrgitmLv == "3" {
  21227. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21228. }
  21229. }
  21230. if item.MedChrgitmType == "08" { //材料费
  21231. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21232. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21233. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21234. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21235. if item.ChrgitmLv == "1" {
  21236. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21237. }
  21238. if item.ChrgitmLv == "2" {
  21239. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21240. }
  21241. if item.ChrgitmLv == "3" {
  21242. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21243. }
  21244. }
  21245. if item.MedChrgitmType == "09" { //西药费
  21246. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21247. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21248. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21249. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21250. if item.ChrgitmLv == "1" {
  21251. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21252. }
  21253. if item.ChrgitmLv == "2" {
  21254. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21255. }
  21256. if item.ChrgitmLv == "3" {
  21257. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21258. }
  21259. }
  21260. if item.MedChrgitmType == "11" { //中成费
  21261. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21262. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21263. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21264. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21265. if item.ChrgitmLv == "1" {
  21266. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21267. }
  21268. if item.ChrgitmLv == "2" {
  21269. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21270. }
  21271. if item.ChrgitmLv == "3" {
  21272. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21273. }
  21274. }
  21275. if item.MedChrgitmType == "14" { //其他费
  21276. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21277. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21278. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21279. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21280. if item.ChrgitmLv == "1" {
  21281. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21282. }
  21283. if item.ChrgitmLv == "2" {
  21284. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21285. }
  21286. if item.ChrgitmLv == "3" {
  21287. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21288. }
  21289. }
  21290. }
  21291. var iteminfoStructs []service.IteminfoStruct
  21292. if bedCostTotal != 0 {
  21293. iteminfo.MedChrgitm = "01"
  21294. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21295. iteminfo.Amt = bedCostTotal
  21296. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21297. iteminfo.ClabAmt = bed_clab_amt
  21298. iteminfo.OthAmt = bed_other_amt
  21299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21300. }
  21301. if checkCostTotal != 0 {
  21302. iteminfo.MedChrgitm = "03"
  21303. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21304. iteminfo.Amt = checkCostTotal
  21305. iteminfo.ClaaSumfee = check_claa_sunmfee
  21306. iteminfo.ClabAmt = check_clab_amt
  21307. iteminfo.OthAmt = check_other_amt
  21308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21309. }
  21310. if laboratoryCostTotal != 0 {
  21311. iteminfo.MedChrgitm = "04"
  21312. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21313. iteminfo.Amt = laboratoryCostTotal
  21314. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21315. iteminfo.ClabAmt = laboratory_clab_amt
  21316. iteminfo.OthAmt = laboratory_other_amt
  21317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21318. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21319. }
  21320. if treatCostTotal != 0 {
  21321. iteminfo.MedChrgitm = "05"
  21322. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21323. iteminfo.Amt = treatCostTotal
  21324. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21325. iteminfo.ClabAmt = treat_clab_amt
  21326. iteminfo.OthAmt = treat_other_amt
  21327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21328. //(struct4101.IteminfoStruct, iteminfo)
  21329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21330. }
  21331. if operationCostTotal != 0 {
  21332. iteminfo.MedChrgitm = "06"
  21333. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21334. iteminfo.Amt = operationCostTotal
  21335. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21336. iteminfo.ClabAmt = operation_clab_amt
  21337. iteminfo.OthAmt = operation_other_amt
  21338. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21339. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21340. }
  21341. if materialCostTotal != 0 {
  21342. iteminfo.MedChrgitm = "08"
  21343. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21344. iteminfo.Amt = materialCostTotal
  21345. iteminfo.ClaaSumfee = material_claa_sunmfee
  21346. iteminfo.ClabAmt = material_clab_amt
  21347. iteminfo.OthAmt = material_other_amt
  21348. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21349. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21350. }
  21351. if westernMedicineCostTotal != 0 {
  21352. iteminfo.MedChrgitm = "09"
  21353. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21354. iteminfo.Amt = westernMedicineCostTotal
  21355. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21356. iteminfo.ClabAmt = westernMedicine_clab_amt
  21357. iteminfo.OthAmt = westernMedicine_other_amt
  21358. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21359. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21360. }
  21361. if chineseTraditionalMedicineCostTotal != 0 {
  21362. iteminfo.MedChrgitm = "11"
  21363. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21364. iteminfo.Amt = westernMedicineCostTotal
  21365. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21366. iteminfo.ClabAmt = westernMedicine_clab_amt
  21367. iteminfo.OthAmt = westernMedicine_other_amt
  21368. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21370. }
  21371. if otherCostTotal != 0 {
  21372. iteminfo.MedChrgitm = "14"
  21373. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21374. iteminfo.Amt = otherCostTotal
  21375. iteminfo.ClaaSumfee = other_claa_sunmfee
  21376. iteminfo.ClabAmt = other_clab_amt
  21377. iteminfo.OthAmt = other_other_amt
  21378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21380. }
  21381. struct4101.IteminfoStruct = iteminfoStructs
  21382. struct4101.Ntly = "中国"
  21383. struct4101.AdmCaty = "A03.06"
  21384. var resOther ResultSeventeenOther
  21385. var res ResultSeventeen
  21386. if miConfig.MdtrtareaAdmvs == "150499" {
  21387. var pp models.PublicParams
  21388. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21389. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21390. pp.FixmedinsName = miConfig.OrgName
  21391. pp.FixmedinsCode = miConfig.Code
  21392. pp.RequestUrl = miConfig.Url
  21393. pp.Cainfo = miConfig.Cainfo
  21394. pp.SecretKey = miConfig.SecretKey
  21395. pp.AccessKey = miConfig.AccessKey
  21396. pp.OpterName = curRoles.UserName
  21397. client := &http.Client{}
  21398. var req *http.Request
  21399. data := make(map[string]interface{})
  21400. data["struct4101"] = struct4101
  21401. data["pp"] = pp
  21402. bytesData, _ := json.Marshal(data)
  21403. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21404. resp, _ := client.Do(req)
  21405. defer resp.Body.Close()
  21406. body, ioErr := ioutil.ReadAll(resp.Body)
  21407. if ioErr != nil {
  21408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21410. return
  21411. }
  21412. var respJSON map[string]interface{}
  21413. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21416. return
  21417. }
  21418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21419. userJSONBytes, _ := json.Marshal(respJSON)
  21420. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21421. utils.ErrorLog("解析失败:%v", err)
  21422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21423. return
  21424. }
  21425. res.InfRefmsgid = resOther.InfRefmsgid
  21426. res.Output = resOther.Output
  21427. res.ErrMsg = resOther.ErrMsg
  21428. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21429. res.Infcode = infocode
  21430. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21431. var pp models.PublicParams
  21432. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21433. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21434. pp.FixmedinsName = miConfig.OrgName
  21435. pp.FixmedinsCode = miConfig.Code
  21436. pp.RequestUrl = miConfig.Url
  21437. pp.Cainfo = miConfig.Cainfo
  21438. pp.SecretKey = miConfig.SecretKey
  21439. pp.AccessKey = miConfig.AccessKey
  21440. pp.OpterName = curRoles.UserName
  21441. result, _ := service.Jxyb4101(struct4101, pp)
  21442. var dat map[string]interface{}
  21443. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21444. fmt.Println(dat)
  21445. } else {
  21446. fmt.Println(err)
  21447. }
  21448. userJSONBytes, _ := json.Marshal(dat)
  21449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21450. utils.ErrorLog("解析失败:%v", err)
  21451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21452. return
  21453. }
  21454. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21455. var pp models.PublicParams
  21456. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21457. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21458. pp.FixmedinsName = miConfig.OrgName
  21459. pp.FixmedinsCode = miConfig.Code
  21460. pp.RequestUrl = miConfig.Url
  21461. pp.Cainfo = miConfig.Cainfo
  21462. pp.SecretKey = miConfig.SecretKey
  21463. pp.AccessKey = miConfig.AccessKey
  21464. pp.OpterName = curRoles.UserName
  21465. result, _ := service.Jxyb4101(struct4101, pp)
  21466. var dat map[string]interface{}
  21467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21468. fmt.Println(dat)
  21469. } else {
  21470. fmt.Println(err)
  21471. }
  21472. userJSONBytes, _ := json.Marshal(dat)
  21473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21474. utils.ErrorLog("解析失败:%v", err)
  21475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21476. return
  21477. }
  21478. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21479. var pp models.PublicParams
  21480. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21481. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21482. pp.FixmedinsName = miConfig.OrgName
  21483. pp.FixmedinsCode = miConfig.Code
  21484. pp.RequestUrl = miConfig.Url
  21485. pp.Cainfo = miConfig.Cainfo
  21486. pp.SecretKey = miConfig.SecretKey
  21487. pp.AccessKey = miConfig.AccessKey
  21488. pp.OpterName = curRoles.UserName
  21489. result, _ := service.Jxyb4101(struct4101, pp)
  21490. var dat map[string]interface{}
  21491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21492. fmt.Println(dat)
  21493. } else {
  21494. fmt.Println(err)
  21495. }
  21496. userJSONBytes, _ := json.Marshal(dat)
  21497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21498. utils.ErrorLog("解析失败:%v", err)
  21499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21500. return
  21501. }
  21502. } else {
  21503. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21504. var dat map[string]interface{}
  21505. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21506. fmt.Println(dat)
  21507. } else {
  21508. fmt.Println(err)
  21509. }
  21510. userJSONBytes, _ := json.Marshal(dat)
  21511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21512. utils.ErrorLog("解析失败:%v", err)
  21513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21514. return
  21515. }
  21516. }
  21517. if res.Infcode != 0 {
  21518. c.ServeSuccessJSON(map[string]interface{}{
  21519. "failed_code": -10,
  21520. "msg": res.ErrMsg,
  21521. })
  21522. return
  21523. } else {
  21524. if miConfig.MdtrtareaAdmvs != "150499" {
  21525. order.FaPiaoNumber = zero
  21526. order.FaPiaoCode = last_order.FaPiaoCode
  21527. service.UpdateOrder(order)
  21528. }
  21529. hisFundSettleListResult := &models.HisFundSettleListResult{
  21530. Number: res.Output.SetlListId,
  21531. Status: 1,
  21532. Ctime: time.Now().Unix(),
  21533. Mtime: time.Now().Unix(),
  21534. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21535. IsUpload: 1,
  21536. OrderId: order_id,
  21537. }
  21538. service.CreateUploadRecord(hisFundSettleListResult)
  21539. c.ServeSuccessJSON(map[string]interface{}{
  21540. "msg": "上传成功",
  21541. "result": hisFundSettleListResult,
  21542. })
  21543. return
  21544. }
  21545. }
  21546. //func (c *HisApiController) GetBatchSettleList() {
  21547. // orders, _ := service.GetAllHisOrder(10106)
  21548. // for _, item := range orders {
  21549. // order_id := item.ID
  21550. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21551. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21552. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21553. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21554. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21555. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21556. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21557. //
  21558. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21559. //
  21560. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21561. //
  21562. // if order.ID == 0 {
  21563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21564. // return
  21565. // }
  21566. // if his.BalanceAccountsType == 2 {
  21567. // continue
  21568. // }
  21569. // struct4101 := service.Struct4101{
  21570. // PsnNo: order.PsnNo,
  21571. // MdtrtId: order.MdtrtId,
  21572. // SetlId: order.SetlId,
  21573. // PsnName: order.PsnName,
  21574. // Gend: order.Gend,
  21575. // Brdy: his.Brdy,
  21576. // Age: his.Age,
  21577. // Naty: order.Naty,
  21578. // PatnCertType: "01",
  21579. // Certno: order.Certno,
  21580. // Prfs: "90",
  21581. // ConerName: roles[0].UserName,
  21582. // PatnRlts: "99",
  21583. // ConerAddr: miConfig.OrgName,
  21584. // ConerTel: admin.Mobile,
  21585. // HiType: order.Insutype,
  21586. // Insuplc: his.InsuplcAdmdvs,
  21587. // MaindiagFlag: "1",
  21588. // BillCode: order.SetlId,
  21589. // BillNo: order.SetlId,
  21590. // BizSn: order.Number,
  21591. // PsnSelfPay: order.PsnPartAmt,
  21592. // PsnOwnPay: order.PsnPartAmt,
  21593. // AcctPay: order.AcctPay,
  21594. // PsnCashpay: order.PsnCashPay,
  21595. // HiPaymtd: "1",
  21596. // Hsorg: his.InsuplcAdmdvs,
  21597. // HsorgOpter: his.InsuplcAdmdvs,
  21598. // MedinsFillPsn: curRoles.UserName,
  21599. // MedinsFillDept: depart.Name,
  21600. // IptMedType: "2",
  21601. // }
  21602. // struct4101.SetlBegnDate = order.SetlTime
  21603. // struct4101.SetlEndDate = order.SetlTime
  21604. // //if order.SettleType == 1 {
  21605. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21606. // // dateStr := t.Format("2006-01-02")
  21607. // // struct4101.SetlBegnDate = dateStr
  21608. // // struct4101.SetlEndDate = dateStr
  21609. // //} else {
  21610. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21611. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21612. // // dateStartStr := t.Format("2006-01-02")
  21613. // // dateEndStr := t2.Format("2006-01-02")
  21614. // // struct4101.SetlBegnDate = dateStartStr
  21615. // // struct4101.SetlEndDate = dateEndStr
  21616. // //}
  21617. //
  21618. // var rf []CustomFundPay
  21619. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21620. //
  21621. // var tempFunPays []service.CustomStruct
  21622. // var tempFunPay610100 service.CustomStruct
  21623. //
  21624. // for _, item := range rf {
  21625. // if item.FundPayType == "610100" {
  21626. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21627. // tempFunPay610100.FundPayType = item.FundPayType
  21628. // } else {
  21629. // var tempFunPay service.CustomStruct
  21630. // tempFunPay.FundPayamt = item.FundPayamt
  21631. // tempFunPay.FundPayType = item.FundPayType
  21632. // tempFunPays = append(tempFunPays, tempFunPay)
  21633. // }
  21634. // }
  21635. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21636. // struct4101.CustomStruct = tempFunPays
  21637. //
  21638. // var tempDiaginfos []service.DiaginfoStructTwo
  21639. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21640. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21641. //
  21642. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21643. // var config []*models.HisXtDiagnoseConfig
  21644. // for _, item := range diagnosis_ids {
  21645. // id, _ := strconv.ParseInt(item, 10, 64)
  21646. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21647. // config = append(config, &diagnosisConfig)
  21648. // }
  21649. //
  21650. // for index, item := range config {
  21651. // if index == 0 {
  21652. // var tempDiaginfo service.DiaginfoStructTwo
  21653. // tempDiaginfo.DiagCode = item.CountryCode
  21654. // tempDiaginfo.DiagName = item.CountryContentName
  21655. // tempDiaginfo.DiagType = "1"
  21656. // tempDiaginfo.MaindiagFlag = "1"
  21657. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21658. // } else {
  21659. //
  21660. // var tempDiaginfo service.DiaginfoStructTwo
  21661. // tempDiaginfo.DiagCode = item.CountryCode
  21662. // tempDiaginfo.DiagName = item.CountryContentName
  21663. // tempDiaginfo.DiagType = "2"
  21664. // tempDiaginfo.MaindiagFlag = "0"
  21665. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21666. // }
  21667. // }
  21668. // struct4101.Diseinfo = tempDiaginfos
  21669. //
  21670. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21671. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21672. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21673. // tempOpspdiseinfo2.OprnOprtCode = ""
  21674. // tempOpspdiseinfo2.OprnOprtName = ""
  21675. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21676. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21677. //
  21678. // var iteminfo service.IteminfoStruct
  21679. //
  21680. // var bedCostTotal float64 = 0 //床位总费
  21681. // var bedCostSelfTotal float64 = 0 //床位自费
  21682. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21683. //
  21684. // var examineCostTotal float64 = 0 //诊查总费
  21685. // var examineCostSelfTotal float64 = 0 //诊查自费
  21686. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21687. //
  21688. // var nursingCostTotal float64 = 0 //护理总费
  21689. // var nursingCostSelfTotal float64 = 0 //护理自费
  21690. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21691. //
  21692. // var chineseMedicineCostTotal float64 = 0 //中成药
  21693. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21694. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21695. //
  21696. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21697. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21698. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21699. //
  21700. // var registerCostTotal float64 = 0 //一般诊疗费
  21701. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21702. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21703. //
  21704. // var operationCostTotal float64 = 0 //手术费
  21705. // var operationCostSelfTotal float64 = 0 //手术费
  21706. // var operationCostPartSelfTotal float64 = 0 //手术费
  21707. //
  21708. // var otherCostTotal float64 = 0 //其他费用
  21709. // var otherCostSelfTotal float64 = 0 //其他费用
  21710. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21711. //
  21712. // var materialCostTotal float64 = 0 //材料费
  21713. // var materialCostSelfTotal float64 = 0 //材料费
  21714. // var materialCostPartSelfTotal float64 = 0 //材料费
  21715. //
  21716. // var westernMedicineCostTotal float64 = 0 //西药费
  21717. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21718. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21719. //
  21720. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21721. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21722. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21723. //
  21724. // var checkCostTotal float64 = 0 //检查费
  21725. // var checkCostSelfTotal float64 = 0 //检查费
  21726. // var checkCostPartSelfTotal float64 = 0 //检查费
  21727. //
  21728. // var laboratoryCostTotal float64 = 0 //化验费
  21729. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21730. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21731. //
  21732. // var treatCostTotal float64 = 0 //治疗费用
  21733. // var treatCostSelfTotal float64 = 0 //治疗费用
  21734. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21735. //
  21736. // decimal.DivisionPrecision = 2
  21737. //
  21738. // var bed_fulamt_ownpay_amt float64 = 0
  21739. //
  21740. // var examine_fulamt_ownpay_amt float64 = 0
  21741. //
  21742. // var nursing_fulamt_ownpay_amt float64 = 0
  21743. //
  21744. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21745. //
  21746. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21747. //
  21748. // var register_fulamt_ownpay_amt float64 = 0
  21749. //
  21750. // var operation_fulamt_ownpay_amt float64 = 0
  21751. // var other_fulamt_ownpay_amt float64 = 0
  21752. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21753. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21754. // var check_fulamt_ownpay_amt float64 = 0
  21755. // var material_fulamt_ownpay_amt float64 = 0
  21756. // var laboratory_fulamt_ownpay_amt float64 = 0
  21757. // var treat_fulamt_ownpay_amt float64 = 0
  21758. //
  21759. // var bed_claa_sunmfee float64 = 0
  21760. // var bed_clab_amt float64 = 0
  21761. // var bed_other_amt float64 = 0
  21762. //
  21763. // var examine_claa_sunmfee float64 = 0
  21764. // var examine_clab_amt float64 = 0
  21765. // var examine_other_amt float64 = 0
  21766. //
  21767. // var nursing_claa_sunmfee float64 = 0
  21768. // var nursing_clab_amt float64 = 0
  21769. // var nursing_other_amt float64 = 0
  21770. //
  21771. // var chinese_medicine_claa_sunmfee float64 = 0
  21772. // var chinese_medicine_clab_amt float64 = 0
  21773. // var chinese_medicine_other_amt float64 = 0
  21774. //
  21775. // var commonly_treatment_claa_sunmfee float64 = 0
  21776. // var commonly_treatment_clab_amt float64 = 0
  21777. // var commonly_treatment_other_amt float64 = 0
  21778. //
  21779. // var operation_claa_sunmfee float64 = 0
  21780. // var operation_clab_amt float64 = 0
  21781. // var operation_other_amt float64 = 0
  21782. //
  21783. // var other_claa_sunmfee float64 = 0
  21784. // var other_clab_amt float64 = 0
  21785. // var other_other_amt float64 = 0
  21786. //
  21787. // var westernMedicine_claa_sunmfee float64 = 0
  21788. // var westernMedicine_clab_amt float64 = 0
  21789. // var westernMedicine_other_amt float64 = 0
  21790. //
  21791. // var chineseTraditional_claa_sunmfee float64 = 0
  21792. // var chineseTraditional_clab_amt float64 = 0
  21793. // var chineseTraditional_other_amt float64 = 0
  21794. //
  21795. // var check_claa_sunmfee float64 = 0
  21796. // var check_clab_amt float64 = 0
  21797. // var check_other_amt float64 = 0
  21798. //
  21799. // var material_claa_sunmfee float64 = 0
  21800. // var material_clab_amt float64 = 0
  21801. // var material_other_amt float64 = 0
  21802. //
  21803. // var laboratory_claa_sunmfee float64 = 0
  21804. // var laboratory_clab_amt float64 = 0
  21805. // var laboratory_other_amt float64 = 0
  21806. //
  21807. // var treat_claa_sunmfee float64 = 0
  21808. // var treat_clab_amt float64 = 0
  21809. // var treat_other_amt float64 = 0
  21810. //
  21811. // var register_claa_sunmfee float64 = 0
  21812. // var register_clab_amt float64 = 0
  21813. // var register_other_amt float64 = 0
  21814. //
  21815. // for _, item := range order.HisOrderInfo {
  21816. // if item.MedChrgitmType == "01" { //床位费
  21817. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21818. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21819. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21820. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21821. // if item.ChrgitmLv == "1" {
  21822. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21823. // }
  21824. // if item.ChrgitmLv == "2" {
  21825. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21826. //
  21827. // }
  21828. // if item.ChrgitmLv == "3" {
  21829. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21830. // }
  21831. //
  21832. // }
  21833. //
  21834. // if item.MedChrgitmType == "02" { //诊查
  21835. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21836. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21837. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21838. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21839. // if item.ChrgitmLv == "1" {
  21840. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21841. // }
  21842. // if item.ChrgitmLv == "2" {
  21843. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21844. //
  21845. // }
  21846. // if item.ChrgitmLv == "3" {
  21847. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21848. // }
  21849. //
  21850. // }
  21851. //
  21852. // if item.MedChrgitmType == "03" { //检查费
  21853. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21854. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21855. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21856. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21857. // if item.ChrgitmLv == "1" {
  21858. //
  21859. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21860. //
  21861. // }
  21862. // if item.ChrgitmLv == "2" {
  21863. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21864. //
  21865. // }
  21866. // if item.ChrgitmLv == "3" {
  21867. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21868. // }
  21869. // }
  21870. //
  21871. // if item.MedChrgitmType == "04" { //化验费
  21872. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21873. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21874. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21875. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21876. // if item.ChrgitmLv == "1" {
  21877. //
  21878. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21879. //
  21880. // }
  21881. // if item.ChrgitmLv == "2" {
  21882. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21883. //
  21884. // }
  21885. // if item.ChrgitmLv == "3" {
  21886. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21887. // }
  21888. // }
  21889. //
  21890. // if item.MedChrgitmType == "05" { //治疗费
  21891. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21892. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21893. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21894. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21895. // if item.ChrgitmLv == "1" {
  21896. //
  21897. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21898. //
  21899. // }
  21900. // if item.ChrgitmLv == "2" {
  21901. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21902. //
  21903. // }
  21904. // if item.ChrgitmLv == "3" {
  21905. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21906. // }
  21907. // }
  21908. //
  21909. // if item.MedChrgitmType == "06" { //手术费
  21910. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21911. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21912. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21913. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21914. //
  21915. // if item.ChrgitmLv == "1" {
  21916. //
  21917. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21918. //
  21919. // }
  21920. // if item.ChrgitmLv == "2" {
  21921. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21922. //
  21923. // }
  21924. // if item.ChrgitmLv == "3" {
  21925. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21926. // }
  21927. // }
  21928. //
  21929. // if item.MedChrgitmType == "07" { //手术费
  21930. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21931. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21932. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21933. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21934. //
  21935. // if item.ChrgitmLv == "1" {
  21936. //
  21937. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21938. //
  21939. // }
  21940. // if item.ChrgitmLv == "2" {
  21941. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21942. //
  21943. // }
  21944. // if item.ChrgitmLv == "3" {
  21945. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21946. // }
  21947. // }
  21948. //
  21949. // if item.MedChrgitmType == "08" { //材料费
  21950. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21951. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21952. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21953. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21954. // if item.ChrgitmLv == "1" {
  21955. //
  21956. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21957. //
  21958. // }
  21959. // if item.ChrgitmLv == "2" {
  21960. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21961. //
  21962. // }
  21963. // if item.ChrgitmLv == "3" {
  21964. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21965. // }
  21966. // }
  21967. // if item.MedChrgitmType == "09" { //西药费
  21968. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21969. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21970. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21971. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21972. // if item.ChrgitmLv == "1" {
  21973. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21974. // }
  21975. // if item.ChrgitmLv == "2" {
  21976. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21977. // }
  21978. // if item.ChrgitmLv == "3" {
  21979. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21980. // }
  21981. // }
  21982. // if item.MedChrgitmType == "10" { //中药饮片
  21983. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21984. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21985. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21986. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21987. // if item.ChrgitmLv == "1" {
  21988. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21989. // }
  21990. // if item.ChrgitmLv == "2" {
  21991. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21992. // }
  21993. // if item.ChrgitmLv == "3" {
  21994. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21995. // }
  21996. // }
  21997. //
  21998. // if item.MedChrgitmType == "11" { //中成费
  21999. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22000. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22001. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22002. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22003. // if item.ChrgitmLv == "1" {
  22004. //
  22005. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22006. //
  22007. // }
  22008. // if item.ChrgitmLv == "2" {
  22009. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22010. //
  22011. // }
  22012. // if item.ChrgitmLv == "3" {
  22013. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22014. // }
  22015. // }
  22016. //
  22017. // if item.MedChrgitmType == "12" { //中成费
  22018. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22019. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22020. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22021. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22022. // if item.ChrgitmLv == "1" {
  22023. //
  22024. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22025. //
  22026. // }
  22027. // if item.ChrgitmLv == "2" {
  22028. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22029. //
  22030. // }
  22031. // if item.ChrgitmLv == "3" {
  22032. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22033. // }
  22034. // }
  22035. //
  22036. // if item.MedChrgitmType == "13" { //中成费
  22037. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22038. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22039. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22040. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22041. // if item.ChrgitmLv == "1" {
  22042. //
  22043. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22044. //
  22045. // }
  22046. // if item.ChrgitmLv == "2" {
  22047. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22048. //
  22049. // }
  22050. // if item.ChrgitmLv == "3" {
  22051. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22052. // }
  22053. // }
  22054. //
  22055. // if item.MedChrgitmType == "14" { //其他费
  22056. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22057. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22058. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22059. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22060. // if item.ChrgitmLv == "1" {
  22061. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22062. //
  22063. // }
  22064. // if item.ChrgitmLv == "2" {
  22065. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22066. //
  22067. // }
  22068. // if item.ChrgitmLv == "3" {
  22069. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22070. // }
  22071. // }
  22072. //
  22073. // }
  22074. //
  22075. // var iteminfoStructs []service.IteminfoStruct
  22076. //
  22077. // if bedCostTotal != 0 {
  22078. // iteminfo.MedChrgitm = "01"
  22079. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22080. // iteminfo.Amt = bedCostTotal
  22081. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22082. // iteminfo.ClabAmt = bed_clab_amt
  22083. // iteminfo.OthAmt = bed_other_amt
  22084. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22085. // }
  22086. //
  22087. // if examineCostTotal != 0 {
  22088. // iteminfo.MedChrgitm = "02"
  22089. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22090. // iteminfo.Amt = examineCostTotal
  22091. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22092. // iteminfo.ClabAmt = examine_clab_amt
  22093. // iteminfo.OthAmt = examine_other_amt
  22094. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22095. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22096. // }
  22097. //
  22098. // if checkCostTotal != 0 {
  22099. // iteminfo.MedChrgitm = "03"
  22100. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22101. // iteminfo.Amt = checkCostTotal
  22102. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22103. // iteminfo.ClabAmt = check_clab_amt
  22104. // iteminfo.OthAmt = check_other_amt
  22105. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22106. //
  22107. // }
  22108. //
  22109. // if laboratoryCostTotal != 0 {
  22110. // iteminfo.MedChrgitm = "04"
  22111. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22112. // iteminfo.Amt = laboratoryCostTotal
  22113. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22114. // iteminfo.ClabAmt = laboratory_clab_amt
  22115. // iteminfo.OthAmt = laboratory_other_amt
  22116. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22117. //
  22118. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22119. //
  22120. // }
  22121. //
  22122. // if treatCostTotal != 0 {
  22123. // iteminfo.MedChrgitm = "05"
  22124. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22125. // iteminfo.Amt = treatCostTotal
  22126. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22127. // iteminfo.ClabAmt = treat_clab_amt
  22128. // iteminfo.OthAmt = treat_other_amt
  22129. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22130. // //(struct4101.IteminfoStruct, iteminfo)
  22131. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22132. // }
  22133. //
  22134. // if operationCostTotal != 0 {
  22135. // iteminfo.MedChrgitm = "06"
  22136. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22137. // iteminfo.Amt = operationCostTotal
  22138. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22139. // iteminfo.ClabAmt = operation_clab_amt
  22140. // iteminfo.OthAmt = operation_other_amt
  22141. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22142. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22143. // }
  22144. //
  22145. // if nursingCostTotal != 0 {
  22146. // iteminfo.MedChrgitm = "07"
  22147. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22148. // iteminfo.Amt = nursingCostTotal
  22149. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22150. // iteminfo.ClabAmt = nursing_clab_amt
  22151. // iteminfo.OthAmt = nursing_other_amt
  22152. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22153. // }
  22154. //
  22155. // if materialCostTotal != 0 {
  22156. // iteminfo.MedChrgitm = "08"
  22157. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22158. // iteminfo.Amt = materialCostTotal
  22159. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22160. // iteminfo.ClabAmt = material_clab_amt
  22161. // iteminfo.OthAmt = material_other_amt
  22162. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22163. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22164. // }
  22165. //
  22166. // if westernMedicineCostTotal != 0 {
  22167. // iteminfo.MedChrgitm = "09"
  22168. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22169. // iteminfo.Amt = westernMedicineCostTotal
  22170. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22171. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22172. // iteminfo.OthAmt = westernMedicine_other_amt
  22173. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22174. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22175. //
  22176. // }
  22177. //
  22178. // if chineseMedicineCostTotal != 0 {
  22179. // iteminfo.MedChrgitm = "10"
  22180. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22181. // iteminfo.Amt = chineseMedicineCostTotal
  22182. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22183. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22184. // iteminfo.OthAmt = chinese_medicine_other_amt
  22185. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22186. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22187. //
  22188. // }
  22189. //
  22190. // if chineseTraditionalMedicineCostTotal != 0 {
  22191. // iteminfo.MedChrgitm = "11"
  22192. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22193. // iteminfo.Amt = westernMedicineCostTotal
  22194. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22195. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22196. // iteminfo.OthAmt = westernMedicine_other_amt
  22197. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22198. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22199. //
  22200. // }
  22201. //
  22202. // if commonlyTreatmentCostTotal != 0 {
  22203. // iteminfo.MedChrgitm = "12"
  22204. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22205. // iteminfo.Amt = commonlyTreatmentCostTotal
  22206. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22207. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22208. // iteminfo.OthAmt = commonly_treatment_other_amt
  22209. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22210. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22211. //
  22212. // }
  22213. //
  22214. // if registerCostTotal != 0 {
  22215. // iteminfo.MedChrgitm = "13"
  22216. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22217. // iteminfo.Amt = registerCostTotal
  22218. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22219. // iteminfo.ClabAmt = register_clab_amt
  22220. // iteminfo.OthAmt = register_other_amt
  22221. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22222. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22223. //
  22224. // }
  22225. //
  22226. // if otherCostTotal != 0 {
  22227. // iteminfo.MedChrgitm = "14"
  22228. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22229. // iteminfo.Amt = otherCostTotal
  22230. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22231. // iteminfo.ClabAmt = other_clab_amt
  22232. // iteminfo.OthAmt = other_other_amt
  22233. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22234. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22235. //
  22236. // }
  22237. // struct4101.IteminfoStruct = iteminfoStructs
  22238. // time_arr := strings.Split(order.SetlTime, " ")
  22239. // struct4101.AdmTime = time_arr[0]
  22240. // struct4101.AdmEndTime = time_arr[0]
  22241. //
  22242. // struct4101.DoctorName = doctor.UserName
  22243. // struct4101.DoctorCode = doctor.DoctorNumber
  22244. //
  22245. // struct4101.Ntly = "中国"
  22246. // struct4101.AdmCaty = "A03.06"
  22247. // var res ResultSeventeen
  22248. // if miConfig.MdtrtareaAdmvs == "421300" {
  22249. // data := make(map[string]interface{})
  22250. // data["struct4101"] = struct4101
  22251. // data["secret_key"] = miConfig.SecretKey
  22252. // data["org_name"] = miConfig.OrgName
  22253. // data["opera"] = curRoles.UserName
  22254. // data["code"] = miConfig.Code
  22255. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22256. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22257. //
  22258. // client := &http.Client{}
  22259. // bytesData, _ := json.Marshal(data)
  22260. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22261. // resp, _ := client.Do(req)
  22262. // defer resp.Body.Close()
  22263. // body, ioErr := ioutil.ReadAll(resp.Body)
  22264. // if ioErr != nil {
  22265. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22267. // return
  22268. // }
  22269. // var respJSON map[string]interface{}
  22270. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22271. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22273. // return
  22274. // }
  22275. //
  22276. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22277. // userJSONBytes, _ := json.Marshal(respJSON)
  22278. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22279. // utils.ErrorLog("解析失败:%v", err)
  22280. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22281. // adminUser := c.GetAdminUserInfo()
  22282. // errlog := &models.HisOrderError{
  22283. // UserOrgId: adminUser.CurrentOrgId,
  22284. // Ctime: time.Now().Unix(),
  22285. // Mtime: time.Now().Unix(),
  22286. // ErrMsg: res.ErrMsg + "解析失败",
  22287. // Status: 1,
  22288. // PatientId: order_id,
  22289. // Stage: 10088,
  22290. // }
  22291. // service.CreateErrMsgLog(errlog)
  22292. // continue
  22293. // }
  22294. //
  22295. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22296. // data := make(map[string]interface{})
  22297. // data["struct4101"] = struct4101
  22298. // data["secret_key"] = miConfig.SecretKey
  22299. // data["org_name"] = miConfig.OrgName
  22300. // data["opera"] = curRoles.UserName
  22301. // data["code"] = miConfig.Code
  22302. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22303. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22304. //
  22305. // client := &http.Client{}
  22306. // bytesData, _ := json.Marshal(data)
  22307. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22308. // resp, _ := client.Do(req)
  22309. // defer resp.Body.Close()
  22310. // body, ioErr := ioutil.ReadAll(resp.Body)
  22311. // if ioErr != nil {
  22312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22314. // return
  22315. // }
  22316. // var respJSON map[string]interface{}
  22317. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22318. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22320. // return
  22321. // }
  22322. //
  22323. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22324. // userJSONBytes, _ := json.Marshal(respJSON)
  22325. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22326. // utils.ErrorLog("解析失败:%v", err)
  22327. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22328. // adminUser := c.GetAdminUserInfo()
  22329. // errlog := &models.HisOrderError{
  22330. // UserOrgId: adminUser.CurrentOrgId,
  22331. // Ctime: time.Now().Unix(),
  22332. // Mtime: time.Now().Unix(),
  22333. // ErrMsg: res.ErrMsg + "解析失败",
  22334. // Status: 1,
  22335. // PatientId: order_id,
  22336. // Stage: 10088,
  22337. // }
  22338. // service.CreateErrMsgLog(errlog)
  22339. // continue
  22340. // }
  22341. //
  22342. // } else {
  22343. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22344. // fmt.Println(result)
  22345. //
  22346. // var dat map[string]interface{}
  22347. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22348. // fmt.Println(dat)
  22349. // } else {
  22350. // fmt.Println(err)
  22351. // }
  22352. // userJSONBytes, _ := json.Marshal(dat)
  22353. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22354. // utils.ErrorLog("解析失败:%v", err)
  22355. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22356. // adminUser := c.GetAdminUserInfo()
  22357. // errlog := &models.HisOrderError{
  22358. // UserOrgId: adminUser.CurrentOrgId,
  22359. // Ctime: time.Now().Unix(),
  22360. // Mtime: time.Now().Unix(),
  22361. // ErrMsg: res.ErrMsg + "解析失败",
  22362. // Status: 1,
  22363. // PatientId: order_id,
  22364. // Stage: 10106,
  22365. // }
  22366. // service.CreateErrMsgLog(errlog)
  22367. // continue
  22368. // }
  22369. // }
  22370. //
  22371. // if res.Infcode != 0 {
  22372. // adminUser := c.GetAdminUserInfo()
  22373. // errlog := &models.HisOrderError{
  22374. // UserOrgId: adminUser.CurrentOrgId,
  22375. // Ctime: time.Now().Unix(),
  22376. // Mtime: time.Now().Unix(),
  22377. // ErrMsg: res.ErrMsg,
  22378. // Status: 1,
  22379. // PatientId: order_id,
  22380. // Stage: 10106,
  22381. // }
  22382. // service.CreateErrMsgLog(errlog)
  22383. // continue
  22384. // } else {
  22385. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22386. // Number: res.Output.SetlListId,
  22387. // Status: 1,
  22388. // Ctime: time.Now().Unix(),
  22389. // Mtime: time.Now().Unix(),
  22390. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22391. // IsUpload: 1,
  22392. // OrderId: order_id,
  22393. // }
  22394. // service.CreateUploadRecord(hisFundSettleListResult)
  22395. // continue
  22396. // }
  22397. // }
  22398. //}
  22399. func (c *HisApiController) GetOrgInfo() {
  22400. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22401. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22402. }
  22403. func (c *HisApiController) GetHisPatientInfo() {
  22404. medical_insurance_card := c.GetString("medical_insurance_card")
  22405. id_card_type, _ := c.GetInt64("id_card_type")
  22406. id_card := c.GetString("id_card")
  22407. adminInfo := c.GetAdminUserInfo()
  22408. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22409. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22410. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22411. IdCardNo := ""
  22412. if id_card_type == 1 {
  22413. IdCardNo = medical_insurance_card
  22414. } else if id_card_type == 2 {
  22415. IdCardNo = id_card
  22416. }
  22417. if config.IsOpen == 1 {
  22418. 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
  22419. resp, requestErr := http.Get(api)
  22420. if requestErr != nil {
  22421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22422. return
  22423. }
  22424. defer resp.Body.Close()
  22425. body, ioErr := ioutil.ReadAll(resp.Body)
  22426. if ioErr != nil {
  22427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22429. return
  22430. }
  22431. var respJSON map[string]interface{}
  22432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22435. return
  22436. }
  22437. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22438. userJSONBytes, _ := json.Marshal(userJSON)
  22439. var res ResultTwo
  22440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22441. utils.ErrorLog("解析失败:%v", err)
  22442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22443. return
  22444. }
  22445. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22446. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22447. infoStr := string(Iinfos)
  22448. idetinfoStr := string(Idetinfos)
  22449. if res.Infcode == 0 {
  22450. his := models.VMHisPatient{
  22451. Status: 1,
  22452. Ctime: time.Now().Unix(),
  22453. Mtime: time.Now().Unix(),
  22454. PsnNo: res.Output.Baseinfo.PsnNo,
  22455. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22456. Certno: res.Output.Baseinfo.Certno,
  22457. PsnName: res.Output.Baseinfo.PsnName,
  22458. Gend: res.Output.Baseinfo.Gend,
  22459. Naty: res.Output.Baseinfo.Naty,
  22460. Iinfo: infoStr,
  22461. Idetinfo: idetinfoStr,
  22462. UserOrgId: adminInfo.CurrentOrgId,
  22463. IsReturn: 1,
  22464. IdCardType: id_card_type,
  22465. }
  22466. c.ServeSuccessJSON(map[string]interface{}{
  22467. "info": his,
  22468. })
  22469. } else {
  22470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22471. return
  22472. }
  22473. }
  22474. }
  22475. //func GetBasBaseInfo() (jsonStr string, err error) {
  22476. //
  22477. // handle := syscall.NewLazyDLL("SSCard.dll")
  22478. // add := handle.NewProc("ReadCardBas")
  22479. // str := make([]byte, 1024)
  22480. // str1 := make([]byte, 1024)
  22481. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22482. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22483. //
  22484. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22485. //
  22486. // fmt.Println("> Add(4,5)的结果为:", ret)
  22487. // handle.Release()
  22488. //
  22489. // return "", nil
  22490. //
  22491. //}
  22492. //func GetQRBaseInfo() (jsonStr string, err error) {
  22493. // handle := syscall.LoadDLL("SSCard.dll")
  22494. // ReadCardBas := handle.FindProc("GetQRBase")
  22495. //
  22496. // str := make([]byte, 256)
  22497. // str1 := make([]byte, 256)
  22498. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22499. //
  22500. // fmt.Println(string(str))
  22501. // fmt.Println(r)
  22502. // return string(str), nil
  22503. //}
  22504. //func CardInit() int {
  22505. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22506. // add := DllTestDef.MustFindProc("Init")
  22507. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22508. // if err != nil {
  22509. // fmt.Println("SSCard的运算结果为:", ret)
  22510. // }
  22511. // result := int(ret)
  22512. // return result
  22513. //}
  22514. //func CardInit() int {
  22515. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22516. // if err != nil {
  22517. // fmt.Println("SSCard的运算结果为:", ret)
  22518. // }
  22519. // fmt.Println(err)
  22520. // result := int(ret)
  22521. // return result
  22522. //}
  22523. func IntPtr(n int) uintptr {
  22524. return uintptr(n)
  22525. }
  22526. func StrPtr(s string) uintptr {
  22527. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22528. }
  22529. type Result2001 struct {
  22530. Cainfo interface{} `json:"cainfo"`
  22531. ErrMsg string `json:"err_msg"`
  22532. InfRefmsgid string `json:"inf_refmsgid"`
  22533. Infcode int64 `json:"infcode"`
  22534. Output struct {
  22535. Trtinfo struct {
  22536. PsnNo string `json:"psn_no"`
  22537. TrtChkType string `json:"trt_chk_type"`
  22538. FundPayType string `json:"fund_pay_type"`
  22539. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22540. Begndate string `json:"begndate"`
  22541. Enddate string `json:"enddate"`
  22542. TrtChkRslt string `json:"trt_chk_rslt"`
  22543. } `json:"trtinfo"`
  22544. } `json:"output"`
  22545. RefmsgTime string `json:"refmsg_time"`
  22546. RespondTime string `json:"respond_time"`
  22547. Signtype interface{} `json:"signtype"`
  22548. WarnMsg interface{} `json:"warn_msg"`
  22549. }
  22550. type Result2001Org10265 struct {
  22551. Cainfo interface{} `json:"cainfo"`
  22552. ErrMsg string `json:"err_msg"`
  22553. InfRefmsgid string `json:"inf_refmsgid"`
  22554. Infcode string `json:"infcode"`
  22555. Output struct {
  22556. Trtinfo struct {
  22557. PsnNo string `json:"psn_no"`
  22558. TrtChkType string `json:"trt_chk_type"`
  22559. FundPayType string `json:"fund_pay_type"`
  22560. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22561. Begndate string `json:"begndate"`
  22562. Enddate string `json:"enddate"`
  22563. TrtChkRslt string `json:"trt_chk_rslt"`
  22564. } `json:"trtinfo"`
  22565. } `json:"output"`
  22566. RefmsgTime string `json:"refmsg_time"`
  22567. RespondTime string `json:"respond_time"`
  22568. Signtype interface{} `json:"signtype"`
  22569. WarnMsg interface{} `json:"warn_msg"`
  22570. }
  22571. type ResultTwo struct {
  22572. ErrMsg string `json:"err_msg"`
  22573. InfRefmsgid string `json:"inf_refmsgid"`
  22574. Infcode int64 `json:"infcode"`
  22575. Output struct {
  22576. Baseinfo struct {
  22577. //Brdy string `json:"brdy"`
  22578. Certno string `json:"certno"`
  22579. Gend string `json:"gend"`
  22580. Naty string `json:"naty"`
  22581. PsnCertType string `json:"psn_cert_type"`
  22582. PsnName string `json:"psn_name"`
  22583. PsnNo string `json:"psn_no"`
  22584. } `json:"baseinfo"`
  22585. Idetinfo []interface{} `json:"idetinfo"`
  22586. Iinfo []struct {
  22587. Balc float64 `json:"balc"`
  22588. CvlservFlag string `json:"cvlserv_flag"`
  22589. EmpName string `json:"emp_name"`
  22590. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22591. Insutype string `json:"insutype"`
  22592. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22593. //PausInsuDate string `json:"paus_insu_date"`
  22594. //PsnInsuDate string `json:"psn_insu_date"`
  22595. PsnInsuStas string `json:"psn_insu_stas"`
  22596. PsnType string `json:"psn_type"`
  22597. } `json:"insuinfo"`
  22598. } `json:"output"`
  22599. RefmsgTime string `json:"refmsg_time"`
  22600. RespondTime string `json:"respond_time"`
  22601. Signtype interface{} `json:"signtype"`
  22602. WarnInfo interface{} `json:"warn_info"`
  22603. }
  22604. type ResultTwo10265 struct {
  22605. ErrMsg string `json:"err_msg"`
  22606. InfRefmsgid string `json:"inf_refmsgid"`
  22607. Infcode string `json:"infcode"`
  22608. Output struct {
  22609. Baseinfo struct {
  22610. //Brdy string `json:"brdy"`
  22611. Certno string `json:"certno"`
  22612. Gend string `json:"gend"`
  22613. Naty string `json:"naty"`
  22614. PsnCertType string `json:"psn_cert_type"`
  22615. PsnName string `json:"psn_name"`
  22616. PsnNo string `json:"psn_no"`
  22617. } `json:"baseinfo"`
  22618. Idetinfo []interface{} `json:"idetinfo"`
  22619. Iinfo []struct {
  22620. Balc float64 `json:"balc"`
  22621. CvlservFlag string `json:"cvlserv_flag"`
  22622. EmpName string `json:"emp_name"`
  22623. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22624. Insutype string `json:"insutype"`
  22625. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22626. PsnInsuStas string `json:"psn_insu_stas"`
  22627. PsnType string `json:"psn_type"`
  22628. } `json:"insuinfo"`
  22629. } `json:"output"`
  22630. RefmsgTime string `json:"refmsg_time"`
  22631. RespondTime string `json:"respond_time"`
  22632. Signtype interface{} `json:"signtype"`
  22633. WarnInfo interface{} `json:"warn_info"`
  22634. }
  22635. type ResultThree 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. Data struct {
  22642. IptOtpNo string `json:"ipt_otp_no"`
  22643. MdtrtID string `json:"mdtrt_id"`
  22644. PsnNo string `json:"psn_no"`
  22645. } `json:"data"`
  22646. } `json:"output"`
  22647. RefmsgTime string `json:"refmsg_time"`
  22648. RespondTime string `json:"respond_time"`
  22649. Signtype interface{} `json:"signtype"`
  22650. WarnMsg interface{} `json:"warn_msg"`
  22651. }
  22652. type ResultThree10265 struct {
  22653. Cainfo interface{} `json:"cainfo"`
  22654. ErrMsg string `json:"err_msg"`
  22655. InfRefmsgid string `json:"inf_refmsgid"`
  22656. Infcode string `json:"infcode"`
  22657. Output struct {
  22658. Data struct {
  22659. IptOtpNo string `json:"ipt_otp_no"`
  22660. MdtrtID string `json:"mdtrt_id"`
  22661. PsnNo string `json:"psn_no"`
  22662. } `json:"data"`
  22663. } `json:"output"`
  22664. RefmsgTime string `json:"refmsg_time"`
  22665. RespondTime string `json:"respond_time"`
  22666. Signtype interface{} `json:"signtype"`
  22667. WarnMsg interface{} `json:"warn_msg"`
  22668. }
  22669. type ResultFour struct {
  22670. Cainfo string `json:"cainfo"`
  22671. ErrMsg string `json:"err_msg"`
  22672. InfRefmsgid string `json:"inf_refmsgid"`
  22673. Infcode int64 `json:"infcode"`
  22674. Output struct {
  22675. Result []struct {
  22676. BasMednFlag string `json:"bas_medn_flag"`
  22677. ChldMedcFlag string `json:"chld_medc_flag"`
  22678. ChrgitmLv string `json:"chrgitm_lv"`
  22679. Cnt float64 `json:"cnt"`
  22680. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22681. DrtReimFlag string `json:"drt_reim_flag"`
  22682. FeedetlSn string `json:"feedetl_sn"`
  22683. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22684. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22685. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22686. ListSpItemFlag string `json:"list_sp_item_flag"`
  22687. LmtUsedFlag string `json:"lmt_used_flag"`
  22688. MedChrgitmType string `json:"med_chrgitm_type"`
  22689. Memo string `json:"memo"`
  22690. OverlmtAmt float64 `json:"overlmt_amt"`
  22691. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22692. Pric float64 `json:"pric"`
  22693. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22694. SelfpayProp float64 `json:"selfpay_prop"`
  22695. } `json:"result"`
  22696. } `json:"output"`
  22697. RefmsgTime string `json:"refmsg_time"`
  22698. RespondTime string `json:"respond_time"`
  22699. Signtype string `json:"signtype"`
  22700. WarnMsg string `json:"warn_msg"`
  22701. }
  22702. type ResultFour10265 struct {
  22703. Cainfo string `json:"cainfo"`
  22704. ErrMsg string `json:"err_msg"`
  22705. InfRefmsgid string `json:"inf_refmsgid"`
  22706. Infcode string `json:"infcode"`
  22707. Output struct {
  22708. Result []struct {
  22709. BasMednFlag string `json:"bas_medn_flag"`
  22710. ChldMedcFlag string `json:"chld_medc_flag"`
  22711. ChrgitmLv string `json:"chrgitm_lv"`
  22712. Cnt float64 `json:"cnt"`
  22713. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22714. DrtReimFlag string `json:"drt_reim_flag"`
  22715. FeedetlSn string `json:"feedetl_sn"`
  22716. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22717. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22718. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22719. ListSpItemFlag string `json:"list_sp_item_flag"`
  22720. LmtUsedFlag string `json:"lmt_used_flag"`
  22721. MedChrgitmType string `json:"med_chrgitm_type"`
  22722. Memo string `json:"memo"`
  22723. OverlmtAmt float64 `json:"overlmt_amt"`
  22724. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22725. Pric float64 `json:"pric"`
  22726. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22727. SelfpayProp float64 `json:"selfpay_prop"`
  22728. } `json:"result"`
  22729. } `json:"output"`
  22730. RefmsgTime string `json:"refmsg_time"`
  22731. RespondTime string `json:"respond_time"`
  22732. Signtype string `json:"signtype"`
  22733. WarnMsg string `json:"warn_msg"`
  22734. }
  22735. type ResultMemo struct {
  22736. InsuAdmdvs string `json:"insuAdmdvs"`
  22737. }
  22738. // [{"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}]
  22739. type ResultIDInfo struct {
  22740. Begntime string `json:"begntime"`
  22741. Endtime string `json:"endtime"`
  22742. Memo string `json:"memo"`
  22743. }
  22744. type ResultFive struct {
  22745. Balc float64 `json:"balc"`
  22746. CvlservFlag string `json:"cvlserv_flag"`
  22747. EmpName string `json:"emp_name"`
  22748. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22749. Insutype string `json:"insutype"`
  22750. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22751. PausInsuDate string `json:"paus_insu_date"`
  22752. PsnInsuDate string `json:"psn_insu_date"`
  22753. PsnInsuStas string `json:"psn_insu_stas"`
  22754. PsnType string `json:"psn_type"`
  22755. }
  22756. type ResultSix struct {
  22757. Cainfo interface{} `json:"cainfo"`
  22758. ErrMsg string `json:"err_msg"`
  22759. InfRefmsgid string `json:"inf_refmsgid"`
  22760. Infcode int64 `json:"infcode"`
  22761. Output struct {
  22762. } `json:"output"`
  22763. RefmsgTime string `json:"refmsg_time"`
  22764. RespondTime string `json:"respond_time"`
  22765. Signtype interface{} `json:"signtype"`
  22766. WarnMsg interface{} `json:"warn_msg"`
  22767. }
  22768. type ResultSix3103 struct {
  22769. Cainfo interface{} `json:"cainfo"`
  22770. ErrMsg string `json:"err_msg"`
  22771. InfRefmsgid string `json:"inf_refmsgid"`
  22772. Infcode int64 `json:"infcode"`
  22773. RefmsgTime string `json:"refmsg_time"`
  22774. RespondTime string `json:"respond_time"`
  22775. Signtype interface{} `json:"signtype"`
  22776. WarnMsg interface{} `json:"warn_msg"`
  22777. }
  22778. type FJ3507Result struct {
  22779. Cainfo interface{} `json:"cainfo"`
  22780. ErrMsg string `json:"err_msg"`
  22781. InfRefmsgid string `json:"inf_refmsgid"`
  22782. Infcode int64 `json:"infcode"`
  22783. Output struct {
  22784. retRslt string `json:"retRslt"`
  22785. msgRslt string `json:"msgRslt"`
  22786. } `json:"output"`
  22787. RefmsgTime string `json:"refmsg_time"`
  22788. RespondTime string `json:"respond_time"`
  22789. Signtype interface{} `json:"signtype"`
  22790. WarnMsg interface{} `json:"warn_msg"`
  22791. }
  22792. type FJ3507ResultFor10188 struct {
  22793. Cainfo interface{} `json:"cainfo"`
  22794. ErrMsg string `json:"err_msg"`
  22795. InfRefmsgid string `json:"inf_refmsgid"`
  22796. Infcode string `json:"infcode"`
  22797. RefmsgTime string `json:"refmsg_time"`
  22798. RespondTime string `json:"respond_time"`
  22799. Signtype interface{} `json:"signtype"`
  22800. WarnMsg interface{} `json:"warn_msg"`
  22801. }
  22802. type Result2406 struct {
  22803. Cainfo interface{} `json:"cainfo"`
  22804. ErrMsg string `json:"err_msg"`
  22805. InfRefmsgid string `json:"inf_refmsgid"`
  22806. Infcode int64 `json:"infcode"`
  22807. Output struct {
  22808. Result struct {
  22809. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22810. } `json:"result"`
  22811. } `json:"output"`
  22812. RefmsgTime string `json:"refmsg_time"`
  22813. RespondTime string `json:"respond_time"`
  22814. Signtype interface{} `json:"signtype"`
  22815. WarnMsg interface{} `json:"warn_msg"`
  22816. }
  22817. type GZResultSix struct {
  22818. Cainfo interface{} `json:"cainfo"`
  22819. ErrMsg string `json:"err_msg"`
  22820. InfRefmsgid string `json:"inf_refmsgid"`
  22821. Infcode int64 `json:"infcode"`
  22822. Output string `json:"output"`
  22823. RefmsgTime string `json:"refmsg_time"`
  22824. RespondTime string `json:"respond_time"`
  22825. Signtype interface{} `json:"signtype"`
  22826. WarnMsg interface{} `json:"warn_msg"`
  22827. }
  22828. type ResultSix10265 struct {
  22829. Cainfo interface{} `json:"cainfo"`
  22830. ErrMsg string `json:"err_msg"`
  22831. InfRefmsgid string `json:"inf_refmsgid"`
  22832. Infcode string `json:"infcode"`
  22833. Output struct {
  22834. } `json:"output"`
  22835. RefmsgTime string `json:"refmsg_time"`
  22836. RespondTime string `json:"respond_time"`
  22837. Signtype interface{} `json:"signtype"`
  22838. WarnMsg interface{} `json:"warn_msg"`
  22839. }
  22840. type ResultSeven struct {
  22841. Cainfo string `json:"cainfo"`
  22842. ErrMsg string `json:"err_msg"`
  22843. InfRefmsgid string `json:"inf_refmsgid"`
  22844. Infcode int64 `json:"infcode"`
  22845. Output struct {
  22846. Setlinfo struct {
  22847. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22848. AcctPay float64 `json:"acct_pay"`
  22849. ActPayDedc float64 `json:"act_pay_dedc"`
  22850. Age float64 `json:"age"`
  22851. Balc float64 `json:"balc"`
  22852. Certno string `json:"certno"`
  22853. ClrOptins string `json:"clr_optins"`
  22854. ClrType string `json:"clr_type"`
  22855. ClrWay string `json:"clr_way"`
  22856. CvlservFlag string `json:"cvlserv_flag"`
  22857. CvlservPay float64 `json:"cvlserv_pay"`
  22858. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22859. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22860. Gend string `json:"gend"`
  22861. HifesPay float64 `json:"hifes_pay"`
  22862. HifmiPay float64 `json:"hifmi_pay"`
  22863. HifpPay float64 `json:"hifp_pay"`
  22864. HospPartAmt float64 `json:"hosp_part_amt"`
  22865. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22866. Insutype string `json:"insutype"`
  22867. MafPay float64 `json:"maf_pay"`
  22868. MdtrtCertType string `json:"mdtrt_cert_type"`
  22869. HifobPay float64 `json:"hifob_pay"`
  22870. MdtrtID string `json:"mdtrt_id"`
  22871. MedType string `json:"med_type"`
  22872. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22873. MedinsSetlID string `json:"medins_setl_id"`
  22874. Naty string `json:"naty"`
  22875. OthPay float64 `json:"oth_pay"`
  22876. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22877. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22878. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22879. PsnCashPay float64 `json:"psn_cash_pay"`
  22880. PsnCertType string `json:"psn_cert_type"`
  22881. PsnName string `json:"psn_name"`
  22882. PsnNo string `json:"psn_no"`
  22883. PsnPartAmt float64 `json:"psn_part_amt"`
  22884. PsnType string `json:"psn_type"`
  22885. SetlID string `json:"setl_id"`
  22886. SetlTime string `json:"setl_time"`
  22887. } `json:"setlinfo"`
  22888. Setldetail interface{} `json:"setldetail"`
  22889. } `json:"output"`
  22890. RefmsgTime string `json:"refmsg_time"`
  22891. RespondTime string `json:"respond_time"`
  22892. Signtype interface{} `json:"signtype"`
  22893. WarnMsg interface{} `json:"warn_msg"`
  22894. }
  22895. type ResultSevenAH struct {
  22896. Cainfo string `json:"cainfo"`
  22897. ErrMsg string `json:"err_msg"`
  22898. InfRefmsgid string `json:"inf_refmsgid"`
  22899. Infcode int64 `json:"infcode"`
  22900. Output struct {
  22901. Setlinfo struct {
  22902. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22903. AcctPay float64 `json:"acct_pay"`
  22904. ActPayDedc float64 `json:"act_pay_dedc"`
  22905. Age float64 `json:"age"`
  22906. Balc float64 `json:"balc"`
  22907. Certno string `json:"certno"`
  22908. ClrOptins string `json:"clr_optins"`
  22909. ClrType string `json:"clr_type"`
  22910. ClrWay string `json:"clr_way"`
  22911. CvlservFlag string `json:"cvlserv_flag"`
  22912. CvlservPay float64 `json:"cvlserv_pay"`
  22913. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22914. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22915. Gend string `json:"gend"`
  22916. HifesPay float64 `json:"hifes_pay"`
  22917. HifmiPay float64 `json:"hifmi_pay"`
  22918. HifpPay float64 `json:"hifp_pay"`
  22919. HospPartAmt float64 `json:"hosp_part_amt"`
  22920. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22921. Insutype string `json:"insutype"`
  22922. MafPay float64 `json:"maf_pay"`
  22923. MdtrtCertType string `json:"mdtrt_cert_type"`
  22924. HifobPay float64 `json:"hifob_pay"`
  22925. MdtrtID string `json:"mdtrt_id"`
  22926. MedType string `json:"med_type"`
  22927. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22928. MedinsSetlID string `json:"medins_setl_id"`
  22929. Naty string `json:"naty"`
  22930. OthPay float64 `json:"oth_pay"`
  22931. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22932. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22933. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22934. PsnCashPay float64 `json:"psn_cash_pay"`
  22935. PsnCertType string `json:"psn_cert_type"`
  22936. PsnName string `json:"psn_name"`
  22937. PsnNo string `json:"psn_no"`
  22938. PsnPartAmt float64 `json:"psn_part_amt"`
  22939. PsnType string `json:"psn_type"`
  22940. SetlID string `json:"setl_id"`
  22941. SetlTime int64 `json:"setl_time"`
  22942. } `json:"setlinfo"`
  22943. Setldetail interface{} `json:"setldetail"`
  22944. } `json:"output"`
  22945. RefmsgTime string `json:"refmsg_time"`
  22946. RespondTime string `json:"respond_time"`
  22947. Signtype interface{} `json:"signtype"`
  22948. WarnMsg interface{} `json:"warn_msg"`
  22949. }
  22950. type ResultSeven10265 struct {
  22951. Cainfo string `json:"cainfo"`
  22952. ErrMsg string `json:"err_msg"`
  22953. InfRefmsgid string `json:"inf_refmsgid"`
  22954. Infcode string `json:"infcode"`
  22955. Output struct {
  22956. Setlinfo struct {
  22957. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22958. AcctPay float64 `json:"acct_pay"`
  22959. ActPayDedc float64 `json:"act_pay_dedc"`
  22960. Age float64 `json:"age"`
  22961. Balc float64 `json:"balc"`
  22962. Certno string `json:"certno"`
  22963. ClrOptins string `json:"clr_optins"`
  22964. ClrType string `json:"clr_type"`
  22965. ClrWay string `json:"clr_way"`
  22966. CvlservFlag string `json:"cvlserv_flag"`
  22967. CvlservPay float64 `json:"cvlserv_pay"`
  22968. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22969. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22970. Gend string `json:"gend"`
  22971. HifesPay float64 `json:"hifes_pay"`
  22972. HifmiPay float64 `json:"hifmi_pay"`
  22973. HifpPay float64 `json:"hifp_pay"`
  22974. HospPartAmt float64 `json:"hosp_part_amt"`
  22975. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22976. Insutype string `json:"insutype"`
  22977. MafPay float64 `json:"maf_pay"`
  22978. MdtrtCertType string `json:"mdtrt_cert_type"`
  22979. HifobPay float64 `json:"hifob_pay"`
  22980. MdtrtID string `json:"mdtrt_id"`
  22981. MedType string `json:"med_type"`
  22982. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22983. MedinsSetlID string `json:"medins_setl_id"`
  22984. Naty string `json:"naty"`
  22985. OthPay float64 `json:"oth_pay"`
  22986. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22987. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22988. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22989. PsnCashPay float64 `json:"psn_cash_pay"`
  22990. PsnCertType string `json:"psn_cert_type"`
  22991. PsnName string `json:"psn_name"`
  22992. PsnNo string `json:"psn_no"`
  22993. PsnPartAmt float64 `json:"psn_part_amt"`
  22994. PsnType string `json:"psn_type"`
  22995. SetlID string `json:"setl_id"`
  22996. SetlTime string `json:"setl_time"`
  22997. } `json:"setlinfo"`
  22998. Setldetail interface{} `json:"setldetail"`
  22999. } `json:"output"`
  23000. RefmsgTime string `json:"refmsg_time"`
  23001. RespondTime string `json:"respond_time"`
  23002. Signtype interface{} `json:"signtype"`
  23003. WarnMsg interface{} `json:"warn_msg"`
  23004. }
  23005. type ResultSeven10265Two struct {
  23006. Cainfo string `json:"cainfo"`
  23007. ErrMsg string `json:"err_msg"`
  23008. InfRefmsgid string `json:"inf_refmsgid"`
  23009. Infcode string `json:"infcode"`
  23010. Output struct {
  23011. Setlinfo struct {
  23012. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23013. AcctPay float64 `json:"acct_pay"`
  23014. ActPayDedc float64 `json:"act_pay_dedc"`
  23015. Age float64 `json:"age"`
  23016. Balc float64 `json:"balc"`
  23017. Certno string `json:"certno"`
  23018. ClrOptins string `json:"clr_optins"`
  23019. ClrType string `json:"clr_type"`
  23020. ClrWay string `json:"clr_way"`
  23021. CvlservFlag string `json:"cvlserv_flag"`
  23022. CvlservPay float64 `json:"cvlserv_pay"`
  23023. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23024. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23025. Gend string `json:"gend"`
  23026. HifesPay float64 `json:"hifes_pay"`
  23027. HifmiPay float64 `json:"hifmi_pay"`
  23028. HifpPay float64 `json:"hifp_pay"`
  23029. HospPartAmt string `json:"hosp_part_amt"`
  23030. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23031. Insutype string `json:"insutype"`
  23032. MafPay float64 `json:"maf_pay"`
  23033. MdtrtCertType string `json:"mdtrt_cert_type"`
  23034. HifobPay float64 `json:"hifob_pay"`
  23035. MdtrtID string `json:"mdtrt_id"`
  23036. MedType string `json:"med_type"`
  23037. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23038. MedinsSetlID string `json:"medins_setl_id"`
  23039. Naty string `json:"naty"`
  23040. OthPay float64 `json:"oth_pay"`
  23041. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23042. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23043. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23044. PsnCashPay float64 `json:"psn_cash_pay"`
  23045. PsnCertType string `json:"psn_cert_type"`
  23046. PsnName string `json:"psn_name"`
  23047. PsnNo string `json:"psn_no"`
  23048. PsnPartAmt float64 `json:"psn_part_amt"`
  23049. PsnType string `json:"psn_type"`
  23050. SetlID string `json:"setl_id"`
  23051. SetlTime string `json:"setl_time"`
  23052. } `json:"setlinfo"`
  23053. Setldetail interface{} `json:"setldetail"`
  23054. } `json:"output"`
  23055. RefmsgTime string `json:"refmsg_time"`
  23056. RespondTime string `json:"respond_time"`
  23057. Signtype interface{} `json:"signtype"`
  23058. WarnMsg interface{} `json:"warn_msg"`
  23059. }
  23060. type ResultSeven10633Two struct {
  23061. Cainfo string `json:"cainfo"`
  23062. ErrMsg string `json:"err_msg"`
  23063. InfRefmsgid string `json:"inf_refmsgid"`
  23064. Infcode string `json:"infcode"`
  23065. Output struct {
  23066. Setlinfo struct {
  23067. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23068. AcctPay float64 `json:"acct_pay"`
  23069. ActPayDedc float64 `json:"act_pay_dedc"`
  23070. Age float64 `json:"age"`
  23071. Balc float64 `json:"balc"`
  23072. Certno string `json:"certno"`
  23073. ClrOptins string `json:"clr_optins"`
  23074. ClrType string `json:"clr_type"`
  23075. ClrWay string `json:"clr_way"`
  23076. CvlservFlag string `json:"cvlserv_flag"`
  23077. CvlservPay float64 `json:"cvlserv_pay"`
  23078. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23079. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23080. Gend string `json:"gend"`
  23081. HifesPay float64 `json:"hifes_pay"`
  23082. HifmiPay float64 `json:"hifmi_pay"`
  23083. HifpPay float64 `json:"hifp_pay"`
  23084. HospPartAmt float64 `json:"hosp_part_amt"`
  23085. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23086. Insutype string `json:"insutype"`
  23087. MafPay float64 `json:"maf_pay"`
  23088. MdtrtCertType string `json:"mdtrt_cert_type"`
  23089. HifobPay float64 `json:"hifob_pay"`
  23090. MdtrtID string `json:"mdtrt_id"`
  23091. MedType string `json:"med_type"`
  23092. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23093. MedinsSetlID string `json:"medins_setl_id"`
  23094. Naty string `json:"naty"`
  23095. OthPay float64 `json:"oth_pay"`
  23096. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23097. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23098. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23099. PsnCashPay float64 `json:"psn_cash_pay"`
  23100. PsnCertType string `json:"psn_cert_type"`
  23101. PsnName string `json:"psn_name"`
  23102. PsnNo string `json:"psn_no"`
  23103. PsnPartAmt float64 `json:"psn_part_amt"`
  23104. PsnType string `json:"psn_type"`
  23105. SetlID string `json:"setl_id"`
  23106. SetlTime string `json:"setl_time"`
  23107. } `json:"setlinfo"`
  23108. Setldetail interface{} `json:"setldetail"`
  23109. } `json:"output"`
  23110. RefmsgTime string `json:"refmsg_time"`
  23111. RespondTime string `json:"respond_time"`
  23112. Signtype interface{} `json:"signtype"`
  23113. WarnMsg interface{} `json:"warn_msg"`
  23114. }
  23115. type GZResultSeven10265Two struct {
  23116. Cainfo string `json:"cainfo"`
  23117. ErrMsg string `json:"err_msg"`
  23118. InfRefmsgid string `json:"inf_refmsgid"`
  23119. Infcode int64 `json:"infcode"`
  23120. Output struct {
  23121. Setlinfo struct {
  23122. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23123. AcctPay float64 `json:"acct_pay"`
  23124. ActPayDedc float64 `json:"act_pay_dedc"`
  23125. Age float64 `json:"age"`
  23126. Balc float64 `json:"balc"`
  23127. Certno string `json:"certno"`
  23128. ClrOptins string `json:"clr_optins"`
  23129. ClrType string `json:"clr_type"`
  23130. ClrWay string `json:"clr_way"`
  23131. CvlservFlag string `json:"cvlserv_flag"`
  23132. CvlservPay float64 `json:"cvlserv_pay"`
  23133. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23134. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23135. Gend string `json:"gend"`
  23136. HifesPay float64 `json:"hifes_pay"`
  23137. HifmiPay float64 `json:"hifmi_pay"`
  23138. HifpPay float64 `json:"hifp_pay"`
  23139. HospPartAmt float64 `json:"hosp_part_amt"`
  23140. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23141. Insutype string `json:"insutype"`
  23142. MafPay float64 `json:"maf_pay"`
  23143. MdtrtCertType string `json:"mdtrt_cert_type"`
  23144. HifobPay float64 `json:"hifob_pay"`
  23145. MdtrtID string `json:"mdtrt_id"`
  23146. MedType string `json:"med_type"`
  23147. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23148. MedinsSetlID string `json:"medins_setl_id"`
  23149. Naty string `json:"naty"`
  23150. OthPay float64 `json:"oth_pay"`
  23151. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23152. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23153. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23154. PsnCashPay float64 `json:"psn_cash_pay"`
  23155. PsnCertType string `json:"psn_cert_type"`
  23156. PsnName string `json:"psn_name"`
  23157. PsnNo string `json:"psn_no"`
  23158. PsnPartAmt float64 `json:"psn_part_amt"`
  23159. PsnType string `json:"psn_type"`
  23160. SetlID string `json:"setl_id"`
  23161. SetlTime string `json:"setl_time"`
  23162. } `json:"setlinfo"`
  23163. Setldetail interface{} `json:"setldetail"`
  23164. } `json:"output"`
  23165. RefmsgTime string `json:"refmsg_time"`
  23166. RespondTime string `json:"respond_time"`
  23167. Signtype interface{} `json:"signtype"`
  23168. WarnMsg interface{} `json:"warn_msg"`
  23169. }
  23170. type ResultEight struct {
  23171. Cainfo string `json:"cainfo"`
  23172. ErrMsg string `json:"err_msg"`
  23173. InfRefmsgid string `json:"inf_refmsgid"`
  23174. Infcode int64 `json:"infcode"`
  23175. Output struct {
  23176. Stmtinfo struct {
  23177. SetlOptins string `json:"setl_optins"`
  23178. StmtRslt string `json:"stmt_rslt"`
  23179. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23180. } `json:"stmtinfo"`
  23181. } `json:"output"`
  23182. RefmsgTime string `json:"refmsg_time"`
  23183. RespondTime string `json:"respond_time"`
  23184. Signtype interface{} `json:"signtype"`
  23185. WarnMsg interface{} `json:"warn_msg"`
  23186. }
  23187. type ResultEightFor10188 struct {
  23188. Cainfo string `json:"cainfo"`
  23189. ErrMsg string `json:"err_msg"`
  23190. InfRefmsgid string `json:"inf_refmsgid"`
  23191. Infcode string `json:"infcode"`
  23192. Output struct {
  23193. Stmtinfo struct {
  23194. SetlOptins string `json:"setl_optins"`
  23195. StmtRslt string `json:"stmt_rslt"`
  23196. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23197. } `json:"stmtinfo"`
  23198. } `json:"output"`
  23199. RefmsgTime string `json:"refmsg_time"`
  23200. RespondTime string `json:"respond_time"`
  23201. Signtype interface{} `json:"signtype"`
  23202. WarnMsg interface{} `json:"warn_msg"`
  23203. }
  23204. type ResultNine struct {
  23205. Cainfo string `json:"cainfo"`
  23206. ErrMsg string `json:"err_msg"`
  23207. InfRefmsgid string `json:"inf_refmsgid"`
  23208. Infcode int64 `json:"infcode"`
  23209. Output struct {
  23210. FileQuryNo string `json:"file_qury_no"`
  23211. } `json:"output"`
  23212. RefmsgTime string `json:"refmsg_time"`
  23213. RespondTime string `json:"respond_time"`
  23214. Signtype interface{} `json:"signtype"`
  23215. WarnMsg interface{} `json:"warn_msg"`
  23216. }
  23217. type ResultTen struct {
  23218. Cainfo string `json:"cainfo"`
  23219. ErrMsg string `json:"err_msg"`
  23220. InfRefmsgid string `json:"inf_refmsgid"`
  23221. Infcode int64 `json:"infcode"`
  23222. Output struct {
  23223. Fileinfo struct {
  23224. DldEndtime string `json:"dld_endtime"`
  23225. FileQuryNo string `json:"file_qury_no"`
  23226. Filename string `json:"filename"`
  23227. } `json:"fileinfo"`
  23228. } `json:"output"`
  23229. RefmsgTime string `json:"refmsg_time"`
  23230. RespondTime string `json:"respond_time"`
  23231. Signtype interface{} `json:"signtype"`
  23232. WarnMsg interface{} `json:"warn_msg"`
  23233. }
  23234. type Result5262 struct {
  23235. ErrMsg string `json:"err_msg"`
  23236. InfRefmsgid string `json:"inf_refmsgid"`
  23237. Infcode int64 `json:"infcode"`
  23238. Output struct {
  23239. PageInfo struct {
  23240. Size int `json:"size"`
  23241. RecordCounts int `json:"record_counts"`
  23242. } `json:"page_info"`
  23243. Idetinfo []interface{} `json:"idetinfo"`
  23244. Result []struct {
  23245. SetlID string `json:"setl_id"`
  23246. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23247. MdtrtID string `json:"mdtrt_id"`
  23248. InitSetlID string `json:"init_setl_id,omitempty"`
  23249. PsnNo string `json:"psn_no"`
  23250. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23251. PsnName string `json:"psn_name"`
  23252. PsnCertType string `json:"psn_cert_type"`
  23253. Certno string `json:"certno"`
  23254. Gend string `json:"gend,omitempty"`
  23255. Naty string `json:"naty,omitempty"`
  23256. Brdy string `json:"brdy,omitempty"`
  23257. Age float64 `json:"age,omitempty"`
  23258. Insutype string `json:"insutype,omitempty"`
  23259. PsnType string `json:"psn_type"`
  23260. CvlservFlag string `json:"cvlserv_flag"`
  23261. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23262. SpPsnType string `json:"sp_psn_type,omitempty"`
  23263. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23264. ClctGrde string `json:"clct_grde,omitempty"`
  23265. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23266. NwbFlag string `json:"nwb_flag,omitempty"`
  23267. InsuAdmdvs string `json:"insu_admdvs"`
  23268. EmpNo string `json:"emp_no,omitempty"`
  23269. EmpName string `json:"emp_name,omitempty"`
  23270. EmpType string `json:"emp_type,omitempty"`
  23271. EconType string `json:"econ_type,omitempty"`
  23272. AfilIndu string `json:"afil_indu,omitempty"`
  23273. AfilRlts string `json:"afil_rlts,omitempty"`
  23274. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23275. PayLoc string `json:"pay_loc,omitempty"`
  23276. FixmedinsCode string `json:"fixmedins_code"`
  23277. FixmedinsName string `json:"fixmedins_name"`
  23278. HospLv string `json:"hosp_lv,omitempty"`
  23279. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23280. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23281. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23282. Begndate string `json:"begndate"`
  23283. Enddate string `json:"enddate"`
  23284. SetlTime string `json:"setl_time"`
  23285. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23286. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23287. MedType string `json:"med_type"`
  23288. SetlType string `json:"setl_type,omitempty"`
  23289. ClrType string `json:"clr_type,omitempty"`
  23290. ClrWay string `json:"clr_way,omitempty"`
  23291. PsnSetlway string `json:"psn_setlway,omitempty"`
  23292. ClrOptins string `json:"clr_optins,omitempty"`
  23293. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23294. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23295. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23296. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23297. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23298. DedcStd float64 `json:"dedc_std,omitempty"`
  23299. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23300. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23301. HifpPay float64 `json:"hifp_pay,omitempty"`
  23302. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23303. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23304. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23305. HifesPay float64 `json:"hifes_pay,omitempty"`
  23306. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23307. HifobPay float64 `json:"hifob_pay,omitempty"`
  23308. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23309. MafPay float64 `json:"maf_pay,omitempty"`
  23310. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23311. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23312. PsnPay float64 `json:"psn_pay,omitempty"`
  23313. AcctPay float64 `json:"acct_pay,omitempty"`
  23314. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23315. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23316. Balc float64 `json:"balc,omitempty"`
  23317. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23318. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23319. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23320. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23321. Year string `json:"year,omitempty"`
  23322. DiseNo string `json:"dise_no,omitempty"`
  23323. DiseName string `json:"dise_name,omitempty"`
  23324. Invono string `json:"invono,omitempty"`
  23325. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23326. ValiFlag string `json:"vali_flag,omitempty"`
  23327. Memo string `json:"memo,omitempty"`
  23328. Rid string `json:"rid"`
  23329. UpdtTime string `json:"updt_time,omitempty"`
  23330. CrterID string `json:"crter_id,omitempty"`
  23331. CrterName string `json:"crter_name,omitempty"`
  23332. CrteTime string `json:"crte_time,omitempty"`
  23333. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23334. OpterID string `json:"opter_id,omitempty"`
  23335. OpterName string `json:"opter_name,omitempty"`
  23336. OptTime string `json:"opt_time,omitempty"`
  23337. OptinsNo string `json:"optins_no,omitempty"`
  23338. PoolareaNo string `json:"poolarea_no,omitempty"`
  23339. } `json:"result"`
  23340. } `json:"output"`
  23341. RefmsgTime string `json:"refmsg_time"`
  23342. RespondTime string `json:"respond_time"`
  23343. Signtype interface{} `json:"signtype"`
  23344. WarnInfo interface{} `json:"warn_info"`
  23345. }
  23346. type Result5267 struct {
  23347. ErrMsg string `json:"err_msg"`
  23348. InfRefmsgid string `json:"inf_refmsgid"`
  23349. Infcode int64 `json:"infcode"`
  23350. Output struct {
  23351. PageInfo struct {
  23352. Size int `json:"size"`
  23353. RecordCounts int `json:"record_counts"`
  23354. } `json:"pageinfo"`
  23355. Result []struct {
  23356. SetlID string `json:"setl_id"`
  23357. ClrOptins string `json:"clr_optins"`
  23358. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23359. MdtrtID string `json:"mdtrt_id"`
  23360. InitSetlID string `json:"init_setl_id,omitempty"`
  23361. PsnNo string `json:"psn_no"`
  23362. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23363. PsnName string `json:"psn_name"`
  23364. PsnCertType string `json:"psn_cert_type"`
  23365. Certno string `json:"certno"`
  23366. Gend string `json:"gend,omitempty"`
  23367. Naty string `json:"naty,omitempty"`
  23368. Brdy string `json:"brdy,omitempty"`
  23369. Age float64 `json:"age,omitempty"`
  23370. Insutype string `json:"insutype,omitempty"`
  23371. PsnType string `json:"psn_type"`
  23372. CvlservFlag string `json:"cvlserv_flag"`
  23373. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23374. SpPsnType string `json:"sp_psn_type,omitempty"`
  23375. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23376. ClctGrde string `json:"clct_grde,omitempty"`
  23377. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23378. NwbFlag string `json:"nwb_flag,omitempty"`
  23379. InsuAdmdvs string `json:"insu_admdvs"`
  23380. EmpNo string `json:"emp_no,omitempty"`
  23381. EmpName string `json:"emp_name,omitempty"`
  23382. EmpType string `json:"emp_type,omitempty"`
  23383. EconType string `json:"econ_type,omitempty"`
  23384. AfilIndu string `json:"afil_indu,omitempty"`
  23385. AfilRlts string `json:"afil_rlts,omitempty"`
  23386. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23387. PayLoc string `json:"pay_loc,omitempty"`
  23388. FixmedinsCode string `json:"fixmedins_code"`
  23389. FixmedinsName string `json:"fixmedins_name"`
  23390. HospLv string `json:"hosp_lv,omitempty"`
  23391. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23392. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23393. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23394. Begndate string `json:"begndate,omitempty"`
  23395. Enddate string `json:"enddate,omitempty"`
  23396. SetlTime string `json:"setl_time,omitempty"`
  23397. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23398. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23399. MedType string `json:"med_type"`
  23400. SetlType string `json:"setl_type,omitempty"`
  23401. ClrType string `json:"clr_type,omitempty"`
  23402. ClrWay string `json:"clr_way,omitempty"`
  23403. PsnSetlway string `json:"psn_setlway,omitempty"`
  23404. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23405. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23406. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23407. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23408. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23409. DedcStd float64 `json:"dedc_std,omitempty"`
  23410. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23411. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23412. HifpPay float64 `json:"hifp_pay,omitempty"`
  23413. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23414. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23415. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23416. HifesPay float64 `json:"hifes_pay,omitempty"`
  23417. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23418. HifobPay float64 `json:"hifob_pay,omitempty"`
  23419. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23420. MafPay float64 `json:"maf_pay,omitempty"`
  23421. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23422. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23423. PsnPay float64 `json:"psn_pay,omitempty"`
  23424. AcctPay float64 `json:"acct_pay,omitempty"`
  23425. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23426. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23427. Balc float64 `json:"balc,omitempty"`
  23428. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23429. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23430. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23431. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23432. Year string `json:"year,omitempty"`
  23433. DiseNo string `json:"dise_no,omitempty"`
  23434. DiseName string `json:"dise_name,omitempty"`
  23435. Invono string `json:"invono,omitempty"`
  23436. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23437. Memo string `json:"memo,omitempty"`
  23438. UpdtTime string `json:"updt_time,omitempty"`
  23439. OpterID string `json:"opter_id,omitempty"`
  23440. OpterName string `json:"opter_name,omitempty"`
  23441. OptTime string `json:"opt_time,omitempty"`
  23442. OptinsNo string `json:"optins_no,omitempty"`
  23443. PoolareaNo string `json:"poolarea_no,omitempty"`
  23444. } `json:"result"`
  23445. } `json:"output"`
  23446. RefmsgTime string `json:"refmsg_time"`
  23447. RespondTime string `json:"respond_time"`
  23448. Signtype interface{} `json:"signtype"`
  23449. WarnInfo interface{} `json:"warn_info"`
  23450. }
  23451. // type Autogenerated struct {
  23452. // Output struct {
  23453. // Setlinfo struct {
  23454. // SetlTime string `json:"setl_time"`
  23455. // CvlservPay float64 `json:"cvlserv_pay"`
  23456. // Year string `json:"year"`
  23457. // MedType string `json:"med_type"`
  23458. // PsnPay float64 `json:"psn_pay"`
  23459. // OpterID string `json:"opter_id"`
  23460. // Begndate string `json:"begndate"`
  23461. // FlxempeFlag string `json:"flxempe_flag"`
  23462. // HifmiPay float64 `json:"hifmi_pay"`
  23463. // PsnNo string `json:"psn_no"`
  23464. // ActPayDedc float64 `json:"act_pay_dedc"`
  23465. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23466. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23467. // ClrWay string `json:"clr_way"`
  23468. // OthPay float64 `json:"oth_pay"`
  23469. // Gend string `json:"gend"`
  23470. // MdtrtID string `json:"mdtrt_id"`
  23471. // AcctPay float64 `json:"acct_pay"`
  23472. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23473. // Insutype string `json:"insutype"`
  23474. // Invono interface{} `json:"invono"`
  23475. // Enddate string `json:"enddate"`
  23476. // CashPayamt float64 `json:"cash_payamt"`
  23477. // PsnType string `json:"psn_type"`
  23478. // FixmedinsName string `json:"fixmedins_name"`
  23479. // HifpPay float64 `json:"hifp_pay"`
  23480. // NewFlag interface{} `json:"new_flag"`
  23481. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23482. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23483. // PayLoc string `json:"pay_loc"`
  23484. // ClrType string `json:"clr_type"`
  23485. // RefdSetlFlag string `json:"refd_setl_flag"`
  23486. // CvlservFlag string `json:"cvlserv_flag"`
  23487. // EmpName string `json:"emp_name"`
  23488. // Brdy string `json:"brdy"`
  23489. // Naty string `json:"naty"`
  23490. // Certno string `json:"certno"`
  23491. // DiseCode string `json:"dise_code"`
  23492. // FixmedinsCode string `json:"fixmedins_code"`
  23493. // DedcHospLv string `json:"dedc_hosp_lv"`
  23494. // OpterName string `json:"opter_name"`
  23495. // Balc float64 `json:"balc"`
  23496. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23497. // PsnCertType string `json:"psn_cert_type"`
  23498. // HifobPay float64 `json:"hifob_pay"`
  23499. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23500. // HifesPay float64 `json:"hifes_pay"`
  23501. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23502. // OptTime string `json:"opt_time"`
  23503. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23504. // SetlID string `json:"setl_id"`
  23505. // MafPay float64 `json:"maf_pay"`
  23506. // PsnName string `json:"psn_name"`
  23507. // InsuOptins interface{} `json:"insu_optins"`
  23508. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23509. // ClrOptins string `json:"clr_optins"`
  23510. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23511. // DiseName string `json:"dise_name"`
  23512. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23513. // Age float64 `json:"age"`
  23514. // DtrtCertType string `json:"dtrt_cert_type"`
  23515. // HospLv string `json:"hosp_lv"`
  23516. // } `json:"setlinfo"`
  23517. // Setldetail []struct {
  23518. // FundPayType string `json:"fund_pay_type"`
  23519. // FundPayamt float64 `json:"fund_payamt"`
  23520. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23521. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23522. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23523. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23524. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23525. // } `json:"setldetail"`
  23526. // } `json:"output"`
  23527. // Infcode int `json:"infcode"`
  23528. // WarnMsg interface{} `json:"warn_msg"`
  23529. // Cainfo interface{} `json:"cainfo"`
  23530. // ErrMsg interface{} `json:"err_msg"`
  23531. // RefmsgTime string `json:"refmsg_time"`
  23532. // Signtype interface{} `json:"signtype"`
  23533. // RespondTime string `json:"respond_time"`
  23534. // InfRefmsgid string `json:"inf_refmsgid"`
  23535. // }
  23536. type Result002 struct {
  23537. Cainfo interface{} `json:"cainfo"`
  23538. ErrMsg string `json:"err_msg"`
  23539. InfRefmsgid string `json:"inf_refmsgid"`
  23540. Infcode int64 `json:"infcode"`
  23541. Output struct {
  23542. RxFile string `json:"rx_file"`
  23543. SignDigest string `json:"sign_digest"`
  23544. SignCertSn string `json:"sign_cert_sn"`
  23545. SignCertDn string `json:"sign_cert_dn"`
  23546. } `json:"output"`
  23547. RefmsgTime string `json:"refmsg_time"`
  23548. RespondTime string `json:"respond_time"`
  23549. Signtype interface{} `json:"signtype"`
  23550. WarnMsg interface{} `json:"warn_msg"`
  23551. }
  23552. type AhResult002 struct {
  23553. RxFile string `json:"rxFile"`
  23554. SignDigest string `json:"signDigest"`
  23555. SignCertSn string `json:"signCertSn"`
  23556. SignCertDn string `json:"signCertDn"`
  23557. }
  23558. type Result003 struct {
  23559. Cainfo interface{} `json:"cainfo"`
  23560. ErrMsg string `json:"err_msg"`
  23561. InfRefmsgid string `json:"inf_refmsgid"`
  23562. Infcode int64 `json:"infcode"`
  23563. Output struct {
  23564. HiRxno string `json:"hi_rxno"`
  23565. RxStasCodg string `json:"rx_stas_codg"`
  23566. RxStasName string `json:"rx_stas_name"`
  23567. } `json:"output"`
  23568. RefmsgTime string `json:"refmsg_time"`
  23569. RespondTime string `json:"respond_time"`
  23570. Signtype interface{} `json:"signtype"`
  23571. WarnMsg interface{} `json:"warn_msg"`
  23572. }
  23573. type AHResult003 struct {
  23574. HiRxno string `json:"hiRxno"`
  23575. RxStasCodg string `json:"rxStasCodg"`
  23576. RxStasName string `json:"rxStasName"`
  23577. }
  23578. type ResultEleven struct {
  23579. Cainfo string `json:"cainfo"`
  23580. ErrMsg string `json:"err_msg"`
  23581. InfRefmsgid string `json:"inf_refmsgid"`
  23582. Infcode int64 `json:"infcode"`
  23583. Output struct {
  23584. Setlinfo struct {
  23585. SetlTime string `json:"setl_time"`
  23586. CvlservPay float64 `json:"cvlserv_pay"`
  23587. Year string `json:"year"`
  23588. MedType string `json:"med_type"`
  23589. PsnPay float64 `json:"psn_pay"`
  23590. OpterID string `json:"opter_id"`
  23591. Begndate string `json:"begndate"`
  23592. FlxempeFlag string `json:"flxempe_flag"`
  23593. HifmiPay float64 `json:"hifmi_pay"`
  23594. PsnNo string `json:"psn_no"`
  23595. ActPayDedc float64 `json:"act_pay_dedc"`
  23596. MedinsSetlID interface{} `json:"medins_setl_id"`
  23597. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23598. ClrWay string `json:"clr_way"`
  23599. OthPay float64 `json:"oth_pay"`
  23600. Gend string `json:"gend"`
  23601. MdtrtID string `json:"mdtrt_id"`
  23602. AcctPay float64 `json:"acct_pay"`
  23603. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23604. Insutype string `json:"insutype"`
  23605. Invono interface{} `json:"invono"`
  23606. Enddate string `json:"enddate"`
  23607. CashPayamt float64 `json:"cash_payamt"`
  23608. PsnType string `json:"psn_type"`
  23609. FixmedinsName string `json:"fixmedins_name"`
  23610. HifpPay float64 `json:"hifp_pay"`
  23611. NewFlag interface{} `json:"new_flag"`
  23612. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23613. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23614. PayLoc string `json:"pay_loc"`
  23615. ClrType string `json:"clr_type"`
  23616. RefdSetlFlag string `json:"refd_setl_flag"`
  23617. CvlservFlag string `json:"cvlserv_flag"`
  23618. EmpName string `json:"emp_name"`
  23619. Brdy string `json:"brdy"`
  23620. Naty string `json:"naty"`
  23621. Certno string `json:"certno"`
  23622. DiseCode string `json:"dise_code"`
  23623. FixmedinsCode string `json:"fixmedins_code"`
  23624. DedcHospLv string `json:"dedc_hosp_lv"`
  23625. OpterName string `json:"opter_name"`
  23626. Balc float64 `json:"balc"`
  23627. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23628. PsnCertType string `json:"psn_cert_type"`
  23629. HifobPay float64 `json:"hifob_pay"`
  23630. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23631. HifesPay float64 `json:"hifes_pay"`
  23632. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23633. OptTime string `json:"opt_time"`
  23634. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23635. SetlID string `json:"setl_id"`
  23636. MafPay float64 `json:"maf_pay"`
  23637. PsnName string `json:"psn_name"`
  23638. InsuOptins interface{} `json:"insu_optins"`
  23639. PrefFundPay interface{} `json:"pref_fund_pay"`
  23640. ClrOptins string `json:"clr_optins"`
  23641. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23642. DiseName string `json:"dise_name"`
  23643. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23644. Age float64 `json:"age"`
  23645. DtrtCertType string `json:"dtrt_cert_type"`
  23646. HospLv string `json:"hosp_lv"`
  23647. PsnCashPay float64 `json:"psn_cash_pay"`
  23648. } `json:"setlinfo"`
  23649. } `json:"output"`
  23650. RefmsgTime string `json:"refmsg_time"`
  23651. RespondTime string `json:"respond_time"`
  23652. Signtype interface{} `json:"signtype"`
  23653. WarnMsg interface{} `json:"warn_msg"`
  23654. }
  23655. type ResultElevenah struct {
  23656. Cainfo string `json:"cainfo"`
  23657. ErrMsg string `json:"err_msg"`
  23658. InfRefmsgid string `json:"inf_refmsgid"`
  23659. Infcode int64 `json:"infcode"`
  23660. Output struct {
  23661. Setlinfo struct {
  23662. SetlTime int64 `json:"setl_time"`
  23663. CvlservPay float64 `json:"cvlserv_pay"`
  23664. Year string `json:"year"`
  23665. MedType string `json:"med_type"`
  23666. PsnPay float64 `json:"psn_pay"`
  23667. OpterID string `json:"opter_id"`
  23668. Begndate int64 `json:"begndate"`
  23669. FlxempeFlag string `json:"flxempe_flag"`
  23670. HifmiPay float64 `json:"hifmi_pay"`
  23671. PsnNo string `json:"psn_no"`
  23672. ActPayDedc float64 `json:"act_pay_dedc"`
  23673. MedinsSetlID interface{} `json:"medins_setl_id"`
  23674. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23675. ClrWay string `json:"clr_way"`
  23676. OthPay float64 `json:"oth_pay"`
  23677. Gend string `json:"gend"`
  23678. MdtrtID string `json:"mdtrt_id"`
  23679. AcctPay float64 `json:"acct_pay"`
  23680. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23681. Insutype string `json:"insutype"`
  23682. Invono interface{} `json:"invono"`
  23683. Enddate int64 `json:"enddate"`
  23684. CashPayamt float64 `json:"cash_payamt"`
  23685. PsnType string `json:"psn_type"`
  23686. FixmedinsName string `json:"fixmedins_name"`
  23687. HifpPay float64 `json:"hifp_pay"`
  23688. NewFlag interface{} `json:"new_flag"`
  23689. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23690. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23691. PayLoc string `json:"pay_loc"`
  23692. ClrType string `json:"clr_type"`
  23693. RefdSetlFlag string `json:"refd_setl_flag"`
  23694. CvlservFlag string `json:"cvlserv_flag"`
  23695. EmpName string `json:"emp_name"`
  23696. Brdy int64 `json:"brdy"`
  23697. Naty string `json:"naty"`
  23698. Certno string `json:"certno"`
  23699. DiseCode string `json:"dise_code"`
  23700. FixmedinsCode string `json:"fixmedins_code"`
  23701. DedcHospLv string `json:"dedc_hosp_lv"`
  23702. OpterName string `json:"opter_name"`
  23703. Balc float64 `json:"balc"`
  23704. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23705. PsnCertType string `json:"psn_cert_type"`
  23706. HifobPay float64 `json:"hifob_pay"`
  23707. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23708. HifesPay float64 `json:"hifes_pay"`
  23709. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23710. OptTime int64 `json:"opt_time"`
  23711. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23712. SetlID string `json:"setl_id"`
  23713. MafPay float64 `json:"maf_pay"`
  23714. PsnName string `json:"psn_name"`
  23715. InsuOptins interface{} `json:"insu_optins"`
  23716. PrefFundPay interface{} `json:"pref_fund_pay"`
  23717. ClrOptins string `json:"clr_optins"`
  23718. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23719. DiseName string `json:"dise_name"`
  23720. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23721. Age float64 `json:"age"`
  23722. DtrtCertType string `json:"dtrt_cert_type"`
  23723. HospLv string `json:"hosp_lv"`
  23724. PsnCashPay float64 `json:"psn_cash_pay"`
  23725. } `json:"setlinfo"`
  23726. } `json:"output"`
  23727. RefmsgTime string `json:"refmsg_time"`
  23728. RespondTime string `json:"respond_time"`
  23729. Signtype interface{} `json:"signtype"`
  23730. WarnMsg interface{} `json:"warn_msg"`
  23731. }
  23732. type ResultEleven10265 struct {
  23733. Cainfo string `json:"cainfo"`
  23734. ErrMsg string `json:"err_msg"`
  23735. InfRefmsgid string `json:"inf_refmsgid"`
  23736. Infcode string `json:"infcode"`
  23737. Output struct {
  23738. Setlinfo struct {
  23739. SetlTime string `json:"setl_time"`
  23740. CvlservPay float64 `json:"cvlserv_pay"`
  23741. Year string `json:"year"`
  23742. MedType string `json:"med_type"`
  23743. PsnPay float64 `json:"psn_pay"`
  23744. OpterID string `json:"opter_id"`
  23745. Begndate string `json:"begndate"`
  23746. FlxempeFlag string `json:"flxempe_flag"`
  23747. HifmiPay float64 `json:"hifmi_pay"`
  23748. PsnNo string `json:"psn_no"`
  23749. ActPayDedc float64 `json:"act_pay_dedc"`
  23750. MedinsSetlID interface{} `json:"medins_setl_id"`
  23751. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23752. ClrWay string `json:"clr_way"`
  23753. OthPay float64 `json:"oth_pay"`
  23754. Gend string `json:"gend"`
  23755. MdtrtID string `json:"mdtrt_id"`
  23756. AcctPay float64 `json:"acct_pay"`
  23757. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23758. Insutype string `json:"insutype"`
  23759. Invono interface{} `json:"invono"`
  23760. Enddate string `json:"enddate"`
  23761. CashPayamt float64 `json:"cash_payamt"`
  23762. PsnType string `json:"psn_type"`
  23763. FixmedinsName string `json:"fixmedins_name"`
  23764. HifpPay float64 `json:"hifp_pay"`
  23765. NewFlag interface{} `json:"new_flag"`
  23766. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23767. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23768. PayLoc string `json:"pay_loc"`
  23769. ClrType string `json:"clr_type"`
  23770. RefdSetlFlag string `json:"refd_setl_flag"`
  23771. CvlservFlag string `json:"cvlserv_flag"`
  23772. EmpName string `json:"emp_name"`
  23773. Brdy string `json:"brdy"`
  23774. Naty string `json:"naty"`
  23775. Certno string `json:"certno"`
  23776. DiseCode string `json:"dise_code"`
  23777. FixmedinsCode string `json:"fixmedins_code"`
  23778. DedcHospLv string `json:"dedc_hosp_lv"`
  23779. OpterName string `json:"opter_name"`
  23780. Balc float64 `json:"balc"`
  23781. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23782. PsnCertType string `json:"psn_cert_type"`
  23783. HifobPay float64 `json:"hifob_pay"`
  23784. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23785. HifesPay float64 `json:"hifes_pay"`
  23786. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23787. OptTime string `json:"opt_time"`
  23788. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23789. SetlID string `json:"setl_id"`
  23790. MafPay float64 `json:"maf_pay"`
  23791. PsnName string `json:"psn_name"`
  23792. InsuOptins interface{} `json:"insu_optins"`
  23793. PrefFundPay interface{} `json:"pref_fund_pay"`
  23794. ClrOptins string `json:"clr_optins"`
  23795. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23796. DiseName string `json:"dise_name"`
  23797. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23798. Age float64 `json:"age"`
  23799. DtrtCertType string `json:"dtrt_cert_type"`
  23800. HospLv string `json:"hosp_lv"`
  23801. PsnCashPay float64 `json:"psn_cash_pay"`
  23802. } `json:"setlinfo"`
  23803. } `json:"output"`
  23804. RefmsgTime string `json:"refmsg_time"`
  23805. RespondTime string `json:"respond_time"`
  23806. Signtype interface{} `json:"signtype"`
  23807. WarnMsg interface{} `json:"warn_msg"`
  23808. }
  23809. type ResultTwelve struct {
  23810. Cainfo string `json:"cainfo"`
  23811. ErrMsg string `json:"err_msg"`
  23812. InfRefmsgid string `json:"inf_refmsgid"`
  23813. Infcode int64 `json:"infcode"`
  23814. Output struct {
  23815. MdtrtId string `json:"mdtrt_id"`
  23816. ChrgBchno string `json:"chrg_bchno"`
  23817. PsnNo string `json:"psn_no"`
  23818. } `json:"output"`
  23819. RefmsgTime string `json:"refmsg_time"`
  23820. RespondTime string `json:"respond_time"`
  23821. Signtype interface{} `json:"signtype"`
  23822. WarnMsg interface{} `json:"warn_msg"`
  23823. }
  23824. type ResultThirteen struct {
  23825. ErrMsg string `json:"err_msg"`
  23826. InfRefmsgid string `json:"inf_refmsgid"`
  23827. Infcode int64 `json:"infcode"`
  23828. Output struct {
  23829. Result struct {
  23830. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23831. } `json:"result"`
  23832. } `json:"output"`
  23833. RefmsgTime string `json:"refmsg_time"`
  23834. RespondTime string `json:"respond_time"`
  23835. Signtype interface{} `json:"signtype"`
  23836. WarnInfo interface{} `json:"warn_info"`
  23837. }
  23838. type ResultThirteen10265 struct {
  23839. ErrMsg string `json:"err_msg"`
  23840. InfRefmsgid string `json:"inf_refmsgid"`
  23841. Infcode string `json:"infcode"`
  23842. Output struct {
  23843. Result struct {
  23844. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23845. } `json:"result"`
  23846. } `json:"output"`
  23847. RefmsgTime string `json:"refmsg_time"`
  23848. RespondTime string `json:"respond_time"`
  23849. Signtype interface{} `json:"signtype"`
  23850. WarnInfo interface{} `json:"warn_info"`
  23851. }
  23852. type ResultFourteen struct {
  23853. ErrMsg string `json:"err_msg"`
  23854. InfRefmsgid string `json:"inf_refmsgid"`
  23855. Infcode int64 `json:"infcode"`
  23856. Output struct {
  23857. } `json:"output"`
  23858. RefmsgTime string `json:"refmsg_time"`
  23859. RespondTime string `json:"respond_time"`
  23860. Signtype interface{} `json:"signtype"`
  23861. WarnInfo interface{} `json:"warn_info"`
  23862. }
  23863. type ResultCFYLJG001 struct {
  23864. ErrMsg string `json:"err_msg"`
  23865. InfRefmsgid string `json:"inf_refmsgid"`
  23866. Infcode int64 `json:"infcode"`
  23867. Output struct {
  23868. RxTraceCode string `json:"rx_trace_code"`
  23869. HiRxno string `json:"hi_rxno"`
  23870. } `json:"output"`
  23871. RefmsgTime string `json:"refmsg_time"`
  23872. RespondTime string `json:"respond_time"`
  23873. Signtype interface{} `json:"signtype"`
  23874. WarnInfo interface{} `json:"warn_info"`
  23875. }
  23876. type ResultCFYLJG001AH struct {
  23877. RxTraceCode string `json:"rxTraceCode"`
  23878. HiRxno string `json:"hiRxno"`
  23879. }
  23880. type ResultCFYLJG007 struct {
  23881. ErrMsg string `json:"err_msg"`
  23882. InfRefmsgid string `json:"inf_refmsgid"`
  23883. Infcode int64 `json:"infcode"`
  23884. Output struct {
  23885. HiRxno string `json:"hi_rxno"`
  23886. RxStasName string `json:"rx_stas_name"`
  23887. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23888. Seltdelts []interface{} `json:"seltdelts"`
  23889. RxUsedStasName string `json:"rx_used_stas_name"`
  23890. RxStasCodg string `json:"rx_stas_codg"`
  23891. } `json:"output"`
  23892. RefmsgTime string `json:"refmsg_time"`
  23893. RespondTime string `json:"respond_time"`
  23894. Signtype interface{} `json:"signtype"`
  23895. WarnInfo interface{} `json:"warn_info"`
  23896. }
  23897. type ResultCFYLJG002 struct {
  23898. ErrMsg string `json:"err_msg"`
  23899. InfRefmsgid string `json:"inf_refmsgid"`
  23900. Infcode int64 `json:"infcode"`
  23901. Output struct {
  23902. RxFile string `json:"rx_file"`
  23903. SignDigest string `json:"sign_digest"`
  23904. SignCertSn string `json:"sign_cert_sn"`
  23905. SignCertDn string `json:"sign_cert_dn"`
  23906. } `json:"output"`
  23907. RefmsgTime string `json:"refmsg_time"`
  23908. RespondTime string `json:"respond_time"`
  23909. Signtype interface{} `json:"signtype"`
  23910. WarnInfo interface{} `json:"warn_info"`
  23911. }
  23912. type ResultCFYLJG003 struct {
  23913. ErrMsg string `json:"err_msg"`
  23914. InfRefmsgid string `json:"inf_refmsgid"`
  23915. Infcode int64 `json:"infcode"`
  23916. Output struct {
  23917. HiRxno string `json:"hi_rxno"`
  23918. RxStasCodg string `json:"rx_stas_codg"`
  23919. RxStasName string `json:"rx_stas_name"`
  23920. } `json:"output"`
  23921. RefmsgTime string `json:"refmsg_time"`
  23922. RespondTime string `json:"respond_time"`
  23923. Signtype interface{} `json:"signtype"`
  23924. WarnInfo interface{} `json:"warn_info"`
  23925. }
  23926. type ResultCFYLJG004 struct {
  23927. ErrMsg string `json:"err_msg"`
  23928. InfRefmsgid string `json:"inf_refmsgid"`
  23929. Infcode int64 `json:"infcode"`
  23930. Output struct {
  23931. HiRxno string `json:"hi_rxno"`
  23932. RxStasCodg string `json:"rx_stas_codg"`
  23933. RxStasName string `json:"rx_stas_name"`
  23934. } `json:"output"`
  23935. RefmsgTime string `json:"refmsg_time"`
  23936. RespondTime string `json:"respond_time"`
  23937. Signtype interface{} `json:"signtype"`
  23938. WarnInfo interface{} `json:"warn_info"`
  23939. }
  23940. type ResultCFYLJG008 struct {
  23941. ErrMsg string `json:"err_msg"`
  23942. InfRefmsgid string `json:"inf_refmsgid"`
  23943. Infcode int64 `json:"infcode"`
  23944. Output struct {
  23945. PoolareaNo string `json:"poolareaNo"`
  23946. AdmdvsName string `json:"admdvsName"`
  23947. Count string `json:"count"`
  23948. } `json:"output"`
  23949. RefmsgTime string `json:"refmsg_time"`
  23950. RespondTime string `json:"respond_time"`
  23951. Signtype interface{} `json:"signtype"`
  23952. WarnInfo interface{} `json:"warn_info"`
  23953. }
  23954. type ResultCFYLJG005 struct {
  23955. ErrMsg string `json:"err_msg"`
  23956. InfRefmsgid string `json:"inf_refmsgid"`
  23957. Infcode int64 `json:"infcode"`
  23958. Output struct {
  23959. HiRxNo string `json:"hi_rxno"`
  23960. FixMedinsCode string `json:"fixmedins_code"`
  23961. FixMedinsName string `json:"fixmedins_name"`
  23962. RxStasCodg string `json:"rx_stas_codg"`
  23963. RxStasName string `json:"rx_stas_name"`
  23964. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23965. RxUserdStasName string `json:"rx_userd_stas_name"`
  23966. PrscTime string `json:"prsc_time"`
  23967. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23968. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23969. RxUsedWayName string `json:"rx_used_way_name"`
  23970. RxFrquCodg string `json:"rx_frqu_codg"`
  23971. RxFrquName string `json:"rx_frqu_name"`
  23972. RxDosunt string `json:"rx_dosunt"`
  23973. RxDoscnt float64 `json:"rx_doscnt"`
  23974. RxDrordDscr string `json:"rx_drord_dscr"`
  23975. ValiDays int64 `json:"vali_days"`
  23976. ValiEndTime string `json:"vali_end_time"`
  23977. ReptFlag string `json:"rept_flag"`
  23978. MaxReptCnt int64 `json:"max_rept_cnt"`
  23979. ReptdCnt int64 `json:"reptd_cnt"`
  23980. MinInrvDays int64 `json:"min_inrv_days"`
  23981. RxTypeCode string `json:"rx_type_code"`
  23982. RxTypeName string `json:"rx_type_name"`
  23983. LongRxFlag string `json:"long_rx_flag"`
  23984. RxDetlList []struct {
  23985. MedListCodg string `json:"med_list_codg"`
  23986. MedinsListCodg string `json:"medins_list_codg"`
  23987. HospPrepFlag string `json:"hosp_prep_flag"`
  23988. RxItemTypeCode string `json:"rx_item_type_code"`
  23989. RxItemTypeName string `json:"rx_item_type_name"`
  23990. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23991. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23992. TcmHerbFoote string `json:"tcmherb_foote"`
  23993. MednTypeCode string `json:"medn_type_code"`
  23994. MednTypeName string `json:"medn_type_name"`
  23995. MainMedcFlag string `json:"main_medc_flag"`
  23996. UrgtFlag string `json:"urgt_flag"`
  23997. BasMednFlag string `json:"bas_medn_flag"`
  23998. ImpDrugFlag string `json:"imp_drug_flag"`
  23999. ProdBarc string `json:"prod_barc"`
  24000. DrugProdname string `json:"drug_prodname"`
  24001. GennameCodg string `json:"genname_codg"`
  24002. DrugGenname string `json:"drug_genname"`
  24003. DrugDosform string `json:"drug_dosform"`
  24004. DrugSpec string `json:"drug_spec"`
  24005. PrdrName string `json:"prdr_name"`
  24006. MedcWayCodg string `json:"medc_way_codg"`
  24007. MedcWayDscr string `json:"medc_way_dscr"`
  24008. MedcBegntime string `json:"medc_begntime"`
  24009. MedcEndtime string `json:"medc_endtime"`
  24010. MedcDays float64 `json:"medc_days"`
  24011. DrugPric float64 `json:"drug_pric"`
  24012. DrugSumamt float64 `json:"drug_sumamt"`
  24013. DrugCnt float64 `json:"drug_cnt"`
  24014. DrugDosunt string `json:"drug_dosunt"`
  24015. SinDoscnt float64 `json:"sin_doscnt"`
  24016. SinDosunt string `json:"sin_dosunt"`
  24017. UsedFrquCodg string `json:"used_frqu_codg"`
  24018. UsedFrquName string `json:"used_frqu_name"`
  24019. DrugTotlcnt string `json:"drug_totlcnt"`
  24020. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24021. DiseCodg string `json:"dise_codg"`
  24022. HospApprFlag string `json:"hosp_appr_flag"`
  24023. } `json:"rx_detl_list"`
  24024. RxOtpinfo struct {
  24025. MedType string `json:"med_type"`
  24026. IptOtpNo string `json:"ipt_otp_no"`
  24027. OtpIptFlag string `json:"otp_ipt_flag"`
  24028. PatnName string `json:"patn_name"`
  24029. PatnAge float64 `json:"patn_age"`
  24030. PatnHgt float64 `json:"patn_hgt"`
  24031. PatnWt float64 `json:"patn_wt"`
  24032. Gend string `json:"gend"`
  24033. GesoVal float64 `json:"geso_val"`
  24034. NwbFlag string `json:"nwb_flag"`
  24035. NwbAge string `json:"nwb_age"`
  24036. SuckPrdFlag string `json:"suck_prd_flag"`
  24037. AlgsHis string `json:"algs_his"`
  24038. Insutype string `json:"insutype"`
  24039. PrscDeptName string `json:"prsc_dept_name"`
  24040. PrscDrName string `json:"prsc_dr_name"`
  24041. PharName string `json:"phar_name"`
  24042. PharChkTime string `json:"phar_chk_time"`
  24043. MdtrtTime string `json:"mdtrt_time"`
  24044. DiseCodg string `json:"dise_codg"`
  24045. DiseName string `json:"dise_name"`
  24046. SpDiseFlag string `json:"sp_dise_flag"`
  24047. MaindiagCode string `json:"maindiag_code"`
  24048. MaindiagName string `json:"maindiag_name"`
  24049. DiseCondDscr string `json:"dise_cond_dscr"`
  24050. FstdiagFlag string `json:"fstdiag_flag"`
  24051. } `json:"rx_otpinfo"`
  24052. RxDiseList []struct {
  24053. DiagType string `json:"diag_type"`
  24054. MaindiagFlag string `json:"maindiag_flag"`
  24055. DiagSrtNo string `json:"diag_srt_no"`
  24056. DiagCode string `json:"diag_code"`
  24057. DiagName string `json:"diag_name"`
  24058. DiagDept string `json:"diag_dept"`
  24059. DiagDrNo string `json:"diag_dr_no"`
  24060. DiagDrName string `json:"diag_dr_name"`
  24061. DiagTime string `json:"diag_time"`
  24062. TcmDiseCode string `json:"tcm_dise_code"`
  24063. TcmDiseName string `json:"tcm_dise_name"`
  24064. TcmSympCode string `json:"tcmsymp_code"`
  24065. TcmSymp string `json:"tcmsymp"`
  24066. } `json:"rx_dise_list"`
  24067. } `json:"output"`
  24068. RefmsgTime string `json:"refmsg_time"`
  24069. RespondTime string `json:"respond_time"`
  24070. Signtype interface{} `json:"signtype"`
  24071. WarnInfo interface{} `json:"warn_info"`
  24072. }
  24073. type ResultCFYLJG006 struct {
  24074. ErrMsg string `json:"err_msg"`
  24075. InfRefmsgid string `json:"inf_refmsgid"`
  24076. Infcode int64 `json:"infcode"`
  24077. Output struct {
  24078. HiRxNo string `json:"hi_rxno"`
  24079. PharCode string `json:"phar_code"`
  24080. PharName string `json:"phar_name"`
  24081. RxChkOpnn string `json:"rx_chk_opnn"`
  24082. RxChkTime string `json:"rx_chk_time"`
  24083. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24084. RxChkStasName string `json:"rx_chk_stas_name"`
  24085. RxStasCodg string `json:"rx_stas_codg"`
  24086. RxStasName string `json:"rx_stas_name"`
  24087. } `json:"output"`
  24088. RefmsgTime string `json:"refmsg_time"`
  24089. RespondTime string `json:"respond_time"`
  24090. Signtype interface{} `json:"signtype"`
  24091. WarnInfo interface{} `json:"warn_info"`
  24092. }
  24093. type ResultFourteen10265 struct {
  24094. ErrMsg string `json:"err_msg"`
  24095. InfRefmsgid string `json:"inf_refmsgid"`
  24096. Infcode string `json:"infcode"`
  24097. Output struct {
  24098. } `json:"output"`
  24099. RefmsgTime string `json:"refmsg_time"`
  24100. RespondTime string `json:"respond_time"`
  24101. Signtype interface{} `json:"signtype"`
  24102. WarnInfo interface{} `json:"warn_info"`
  24103. }
  24104. type ResultSixteen struct {
  24105. Cainfo string `json:"cainfo"`
  24106. ErrMsg string `json:"err_msg"`
  24107. InfRefmsgid string `json:"inf_refmsgid"`
  24108. Infcode int64 `json:"infcode"`
  24109. Output struct {
  24110. Setlinfo struct {
  24111. MdtrtID string `json:"mdtrt_id"`
  24112. SetlID string `json:"setl_id"`
  24113. ClrOptins string `json:"clr_optins"`
  24114. SetlTime string `json:"setl_time"`
  24115. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24116. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24117. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24118. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24119. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24120. ActPayDedc float64 `json:"act_pay_dedc"`
  24121. HifpPay float64 `json:"hifp_pay"`
  24122. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24123. Lfpay float64 `json:"selfpay"`
  24124. CvlservPay float64 `json:"cvlserv_pay"`
  24125. HifesPay float64 `json:"hifes_pay"`
  24126. HifmiPay float64 `json:"hifmi_pay"`
  24127. HifobPay float64 `json:"hifob_pay"`
  24128. MafPay float64 `json:"maf_pay"`
  24129. OthPay float64 `json:"oth_pay"`
  24130. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24131. PsnPartAmt float64 `json:"psn_part_amt"`
  24132. AcctPay float64 `json:"acct_pay"`
  24133. Balc float64 `json:"balc"`
  24134. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24135. HospPartAmt float64 `json:"hosp_part_amt"`
  24136. MedinsSetlID string `json:"medins_setl_id"`
  24137. PdnCashPay string `json:"pdn_cash_pay"`
  24138. } `json:"setlinfo"`
  24139. } `json:"output"`
  24140. RefmsgTime string `json:"refmsg_time"`
  24141. RespondTime string `json:"respond_time"`
  24142. Signtype interface{} `json:"signtype"`
  24143. WarnMsg interface{} `json:"warn_msg"`
  24144. }
  24145. type ResultSixteen10265 struct {
  24146. Cainfo string `json:"cainfo"`
  24147. ErrMsg string `json:"err_msg"`
  24148. InfRefmsgid string `json:"inf_refmsgid"`
  24149. Infcode string `json:"infcode"`
  24150. Output struct {
  24151. Setlinfo struct {
  24152. MdtrtID string `json:"mdtrt_id"`
  24153. SetlID string `json:"setl_id"`
  24154. ClrOptins string `json:"clr_optins"`
  24155. SetlTime string `json:"setl_time"`
  24156. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24157. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24158. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24159. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24160. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24161. ActPayDedc float64 `json:"act_pay_dedc"`
  24162. HifpPay float64 `json:"hifp_pay"`
  24163. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24164. Lfpay float64 `json:"selfpay"`
  24165. CvlservPay float64 `json:"cvlserv_pay"`
  24166. HifesPay float64 `json:"hifes_pay"`
  24167. HifmiPay float64 `json:"hifmi_pay"`
  24168. HifobPay float64 `json:"hifob_pay"`
  24169. MafPay float64 `json:"maf_pay"`
  24170. OthPay float64 `json:"oth_pay"`
  24171. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24172. PsnPartAmt float64 `json:"psn_part_amt"`
  24173. AcctPay float64 `json:"acct_pay"`
  24174. Balc float64 `json:"balc"`
  24175. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24176. HospPartAmt float64 `json:"hosp_part_amt"`
  24177. MedinsSetlID string `json:"medins_setl_id"`
  24178. PdnCashPay string `json:"pdn_cash_pay"`
  24179. } `json:"setlinfo"`
  24180. } `json:"output"`
  24181. RefmsgTime string `json:"refmsg_time"`
  24182. RespondTime string `json:"respond_time"`
  24183. Signtype interface{} `json:"signtype"`
  24184. WarnMsg interface{} `json:"warn_msg"`
  24185. }
  24186. type ResultSixteen10265Two struct {
  24187. Cainfo string `json:"cainfo"`
  24188. ErrMsg string `json:"err_msg"`
  24189. InfRefmsgid string `json:"inf_refmsgid"`
  24190. Infcode string `json:"infcode"`
  24191. Output struct {
  24192. Setlinfo interface{} `json:"setlinfo"`
  24193. } `json:"output"`
  24194. RefmsgTime string `json:"refmsg_time"`
  24195. RespondTime string `json:"respond_time"`
  24196. Signtype interface{} `json:"signtype"`
  24197. WarnMsg interface{} `json:"warn_msg"`
  24198. }
  24199. type ResultgzSixteen10265Two struct {
  24200. Cainfo string `json:"cainfo"`
  24201. ErrMsg string `json:"err_msg"`
  24202. InfRefmsgid string `json:"inf_refmsgid"`
  24203. Infcode int64 `json:"infcode"`
  24204. Output struct {
  24205. Setlinfo interface{} `json:"setlinfo"`
  24206. } `json:"output"`
  24207. RefmsgTime string `json:"refmsg_time"`
  24208. RespondTime string `json:"respond_time"`
  24209. Signtype interface{} `json:"signtype"`
  24210. WarnMsg interface{} `json:"warn_msg"`
  24211. }
  24212. type ResultSeventeen struct {
  24213. ErrMsg string `json:"err_msg"`
  24214. InfRefmsgid string `json:"inf_refmsgid"`
  24215. Infcode int64 `json:"infcode"`
  24216. Output struct {
  24217. SetlListId string `json:"setl_list_id"`
  24218. } `json:"output"`
  24219. RefmsgTime string `json:"refmsg_time"`
  24220. RespondTime string `json:"respond_time"`
  24221. Signtype string `json:"signtype"`
  24222. WarnInfo string `json:"warn_info"`
  24223. }
  24224. type ResultSeventeenOther struct {
  24225. ErrMsg string `json:"err_msg"`
  24226. InfRefmsgid string `json:"inf_refmsgid"`
  24227. Infcode string `json:"infcode"`
  24228. Output struct {
  24229. SetlListId string `json:"setl_list_id"`
  24230. } `json:"output"`
  24231. RefmsgTime string `json:"refmsg_time"`
  24232. RespondTime string `json:"respond_time"`
  24233. Signtype string `json:"signtype"`
  24234. WarnInfo string `json:"warn_info"`
  24235. }
  24236. type Result90991 struct {
  24237. ErrMsg string `json:"err_msg"`
  24238. InfRefmsgid string `json:"inf_refmsgid"`
  24239. Infcode int64 `json:"infcode"`
  24240. Output struct {
  24241. Result struct {
  24242. PsnNo string `json:"psn_no"`
  24243. CardStat string `json:"card_stat"`
  24244. Certno string `json:"certno"`
  24245. PsnName string `json:"psn_name"`
  24246. CheckStat string `json:"check_stat"`
  24247. SscnoCheckStat string `json:"sscno_check_stat"`
  24248. } `json:"result"`
  24249. } `json:"output"`
  24250. RefmsgTime string `json:"refmsg_time"`
  24251. RespondTime string `json:"respond_time"`
  24252. Signtype interface{} `json:"signtype"`
  24253. WarnInfo interface{} `json:"warn_info"`
  24254. }
  24255. type Result90100 struct {
  24256. ErrMsg string `json:"err_msg"`
  24257. InfRefmsgid string `json:"inf_refmsgid"`
  24258. Infcode int64 `json:"infcode"`
  24259. Output struct {
  24260. PoolareaNo string `json:"poolarea_no"`
  24261. PoolareaNoName string `json:"poolarea_no_name"`
  24262. Insutype string `json:"insutype"`
  24263. InsutypeName string `json:"insutype_name"`
  24264. ClctType string `json:"clct_type"`
  24265. ClctTypeName string `json:"clct_type_name"`
  24266. ClctFlag string `json:"clct_flag"`
  24267. ClctFlagName string `json:"clct_flag_name"`
  24268. AccrymBegn string `json:"accrym_begn"`
  24269. AccrymEnd string `json:"accrym_end"`
  24270. ClctTime string `json:"clct_time"`
  24271. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24272. } `json:"output"`
  24273. RefmsgTime string `json:"refmsg_time"`
  24274. RespondTime string `json:"respond_time"`
  24275. Signtype interface{} `json:"signtype"`
  24276. WarnInfo interface{} `json:"warn_info"`
  24277. }
  24278. type Custom struct {
  24279. DetItemFeeSumamt string
  24280. Cut string
  24281. FeedetlSn string
  24282. Price string
  24283. MedListCodg string
  24284. Type int64
  24285. AdviceId int64
  24286. ProjectId int64
  24287. ItemId int64
  24288. }
  24289. type Result5301 struct {
  24290. ErrMsg string `json:"err_msg"`
  24291. InfRefmsgid string `json:"inf_refmsgid"`
  24292. Infcode int64 `json:"infcode"`
  24293. Output struct {
  24294. Result []struct {
  24295. OpspDiseCode string `json:"opsp_dise_code"`
  24296. OpspDiseName string `json:"opsp_dise_name"`
  24297. Begndate string `json:"begndate"`
  24298. Enddate string `json:"enddate"`
  24299. } `json:"feedetail"`
  24300. } `json:"output"`
  24301. RefmsgTime string `json:"refmsg_time"`
  24302. RespondTime string `json:"respond_time"`
  24303. Signtype interface{} `json:"signtype"`
  24304. WarnInfo interface{} `json:"warn_info"`
  24305. }
  24306. type Result5301For10265 struct {
  24307. ErrMsg string `json:"err_msg"`
  24308. InfRefmsgid string `json:"inf_refmsgid"`
  24309. Infcode string `json:"infcode"`
  24310. Output struct {
  24311. Result []struct {
  24312. OpspDiseCode string `json:"opsp_dise_code"`
  24313. OpspDiseName string `json:"opsp_dise_name"`
  24314. Begndate string `json:"begndate"`
  24315. Enddate string `json:"enddate"`
  24316. } `json:"feedetail"`
  24317. } `json:"output"`
  24318. RefmsgTime string `json:"refmsg_time"`
  24319. RespondTime string `json:"respond_time"`
  24320. Signtype interface{} `json:"signtype"`
  24321. WarnInfo interface{} `json:"warn_info"`
  24322. }
  24323. //获取个人信息----挂号-----上传就诊信息
  24324. func (c *HisApiController) GetRegisterInfo() {
  24325. id, _ := c.GetInt64("id")
  24326. record_time := c.GetString("record_time")
  24327. settlementValue, _ := c.GetInt64("settlement_value")
  24328. medical_insurance_card := c.GetString("medical_insurance_card")
  24329. name := c.GetString("name")
  24330. id_card_type, _ := c.GetInt64("id_card_type")
  24331. certificates, _ := c.GetInt64("certificates")
  24332. medical_care, _ := c.GetInt64("medical_care")
  24333. birthday := c.GetString("birthday")
  24334. id_card := c.GetString("id_card")
  24335. register_type, _ := c.GetInt64("register")
  24336. doctor, _ := c.GetInt64("doctor")
  24337. department, _ := c.GetInt64("department")
  24338. gender, _ := c.GetInt64("sex")
  24339. registration_fee, _ := c.GetFloat("registration_fee")
  24340. medical_expenses, _ := c.GetFloat("medical_expenses")
  24341. social_type, _ := c.GetInt64("social_type")
  24342. admin_user_id, _ := c.GetInt64("admin_user_id")
  24343. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24344. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24345. mdtrt_type := c.GetString("mdtrt_type")
  24346. if id_card_type == 5 {
  24347. id_card_type = 4
  24348. }
  24349. timeLayout := "2006-01-02"
  24350. loc, _ := time.LoadLocation("Local")
  24351. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24352. birthUnix := birthdays.Unix()
  24353. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24354. if err != nil {
  24355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24356. return
  24357. }
  24358. recordDateTime := theTime.Unix()
  24359. adminInfo := c.GetAdminUserInfo()
  24360. var patient service.Patients
  24361. if id == 0 {
  24362. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24363. } else {
  24364. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24365. }
  24366. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24367. if patientPrescription.ID == 0 {
  24368. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24369. }
  24370. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24371. if patient.ID == 0 {
  24372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24373. return
  24374. }
  24375. if len(patient.IdCardNo) == 0 {
  24376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24377. return
  24378. }
  24379. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24380. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24381. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24382. //就诊结算未完成,不能进行二次挂号
  24383. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24384. if len(his) >= 1 {
  24385. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24386. if len(his) >= 1 && order.ID == 0 {
  24387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24388. return
  24389. }
  24390. }
  24391. var aaaa string
  24392. //var register_log string
  24393. if config.IsOpen == 1 {
  24394. var res ResultTwo
  24395. var res10265 ResultTwo10265
  24396. var PsnNo string
  24397. var PsnCertType string
  24398. var Certno string
  24399. var PsnName string
  24400. var Gend string
  24401. var Naty string
  24402. var Brdy string
  24403. var Age float64
  24404. var infoStr string
  24405. var idetinfoStr string
  24406. var infocode int64
  24407. var verify_number string
  24408. fmt.Println(verify_number)
  24409. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24410. psn_info, _ := service.GetPsnByPatientId(id)
  24411. PsnNo = psn_info.PsnNo
  24412. PsnCertType = psn_info.PsnCertType
  24413. Certno = psn_info.Certno
  24414. PsnName = psn_info.PsnName
  24415. Gend = psn_info.Gend
  24416. Naty = psn_info.Naty
  24417. Brdy = psn_info.Brdy
  24418. Age = psn_info.Age
  24419. infoStr = psn_info.Insuinfo
  24420. idetinfoStr = psn_info.Idetinfo
  24421. infocode = 0
  24422. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24423. psn_info, _ := service.GetPsnByPatientId(id)
  24424. PsnNo = psn_info.PsnNo
  24425. PsnCertType = psn_info.PsnCertType
  24426. Certno = psn_info.Certno
  24427. PsnName = psn_info.PsnName
  24428. Gend = psn_info.Gend
  24429. Naty = psn_info.Naty
  24430. Brdy = psn_info.Brdy
  24431. Age = psn_info.Age
  24432. infoStr = psn_info.Insuinfo
  24433. idetinfoStr = psn_info.Idetinfo
  24434. infocode = 0
  24435. verify_number = psn_info.VerifyNumber
  24436. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24437. if id_card_type == 2 {
  24438. //请求内网数据
  24439. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24440. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24441. "&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
  24442. resp, requestErr := http.Get(api)
  24443. if requestErr != nil {
  24444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24445. return
  24446. }
  24447. body, ioErr := ioutil.ReadAll(resp.Body)
  24448. if ioErr != nil {
  24449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24451. return
  24452. }
  24453. var respJSON map[string]interface{}
  24454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24457. return
  24458. }
  24459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24460. result_byte, _ := json.Marshal(respJSON)
  24461. result := string(result_byte)
  24462. var dat map[string]interface{}
  24463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24464. fmt.Println(dat)
  24465. } else {
  24466. fmt.Println(err)
  24467. }
  24468. userJSONBytes, _ := json.Marshal(dat)
  24469. var res ResultTwo
  24470. var resTwo10265 ResultTwo10265
  24471. if miConfig.Code == "H15049901371" {
  24472. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24473. utils.ErrorLog("解析失败:%v", err)
  24474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24475. return
  24476. }
  24477. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24478. res.Infcode = Infcode
  24479. res.ErrMsg = resTwo10265.ErrMsg
  24480. res.Output = resTwo10265.Output
  24481. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24482. res.RespondTime = resTwo10265.RespondTime
  24483. res.WarnInfo = resTwo10265.WarnInfo
  24484. } else {
  24485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24486. utils.ErrorLog("解析失败:%v", err)
  24487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24488. return
  24489. }
  24490. }
  24491. //var insutypes []string
  24492. //var insutype string
  24493. //var is390 int = 0
  24494. //var is310 int = 0
  24495. //for _, item := range res.Output.Iinfo {
  24496. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24497. // insutypes = append(insutypes, item.Insutype)
  24498. // }
  24499. //}
  24500. //if len(insutypes) == 1 {
  24501. // insutype = insutypes[0]
  24502. //} else {
  24503. // for _, i := range insutypes {
  24504. // if i == "390" {
  24505. // is390 = 1
  24506. // }
  24507. //
  24508. // if i == "310" {
  24509. // is310 = 1
  24510. // }
  24511. // }
  24512. //}
  24513. //if is390 == 1 {
  24514. // insutype = "390"
  24515. //}
  24516. //if is310 == 1 {
  24517. // insutype = "310"
  24518. //}
  24519. //if len(insutypes) == 0 {
  24520. // insutype = "310"
  24521. //}
  24522. PsnNo = res.Output.Baseinfo.PsnNo
  24523. PsnCertType = res.Output.Baseinfo.PsnCertType
  24524. Certno = res.Output.Baseinfo.Certno
  24525. PsnName = res.Output.Baseinfo.PsnName
  24526. Gend = res.Output.Baseinfo.Gend
  24527. Naty = res.Output.Baseinfo.Naty
  24528. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24529. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24530. infoStr = string(Iinfos)
  24531. idetinfoStr = string(Idetinfos)
  24532. infocode = res.Infcode
  24533. //infocode = 0
  24534. //verify_number = psn_info.VerifyNumber
  24535. } else {
  24536. psn_info, _ := service.GetPsnByPatientId(id)
  24537. PsnNo = psn_info.PsnNo
  24538. PsnCertType = psn_info.PsnCertType
  24539. Certno = psn_info.Certno
  24540. PsnName = psn_info.PsnName
  24541. Gend = psn_info.Gend
  24542. Naty = psn_info.Naty
  24543. Brdy = psn_info.Brdy
  24544. Age = psn_info.Age
  24545. infoStr = psn_info.Insuinfo
  24546. idetinfoStr = psn_info.Idetinfo
  24547. infocode = 0
  24548. verify_number = psn_info.VerifyNumber
  24549. }
  24550. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24551. if id_card_type == 1 {
  24552. psn_info, _ := service.GetPsnByPatientId(id)
  24553. PsnNo = psn_info.PsnNo
  24554. PsnCertType = psn_info.PsnCertType
  24555. Certno = psn_info.Certno
  24556. PsnName = psn_info.PsnName
  24557. Gend = psn_info.Gend
  24558. Naty = psn_info.Naty
  24559. Brdy = psn_info.Brdy
  24560. Age = psn_info.Age
  24561. infoStr = psn_info.Insuinfo
  24562. idetinfoStr = psn_info.Idetinfo
  24563. infocode = 0
  24564. verify_number = psn_info.VerifyNumber
  24565. } else if id_card_type == 2 {
  24566. 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)
  24567. fmt.Println(errMsgLog)
  24568. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24569. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24570. utils.ErrorLog("解析失败:%v", err)
  24571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24572. return
  24573. }
  24574. PsnNo = res.Output.Baseinfo.PsnNo
  24575. PsnCertType = res.Output.Baseinfo.PsnCertType
  24576. Certno = res.Output.Baseinfo.Certno
  24577. PsnName = res.Output.Baseinfo.PsnName
  24578. Gend = res.Output.Baseinfo.Gend
  24579. Naty = res.Output.Baseinfo.Naty
  24580. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24581. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24582. infoStr = string(Iinfos)
  24583. idetinfoStr = string(Idetinfos)
  24584. infocode = res.Infcode
  24585. }
  24586. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24587. if id_card_type == 1 {
  24588. psn_info, _ := service.GetPsnByPatientId(id)
  24589. PsnNo = psn_info.PsnNo
  24590. PsnCertType = psn_info.PsnCertType
  24591. Certno = psn_info.Certno
  24592. PsnName = psn_info.PsnName
  24593. Gend = psn_info.Gend
  24594. Naty = psn_info.Naty
  24595. Brdy = psn_info.Brdy
  24596. Age = psn_info.Age
  24597. infoStr = psn_info.Insuinfo
  24598. idetinfoStr = psn_info.Idetinfo
  24599. infocode = 0
  24600. verify_number = psn_info.VerifyNumber
  24601. } else if id_card_type == 2 {
  24602. 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, "")
  24603. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24605. utils.ErrorLog("解析失败:%v", err)
  24606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24607. return
  24608. }
  24609. PsnNo = res.Output.Baseinfo.PsnNo
  24610. PsnCertType = res.Output.Baseinfo.PsnCertType
  24611. Certno = res.Output.Baseinfo.Certno
  24612. PsnName = res.Output.Baseinfo.PsnName
  24613. Gend = res.Output.Baseinfo.Gend
  24614. Naty = res.Output.Baseinfo.Naty
  24615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24617. infoStr = string(Iinfos)
  24618. idetinfoStr = string(Idetinfos)
  24619. infocode = res.Infcode
  24620. } else {
  24621. psn_info, _ := service.GetPsnByPatientId(id)
  24622. PsnNo = psn_info.PsnNo
  24623. PsnCertType = psn_info.PsnCertType
  24624. Certno = psn_info.Certno
  24625. PsnName = psn_info.PsnName
  24626. Gend = psn_info.Gend
  24627. Naty = psn_info.Naty
  24628. Brdy = psn_info.Brdy
  24629. Age = psn_info.Age
  24630. infoStr = psn_info.Insuinfo
  24631. idetinfoStr = psn_info.Idetinfo
  24632. infocode = 0
  24633. verify_number = psn_info.VerifyNumber
  24634. }
  24635. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24636. if id_card_type == 1 {
  24637. psn_info, _ := service.GetPsnByPatientId(id)
  24638. PsnNo = psn_info.PsnNo
  24639. PsnCertType = psn_info.PsnCertType
  24640. Certno = psn_info.Certno
  24641. PsnName = psn_info.PsnName
  24642. Gend = psn_info.Gend
  24643. Naty = psn_info.Naty
  24644. Brdy = psn_info.Brdy
  24645. Age = psn_info.Age
  24646. infoStr = psn_info.Insuinfo
  24647. idetinfoStr = psn_info.Idetinfo
  24648. infocode = 0
  24649. verify_number = psn_info.VerifyNumber
  24650. } else if id_card_type == 2 {
  24651. psn_info, _ := service.GetPsnByPatientId(id)
  24652. PsnNo = psn_info.PsnNo
  24653. PsnCertType = psn_info.PsnCertType
  24654. Certno = psn_info.Certno
  24655. PsnName = psn_info.PsnName
  24656. Gend = psn_info.Gend
  24657. Naty = psn_info.Naty
  24658. Brdy = psn_info.Brdy
  24659. Age = psn_info.Age
  24660. infoStr = psn_info.Insuinfo
  24661. idetinfoStr = psn_info.Idetinfo
  24662. infocode = 0
  24663. verify_number = psn_info.VerifyNumber
  24664. } else {
  24665. psn_info, _ := service.GetPsnByPatientId(id)
  24666. PsnNo = psn_info.PsnNo
  24667. PsnCertType = psn_info.PsnCertType
  24668. Certno = psn_info.Certno
  24669. PsnName = psn_info.PsnName
  24670. Gend = psn_info.Gend
  24671. Naty = psn_info.Naty
  24672. Brdy = psn_info.Brdy
  24673. Age = psn_info.Age
  24674. infoStr = psn_info.Insuinfo
  24675. idetinfoStr = psn_info.Idetinfo
  24676. infocode = 0
  24677. verify_number = psn_info.VerifyNumber
  24678. }
  24679. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24680. if id_card_type == 1 {
  24681. psn_info, _ := service.GetPsnByPatientId(id)
  24682. PsnNo = psn_info.PsnNo
  24683. PsnCertType = psn_info.PsnCertType
  24684. Certno = psn_info.Certno
  24685. PsnName = psn_info.PsnName
  24686. Gend = psn_info.Gend
  24687. Naty = psn_info.Naty
  24688. Brdy = psn_info.Brdy
  24689. Age = psn_info.Age
  24690. infoStr = psn_info.Insuinfo
  24691. idetinfoStr = psn_info.Idetinfo
  24692. infocode = 0
  24693. verify_number = psn_info.VerifyNumber
  24694. } else if id_card_type == 2 {
  24695. psn_info, _ := service.GetPsnByPatientId(id)
  24696. PsnNo = psn_info.PsnNo
  24697. PsnCertType = psn_info.PsnCertType
  24698. Certno = psn_info.Certno
  24699. PsnName = psn_info.PsnName
  24700. Gend = psn_info.Gend
  24701. Naty = psn_info.Naty
  24702. Brdy = psn_info.Brdy
  24703. Age = psn_info.Age
  24704. infoStr = psn_info.Insuinfo
  24705. idetinfoStr = psn_info.Idetinfo
  24706. infocode = 0
  24707. verify_number = psn_info.VerifyNumber
  24708. } else {
  24709. psn_info, _ := service.GetPsnByPatientId(id)
  24710. PsnNo = psn_info.PsnNo
  24711. PsnCertType = psn_info.PsnCertType
  24712. Certno = psn_info.Certno
  24713. PsnName = psn_info.PsnName
  24714. Gend = psn_info.Gend
  24715. Naty = psn_info.Naty
  24716. Brdy = psn_info.Brdy
  24717. Age = psn_info.Age
  24718. infoStr = psn_info.Insuinfo
  24719. idetinfoStr = psn_info.Idetinfo
  24720. infocode = 0
  24721. verify_number = psn_info.VerifyNumber
  24722. }
  24723. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24724. psn_info, _ := service.GetPsnByPatientId(id)
  24725. PsnNo = psn_info.PsnNo
  24726. PsnCertType = psn_info.PsnCertType
  24727. Certno = psn_info.Certno
  24728. PsnName = psn_info.PsnName
  24729. Gend = psn_info.Gend
  24730. Naty = psn_info.Naty
  24731. Brdy = psn_info.Brdy
  24732. Age = psn_info.Age
  24733. infoStr = psn_info.Insuinfo
  24734. idetinfoStr = psn_info.Idetinfo
  24735. infocode = 0
  24736. verify_number = psn_info.VerifyNumber
  24737. idetinfoStr = psn_info.Idetinfo
  24738. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24739. if id_card_type == 1 {
  24740. psn_info, _ := service.GetPsnByPatientId(id)
  24741. PsnNo = psn_info.PsnNo
  24742. PsnCertType = psn_info.PsnCertType
  24743. Certno = psn_info.Certno
  24744. PsnName = psn_info.PsnName
  24745. Gend = psn_info.Gend
  24746. Naty = psn_info.Naty
  24747. Brdy = psn_info.Brdy
  24748. Age = psn_info.Age
  24749. infoStr = psn_info.Insuinfo
  24750. idetinfoStr = psn_info.Idetinfo
  24751. infocode = 0
  24752. verify_number = psn_info.VerifyNumber
  24753. } else if id_card_type == 2 {
  24754. 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)
  24755. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24756. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24757. utils.ErrorLog("解析失败:%v", err)
  24758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24759. return
  24760. }
  24761. PsnNo = res.Output.Baseinfo.PsnNo
  24762. PsnCertType = res.Output.Baseinfo.PsnCertType
  24763. Certno = res.Output.Baseinfo.Certno
  24764. PsnName = res.Output.Baseinfo.PsnName
  24765. Gend = res.Output.Baseinfo.Gend
  24766. Naty = res.Output.Baseinfo.Naty
  24767. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24768. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24769. infoStr = string(Iinfos)
  24770. idetinfoStr = string(Idetinfos)
  24771. infocode = res.Infcode
  24772. } else if id_card_type == 4 {
  24773. psn_info, _ := service.GetPsnByPatientId(id)
  24774. PsnNo = psn_info.PsnNo
  24775. PsnCertType = psn_info.PsnCertType
  24776. Certno = psn_info.Certno
  24777. PsnName = psn_info.PsnName
  24778. Gend = psn_info.Gend
  24779. Naty = psn_info.Naty
  24780. Brdy = psn_info.Brdy
  24781. Age = psn_info.Age
  24782. infoStr = psn_info.Insuinfo
  24783. idetinfoStr = psn_info.Idetinfo
  24784. infocode = 0
  24785. verify_number = psn_info.VerifyNumber
  24786. }
  24787. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24788. var result string
  24789. var requestLog string
  24790. 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), "")
  24791. if id_card_type == 4 {
  24792. psn_info, _ := service.GetPsnByPatientId(id)
  24793. PsnNo = psn_info.PsnNo
  24794. PsnCertType = psn_info.PsnCertType
  24795. Certno = psn_info.Certno
  24796. PsnName = psn_info.PsnName
  24797. Gend = psn_info.Gend
  24798. Naty = psn_info.Naty
  24799. Brdy = psn_info.Brdy
  24800. Age = psn_info.Age
  24801. infoStr = psn_info.Insuinfo
  24802. idetinfoStr = psn_info.Idetinfo
  24803. infocode = 0
  24804. verify_number = psn_info.VerifyNumber
  24805. } else {
  24806. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24807. if miConfig.Code == "H15049901371" {
  24808. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24809. utils.ErrorLog("解析失败:%v", err)
  24810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24811. return
  24812. }
  24813. res.ErrMsg = res10265.ErrMsg
  24814. res.Output = res10265.Output
  24815. res.InfRefmsgid = res10265.InfRefmsgid
  24816. } else {
  24817. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24818. utils.ErrorLog("解析失败:%v", err)
  24819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24820. return
  24821. }
  24822. }
  24823. PsnNo = res.Output.Baseinfo.PsnNo
  24824. PsnCertType = res.Output.Baseinfo.PsnCertType
  24825. Certno = res.Output.Baseinfo.Certno
  24826. PsnName = res.Output.Baseinfo.PsnName
  24827. Gend = res.Output.Baseinfo.Gend
  24828. Naty = res.Output.Baseinfo.Naty
  24829. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24830. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24831. infoStr = string(Iinfos)
  24832. idetinfoStr = string(Idetinfos)
  24833. if miConfig.Code == "H15049901371" {
  24834. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24835. } else {
  24836. infocode = res.Infcode
  24837. }
  24838. }
  24839. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24840. psn_info, _ := service.GetPsnByPatientId(id)
  24841. PsnNo = psn_info.PsnNo
  24842. PsnCertType = psn_info.PsnCertType
  24843. Certno = psn_info.Certno
  24844. PsnName = psn_info.PsnName
  24845. Gend = psn_info.Gend
  24846. Naty = psn_info.Naty
  24847. Brdy = psn_info.Brdy
  24848. Age = psn_info.Age
  24849. infoStr = psn_info.Insuinfo
  24850. idetinfoStr = psn_info.Idetinfo
  24851. infocode = 0
  24852. verify_number = psn_info.VerifyNumber
  24853. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24854. psn_info, _ := service.GetPsnByPatientId(id)
  24855. PsnNo = psn_info.PsnNo
  24856. PsnCertType = psn_info.PsnCertType
  24857. Certno = psn_info.Certno
  24858. PsnName = psn_info.PsnName
  24859. Gend = psn_info.Gend
  24860. Naty = psn_info.Naty
  24861. Brdy = psn_info.Brdy
  24862. Age = psn_info.Age
  24863. infoStr = psn_info.Insuinfo
  24864. idetinfoStr = psn_info.Idetinfo
  24865. infocode = 0
  24866. verify_number = psn_info.VerifyNumber
  24867. } else {
  24868. var result string
  24869. var requestLog string
  24870. //if miConfig.UserOrgId == 10138 {
  24871. if id_card_type != 4 || id_card_type != 1 {
  24872. var insa string
  24873. if len(patient.InsuplcAdmdvs) > 0 {
  24874. insa = patient.InsuplcAdmdvs
  24875. } else {
  24876. insa = miConfig.InsuplcAdmdvs
  24877. }
  24878. //psn_info, _ := service.GetPsnByPatientId(id)
  24879. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24880. 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)
  24881. }
  24882. //}
  24883. //else {
  24884. // var insa string
  24885. // if len(patient.InsuplcAdmdvs) > 0 {
  24886. // insa = patient.InsuplcAdmdvs
  24887. // } else {
  24888. // insa = miConfig.InsuplcAdmdvs
  24889. // }
  24890. // 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)
  24891. //}
  24892. if id_card_type == 4 || id_card_type == 1 {
  24893. psn_info, _ := service.GetPsnByPatientId(id)
  24894. PsnNo = psn_info.PsnNo
  24895. PsnCertType = psn_info.PsnCertType
  24896. Certno = psn_info.Certno
  24897. PsnName = psn_info.PsnName
  24898. Gend = psn_info.Gend
  24899. Naty = psn_info.Naty
  24900. Brdy = psn_info.Brdy
  24901. Age = psn_info.Age
  24902. infoStr = psn_info.Insuinfo
  24903. idetinfoStr = psn_info.Idetinfo
  24904. infocode = 0
  24905. verify_number = psn_info.VerifyNumber
  24906. } else {
  24907. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24908. if miConfig.Code == "H15049901371" {
  24909. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24910. utils.ErrorLog("解析失败:%v", err)
  24911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24912. return
  24913. }
  24914. res.ErrMsg = res10265.ErrMsg
  24915. res.Output = res10265.Output
  24916. res.InfRefmsgid = res10265.InfRefmsgid
  24917. } else {
  24918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24919. utils.ErrorLog("解析失败:%v", err)
  24920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24921. return
  24922. }
  24923. }
  24924. PsnNo = res.Output.Baseinfo.PsnNo
  24925. PsnCertType = res.Output.Baseinfo.PsnCertType
  24926. Certno = res.Output.Baseinfo.Certno
  24927. PsnName = res.Output.Baseinfo.PsnName
  24928. Gend = res.Output.Baseinfo.Gend
  24929. Naty = res.Output.Baseinfo.Naty
  24930. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24931. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24932. infoStr = string(Iinfos)
  24933. idetinfoStr = string(Idetinfos)
  24934. if miConfig.Code == "H15049901371" {
  24935. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24936. } else {
  24937. infocode = res.Infcode
  24938. }
  24939. }
  24940. }
  24941. if infocode == 0 {
  24942. his := models.VMHisPatient{
  24943. Name: name,
  24944. Gender: gender,
  24945. Birthday: birthUnix,
  24946. MedicalTreatmentType: medical_care,
  24947. IdType: certificates,
  24948. IdCardNo: id_card,
  24949. BalanceAccountsType: settlementValue,
  24950. SocialType: social_type,
  24951. MedicalInsuranceNumber: medical_insurance_card,
  24952. RegisterType: register_type,
  24953. RegisterCost: registration_fee,
  24954. TreatmentCost: medical_expenses,
  24955. Status: 1,
  24956. Ctime: time.Now().Unix(),
  24957. Mtime: time.Now().Unix(),
  24958. PsnNo: PsnNo,
  24959. PsnCertType: PsnCertType,
  24960. Certno: Certno,
  24961. PsnName: PsnName,
  24962. Gend: Gend,
  24963. Naty: Naty,
  24964. Brdy: Brdy,
  24965. Age: Age,
  24966. Iinfo: infoStr,
  24967. Idetinfo: idetinfoStr,
  24968. PatientId: patient.ID,
  24969. RecordDate: theTime.Unix(),
  24970. UserOrgId: adminInfo.CurrentOrgId,
  24971. AdminUserId: admin_user_id,
  24972. IsReturn: 1,
  24973. IdCardType: id_card_type,
  24974. Doctor: doctor,
  24975. Departments: department,
  24976. MdtrtGrpType: mdtrt_type,
  24977. }
  24978. timestamp := time.Now().Unix()
  24979. tempTime := time.Unix(timestamp, 0)
  24980. timeFormat := tempTime.Format("20060102150405")
  24981. chrgBchno := rand.Intn(100000) + 10000
  24982. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24983. his.Number = ipt_otp_no
  24984. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24985. department, _ := service.GetDepartMentDetail(department)
  24986. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24987. IdCardNo := ""
  24988. if id_card_type == 1 {
  24989. // IdCardNo = medical_insurance_card
  24990. IdCardNo = patient.IdCardNo
  24991. } else {
  24992. IdCardNo = patient.IdCardNo
  24993. }
  24994. var rf []*ResultFive
  24995. json.Unmarshal([]byte(his.Iinfo), &rf)
  24996. var insutypes []*ResultFive
  24997. var insutype string
  24998. var insuplc_admdvs_temp string
  24999. var is390 int = 0
  25000. var is310 int = 0
  25001. for _, item := range rf {
  25002. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25003. insutypes = append(insutypes, item)
  25004. }
  25005. }
  25006. if len(insutypes) == 1 {
  25007. insutype = insutypes[0].Insutype
  25008. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25009. if insutype == "390" {
  25010. is390 = 1
  25011. }
  25012. if insutype == "310" {
  25013. is310 = 1
  25014. }
  25015. } else {
  25016. for _, i := range insutypes {
  25017. if i.Insutype == "390" {
  25018. is390 = 1
  25019. }
  25020. if i.Insutype == "310" {
  25021. is310 = 1
  25022. }
  25023. }
  25024. }
  25025. if is390 == 1 {
  25026. insutype = "390"
  25027. }
  25028. if is310 == 1 {
  25029. insutype = "310"
  25030. }
  25031. fmt.Println(social_type)
  25032. if social_type > 0 {
  25033. insutype = strconv.FormatInt(social_type, 10)
  25034. }
  25035. var infocode int64
  25036. var resThree ResultThree
  25037. var resThree10265 ResultThree10265
  25038. if len(insuplc_admdvs) == 0 {
  25039. psn_info, _ := service.GetPsnByPatientId(id)
  25040. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25041. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25042. //}
  25043. } else {
  25044. insuplc_admdvs_temp = insuplc_admdvs
  25045. }
  25046. if miConfig.MdtrtareaAdmvs == "421300" {
  25047. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25048. psn_info, _ := service.GetPsnByPatientId(id)
  25049. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25050. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25051. "&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
  25052. resp, requestErr := http.Get(api)
  25053. if requestErr != nil {
  25054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25055. return
  25056. }
  25057. body, ioErr := ioutil.ReadAll(resp.Body)
  25058. if ioErr != nil {
  25059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25061. return
  25062. }
  25063. var respJSON map[string]interface{}
  25064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25067. return
  25068. }
  25069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25070. result, _ := json.Marshal(respJSON)
  25071. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25072. utils.ErrorLog("解析失败:%v", err)
  25073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25074. return
  25075. }
  25076. infocode = resThree.Infcode
  25077. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25078. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25079. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25080. // insuplc_admdvs_temp =
  25081. //}
  25082. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25083. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25084. //}
  25085. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25086. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25087. "&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
  25088. resp, requestErr := http.Get(api)
  25089. if requestErr != nil {
  25090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25091. return
  25092. }
  25093. body, ioErr := ioutil.ReadAll(resp.Body)
  25094. if ioErr != nil {
  25095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25097. return
  25098. }
  25099. var respJSON map[string]interface{}
  25100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25103. return
  25104. }
  25105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25106. result, _ := json.Marshal(respJSON)
  25107. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25108. utils.ErrorLog("解析失败:%v", err)
  25109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25110. return
  25111. }
  25112. infocode = resThree.Infcode
  25113. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25114. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25115. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25116. // insuplc_admdvs_temp =
  25117. //}
  25118. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25119. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25120. //}
  25121. utils.ErrorLog("解析失败:%v", insutype)
  25122. utils.ErrorLog("解析失败:%v", PsnNo)
  25123. utils.ErrorLog("解析失败:%v", Certno)
  25124. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25125. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25126. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25127. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25128. utils.ErrorLog("解析失败:%v", PsnNo)
  25129. utils.ErrorLog("解析失败:%v", department.Number)
  25130. utils.ErrorLog("解析失败:%v", department.Name)
  25131. utils.ErrorLog("解析失败:%v", roles.UserName)
  25132. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25133. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25134. "&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
  25135. resp, requestErr := http.Get(api)
  25136. if requestErr != nil {
  25137. utils.ErrorLog("解析失败:%v", requestErr)
  25138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25139. return
  25140. }
  25141. body, ioErr := ioutil.ReadAll(resp.Body)
  25142. if ioErr != nil {
  25143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25145. return
  25146. }
  25147. var respJSON map[string]interface{}
  25148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25151. return
  25152. }
  25153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25154. result, _ := json.Marshal(respJSON)
  25155. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25156. utils.ErrorLog("解析失败:%v", err)
  25157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25158. return
  25159. }
  25160. infocode = resThree.Infcode
  25161. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25162. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25163. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25164. // insuplc_admdvs_temp =
  25165. //}
  25166. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25167. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25168. //}
  25169. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25170. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25171. "&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
  25172. resp, requestErr := http.Get(api)
  25173. if requestErr != nil {
  25174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25175. return
  25176. }
  25177. body, ioErr := ioutil.ReadAll(resp.Body)
  25178. if ioErr != nil {
  25179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25181. return
  25182. }
  25183. var respJSON map[string]interface{}
  25184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25187. return
  25188. }
  25189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25190. result, _ := json.Marshal(respJSON)
  25191. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25192. utils.ErrorLog("解析失败:%v", err)
  25193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25194. return
  25195. }
  25196. infocode = resThree.Infcode
  25197. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25198. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25199. psn_info, _ := service.GetPsnByPatientId(id)
  25200. var verify_number string
  25201. if id_card_type == 4 {
  25202. verify_number = psn_info.VerifyNumber
  25203. } else if id_card_type == 1 {
  25204. bas := strings.Split(psn_info.CardInfo, "|")
  25205. cardNumber := bas[2]
  25206. verify_number = cardNumber
  25207. }
  25208. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25209. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25210. "&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
  25211. resp, requestErr := http.Get(api)
  25212. if requestErr != nil {
  25213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25214. return
  25215. }
  25216. body, ioErr := ioutil.ReadAll(resp.Body)
  25217. if ioErr != nil {
  25218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25220. return
  25221. }
  25222. var respJSON map[string]interface{}
  25223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25226. return
  25227. }
  25228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25229. result, _ := json.Marshal(respJSON)
  25230. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25231. // utils.ErrorLog("解析失败:%v", err)
  25232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25233. // return
  25234. //}
  25235. //infocode = resThree.Infcode
  25236. //result, _ := json.Marshal(respJSON)
  25237. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25238. utils.ErrorLog("解析失败:%v", err)
  25239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25240. return
  25241. }
  25242. resThree.ErrMsg = resThree10265.ErrMsg
  25243. resThree.Output = resThree10265.Output
  25244. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25245. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25246. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25247. psn_info, _ := service.GetPsnByPatientId(id)
  25248. his.PsnNo = psn_info.PsnNo
  25249. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25250. var cert_no string
  25251. if id_card_type == 3 {
  25252. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25253. cert_no = IdCardNo
  25254. } else if id_card_type == 4 {
  25255. cert_no = IdCardNo
  25256. psn_info.VerifyNumber = psn_info.VerifyNumber
  25257. } else {
  25258. bas := strings.Split(psn_info.CardInfo, "|")
  25259. cert_no = bas[2]
  25260. }
  25261. var hisPrescription []*models.HisPrescription
  25262. fmt.Println(hisPrescription)
  25263. for _, item := range rf {
  25264. if item.Insutype == insutype {
  25265. //insuplc_admdvs = item.InsuplcAdmdvs
  25266. his.InsuplcAdmdvs = insuplc_admdvs
  25267. }
  25268. }
  25269. his.Insutype = insutype
  25270. var res3101 Result3101
  25271. res3101.Infcode = "0"
  25272. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25273. if res3101.Infcode == "0" {
  25274. fmt.Println("33333333")
  25275. if len(res3101.Output.Result) > 0 {
  25276. fmt.Println("222222")
  25277. for _, item := range res3101.Output.Result {
  25278. if len(res3101.ErrMsg) == 0 {
  25279. res3101.ErrMsg = item.VolaCont
  25280. } else {
  25281. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25282. }
  25283. }
  25284. c.ServeSuccessJSON(map[string]interface{}{
  25285. "failed_code": -10,
  25286. "msg": res3101.ErrMsg,
  25287. })
  25288. return
  25289. } else {
  25290. fmt.Println("11111")
  25291. var api string
  25292. if miConfig.MdtrtareaAdmvs == "320830" {
  25293. ipt_otp_no = timeFormat
  25294. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25295. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25296. "&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
  25297. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25298. ipt_otp_no = timeFormat
  25299. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25300. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25301. "&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
  25302. } else {
  25303. ipt_otp_no = timeFormat
  25304. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25305. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25306. "&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
  25307. }
  25308. resp, requestErr := http.Get(api)
  25309. if requestErr != nil {
  25310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25311. return
  25312. }
  25313. body, ioErr := ioutil.ReadAll(resp.Body)
  25314. if ioErr != nil {
  25315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25317. return
  25318. }
  25319. var respJSON map[string]interface{}
  25320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25323. return
  25324. }
  25325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25326. result, _ := json.Marshal(respJSON)
  25327. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25328. utils.ErrorLog("解析失败:%v", err)
  25329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25330. return
  25331. }
  25332. resThree.ErrMsg = resThree10265.ErrMsg
  25333. resThree.Output = resThree10265.Output
  25334. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25335. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25336. }
  25337. } else if res3101.Infcode != "0" {
  25338. c.ServeSuccessJSON(map[string]interface{}{
  25339. "failed_code": -10,
  25340. "msg": res3101.ErrMsg,
  25341. })
  25342. return
  25343. }
  25344. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25345. psn_info, _ := service.GetPsnByPatientId(id)
  25346. var cert_no string
  25347. if id_card_type == 1 {
  25348. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25349. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25350. } else if id_card_type == 4 {
  25351. cert_no = psn_info.VerifyNumber
  25352. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25353. } else {
  25354. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25355. cert_no = psn_info.VerifyNumber
  25356. }
  25357. 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)
  25358. saveLog(result, requestLog, "2201", "挂号")
  25359. if miConfig.Code == "H15049901371" {
  25360. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25361. utils.ErrorLog("解析失败:%v", err)
  25362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25363. return
  25364. }
  25365. resThree.ErrMsg = resThree10265.ErrMsg
  25366. resThree.Output = resThree10265.Output
  25367. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25368. } else {
  25369. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25370. utils.ErrorLog("解析失败:%v", err)
  25371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25372. return
  25373. }
  25374. }
  25375. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25376. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25377. psn_info, _ := service.GetPsnByPatientId(id)
  25378. var result string
  25379. var requestLog string
  25380. if id_card_type == 1 {
  25381. bas := strings.Split(psn_info.CardInfo, "|")
  25382. basNumber := bas[2]
  25383. card_sn := bas[3]
  25384. 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)
  25385. saveLog(result, requestLog, "2201A", "挂号")
  25386. } else if id_card_type == 2 {
  25387. 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, "", "", "", "", "", "")
  25388. saveLog(result, requestLog, "2201A", "挂号")
  25389. } else {
  25390. 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)
  25391. saveLog(result, requestLog, "2201A", "挂号")
  25392. }
  25393. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25394. utils.ErrorLog("解析失败:%v", err)
  25395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25396. return
  25397. }
  25398. infocode = resThree.Infcode
  25399. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25400. psn_info, _ := service.GetPsnByPatientId(id)
  25401. var result string
  25402. var requestLog string
  25403. if id_card_type == 1 {
  25404. bas := strings.Split(psn_info.CardInfo, "|")
  25405. basNumber := bas[2]
  25406. card_sn := ""
  25407. 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)
  25408. saveLog(result, requestLog, "2201A", "挂号")
  25409. } else if id_card_type == 2 {
  25410. 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, "", "", "", "", "", "")
  25411. saveLog(result, requestLog, "2201A", "挂号")
  25412. } else {
  25413. 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)
  25414. saveLog(result, requestLog, "2201A", "挂号")
  25415. }
  25416. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25417. utils.ErrorLog("解析失败:%v", err)
  25418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25419. return
  25420. }
  25421. infocode = resThree.Infcode
  25422. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25423. psn_info, _ := service.GetPsnByPatientId(id)
  25424. var result string
  25425. var requestLog string
  25426. if id_card_type == 1 {
  25427. bas := strings.Split(psn_info.CardInfo, "|")
  25428. basNumber := bas[2]
  25429. card_sn := ""
  25430. 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)
  25431. saveLog(result, requestLog, "2201A", "挂号")
  25432. } else if id_card_type == 2 {
  25433. 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, "", "", "", "", "", "")
  25434. saveLog(result, requestLog, "2201A", "挂号")
  25435. } else {
  25436. 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)
  25437. saveLog(result, requestLog, "2201A", "挂号")
  25438. }
  25439. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25440. utils.ErrorLog("解析失败:%v", err)
  25441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25442. return
  25443. }
  25444. infocode = resThree.Infcode
  25445. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25446. psn_info, _ := service.GetPsnByPatientId(id)
  25447. his.PsnNo = psn_info.PsnNo
  25448. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25449. var cert_no string
  25450. if id_card_type == 1 {
  25451. bas := strings.Split(psn_info.CardInfo, "|")
  25452. cert_no = bas[2]
  25453. } else if id_card_type == 4 {
  25454. cert_no = psn_info.VerifyNumber
  25455. psn_info.VerifyNumber = psn_info.VerifyNumber
  25456. IdCardNo = psn_info.VerifyNumber
  25457. } else {
  25458. cert_no = IdCardNo
  25459. psn_info.VerifyNumber = cert_no
  25460. }
  25461. for _, item := range rf {
  25462. if item.Insutype == insutype {
  25463. his.InsuplcAdmdvs = insuplc_admdvs
  25464. }
  25465. }
  25466. his.Insutype = insutype
  25467. var api string
  25468. ipt_otp_no = timeFormat
  25469. 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 +
  25470. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25471. "&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
  25472. resp, requestErr := http.Get(api)
  25473. if requestErr != nil {
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. body, ioErr := ioutil.ReadAll(resp.Body)
  25478. if ioErr != nil {
  25479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25481. return
  25482. }
  25483. var respJSON map[string]interface{}
  25484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25487. return
  25488. }
  25489. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25490. if status == "0" {
  25491. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25492. c.ServeSuccessJSON(map[string]interface{}{
  25493. "failed_code": -10,
  25494. "msg": err_msg,
  25495. })
  25496. return
  25497. }
  25498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25499. result, _ := json.Marshal(respJSON)
  25500. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25501. utils.ErrorLog("解析失败:%v", err)
  25502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25503. return
  25504. }
  25505. infocode = resThree.Infcode
  25506. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25507. psn_info, _ := service.GetPsnByPatientId(id)
  25508. his.PsnNo = psn_info.PsnNo
  25509. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25510. var cert_no string
  25511. if id_card_type == 1 {
  25512. bas := strings.Split(psn_info.CardInfo, "|")
  25513. cert_no = bas[2]
  25514. } else if id_card_type == 4 {
  25515. cert_no = psn_info.VerifyNumber
  25516. psn_info.VerifyNumber = psn_info.VerifyNumber
  25517. IdCardNo = psn_info.VerifyNumber
  25518. } else {
  25519. cert_no = IdCardNo
  25520. psn_info.VerifyNumber = cert_no
  25521. }
  25522. for _, item := range rf {
  25523. if item.Insutype == insutype {
  25524. his.InsuplcAdmdvs = insuplc_admdvs
  25525. patient.InsuplcAdmdvs = insuplc_admdvs
  25526. }
  25527. }
  25528. his.Insutype = insutype
  25529. var api string
  25530. ipt_otp_no = timeFormat
  25531. 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 +
  25532. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25533. "&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
  25534. resp, requestErr := http.Get(api)
  25535. if requestErr != nil {
  25536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25537. return
  25538. }
  25539. body, ioErr := ioutil.ReadAll(resp.Body)
  25540. if ioErr != nil {
  25541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25543. return
  25544. }
  25545. var respJSON map[string]interface{}
  25546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25549. return
  25550. }
  25551. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25552. if status == "0" {
  25553. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25554. c.ServeSuccessJSON(map[string]interface{}{
  25555. "failed_code": -10,
  25556. "msg": err_msg,
  25557. })
  25558. return
  25559. }
  25560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25561. result, _ := json.Marshal(respJSON)
  25562. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25563. utils.ErrorLog("解析失败:%v", err)
  25564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25565. return
  25566. }
  25567. infocode = resThree.Infcode
  25568. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25569. hour := time.Now().Format("15")
  25570. min := time.Now().Format("04")
  25571. sec := time.Now().Format("05")
  25572. begin := record_time + " " + hour + ":" + min + ":" + sec
  25573. psn_info, _ := service.GetPsnByPatientId(id)
  25574. var result string
  25575. var requestLog string
  25576. if id_card_type == 1 {
  25577. bas := strings.Split(psn_info.CardInfo, "|")
  25578. basNumber := bas[2]
  25579. card_sn := bas[3]
  25580. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, begin)
  25581. saveLog(result, requestLog, "2201A", "挂号")
  25582. } else if id_card_type == 2 {
  25583. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, psn_info.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "", begin)
  25584. saveLog(result, requestLog, "2201A", "挂号")
  25585. } else {
  25586. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "", begin)
  25587. saveLog(result, requestLog, "2201A", "挂号")
  25588. }
  25589. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25590. utils.ErrorLog("解析失败:%v", err)
  25591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25592. return
  25593. }
  25594. infocode = resThree.Infcode
  25595. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25596. psn_info, _ := service.GetPsnByPatientId(id)
  25597. 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)
  25598. saveLog(result, requestLog, "2201A", "挂号")
  25599. if miConfig.Code == "H15049901371" {
  25600. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25601. utils.ErrorLog("解析失败:%v", err)
  25602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25603. return
  25604. }
  25605. resThree.ErrMsg = resThree10265.ErrMsg
  25606. resThree.Output = resThree10265.Output
  25607. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25608. } else {
  25609. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25610. utils.ErrorLog("解析失败:%v", err)
  25611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25612. return
  25613. }
  25614. }
  25615. if miConfig.Code == "H15049901371" {
  25616. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25617. } else {
  25618. infocode = resThree.Infcode
  25619. }
  25620. } else {
  25621. psn_info, _ := service.GetPsnByPatientId(id)
  25622. if id_card_type == 4 || id_card_type == 1 {
  25623. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25624. }
  25625. var rf []*ResultFive
  25626. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25627. var insutypes []*ResultFive
  25628. var insutype string
  25629. var is390 int = 0
  25630. var is310 int = 0
  25631. for _, item := range rf {
  25632. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25633. insutypes = append(insutypes, item)
  25634. }
  25635. }
  25636. if len(insutypes) == 1 {
  25637. insutype = insutypes[0].Insutype
  25638. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25639. } else {
  25640. for _, i := range insutypes {
  25641. if i.Insutype == "390" {
  25642. is390 = 1
  25643. }
  25644. if i.Insutype == "310" {
  25645. is310 = 1
  25646. }
  25647. }
  25648. }
  25649. if is390 == 1 {
  25650. insutype = "390"
  25651. }
  25652. if is310 == 1 {
  25653. insutype = "310"
  25654. }
  25655. fmt.Println(len(insutypes))
  25656. if len(insutypes) == 0 {
  25657. for index, item := range rf {
  25658. if index == 0 {
  25659. insutype = item.Insutype
  25660. insuplc_admdvs = item.InsuplcAdmdvs
  25661. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25662. }
  25663. }
  25664. fmt.Println(insutype)
  25665. fmt.Println(insuplc_admdvs)
  25666. }
  25667. if social_type > 0 {
  25668. insutype = strconv.FormatInt(social_type, 10)
  25669. }
  25670. fmt.Println("--------")
  25671. fmt.Println(psn_info)
  25672. fmt.Println(psn_info.PsnNo)
  25673. for _, item := range rf {
  25674. if item.Insutype == insutype {
  25675. insutype = item.Insutype
  25676. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25677. }
  25678. }
  25679. if miConfig.MdtrtareaAdmvs == "441202" {
  25680. var hisPrescription []*models.HisPrescription
  25681. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25682. if res3101.Infcode == 0 {
  25683. fmt.Println("33333333")
  25684. if len(res3101.Output.Result) > 0 {
  25685. fmt.Println("222222")
  25686. for _, item := range res3101.Output.Result {
  25687. if len(res3101.ErrMsg) == 0 {
  25688. res3101.ErrMsg = item.VolaCont
  25689. } else {
  25690. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25691. }
  25692. }
  25693. c.ServeSuccessJSON(map[string]interface{}{
  25694. "failed_code": -10,
  25695. "msg": res3101.ErrMsg,
  25696. })
  25697. return
  25698. } else {
  25699. hour := time.Now().Format("15")
  25700. min := time.Now().Format("04")
  25701. sec := time.Now().Format("05")
  25702. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25703. fmt.Println(record_time_two)
  25704. 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)
  25705. saveLog(result, requestLog, "2201A", "挂号")
  25706. if miConfig.Code == "H15049901371" {
  25707. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25708. utils.ErrorLog("解析失败:%v", err)
  25709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25710. return
  25711. }
  25712. resThree.ErrMsg = resThree10265.ErrMsg
  25713. resThree.Output = resThree10265.Output
  25714. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25715. } else {
  25716. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25717. utils.ErrorLog("解析失败:%v", err)
  25718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25719. return
  25720. }
  25721. }
  25722. if miConfig.Code == "H15049901371" {
  25723. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25724. } else {
  25725. infocode = resThree.Infcode
  25726. }
  25727. }
  25728. } else if res3101.Infcode != 0 {
  25729. c.ServeSuccessJSON(map[string]interface{}{
  25730. "failed_code": -10,
  25731. "msg": res3101.ErrMsg,
  25732. })
  25733. return
  25734. }
  25735. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25736. var hisPrescription []*models.HisPrescription
  25737. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25738. if res3101.Infcode == 0 {
  25739. fmt.Println("33333333")
  25740. if len(res3101.Output.Result) > 0 {
  25741. fmt.Println("222222")
  25742. for _, item := range res3101.Output.Result {
  25743. if len(res3101.ErrMsg) == 0 {
  25744. res3101.ErrMsg = item.VolaCont
  25745. } else {
  25746. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25747. }
  25748. }
  25749. c.ServeSuccessJSON(map[string]interface{}{
  25750. "failed_code": -10,
  25751. "msg": res3101.ErrMsg,
  25752. })
  25753. return
  25754. } else {
  25755. hour := time.Now().Format("15")
  25756. min := time.Now().Format("04")
  25757. sec := time.Now().Format("05")
  25758. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25759. fmt.Println(record_time_two)
  25760. 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)
  25761. saveLog(result, requestLog, "2201A", "挂号")
  25762. if miConfig.Code == "H15049901371" {
  25763. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25764. utils.ErrorLog("解析失败:%v", err)
  25765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25766. return
  25767. }
  25768. resThree.ErrMsg = resThree10265.ErrMsg
  25769. resThree.Output = resThree10265.Output
  25770. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25771. } else {
  25772. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25773. utils.ErrorLog("解析失败:%v", err)
  25774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25775. return
  25776. }
  25777. }
  25778. if miConfig.Code == "H15049901371" {
  25779. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25780. } else {
  25781. infocode = resThree.Infcode
  25782. }
  25783. }
  25784. } else if res3101.Infcode != 0 {
  25785. c.ServeSuccessJSON(map[string]interface{}{
  25786. "failed_code": -10,
  25787. "msg": res3101.ErrMsg,
  25788. })
  25789. return
  25790. }
  25791. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25792. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25793. psn_info, _ := service.GetPsnByPatientId(id)
  25794. var verify_number string
  25795. if id_card_type == 4 {
  25796. verify_number = psn_info.VerifyNumber
  25797. } else if id_card_type == 1 {
  25798. bas := strings.Split(psn_info.CardInfo, "|")
  25799. cardNumber := bas[2]
  25800. verify_number = cardNumber
  25801. } else {
  25802. verify_number = psn_info.Certno
  25803. }
  25804. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25805. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25806. "&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
  25807. resp, requestErr := http.Get(api)
  25808. if requestErr != nil {
  25809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25810. return
  25811. }
  25812. body, ioErr := ioutil.ReadAll(resp.Body)
  25813. if ioErr != nil {
  25814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25816. return
  25817. }
  25818. var respJSON map[string]interface{}
  25819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25822. return
  25823. }
  25824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25825. result, _ := json.Marshal(respJSON)
  25826. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25827. utils.ErrorLog("解析失败:%v", err)
  25828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25829. return
  25830. }
  25831. infocode = resThree.Infcode
  25832. } else {
  25833. hour := time.Now().Format("15")
  25834. min := time.Now().Format("04")
  25835. sec := time.Now().Format("05")
  25836. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25837. if id_card_type == 1 {
  25838. for _, item := range rf {
  25839. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25840. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25841. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25842. } else if strconv.FormatInt(social_type, 10) == "390" {
  25843. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25844. } else {
  25845. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25846. }
  25847. }
  25848. }
  25849. }
  25850. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25851. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25852. }
  25853. if id_card_type == 1 {
  25854. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25855. bas := strings.Split(psn_info.CardInfo, "|")
  25856. basNumber := bas[1]
  25857. IdCardNo = basNumber
  25858. }
  25859. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25860. IdCardNo = psn_info.VerifyNumber
  25861. }
  25862. if len(insuplc_admdvs_temp) == 0 {
  25863. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25864. }
  25865. var result string
  25866. var requestLog string
  25867. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  25868. var hisPrescription []*models.HisPrescription
  25869. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25870. if res3101.Infcode == 0 {
  25871. if len(res3101.Output.Result) > 0 {
  25872. if len(res3101.Output.Result) > 0 {
  25873. c.ServeSuccessJSON(map[string]interface{}{
  25874. "failed_code": -10,
  25875. "failed_type": 100,
  25876. "warm_type": 1,
  25877. "msg": res3101,
  25878. })
  25879. return
  25880. } else {
  25881. c.ServeSuccessJSON(map[string]interface{}{
  25882. "failed_code": -10,
  25883. "msg": res3101.ErrMsg,
  25884. })
  25885. return
  25886. }
  25887. } else {
  25888. hour := time.Now().Format("15")
  25889. min := time.Now().Format("04")
  25890. sec := time.Now().Format("05")
  25891. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25892. fmt.Println(record_time_two)
  25893. if his.IdCardType == 2 {
  25894. IdCardNo = psn_info.Certno
  25895. psn_info.VerifyNumber = psn_info.Certno
  25896. } else if his.IdCardType == 4 {
  25897. IdCardNo = psn_info.Certno
  25898. } else {
  25899. bas := strings.Split(psn_info.CardInfo, "|")
  25900. IdCardNo = bas[2]
  25901. }
  25902. aaaa = insutype
  25903. 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)
  25904. saveLog(result, requestLog, "2201A", "挂号")
  25905. if miConfig.Code == "H15049901371" {
  25906. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25907. utils.ErrorLog("解析失败:%v", err)
  25908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25909. return
  25910. }
  25911. resThree.ErrMsg = resThree10265.ErrMsg
  25912. resThree.Output = resThree10265.Output
  25913. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25914. } else {
  25915. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25916. utils.ErrorLog("解析失败:%v", err)
  25917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25918. return
  25919. }
  25920. }
  25921. if miConfig.Code == "H15049901371" {
  25922. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25923. } else {
  25924. infocode = resThree.Infcode
  25925. }
  25926. }
  25927. } else if res3101.Infcode != 0 {
  25928. c.ServeSuccessJSON(map[string]interface{}{
  25929. "failed_code": -10,
  25930. "msg": res3101.ErrMsg,
  25931. })
  25932. return
  25933. }
  25934. } else {
  25935. psn_info, _ := service.GetPsnByPatientId(id)
  25936. var rf []*ResultFive
  25937. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25938. //var insutypes []*ResultFive
  25939. var insutype string
  25940. var insutypes []*ResultFive
  25941. var is390 int = 0
  25942. var is310 int = 0
  25943. for _, item := range rf {
  25944. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25945. insutypes = append(insutypes, item)
  25946. }
  25947. }
  25948. if len(insutypes) == 1 {
  25949. insutype = insutypes[0].Insutype
  25950. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25951. } else {
  25952. for _, i := range insutypes {
  25953. if i.Insutype == "390" {
  25954. is390 = 1
  25955. }
  25956. if i.Insutype == "310" {
  25957. is310 = 1
  25958. }
  25959. }
  25960. }
  25961. if is390 == 1 {
  25962. insutype = "390"
  25963. }
  25964. if is310 == 1 {
  25965. insutype = "310"
  25966. }
  25967. if len(insutypes) == 0 {
  25968. insutype = "310"
  25969. }
  25970. if social_type > 0 {
  25971. insutype = strconv.FormatInt(social_type, 10)
  25972. }
  25973. for _, item := range rf {
  25974. if item.Insutype == insutype {
  25975. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25976. }
  25977. }
  25978. if len(insuplc_admdvs_tt) > 0 {
  25979. insuplc_admdvs_temp = insuplc_admdvs_tt
  25980. }
  25981. 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)
  25982. saveLog(result, requestLog, "2201A", "挂号")
  25983. }
  25984. if miConfig.Code == "H15049901371" {
  25985. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25986. utils.ErrorLog("解析失败:%v", err)
  25987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25988. return
  25989. }
  25990. resThree.ErrMsg = resThree10265.ErrMsg
  25991. resThree.Output = resThree10265.Output
  25992. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25993. } else {
  25994. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25995. utils.ErrorLog("解析失败:%v", err)
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. }
  26000. if miConfig.Code == "H15049901371" {
  26001. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26002. } else {
  26003. infocode = resThree.Infcode
  26004. }
  26005. }
  26006. }
  26007. if infocode == -1 {
  26008. adminUser := c.GetAdminUserInfo()
  26009. errlog := &models.HisOrderError{
  26010. UserOrgId: adminUser.CurrentOrgId,
  26011. Ctime: time.Now().Unix(),
  26012. Mtime: time.Now().Unix(),
  26013. ErrMsg: resThree.ErrMsg,
  26014. Status: 1,
  26015. PatientId: id,
  26016. RecordTime: recordDateTime,
  26017. Stage: 2,
  26018. }
  26019. service.CreateErrMsgLog(errlog)
  26020. c.ServeSuccessJSON(map[string]interface{}{
  26021. "failed_code": -10,
  26022. "msg": resThree.ErrMsg,
  26023. })
  26024. return
  26025. }
  26026. utils.ErrorLog("解析失败:%v", insutype)
  26027. his.Number = resThree.Output.Data.MdtrtID
  26028. his.PsnNo = resThree.Output.Data.PsnNo
  26029. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26030. his.IdCardNo = patient.IdCardNo
  26031. his.PhoneNumber = patient.Phone
  26032. his.UserOrgId = adminInfo.CurrentOrgId
  26033. his.Insutype = insutype
  26034. if miConfig.Code == "H44030500255" {
  26035. his.Insutype = aaaa
  26036. }
  26037. his.Ctime = time.Now().Unix()
  26038. his.Mtime = time.Now().Unix()
  26039. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26040. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26041. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26042. }
  26043. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26044. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26045. }
  26046. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26047. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26048. }
  26049. his.Status = 1
  26050. his.MdtrtGrpType = mdtrt_type
  26051. service.UpdateHisPatientStatus(&his)
  26052. service.UpdateHisPatient123(&patient)
  26053. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26054. c.ServeSuccessJSON(map[string]interface{}{
  26055. "his_info": his,
  26056. })
  26057. } else {
  26058. adminUser := c.GetAdminUserInfo()
  26059. errlog := &models.HisOrderError{
  26060. UserOrgId: adminUser.CurrentOrgId,
  26061. Ctime: time.Now().Unix(),
  26062. Mtime: time.Now().Unix(),
  26063. ErrMsg: res.ErrMsg,
  26064. Status: 1,
  26065. PatientId: id,
  26066. RecordTime: recordDateTime,
  26067. Stage: 1,
  26068. }
  26069. service.CreateErrMsgLog(errlog)
  26070. c.ServeSuccessJSON(map[string]interface{}{
  26071. "failed_code": -10,
  26072. "msg": res.ErrMsg,
  26073. })
  26074. return
  26075. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26076. }
  26077. }
  26078. }
  26079. func (c *HisApiController) GetUploadInfo() {
  26080. id, _ := c.GetInt64("id")
  26081. record_time := c.GetString("record_time")
  26082. his_patient_id, _ := c.GetInt64("his_patient_id")
  26083. order_id, _ := c.GetInt64("order_id")
  26084. pay_way, _ := c.GetInt64("pay_way")
  26085. pay_ways := c.GetString("pay_ways")
  26086. oth_desc := c.GetString("oth_desc")
  26087. pay_price, _ := c.GetFloat("pay_price")
  26088. pay_card_no := c.GetString("pay_card_no")
  26089. discount_price, _ := c.GetFloat("discount_price")
  26090. preferential_price, _ := c.GetFloat("preferential_price")
  26091. reality_price, _ := c.GetFloat("reality_price")
  26092. found_price, _ := c.GetFloat("found_price")
  26093. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26094. private_price, _ := c.GetFloat("private_price")
  26095. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26096. admin_user_id, _ := c.GetInt64("admin_user_id")
  26097. fapiao_code := c.GetString("fapiao_code")
  26098. fapiao_number := c.GetString("fapiao_number")
  26099. diagnosis_id := c.GetString("diagnosis")
  26100. sick_type, _ := c.GetInt64("sick_type")
  26101. reg_type, _ := c.GetInt64("p_type")
  26102. begin_time := c.GetString("begin_time")
  26103. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26104. cash_pay := c.GetString("cash_pay")
  26105. band_card_pay := c.GetString("band_card_pay")
  26106. wechat_pay := c.GetString("wechat_pay")
  26107. ali_pay := c.GetString("ali_pay")
  26108. jifen_pay := c.GetString("jifen_pay")
  26109. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26110. fmt.Println(acct_used_flag)
  26111. id_str := c.GetString("ids")
  26112. ids_arr := strings.Split(id_str, ",")
  26113. timeLayout := "2006-01-02"
  26114. loc, _ := time.LoadLocation("Local")
  26115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26116. if err != nil {
  26117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26118. return
  26119. }
  26120. recordDateTime := theTime.Unix()
  26121. adminUser := c.GetAdminUserInfo()
  26122. var tempOrder models.HisOrder
  26123. tempOrder, _ = service.GetHisOrderByID(order_id)
  26124. var prescriptions []*models.HisPrescription
  26125. var start_time int64
  26126. var end_time int64
  26127. //押金模块
  26128. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26129. tmp_decimal := c.GetString("tmp_decimal")
  26130. var decimal float64 //本次使用的押金
  26131. var errmsg error
  26132. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26133. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26134. return
  26135. }
  26136. if len(tmp_decimal) > 0 {
  26137. if tmp_decimal[0] == 45 {
  26138. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26139. return
  26140. }
  26141. }
  26142. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26143. fmt.Println(errs)
  26144. decimal = tt
  26145. //if adminUser.CurrentOrgId == 10106{
  26146. // if len(fapiao_code) == 0{
  26147. // fapiao_code = "144072080589"
  26148. // }
  26149. // if len(fapiao_number) == 0{
  26150. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26151. // if order.ID == 0{
  26152. // fapiao_number = "00001520"
  26153. // }else{
  26154. // //fapiao_code = "00001520"
  26155. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26156. // var zero string
  26157. // if fpNumber >= 1000{
  26158. // zero = "0000" + strconv.Itoa(fpNumber)
  26159. // }else if fpNumber >= 10000{
  26160. // zero = "000" + strconv.Itoa(fpNumber)
  26161. // } else if fpNumber >= 100000{
  26162. // zero = "00" + strconv.Itoa(fpNumber)
  26163. // } else if fpNumber >= 1000000{
  26164. // zero = "0" + strconv.Itoa(fpNumber)
  26165. // }else {
  26166. // zero = strconv.Itoa(fpNumber)
  26167. // }
  26168. // fapiao_number = zero
  26169. // }
  26170. // }
  26171. //}
  26172. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26173. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26174. var patientPrescription models.HisPrescriptionInfo
  26175. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26176. if patientPrescription.ID == 0 {
  26177. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26178. }
  26179. //if patientPrescription.Do
  26180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26181. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26182. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26183. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26184. var config []*models.HisXtDiagnoseConfig
  26185. for _, item := range diagnosis_ids {
  26186. id, _ := strconv.ParseInt(item, 10, 64)
  26187. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26188. config = append(config, &diagnosisConfig)
  26189. }
  26190. sickConfig, _ := service.FindSickById(sick_type)
  26191. //if tempOrder.ID == 0 {
  26192. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26193. //}
  26194. if tempOrder.ID == 0 {
  26195. var result string
  26196. var requestLog string
  26197. var res2 ResultSix
  26198. var res3 GZResultSix
  26199. var ressix10265 ResultSix10265
  26200. if miConfig.MdtrtareaAdmvs == "421300" {
  26201. data := make(map[string]interface{})
  26202. client := &http.Client{}
  26203. data["psn_no"] = his.PsnNo
  26204. data["mdtrt_id"] = his.Number
  26205. data["opter"] = roles.UserName
  26206. data["org_name"] = miConfig.OrgName
  26207. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26208. data["doctor_id"] = doctor_info.DoctorNumber
  26209. data["doctor_name"] = doctor_info.UserName
  26210. data["department"] = department.Name
  26211. data["fixmedins_code"] = miConfig.Code
  26212. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26213. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26214. data["secret_key"] = miConfig.SecretKey
  26215. data["sick_code"] = sickConfig.CountryCode
  26216. data["sick_name"] = sickConfig.ClassName
  26217. data["dept"] = strconv.FormatInt(department.ID, 10)
  26218. data["config"] = config
  26219. data["begin_time"] = begin_time
  26220. bytesData, _ := json.Marshal(data)
  26221. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26222. resp, _ := client.Do(req)
  26223. defer resp.Body.Close()
  26224. body, ioErr := ioutil.ReadAll(resp.Body)
  26225. if ioErr != nil {
  26226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26228. return
  26229. }
  26230. var respJSON map[string]interface{}
  26231. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26234. return
  26235. }
  26236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26237. userJSONBytes, _ := json.Marshal(respJSON)
  26238. fmt.Println("log")
  26239. fmt.Println(string(userJSONBytes))
  26240. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26241. utils.ErrorLog("解析失败:%v", err)
  26242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26243. return
  26244. }
  26245. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26246. data := make(map[string]interface{})
  26247. client := &http.Client{}
  26248. data["psn_no"] = his.PsnNo
  26249. data["mdtrt_id"] = his.Number
  26250. data["opter"] = roles.UserName
  26251. data["org_name"] = miConfig.OrgName
  26252. if reg_type == 11 && his.Insutype == "390" {
  26253. data["med_type"] = "110104"
  26254. } else {
  26255. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26256. }
  26257. data["doctor_id"] = doctor_info.DoctorNumber
  26258. data["doctor_name"] = doctor_info.UserName
  26259. data["department"] = department.Name
  26260. data["fixmedins_code"] = miConfig.Code
  26261. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26262. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26263. data["secret_key"] = miConfig.SecretKey
  26264. data["sick_code"] = sickConfig.CountryCode
  26265. data["sick_name"] = sickConfig.ClassName
  26266. data["dept"] = strconv.FormatInt(department.ID, 10)
  26267. data["config"] = config
  26268. data["begin_time"] = begin_time
  26269. bytesData, _ := json.Marshal(data)
  26270. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26271. resp, _ := client.Do(req)
  26272. defer resp.Body.Close()
  26273. body, ioErr := ioutil.ReadAll(resp.Body)
  26274. if ioErr != nil {
  26275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26277. return
  26278. }
  26279. var respJSON map[string]interface{}
  26280. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26283. return
  26284. }
  26285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26286. userJSONBytes, _ := json.Marshal(respJSON)
  26287. fmt.Println("log")
  26288. fmt.Println(string(userJSONBytes))
  26289. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26290. utils.ErrorLog("解析失败:%v", err)
  26291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26292. return
  26293. }
  26294. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26295. data := make(map[string]interface{})
  26296. client := &http.Client{}
  26297. data["psn_no"] = his.PsnNo
  26298. data["mdtrt_id"] = his.Number
  26299. data["opter"] = roles.UserName
  26300. data["org_name"] = miConfig.OrgName
  26301. if reg_type == 11 && his.Insutype == "390" {
  26302. data["med_type"] = "110104"
  26303. } else {
  26304. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26305. }
  26306. data["doctor_id"] = doctor_info.DoctorNumber
  26307. data["doctor_name"] = doctor_info.UserName
  26308. data["department"] = department.Name
  26309. data["fixmedins_code"] = miConfig.Code
  26310. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26311. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26312. data["secret_key"] = miConfig.SecretKey
  26313. data["sick_code"] = sickConfig.CountryCode
  26314. data["sick_name"] = sickConfig.ClassName
  26315. data["dept"] = strconv.FormatInt(department.ID, 10)
  26316. data["config"] = config
  26317. data["begin_time"] = begin_time
  26318. bytesData, _ := json.Marshal(data)
  26319. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26320. resp, _ := client.Do(req)
  26321. defer resp.Body.Close()
  26322. body, ioErr := ioutil.ReadAll(resp.Body)
  26323. if ioErr != nil {
  26324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26326. return
  26327. }
  26328. var respJSON map[string]interface{}
  26329. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26332. return
  26333. }
  26334. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26335. userJSONBytes, _ := json.Marshal(respJSON)
  26336. fmt.Println("log")
  26337. fmt.Println(string(userJSONBytes))
  26338. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26339. utils.ErrorLog("解析失败:%v", err)
  26340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26341. return
  26342. }
  26343. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26344. data := make(map[string]interface{})
  26345. client := &http.Client{}
  26346. data["psn_no"] = his.PsnNo
  26347. data["mdtrt_id"] = his.Number
  26348. data["opter"] = roles.UserName
  26349. data["org_name"] = miConfig.OrgName
  26350. if reg_type == 11 && his.Insutype == "390" {
  26351. data["med_type"] = "110104"
  26352. } else {
  26353. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26354. }
  26355. data["doctor_id"] = doctor_info.DoctorNumber
  26356. data["doctor_name"] = doctor_info.UserName
  26357. data["department"] = department.Name
  26358. data["fixmedins_code"] = miConfig.Code
  26359. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26360. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26361. data["secret_key"] = miConfig.SecretKey
  26362. data["sick_code"] = sickConfig.CountryCode
  26363. data["sick_name"] = sickConfig.ClassName
  26364. data["dept"] = strconv.FormatInt(department.ID, 10)
  26365. data["config"] = config
  26366. data["begin_time"] = begin_time
  26367. bytesData, _ := json.Marshal(data)
  26368. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26369. resp, _ := client.Do(req)
  26370. defer resp.Body.Close()
  26371. body, ioErr := ioutil.ReadAll(resp.Body)
  26372. if ioErr != nil {
  26373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26375. return
  26376. }
  26377. var respJSON map[string]interface{}
  26378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26381. return
  26382. }
  26383. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26384. userJSONBytes, _ := json.Marshal(respJSON)
  26385. fmt.Println("log")
  26386. fmt.Println(string(userJSONBytes))
  26387. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26388. utils.ErrorLog("解析失败:%v", err)
  26389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26390. return
  26391. }
  26392. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26393. data := make(map[string]interface{})
  26394. client := &http.Client{}
  26395. data["psn_no"] = his.PsnNo
  26396. data["mdtrt_id"] = his.Number
  26397. data["doctor"] = roles.UserName
  26398. data["department"] = department.Name
  26399. data["org_name"] = miConfig.OrgName
  26400. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26401. data["doctor_id"] = doctor_info.DoctorNumber
  26402. data["new_doctor_name"] = doctor_info.UserName
  26403. data["fixmedins_code"] = miConfig.Code
  26404. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26405. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26406. data["secret_key"] = miConfig.SecretKey
  26407. data["sick_code"] = sickConfig.CountryCode
  26408. data["sick_name"] = sickConfig.ClassName
  26409. data["url"] = miConfig.Url
  26410. data["ak"] = miConfig.AccessKey
  26411. data["begin_time"] = begin_time
  26412. data["cainfo"] = miConfig.Cainfo
  26413. data["dept"] = strconv.FormatInt(department.ID, 10)
  26414. data["config"] = config
  26415. bytesData, _ := json.Marshal(data)
  26416. var req *http.Request
  26417. if miConfig.MdtrtareaAdmvs == "320830" {
  26418. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26419. //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 +
  26420. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26421. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26422. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26423. //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 +
  26424. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26425. } else {
  26426. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26427. }
  26428. resp, _ := client.Do(req)
  26429. defer resp.Body.Close()
  26430. body, ioErr := ioutil.ReadAll(resp.Body)
  26431. if ioErr != nil {
  26432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26434. return
  26435. }
  26436. var respJSON map[string]interface{}
  26437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26440. return
  26441. }
  26442. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26443. userJSONBytes, _ := json.Marshal(respJSON)
  26444. fmt.Println("log")
  26445. fmt.Println(string(userJSONBytes))
  26446. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26447. utils.ErrorLog("解析失败:%v", err)
  26448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26449. return
  26450. }
  26451. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26452. res2.Output = ressix10265.Output
  26453. res2.ErrMsg = ressix10265.ErrMsg
  26454. res2.Cainfo = ressix10265.Cainfo
  26455. res2.WarnMsg = ressix10265.WarnMsg
  26456. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26457. res2.Infcode = infocode
  26458. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26459. data := make(map[string]interface{})
  26460. client := &http.Client{}
  26461. data["psn_no"] = his.PsnNo
  26462. data["mdtrt_id"] = his.Number
  26463. data["doctor"] = roles.UserName
  26464. data["department"] = department.Name
  26465. data["org_name"] = miConfig.OrgName
  26466. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26467. data["doctor_id"] = doctor_info.DoctorNumber
  26468. data["new_doctor_name"] = doctor_info.UserName
  26469. data["fixmedins_code"] = miConfig.Code
  26470. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26471. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26472. data["secret_key"] = miConfig.SecretKey
  26473. data["sick_code"] = sickConfig.CountryCode
  26474. data["sick_name"] = sickConfig.ClassName
  26475. data["url"] = miConfig.Url
  26476. data["ak"] = miConfig.AccessKey
  26477. data["begin_time"] = begin_time
  26478. data["cainfo"] = miConfig.Cainfo
  26479. data["dept"] = strconv.FormatInt(department.ID, 10)
  26480. data["config"] = config
  26481. bytesData, _ := json.Marshal(data)
  26482. var req *http.Request
  26483. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26484. resp, _ := client.Do(req)
  26485. defer resp.Body.Close()
  26486. body, ioErr := ioutil.ReadAll(resp.Body)
  26487. if ioErr != nil {
  26488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26490. return
  26491. }
  26492. var respJSON map[string]interface{}
  26493. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26496. return
  26497. }
  26498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26499. userJSONBytes, _ := json.Marshal(respJSON)
  26500. fmt.Println("log")
  26501. fmt.Println(string(userJSONBytes))
  26502. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26503. utils.ErrorLog("解析失败:%v", err)
  26504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26505. return
  26506. }
  26507. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26508. res2.Output = ressix10265.Output
  26509. res2.ErrMsg = ressix10265.ErrMsg
  26510. res2.Cainfo = ressix10265.Cainfo
  26511. res2.WarnMsg = ressix10265.WarnMsg
  26512. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26513. res2.Infcode = infocode
  26514. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26515. 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)
  26516. saveLog(result, requestLog, "2203", "上传就诊信息")
  26517. var respJSON2 map[string]interface{}
  26518. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26521. return
  26522. }
  26523. userJSONBytes2, _ := json.Marshal(respJSON2)
  26524. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26525. utils.ErrorLog("解析失败:%v", err)
  26526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26527. return
  26528. }
  26529. 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)
  26530. fmt.Println(result2)
  26531. fmt.Println(src_request)
  26532. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26533. data := make(map[string]interface{})
  26534. client := &http.Client{}
  26535. data["psn_no"] = his.PsnNo
  26536. data["mdtrt_id"] = his.Number
  26537. data["doctor"] = roles.UserName
  26538. data["department"] = department.Name
  26539. data["org_name"] = miConfig.OrgName
  26540. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26541. data["doctor_id"] = doctor_info.DoctorNumber
  26542. data["new_doctor_name"] = doctor_info.UserName
  26543. data["fixmedins_code"] = miConfig.Code
  26544. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26545. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26546. data["secret_key"] = miConfig.SecretKey
  26547. data["sick_code"] = sickConfig.CountryCode
  26548. data["sick_name"] = sickConfig.ClassName
  26549. data["url"] = miConfig.Url
  26550. data["ak"] = miConfig.AccessKey
  26551. data["begin_time"] = begin_time
  26552. data["cainfo"] = miConfig.Cainfo
  26553. data["dept"] = strconv.FormatInt(department.ID, 10)
  26554. data["config"] = config
  26555. bytesData, _ := json.Marshal(data)
  26556. var req *http.Request
  26557. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26558. resp, _ := client.Do(req)
  26559. defer resp.Body.Close()
  26560. body, ioErr := ioutil.ReadAll(resp.Body)
  26561. if ioErr != nil {
  26562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26564. return
  26565. }
  26566. var respJSON map[string]interface{}
  26567. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26570. return
  26571. }
  26572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26573. userJSONBytes, _ := json.Marshal(respJSON)
  26574. fmt.Println("log")
  26575. fmt.Println(string(userJSONBytes))
  26576. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26577. utils.ErrorLog("解析失败:%v", err)
  26578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26579. return
  26580. }
  26581. } else {
  26582. if miConfig.MdtrtareaAdmvs == "440781" { //
  26583. 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)
  26584. } else {
  26585. if miConfig.Code == "H15049901371" {
  26586. //赤峰地区国家医保医疗类别
  26587. //职工透析:医疗类别选特殊情况门诊990502
  26588. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26589. var med_type string
  26590. if his.Insutype == "390" {
  26591. if reg_type == 14 {
  26592. med_type = "9933"
  26593. } else if reg_type == 11 {
  26594. med_type = "11"
  26595. }
  26596. } else if his.Insutype == "310" {
  26597. if reg_type == 14 {
  26598. med_type = "990502"
  26599. } else if reg_type == 11 {
  26600. med_type = "11"
  26601. }
  26602. }
  26603. 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)
  26604. } else {
  26605. 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)
  26606. }
  26607. }
  26608. saveLog(result, requestLog, "2203", "上传就诊信息")
  26609. var respJSON2 map[string]interface{}
  26610. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26613. return
  26614. }
  26615. userJSONBytes2, _ := json.Marshal(respJSON2)
  26616. if miConfig.Code == "H15049901371" {
  26617. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26618. utils.ErrorLog("解析失败:%v", err)
  26619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26620. return
  26621. }
  26622. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26623. res2.Output = ressix10265.Output
  26624. res2.ErrMsg = ressix10265.ErrMsg
  26625. res2.Cainfo = ressix10265.Cainfo
  26626. res2.WarnMsg = ressix10265.WarnMsg
  26627. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26628. res2.Infcode = infocode
  26629. } else {
  26630. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26631. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26632. utils.ErrorLog("解析失败:%v", err)
  26633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26634. return
  26635. }
  26636. res2.Infcode = res3.Infcode
  26637. } else {
  26638. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26639. utils.ErrorLog("解析失败:%v", err)
  26640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26641. return
  26642. }
  26643. }
  26644. }
  26645. }
  26646. if res2.Infcode == -1 {
  26647. adminUser := c.GetAdminUserInfo()
  26648. errlog := &models.HisOrderError{
  26649. UserOrgId: adminUser.CurrentOrgId,
  26650. Ctime: time.Now().Unix(),
  26651. Mtime: time.Now().Unix(),
  26652. ErrMsg: res2.ErrMsg,
  26653. Status: 1,
  26654. PatientId: id,
  26655. RecordTime: recordDateTime,
  26656. Stage: 3,
  26657. }
  26658. service.CreateErrMsgLog(errlog)
  26659. c.ServeSuccessJSON(map[string]interface{}{
  26660. "failed_code": -10,
  26661. "msg": res2.ErrMsg,
  26662. })
  26663. return
  26664. } else {
  26665. his.Diagnosis = diagnosis_id
  26666. his.SickType = sickConfig.ID
  26667. //var p_type int64
  26668. //if reg_type == 1111 || reg_type == 1112 {
  26669. // p_type = 11
  26670. //
  26671. //}
  26672. his.PType = fmt.Sprintf("%d", reg_type)
  26673. service.UpdateHisPatientThree(&his)
  26674. data := make(map[string]interface{})
  26675. if settle_accounts_type == 1 { //日结
  26676. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26677. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26678. } else {
  26679. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26680. }
  26681. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26682. data["pre"] = prescriptions
  26683. } else { //月结
  26684. start_time_str := c.GetString("start_time")
  26685. end_time_str := c.GetString("end_time")
  26686. timeLayout := "2006-01-02"
  26687. loc, _ := time.LoadLocation("Local")
  26688. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26689. if err != nil {
  26690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26691. return
  26692. }
  26693. recordStartTime := theStartTime.Unix()
  26694. start_time = recordStartTime
  26695. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26696. if err != nil {
  26697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26698. return
  26699. }
  26700. recordEndTime := theEndTime.Unix()
  26701. end_time = recordEndTime
  26702. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26703. data["pre"] = prescriptions
  26704. }
  26705. timestamp := time.Now().Unix()
  26706. tempTime := time.Unix(timestamp, 0)
  26707. timeFormat := tempTime.Format("20060102150405")
  26708. chrgBchno := rand.Intn(100000) + 10000
  26709. new_chrg_bchno := ""
  26710. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26711. new_chrg_bchno = chrg_bchno
  26712. strconv.FormatInt(his.PatientId, 10)
  26713. client := &http.Client{}
  26714. if adminUser.CurrentOrgId == 10265 {
  26715. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26716. new_chrg_bchno = "0000"
  26717. }
  26718. }
  26719. data["psn_no"] = his.PsnNo
  26720. data["mdtrt_id"] = his.Number
  26721. data["chrg_bchno"] = new_chrg_bchno
  26722. data["org_name"] = miConfig.OrgName
  26723. data["doctor"] = doctor_info.UserName
  26724. data["doctor_id"] = doctor_info.DoctorNumber
  26725. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26726. data["fixmedins_code"] = miConfig.Code
  26727. data["dept_code"] = department.Number
  26728. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26729. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26730. data["secret_key"] = miConfig.SecretKey
  26731. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26732. data["url"] = miConfig.Url
  26733. data["ak"] = miConfig.AccessKey
  26734. data["new_doctor_name"] = patientPrescription.Doctor
  26735. data["diag_code"] = sickConfig.CountryCode
  26736. data["cainfo"] = miConfig.Cainfo
  26737. data["opter"] = roles.UserName
  26738. var ids []int64
  26739. for _, item := range prescriptions {
  26740. ids = append(ids, item.ID)
  26741. }
  26742. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26743. if config.IsOpen == 1 { //对接了医保,走医保流程
  26744. var res ResultFour
  26745. var resFour10265 ResultFour10265
  26746. if miConfig.MdtrtareaAdmvs == "421300" {
  26747. bytesData, _ := json.Marshal(data)
  26748. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26749. resp, _ := client.Do(req)
  26750. defer resp.Body.Close()
  26751. body, ioErr := ioutil.ReadAll(resp.Body)
  26752. if ioErr != nil {
  26753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26755. return
  26756. }
  26757. var respJSON map[string]interface{}
  26758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26761. return
  26762. }
  26763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26764. userJSONBytes, _ := json.Marshal(respJSON)
  26765. fmt.Println("log")
  26766. fmt.Println(string(userJSONBytes))
  26767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26768. utils.ErrorLog("解析失败:%v", err)
  26769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26770. return
  26771. }
  26772. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26773. bytesData, _ := json.Marshal(data)
  26774. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26775. resp, _ := client.Do(req)
  26776. defer resp.Body.Close()
  26777. body, ioErr := ioutil.ReadAll(resp.Body)
  26778. if ioErr != nil {
  26779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26781. return
  26782. }
  26783. var respJSON map[string]interface{}
  26784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26787. return
  26788. }
  26789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26790. userJSONBytes, _ := json.Marshal(respJSON)
  26791. fmt.Println("log")
  26792. fmt.Println(string(userJSONBytes))
  26793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26794. utils.ErrorLog("解析失败:%v", err)
  26795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26796. return
  26797. }
  26798. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26799. bytesData, _ := json.Marshal(data)
  26800. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26801. resp, _ := client.Do(req)
  26802. defer resp.Body.Close()
  26803. body, ioErr := ioutil.ReadAll(resp.Body)
  26804. if ioErr != nil {
  26805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26807. return
  26808. }
  26809. var respJSON map[string]interface{}
  26810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26813. return
  26814. }
  26815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26816. userJSONBytes, _ := json.Marshal(respJSON)
  26817. fmt.Println("log")
  26818. fmt.Println(string(userJSONBytes))
  26819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26820. utils.ErrorLog("解析失败:%v", err)
  26821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26822. return
  26823. }
  26824. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26825. bytesData, _ := json.Marshal(data)
  26826. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26827. resp, _ := client.Do(req)
  26828. defer resp.Body.Close()
  26829. body, ioErr := ioutil.ReadAll(resp.Body)
  26830. if ioErr != nil {
  26831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26833. return
  26834. }
  26835. var respJSON map[string]interface{}
  26836. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26839. return
  26840. }
  26841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26842. userJSONBytes, _ := json.Marshal(respJSON)
  26843. fmt.Println("log")
  26844. fmt.Println(string(userJSONBytes))
  26845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26846. utils.ErrorLog("解析失败:%v", err)
  26847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26848. return
  26849. }
  26850. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26851. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26852. var result3101 Result3101
  26853. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26854. result3101.Infcode = "0"
  26855. if result3101.Infcode == "0" {
  26856. if len(result3101.Output.Result) > 0 {
  26857. var errMsgs []string
  26858. for _, item := range result3101.Output.Result {
  26859. errMsgs = append(errMsgs, item.VolaCont)
  26860. }
  26861. c.ServeSuccessJSON(map[string]interface{}{
  26862. "failed_code": -10,
  26863. "msg": errMsgs,
  26864. })
  26865. return
  26866. }
  26867. }
  26868. bytesData, _ := json.Marshal(data)
  26869. var req *http.Request
  26870. if miConfig.MdtrtareaAdmvs == "320830" {
  26871. data["diag_code"] = sickConfig.CountryCode
  26872. fmt.Println(data)
  26873. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  26874. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26875. data["diag_code"] = sickConfig.CountryCode
  26876. fmt.Println(data)
  26877. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26878. } else {
  26879. data["diag_code"] = sickConfig.CountryCode
  26880. fmt.Println(data)
  26881. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26882. }
  26883. resp, _ := client.Do(req)
  26884. defer resp.Body.Close()
  26885. body, ioErr := ioutil.ReadAll(resp.Body)
  26886. if ioErr != nil {
  26887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26889. return
  26890. }
  26891. var respJSON map[string]interface{}
  26892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26895. return
  26896. }
  26897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26898. userJSONBytes, _ := json.Marshal(respJSON)
  26899. fmt.Println("log")
  26900. fmt.Println(string(userJSONBytes))
  26901. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26902. utils.ErrorLog("解析失败:%v", err)
  26903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26904. return
  26905. }
  26906. res.InfRefmsgid = resFour10265.InfRefmsgid
  26907. res.Output = resFour10265.Output
  26908. res.ErrMsg = resFour10265.ErrMsg
  26909. res.Cainfo = resFour10265.Cainfo
  26910. res.WarnMsg = resFour10265.WarnMsg
  26911. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26912. res.Infcode = infocode
  26913. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26914. var pagesize int = 2
  26915. var start int = 1
  26916. var stop int
  26917. var pagecount int
  26918. var curpage int
  26919. var isSuccess bool = true
  26920. data["doctor_id"] = doctor_info.DoctorNumber
  26921. //总页数,向上取整,注意除之前要先转换类型为float64
  26922. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26923. for curpage = 1; curpage <= pagecount; curpage++ {
  26924. if curpage == 1 {
  26925. start = 1
  26926. } else {
  26927. start = (curpage-1)*pagesize + 1
  26928. }
  26929. stop = curpage * pagesize
  26930. if stop > len(prescriptions) {
  26931. stop = len(prescriptions)
  26932. }
  26933. //var requestLog string
  26934. data["pre"] = prescriptions[start-1 : stop]
  26935. fmt.Println(data["pre"])
  26936. bytesData, _ := json.Marshal(data)
  26937. var req *http.Request
  26938. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26939. resp, _ := client.Do(req)
  26940. defer resp.Body.Close()
  26941. body, ioErr := ioutil.ReadAll(resp.Body)
  26942. if ioErr != nil {
  26943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26945. return
  26946. }
  26947. var respJSON map[string]interface{}
  26948. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26951. return
  26952. }
  26953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26954. userJSONBytes, _ := json.Marshal(respJSON)
  26955. fmt.Println("log")
  26956. fmt.Println(string(userJSONBytes))
  26957. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26958. utils.ErrorLog("解析失败:%v", err)
  26959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26960. return
  26961. }
  26962. res.InfRefmsgid = resFour10265.InfRefmsgid
  26963. res.Output = resFour10265.Output
  26964. res.ErrMsg = resFour10265.ErrMsg
  26965. res.Cainfo = resFour10265.Cainfo
  26966. res.WarnMsg = resFour10265.WarnMsg
  26967. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26968. res.Infcode = infocode
  26969. if infocode == 0 {
  26970. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  26971. } else {
  26972. isSuccess = false
  26973. errlog := &models.HisOrderError{
  26974. UserOrgId: adminUser.CurrentOrgId,
  26975. Ctime: time.Now().Unix(),
  26976. Mtime: time.Now().Unix(),
  26977. Number: chrg_bchno,
  26978. ErrMsg: "",
  26979. Status: 1,
  26980. PatientId: id,
  26981. RecordTime: recordDateTime,
  26982. Stage: 4,
  26983. }
  26984. service.CreateErrMsgLog(errlog)
  26985. c.ServeSuccessJSON(map[string]interface{}{
  26986. "failed_code": -10,
  26987. "msg": res.ErrMsg,
  26988. })
  26989. return
  26990. }
  26991. }
  26992. if isSuccess {
  26993. res.Infcode = 0
  26994. }
  26995. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26996. 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)
  26997. var dat map[string]interface{}
  26998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26999. fmt.Println(dat)
  27000. } else {
  27001. fmt.Println(err)
  27002. }
  27003. saveLog(result, request_log, "2204", "上传费用明细")
  27004. userJSONBytes, _ := json.Marshal(dat)
  27005. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27006. utils.ErrorLog("解析失败:%v", err)
  27007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27008. return
  27009. }
  27010. res.InfRefmsgid = resFour10265.InfRefmsgid
  27011. res.Output = resFour10265.Output
  27012. res.ErrMsg = resFour10265.ErrMsg
  27013. res.Cainfo = resFour10265.Cainfo
  27014. res.WarnMsg = resFour10265.WarnMsg
  27015. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27016. res.Infcode = infocode
  27017. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27018. bytesData, _ := json.Marshal(data)
  27019. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27020. resp, _ := client.Do(req)
  27021. defer resp.Body.Close()
  27022. body, ioErr := ioutil.ReadAll(resp.Body)
  27023. if ioErr != nil {
  27024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27026. return
  27027. }
  27028. var respJSON map[string]interface{}
  27029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27032. return
  27033. }
  27034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27035. userJSONBytes, _ := json.Marshal(respJSON)
  27036. fmt.Println("log")
  27037. fmt.Println(string(userJSONBytes))
  27038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27039. utils.ErrorLog("解析失败:%v", err)
  27040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27041. return
  27042. }
  27043. } else {
  27044. if miConfig.Code == "H15049901371" {
  27045. 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)
  27046. var dat map[string]interface{}
  27047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27048. fmt.Println(dat)
  27049. } else {
  27050. fmt.Println(err)
  27051. }
  27052. saveLog(result, request_log, "2204", "上传费用明细")
  27053. userJSONBytes, _ := json.Marshal(dat)
  27054. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27055. utils.ErrorLog("解析失败:%v", err)
  27056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27057. return
  27058. }
  27059. res.InfRefmsgid = resFour10265.InfRefmsgid
  27060. res.Output = resFour10265.Output
  27061. res.ErrMsg = resFour10265.ErrMsg
  27062. res.Cainfo = resFour10265.Cainfo
  27063. res.WarnMsg = resFour10265.WarnMsg
  27064. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27065. res.Infcode = infocode
  27066. } else {
  27067. 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)
  27068. var dat map[string]interface{}
  27069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27070. fmt.Println(dat)
  27071. } else {
  27072. fmt.Println(err)
  27073. }
  27074. saveLog(result, request_log, "2204", "上传费用明细")
  27075. userJSONBytes, _ := json.Marshal(dat)
  27076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27077. utils.ErrorLog("解析失败:%v", err)
  27078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27079. return
  27080. }
  27081. }
  27082. }
  27083. if res.Infcode == 0 {
  27084. order := &models.HisOrder{
  27085. UserOrgId: adminUser.CurrentOrgId,
  27086. HisPatientId: his.ID,
  27087. PatientId: his.PatientId,
  27088. SettleAccountsDate: recordDateTime,
  27089. MdtrtId: his.Number,
  27090. PsnNo: his.PsnNo,
  27091. MedType: strconv.FormatInt(reg_type, 10),
  27092. Ctime: time.Now().Unix(),
  27093. Mtime: time.Now().Unix(),
  27094. Status: 1,
  27095. Number: chrg_bchno,
  27096. Infcode: res.Infcode,
  27097. WarnMsg: res.WarnMsg,
  27098. Cainfo: res.Cainfo,
  27099. ErrMsg: res.ErrMsg,
  27100. RespondTime: res.RefmsgTime,
  27101. InfRefmsgid: res.InfRefmsgid,
  27102. OrderStatus: 1,
  27103. PayWay: pay_way,
  27104. PayWays: pay_ways,
  27105. OthDesc: oth_desc,
  27106. PayPrice: pay_price,
  27107. PayCardNo: pay_card_no,
  27108. DiscountPrice: discount_price,
  27109. PreferentialPrice: preferential_price,
  27110. RealityPrice: reality_price,
  27111. FoundPrice: found_price,
  27112. MedicalInsurancePrice: medical_insurance_price,
  27113. PrivatePrice: private_price,
  27114. IsMedicineInsurance: 1,
  27115. SettleType: settle_accounts_type,
  27116. SettleStartTime: start_time,
  27117. SettleEndTime: end_time,
  27118. Creator: roles.AdminUserId,
  27119. Modify: roles.AdminUserId,
  27120. FaPiaoNumber: fapiao_number,
  27121. FaPiaoCode: fapiao_code,
  27122. PType: 2,
  27123. Diagnosis: diagnosis_id,
  27124. CashPay: cash_pay,
  27125. WechatPay: wechat_pay,
  27126. AliPay: ali_pay,
  27127. JifenPay: jifen_pay,
  27128. BandCardPay: band_card_pay,
  27129. }
  27130. err = service.CreateOrder(order)
  27131. if err != nil {
  27132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27133. return
  27134. }
  27135. for _, item := range res.Output.Result {
  27136. temp := strings.Split(item.FeedetlSn, "-")
  27137. var advice_id int64 = 0
  27138. var project_id int64 = 0
  27139. var types int64 = 0
  27140. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27141. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27142. if temp[1] == "1" {
  27143. advice_id = id
  27144. project_id = 0
  27145. } else if temp[1] == "2" {
  27146. advice_id = 0
  27147. project_id = id
  27148. }
  27149. if item.MedChrgitmType == "9" {
  27150. item.MedChrgitmType = "09"
  27151. }
  27152. info := &models.HisOrderInfo{
  27153. OrderNumber: order.Number,
  27154. FeedetlSn: item.FeedetlSn,
  27155. UploadDate: time.Now().Unix(),
  27156. AdviceId: advice_id,
  27157. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27158. Cnt: item.Cnt,
  27159. Pric: float64(item.Pric),
  27160. PatientId: his.PatientId,
  27161. PricUplmtAmt: item.PricUplmtAmt,
  27162. SelfpayProp: item.SelfpayProp,
  27163. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27164. OverlmtAmt: item.OverlmtAmt,
  27165. PreselfpayAmt: item.PreselfpayAmt,
  27166. BasMednFlag: item.BasMednFlag,
  27167. MedChrgitmType: item.MedChrgitmType,
  27168. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27169. Status: 1,
  27170. Memo: item.Memo,
  27171. Mtime: time.Now().Unix(),
  27172. InscpScpAmt: item.InscpScpAmt,
  27173. DrtReimFlag: item.DrtReimFlag,
  27174. Ctime: time.Now().Unix(),
  27175. ListSpItemFlag: item.ListSpItemFlag,
  27176. ChldMedcFlag: item.ChldMedcFlag,
  27177. LmtUsedFlag: item.LmtUsedFlag,
  27178. ChrgitmLv: item.ChrgitmLv,
  27179. UserOrgId: adminUser.CurrentOrgId,
  27180. HisPatientId: his.ID,
  27181. OrderId: order.ID,
  27182. ProjectId: project_id,
  27183. Type: types,
  27184. }
  27185. service.CreateOrderInfo(info)
  27186. }
  27187. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27188. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27189. var total float64
  27190. for _, item := range prescriptions {
  27191. if item.Type == 1 { //药品
  27192. for _, subItem := range item.HisDoctorAdviceInfo {
  27193. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27194. total_one := price * subItem.PrescribingNumber
  27195. total = total + total_one
  27196. }
  27197. }
  27198. if item.Type == 2 { //项目
  27199. for _, subItem := range item.HisPrescriptionProject {
  27200. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27201. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27202. total_one := price * cnt
  27203. total = total + total_one
  27204. }
  27205. }
  27206. }
  27207. allTotal := fmt.Sprintf("%.2f", total)
  27208. //if adminUser.CurrentOrgId == 9919 {
  27209. //
  27210. // allTotal = fmt.Sprintf("%.2f", total)
  27211. //
  27212. //} else {
  27213. //
  27214. // allTotal = fmt.Sprintf("%.2f", total)
  27215. //
  27216. //}
  27217. if res.Infcode == 0 {
  27218. var rf []*ResultFive
  27219. json.Unmarshal([]byte(his.Iinfo), &rf)
  27220. chrg_bchno := chrg_bchno
  27221. cert_no := his.Certno
  27222. var insutypes []string
  27223. var insutype string
  27224. var is390 int = 0
  27225. var is310 int = 0
  27226. for _, item := range rf {
  27227. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27228. insutypes = append(insutypes, item.Insutype)
  27229. }
  27230. }
  27231. if len(insutypes) == 1 {
  27232. insutype = insutypes[0]
  27233. } else {
  27234. for _, i := range insutypes {
  27235. if i == "390" {
  27236. is390 = 1
  27237. }
  27238. if i == "310" {
  27239. is310 = 1
  27240. }
  27241. }
  27242. }
  27243. if is390 == 1 {
  27244. insutype = "390"
  27245. }
  27246. if is310 == 1 {
  27247. insutype = "310"
  27248. }
  27249. if len(insutypes) == 0 {
  27250. insutype = "310"
  27251. }
  27252. if len(insutypes) == 2 {
  27253. insutype = strconv.FormatInt(his.SocialType, 10)
  27254. }
  27255. insutype = strconv.FormatInt(his.SocialType, 10)
  27256. //insutype = "390"
  27257. if his.IdCardType == 1 {
  27258. // cert_no = his.MedicalInsuranceNumber
  27259. cert_no = his.Certno
  27260. } else {
  27261. cert_no = his.Certno
  27262. }
  27263. var res ResultSeven
  27264. var resSeven10265 ResultSeven10265
  27265. var gzresSeven10265Two GZResultSeven10265Two
  27266. var src_resquest string
  27267. var result2 string
  27268. if miConfig.MdtrtareaAdmvs == "421300" {
  27269. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27270. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27271. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27273. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27274. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27275. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27276. resp, requestErr := http.Get(api)
  27277. if requestErr != nil {
  27278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27279. return
  27280. }
  27281. body, ioErr := ioutil.ReadAll(resp.Body)
  27282. if ioErr != nil {
  27283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27285. return
  27286. }
  27287. var respJSON map[string]interface{}
  27288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27291. return
  27292. }
  27293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27294. result, _ := json.Marshal(respJSON)
  27295. if miConfig.Code == "H15049901371" {
  27296. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27297. utils.ErrorLog("解析失败:%v", err)
  27298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27299. return
  27300. }
  27301. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27302. res.Output = resSeven10265.Output
  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. } else {
  27309. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27310. utils.ErrorLog("解析失败:%v", err)
  27311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27312. return
  27313. }
  27314. }
  27315. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27316. if reg_type == 11 && his.Insutype == "390" {
  27317. reg_type = 110104
  27318. }
  27319. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27320. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27321. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27322. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27323. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27324. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27325. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27326. resp, requestErr := http.Get(api)
  27327. if requestErr != nil {
  27328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27329. return
  27330. }
  27331. body, ioErr := ioutil.ReadAll(resp.Body)
  27332. if ioErr != nil {
  27333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27335. return
  27336. }
  27337. var respJSON map[string]interface{}
  27338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27341. return
  27342. }
  27343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27344. result, _ := json.Marshal(respJSON)
  27345. if miConfig.Code == "H15049901371" {
  27346. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27347. utils.ErrorLog("解析失败:%v", err)
  27348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27349. return
  27350. }
  27351. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27352. res.Output = resSeven10265.Output
  27353. res.ErrMsg = resSeven10265.ErrMsg
  27354. res.Cainfo = resSeven10265.Cainfo
  27355. res.WarnMsg = resSeven10265.WarnMsg
  27356. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27357. res.Infcode = infocode
  27358. } else {
  27359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27360. utils.ErrorLog("解析失败:%v", err)
  27361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27362. return
  27363. }
  27364. }
  27365. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27366. if reg_type == 11 && his.Insutype == "390" {
  27367. reg_type = 110104
  27368. }
  27369. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27370. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27371. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27372. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27373. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27374. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27375. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27376. resp, requestErr := http.Get(api)
  27377. if requestErr != nil {
  27378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27379. return
  27380. }
  27381. body, ioErr := ioutil.ReadAll(resp.Body)
  27382. if ioErr != nil {
  27383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27385. return
  27386. }
  27387. var respJSON map[string]interface{}
  27388. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27391. return
  27392. }
  27393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27394. result, _ := json.Marshal(respJSON)
  27395. if miConfig.Code == "H15049901371" {
  27396. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27397. utils.ErrorLog("解析失败:%v", err)
  27398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27399. return
  27400. }
  27401. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27402. res.Output = resSeven10265.Output
  27403. res.ErrMsg = resSeven10265.ErrMsg
  27404. res.Cainfo = resSeven10265.Cainfo
  27405. res.WarnMsg = resSeven10265.WarnMsg
  27406. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27407. res.Infcode = infocode
  27408. } else {
  27409. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27410. utils.ErrorLog("解析失败:%v", err)
  27411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27412. return
  27413. }
  27414. }
  27415. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27416. if reg_type == 11 && his.Insutype == "390" {
  27417. reg_type = 110104
  27418. }
  27419. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27420. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27421. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27422. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27423. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27424. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27425. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27426. resp, requestErr := http.Get(api)
  27427. if requestErr != nil {
  27428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27429. return
  27430. }
  27431. body, ioErr := ioutil.ReadAll(resp.Body)
  27432. if ioErr != nil {
  27433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27435. return
  27436. }
  27437. var respJSON map[string]interface{}
  27438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27441. return
  27442. }
  27443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27444. result, _ := json.Marshal(respJSON)
  27445. if miConfig.Code == "H15049901371" {
  27446. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27447. utils.ErrorLog("解析失败:%v", err)
  27448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27449. return
  27450. }
  27451. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27452. res.Output = resSeven10265.Output
  27453. res.ErrMsg = resSeven10265.ErrMsg
  27454. res.Cainfo = resSeven10265.Cainfo
  27455. res.WarnMsg = resSeven10265.WarnMsg
  27456. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27457. res.Infcode = infocode
  27458. } else {
  27459. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27460. utils.ErrorLog("解析失败:%v", err)
  27461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27462. return
  27463. }
  27464. }
  27465. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27466. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27467. var result3101 Result3101
  27468. //utils.ErrorLog("解析失败:%v", result3101)
  27469. result3101.Infcode = "0"
  27470. if result3101.Infcode == "0" {
  27471. if len(result3101.Output.Result) > 0 {
  27472. var errMsgs []string
  27473. for _, item := range result3101.Output.Result {
  27474. errMsgs = append(errMsgs, item.VolaCont)
  27475. }
  27476. c.ServeSuccessJSON(map[string]interface{}{
  27477. "failed_code": -10,
  27478. "msg": errMsgs,
  27479. })
  27480. return
  27481. } else {
  27482. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27483. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27484. bas := strings.Split(psn_info.CardInfo, "|")
  27485. if his.IdCardType == 1 {
  27486. cert_no = bas[2]
  27487. } else if his.IdCardType == 3 {
  27488. cert_no = his.Certno
  27489. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27490. } else if his.IdCardType == 4 {
  27491. cert_no = his.Certno
  27492. psn_info.VerifyNumber = psn_info.VerifyNumber
  27493. }
  27494. var api string
  27495. if miConfig.MdtrtareaAdmvs == "320830" {
  27496. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27497. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27498. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27499. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27500. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27501. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27502. "&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
  27503. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27504. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27505. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27506. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27507. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27508. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27509. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27510. "&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
  27511. } else {
  27512. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27513. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27514. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27516. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27517. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27518. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  27519. }
  27520. resp, requestErr := http.Get(api)
  27521. if requestErr != nil {
  27522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27523. return
  27524. }
  27525. body, ioErr := ioutil.ReadAll(resp.Body)
  27526. if ioErr != nil {
  27527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27529. return
  27530. }
  27531. var respJSON map[string]interface{}
  27532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27535. return
  27536. }
  27537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27538. result, _ := json.Marshal(respJSON)
  27539. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27540. utils.ErrorLog("解析失败:%v", err)
  27541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27542. return
  27543. }
  27544. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27545. res.Output = resSeven10265.Output
  27546. res.ErrMsg = resSeven10265.ErrMsg
  27547. res.Cainfo = resSeven10265.Cainfo
  27548. res.WarnMsg = resSeven10265.WarnMsg
  27549. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27550. res.Infcode = infocode
  27551. }
  27552. }
  27553. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27554. psn_info, _ := service.GetPsnByPatientId(id)
  27555. var verify_number string
  27556. if psn_info.IdCardType == 4 {
  27557. verify_number = psn_info.VerifyNumber
  27558. } else if psn_info.IdCardType == 1 {
  27559. bas := strings.Split(psn_info.CardInfo, "|")
  27560. cardNumber := bas[2]
  27561. verify_number = cardNumber
  27562. } else {
  27563. psn_info.IdCardType = 2
  27564. verify_number = psn_info.Certno
  27565. }
  27566. var api string
  27567. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27568. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27569. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27570. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27571. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27572. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27573. "&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
  27574. resp, requestErr := http.Get(api)
  27575. if requestErr != nil {
  27576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27577. return
  27578. }
  27579. body, ioErr := ioutil.ReadAll(resp.Body)
  27580. if ioErr != nil {
  27581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27583. return
  27584. }
  27585. var respJSON map[string]interface{}
  27586. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27589. return
  27590. }
  27591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27592. result, _ := json.Marshal(respJSON)
  27593. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27594. utils.ErrorLog("解析失败:%v", err)
  27595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27596. return
  27597. }
  27598. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27599. res.Output = resSeven10265.Output
  27600. res.ErrMsg = resSeven10265.ErrMsg
  27601. res.Cainfo = resSeven10265.Cainfo
  27602. res.WarnMsg = resSeven10265.WarnMsg
  27603. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27604. res.Infcode = infocode
  27605. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27606. var cert_no string
  27607. if his.IdCardType == 4 {
  27608. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27609. cert_no = psn_info.VerifyNumber
  27610. 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)
  27611. } else if his.IdCardType == 1 {
  27612. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27613. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27614. 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)
  27615. }
  27616. //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)
  27617. var dat map[string]interface{}
  27618. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27619. fmt.Println(dat)
  27620. } else {
  27621. fmt.Println(err)
  27622. }
  27623. saveLog(result2, src_resquest, "2207", "结算")
  27624. userJSONBytes, _ := json.Marshal(dat)
  27625. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27626. utils.ErrorLog("解析失败:%v", err)
  27627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27628. return
  27629. }
  27630. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27631. res.Output = resSeven10265.Output
  27632. res.ErrMsg = resSeven10265.ErrMsg
  27633. res.Cainfo = resSeven10265.Cainfo
  27634. res.WarnMsg = resSeven10265.WarnMsg
  27635. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27636. res.Infcode = infocode
  27637. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27638. res2 := c.GetoleInfo()
  27639. if res2.Infcode == 0 {
  27640. var result string
  27641. var request_log string
  27642. var result_log string
  27643. if res2.Output.MdtrtCertType == "02" {
  27644. 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)
  27645. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27646. } else if res2.Output.MdtrtCertType == "01" {
  27647. 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)
  27648. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27649. } else {
  27650. 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)
  27651. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27652. }
  27653. var dat map[string]interface{}
  27654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27655. fmt.Println(dat)
  27656. } else {
  27657. fmt.Println(err)
  27658. }
  27659. userJSONBytes, _ := json.Marshal(dat)
  27660. var res5 ResultTwo
  27661. //var resTwo10265 ResultTwo10265
  27662. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27663. utils.ErrorLog("解析失败:%v", err)
  27664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27665. return
  27666. }
  27667. if res5.Infcode == -1 {
  27668. c.ServeSuccessJSON(map[string]interface{}{
  27669. "failed_code": -10,
  27670. "msg": res5.ErrMsg,
  27671. })
  27672. return
  27673. }
  27674. var insutypes []string
  27675. var insutype string
  27676. var is390 int = 0
  27677. var is310 int = 0
  27678. for _, item := range res5.Output.Iinfo {
  27679. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27680. insutypes = append(insutypes, item.Insutype)
  27681. }
  27682. }
  27683. if len(insutypes) == 1 {
  27684. insutype = insutypes[0]
  27685. } else {
  27686. for _, i := range insutypes {
  27687. if i == "390" {
  27688. is390 = 1
  27689. }
  27690. if i == "310" {
  27691. is310 = 1
  27692. }
  27693. }
  27694. }
  27695. if is390 == 1 {
  27696. insutype = "390"
  27697. }
  27698. if is310 == 1 {
  27699. insutype = "310"
  27700. }
  27701. if len(insutypes) == 0 {
  27702. insutype = "310"
  27703. }
  27704. fmt.Println(insutype)
  27705. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27706. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27707. infoStr := string(Iinfos)
  27708. idetinfoStr := string(Idetinfos)
  27709. psn := &models.HisPsn{
  27710. PsnNo: res5.Output.Baseinfo.PsnNo,
  27711. PatientId: id,
  27712. Certno: res5.Output.Baseinfo.Certno,
  27713. Gend: res5.Output.Baseinfo.Gend,
  27714. Naty: res5.Output.Baseinfo.Naty,
  27715. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27716. PsnName: res5.Output.Baseinfo.PsnName,
  27717. Idetinfo: idetinfoStr,
  27718. Insuinfo: infoStr,
  27719. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27720. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27721. VerifyNumber: res2.Output.EcToken,
  27722. }
  27723. if res2.Output.MdtrtCertType == "01" {
  27724. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27725. psn.VerifyNumber = res2.Output.EcToken
  27726. } else if res2.Output.MdtrtCertType == "02" {
  27727. psn.VerifyNumber = res2.Output.CardNo
  27728. } else {
  27729. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27730. }
  27731. service.CreateHisPsn(psn)
  27732. if res2.Output.MdtrtCertType == "01" {
  27733. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27734. token := res2.Output.EcToken
  27735. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  27736. } else if res2.Output.MdtrtCertType == "02" {
  27737. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  27738. } else {
  27739. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  27740. }
  27741. var dat2 map[string]interface{}
  27742. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27743. fmt.Println(dat2)
  27744. } else {
  27745. fmt.Println(err)
  27746. }
  27747. userJSONBytes3, _ := json.Marshal(dat2)
  27748. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27749. utils.ErrorLog("解析失败:%v", err)
  27750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27751. return
  27752. }
  27753. saveLog(result2, src_resquest, "2207", "结算")
  27754. } else {
  27755. c.ServeSuccessJSON(map[string]interface{}{
  27756. "failed_code": -10,
  27757. "msg": res2.ErrMsg,
  27758. })
  27759. return
  27760. }
  27761. } else {
  27762. if miConfig.Code == "H15049901371" {
  27763. //赤峰地区国家医保医疗类别
  27764. //职工透析:医疗类别选特殊情况门诊990502
  27765. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27766. var med_type string
  27767. if his.Insutype == "390" {
  27768. if reg_type == 14 {
  27769. med_type = "9933"
  27770. } else if reg_type == 11 {
  27771. med_type = "11"
  27772. }
  27773. } else if his.Insutype == "310" {
  27774. if reg_type == 14 {
  27775. med_type = "990502"
  27776. } else if reg_type == 11 {
  27777. med_type = "11"
  27778. }
  27779. }
  27780. 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)
  27781. } else {
  27782. if his.IdCardType == 4 {
  27783. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27784. var token string
  27785. token = psn_info.VerifyNumber
  27786. 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)
  27787. } else {
  27788. if his.IdCardType == 1 {
  27789. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27790. bas := strings.Split(psn_info.CardInfo, "|")
  27791. basNumber := bas[2]
  27792. cert_no = basNumber
  27793. }
  27794. 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)
  27795. }
  27796. }
  27797. //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)
  27798. var dat map[string]interface{}
  27799. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27800. fmt.Println(dat)
  27801. } else {
  27802. fmt.Println(err)
  27803. }
  27804. saveLog(result2, src_resquest, "2207", "结算")
  27805. userJSONBytes, _ := json.Marshal(dat)
  27806. if miConfig.Code == "H15049901371" {
  27807. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27808. utils.ErrorLog("解析失败:%v", err)
  27809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27810. return
  27811. }
  27812. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27813. res.Output = resSeven10265.Output
  27814. res.ErrMsg = resSeven10265.ErrMsg
  27815. res.Cainfo = resSeven10265.Cainfo
  27816. res.WarnMsg = resSeven10265.WarnMsg
  27817. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27818. res.Infcode = infocode
  27819. } else {
  27820. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27821. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27822. utils.ErrorLog("解析失败:%v", err)
  27823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27824. return
  27825. }
  27826. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27827. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27828. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27829. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27830. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27831. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27832. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27833. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27834. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27835. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27836. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27837. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27838. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27839. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27840. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27841. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27842. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27843. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27844. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27845. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27846. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27847. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27848. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27849. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27850. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27851. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27852. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27853. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27854. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27855. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27856. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27857. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27858. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27859. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27860. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27861. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27862. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27863. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27864. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27865. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27866. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27867. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27868. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27869. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27870. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27871. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27872. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27873. res.Cainfo = gzresSeven10265Two.Cainfo
  27874. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27875. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27876. //res.Infcode = infocode
  27877. } else {
  27878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27879. utils.ErrorLog("解析失败:%v", err)
  27880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27881. return
  27882. }
  27883. }
  27884. }
  27885. }
  27886. if res.Infcode == -1 {
  27887. errlog := &models.HisOrderError{
  27888. UserOrgId: adminUser.CurrentOrgId,
  27889. Ctime: time.Now().Unix(),
  27890. Mtime: time.Now().Unix(),
  27891. Number: chrg_bchno,
  27892. ErrMsg: res.ErrMsg,
  27893. Status: 1,
  27894. PatientId: id,
  27895. RecordTime: recordDateTime,
  27896. Stage: 6,
  27897. }
  27898. service.CreateErrMsgLog(errlog)
  27899. c.ServeSuccessJSON(map[string]interface{}{
  27900. "failed_code": -10,
  27901. "msg": res.ErrMsg,
  27902. })
  27903. return
  27904. } else {
  27905. sickConfig, _ := service.FindSickById(his.SickType)
  27906. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27907. order.OrderStatus = 2
  27908. order.Status = 1
  27909. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27910. order.SetlId = res.Output.Setlinfo.SetlID
  27911. order.PsnNo = res.Output.Setlinfo.PsnNo
  27912. order.PsnName = res.Output.Setlinfo.PsnName
  27913. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27914. order.Certno = res.Output.Setlinfo.Certno
  27915. order.Gend = res.Output.Setlinfo.Gend
  27916. order.Naty = res.Output.Setlinfo.Naty
  27917. order.Age = res.Output.Setlinfo.Age
  27918. order.Insutype = res.Output.Setlinfo.Insutype
  27919. order.PsnType = res.Output.Setlinfo.PsnType
  27920. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27921. order.SetlTime = res.Output.Setlinfo.SetlTime
  27922. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27923. if res.Output.Setlinfo.MedType == "140101" {
  27924. order.MedType = "14"
  27925. } else {
  27926. if res.Output.Setlinfo.MedType == "110104" {
  27927. order.MedType = "11"
  27928. } else {
  27929. order.MedType = res.Output.Setlinfo.MedType
  27930. }
  27931. }
  27932. if reg_type == 1112 {
  27933. order.MedType = "1112"
  27934. }
  27935. if reg_type == 1111 {
  27936. order.MedType = "1111"
  27937. }
  27938. order.ClrType = res.Output.Setlinfo.ClrType
  27939. if adminUser.CurrentOrgId == 10480 {
  27940. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27941. order.ClrType = "11"
  27942. } else {
  27943. order.ClrType = "9903"
  27944. }
  27945. }
  27946. if adminUser.CurrentOrgId == 10721 {
  27947. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27948. order.ClrType = "11"
  27949. } else {
  27950. order.ClrType = "9903"
  27951. }
  27952. }
  27953. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27954. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27955. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27956. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27957. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27958. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27959. order.HifpPay = res.Output.Setlinfo.HifpPay
  27960. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27961. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27962. order.HifesPay = res.Output.Setlinfo.HifesPay
  27963. order.HifobPay = res.Output.Setlinfo.HifobPay
  27964. order.MafPay = res.Output.Setlinfo.MafPay
  27965. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27966. order.OthPay = res.Output.Setlinfo.OthPay
  27967. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27968. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27969. order.AcctPay = res.Output.Setlinfo.AcctPay
  27970. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27971. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27972. order.Balc = res.Output.Setlinfo.Balc
  27973. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27974. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27975. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27976. //order.ClrType = res.Output.Setlinfo.ClrType
  27977. order.ClrWay = res.Output.Setlinfo.ClrWay
  27978. order.Creator = order.Creator
  27979. order.Modify = roles.AdminUserId
  27980. order.RequestLog = src_resquest
  27981. order.FaPiaoNumber = fapiao_number
  27982. order.FaPiaoCode = fapiao_code
  27983. order.SickName = sickConfig.ClassName
  27984. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27985. //detailStr := string(setlDetail)
  27986. //order.SetlDetail = detailStr
  27987. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27988. err = service.UpDateOrder(order)
  27989. if err == nil {
  27990. //判断是否使用了押金
  27991. if dec_way == "true" {
  27992. tmpstring := strconv.FormatInt(order.ID, 10)
  27993. order.Decimal = decimal
  27994. service.UpDateOrder(order)
  27995. //扣押金
  27996. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27997. if errmsg != nil {
  27998. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27999. return
  28000. }
  28001. }
  28002. c.ServeSuccessJSON(map[string]interface{}{
  28003. "msg": "结算成功",
  28004. })
  28005. } else {
  28006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28007. return
  28008. }
  28009. }
  28010. } else {
  28011. adminUser := c.GetAdminUserInfo()
  28012. errlog := &models.HisOrderError{
  28013. UserOrgId: adminUser.CurrentOrgId,
  28014. Ctime: time.Now().Unix(),
  28015. Mtime: time.Now().Unix(),
  28016. ErrMsg: res.ErrMsg,
  28017. Status: 1,
  28018. PatientId: id,
  28019. RecordTime: recordDateTime,
  28020. Stage: 4,
  28021. }
  28022. service.CreateErrMsgLog(errlog)
  28023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28024. return
  28025. }
  28026. } else {
  28027. adminUser := c.GetAdminUserInfo()
  28028. errlog := &models.HisOrderError{
  28029. UserOrgId: adminUser.CurrentOrgId,
  28030. Ctime: time.Now().Unix(),
  28031. Mtime: time.Now().Unix(),
  28032. ErrMsg: res.ErrMsg,
  28033. Status: 1,
  28034. PatientId: id,
  28035. RecordTime: recordDateTime,
  28036. Stage: 4,
  28037. }
  28038. service.CreateErrMsgLog(errlog)
  28039. c.ServeSuccessJSON(map[string]interface{}{
  28040. "failed_code": -10,
  28041. "msg": res.ErrMsg,
  28042. })
  28043. return
  28044. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28045. //return
  28046. }
  28047. }
  28048. }
  28049. } else if tempOrder.ID > 0 {
  28050. if tempOrder.IsPre == 1 {
  28051. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28052. var rf []*ResultFive
  28053. json.Unmarshal([]byte(his.Iinfo), &rf)
  28054. chrg_bchno := tempOrder.Number
  28055. cert_no := his.Certno
  28056. var insutypes []string
  28057. var insutype string
  28058. var is390 int = 0
  28059. var is310 int = 0
  28060. for _, item := range rf {
  28061. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28062. insutypes = append(insutypes, item.Insutype)
  28063. }
  28064. }
  28065. if len(insutypes) == 1 {
  28066. insutype = insutypes[0]
  28067. } else {
  28068. for _, i := range insutypes {
  28069. if i == "390" {
  28070. is390 = 1
  28071. }
  28072. if i == "310" {
  28073. is310 = 1
  28074. }
  28075. }
  28076. }
  28077. if is390 == 1 {
  28078. insutype = "390"
  28079. }
  28080. if is310 == 1 {
  28081. insutype = "310"
  28082. }
  28083. if len(insutypes) == 0 {
  28084. insutype = "310"
  28085. }
  28086. if len(insutypes) == 2 {
  28087. insutype = strconv.FormatInt(his.SocialType, 10)
  28088. }
  28089. //insutype = "390"
  28090. if his.IdCardType == 1 {
  28091. // cert_no = his.MedicalInsuranceNumber
  28092. cert_no = his.Certno
  28093. } else {
  28094. cert_no = his.Certno
  28095. }
  28096. var res ResultSeven
  28097. var ahres ResultSevenAH
  28098. var resSeven10265 ResultSeven10265
  28099. var gzresSeven10265Two GZResultSeven10265Two
  28100. var src_resquest string
  28101. var result2 string
  28102. if miConfig.MdtrtareaAdmvs == "450721" {
  28103. res2 := c.GetoleInfo()
  28104. if res2.Infcode == 0 {
  28105. var result string
  28106. var request_log string
  28107. var result_log string
  28108. if res2.Output.MdtrtCertType == "02" {
  28109. 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)
  28110. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28111. } else if res2.Output.MdtrtCertType == "01" {
  28112. 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)
  28113. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28114. } else {
  28115. 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)
  28116. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28117. }
  28118. var dat map[string]interface{}
  28119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28120. fmt.Println(dat)
  28121. } else {
  28122. fmt.Println(err)
  28123. }
  28124. userJSONBytes, _ := json.Marshal(dat)
  28125. var res5 ResultTwo
  28126. //var resTwo10265 ResultTwo10265
  28127. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28128. utils.ErrorLog("解析失败:%v", err)
  28129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28130. return
  28131. }
  28132. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28133. if res5.Infcode == -1 {
  28134. c.ServeSuccessJSON(map[string]interface{}{
  28135. "failed_code": -10,
  28136. "msg": res5.ErrMsg,
  28137. })
  28138. return
  28139. }
  28140. var insutypes []string
  28141. var insutype string
  28142. var is390 int = 0
  28143. var is310 int = 0
  28144. for _, item := range res5.Output.Iinfo {
  28145. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28146. insutypes = append(insutypes, item.Insutype)
  28147. }
  28148. }
  28149. if len(insutypes) == 1 {
  28150. insutype = insutypes[0]
  28151. } else {
  28152. for _, i := range insutypes {
  28153. if i == "390" {
  28154. is390 = 1
  28155. }
  28156. if i == "310" {
  28157. is310 = 1
  28158. }
  28159. }
  28160. }
  28161. if is390 == 1 {
  28162. insutype = "390"
  28163. }
  28164. if is310 == 1 {
  28165. insutype = "310"
  28166. }
  28167. if len(insutypes) == 0 {
  28168. insutype = "310"
  28169. }
  28170. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28171. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28172. infoStr := string(Iinfos)
  28173. idetinfoStr := string(Idetinfos)
  28174. psn := &models.HisPsn{
  28175. PsnNo: res5.Output.Baseinfo.PsnNo,
  28176. PatientId: id,
  28177. Certno: res5.Output.Baseinfo.Certno,
  28178. Gend: res5.Output.Baseinfo.Gend,
  28179. Naty: res5.Output.Baseinfo.Naty,
  28180. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28181. PsnName: res5.Output.Baseinfo.PsnName,
  28182. Idetinfo: idetinfoStr,
  28183. Insuinfo: infoStr,
  28184. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28185. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28186. VerifyNumber: res2.Output.EcToken,
  28187. }
  28188. service.CreateHisPsn(psn)
  28189. if res2.Output.MdtrtCertType == "01" {
  28190. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28191. token := res2.Output.EcToken
  28192. 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)
  28193. } else if res2.Output.MdtrtCertType == "02" {
  28194. 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)
  28195. } else {
  28196. 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)
  28197. }
  28198. var dat2 map[string]interface{}
  28199. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28200. fmt.Println(dat2)
  28201. } else {
  28202. fmt.Println(err)
  28203. }
  28204. userJSONBytes3, _ := json.Marshal(dat2)
  28205. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28206. utils.ErrorLog("解析失败:%v", err)
  28207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28208. return
  28209. }
  28210. saveLog(result2, src_resquest, "2207", "结算")
  28211. } else {
  28212. c.ServeSuccessJSON(map[string]interface{}{
  28213. "failed_code": -10,
  28214. "msg": res2.ErrMsg,
  28215. })
  28216. return
  28217. }
  28218. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28219. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28220. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28221. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28223. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28224. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28225. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28226. resp, requestErr := http.Get(api)
  28227. if requestErr != nil {
  28228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28229. return
  28230. }
  28231. body, ioErr := ioutil.ReadAll(resp.Body)
  28232. if ioErr != nil {
  28233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28235. return
  28236. }
  28237. var respJSON map[string]interface{}
  28238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28241. return
  28242. }
  28243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28244. result, _ := json.Marshal(respJSON)
  28245. fmt.Println("log")
  28246. fmt.Println(string(result))
  28247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28248. utils.ErrorLog("解析失败:%v", err)
  28249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28250. return
  28251. }
  28252. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28253. if reg_type == 11 && his.Insutype == "390" {
  28254. reg_type = 110104
  28255. }
  28256. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28257. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28258. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28260. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28261. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28262. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28263. resp, requestErr := http.Get(api)
  28264. if requestErr != nil {
  28265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28266. return
  28267. }
  28268. body, ioErr := ioutil.ReadAll(resp.Body)
  28269. if ioErr != nil {
  28270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28272. return
  28273. }
  28274. var respJSON map[string]interface{}
  28275. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28278. return
  28279. }
  28280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28281. result, _ := json.Marshal(respJSON)
  28282. fmt.Println("log")
  28283. fmt.Println(string(result))
  28284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28285. utils.ErrorLog("解析失败:%v", err)
  28286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28287. return
  28288. }
  28289. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28290. if reg_type == 11 && his.Insutype == "390" {
  28291. reg_type = 110104
  28292. }
  28293. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28294. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28295. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28296. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28297. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28298. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28299. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28300. resp, requestErr := http.Get(api)
  28301. if requestErr != nil {
  28302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28303. return
  28304. }
  28305. body, ioErr := ioutil.ReadAll(resp.Body)
  28306. if ioErr != nil {
  28307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28309. return
  28310. }
  28311. var respJSON map[string]interface{}
  28312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28315. return
  28316. }
  28317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28318. result, _ := json.Marshal(respJSON)
  28319. fmt.Println("log")
  28320. fmt.Println(string(result))
  28321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28322. utils.ErrorLog("解析失败:%v", err)
  28323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28324. return
  28325. }
  28326. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28327. if reg_type == 11 && his.Insutype == "390" {
  28328. reg_type = 110104
  28329. }
  28330. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28331. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28332. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28333. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28334. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28335. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28336. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28337. resp, requestErr := http.Get(api)
  28338. if requestErr != nil {
  28339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28340. return
  28341. }
  28342. body, ioErr := ioutil.ReadAll(resp.Body)
  28343. if ioErr != nil {
  28344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28346. return
  28347. }
  28348. var respJSON map[string]interface{}
  28349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28352. return
  28353. }
  28354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28355. result, _ := json.Marshal(respJSON)
  28356. fmt.Println("log")
  28357. fmt.Println(string(result))
  28358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28359. utils.ErrorLog("解析失败:%v", err)
  28360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28361. return
  28362. }
  28363. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28364. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28365. var result3101 Result3101
  28366. //utils.ErrorLog("解析失败:%v", result3101)
  28367. result3101.Infcode = "0"
  28368. if result3101.Infcode == "0" {
  28369. if len(result3101.Output.Result) > 0 {
  28370. var errMsgs []string
  28371. for _, item := range result3101.Output.Result {
  28372. errMsgs = append(errMsgs, item.VolaCont)
  28373. }
  28374. c.ServeSuccessJSON(map[string]interface{}{
  28375. "failed_code": -10,
  28376. "msg": errMsgs,
  28377. })
  28378. return
  28379. } else {
  28380. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28381. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28382. bas := strings.Split(psn_info.CardInfo, "|")
  28383. if his.IdCardType == 1 {
  28384. cert_no = bas[2]
  28385. } else if his.IdCardType == 3 {
  28386. cert_no = his.Certno
  28387. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28388. } else if his.IdCardType == 4 {
  28389. cert_no = his.Certno
  28390. psn_info.VerifyNumber = psn_info.VerifyNumber
  28391. }
  28392. //江苏地区国家医保医疗类别
  28393. //职工透析:医疗类别选特殊情况门诊9933
  28394. //居民血透门慢: 医疗类别选门诊慢病1402
  28395. //var med_type string
  28396. //if his.Insutype == "310" {
  28397. // if reg_type == 14 {
  28398. // med_type = "9933"
  28399. // } else if reg_type == 11 {
  28400. // med_type = "11"
  28401. //
  28402. // }
  28403. //} else if his.Insutype == "390" {
  28404. // if reg_type == 14 {
  28405. // med_type = "1402"
  28406. // } else if reg_type == 11 {
  28407. // med_type = "11"
  28408. // }
  28409. //}
  28410. var api string
  28411. if miConfig.MdtrtareaAdmvs == "320830" {
  28412. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28413. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28414. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28415. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28416. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28417. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28418. "&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
  28419. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28420. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28421. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28422. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28423. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28424. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28425. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28426. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28427. "&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
  28428. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28429. } else {
  28430. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28431. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28432. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28433. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28434. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28435. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28436. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28437. "&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
  28438. }
  28439. resp, requestErr := http.Get(api)
  28440. if requestErr != nil {
  28441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28442. return
  28443. }
  28444. body, ioErr := ioutil.ReadAll(resp.Body)
  28445. if ioErr != nil {
  28446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28448. return
  28449. }
  28450. var respJSON map[string]interface{}
  28451. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28454. return
  28455. }
  28456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28457. result, _ := json.Marshal(respJSON)
  28458. fmt.Println("log")
  28459. fmt.Println(string(result))
  28460. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28461. utils.ErrorLog("解析失败:%v", err)
  28462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28463. return
  28464. }
  28465. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28466. res.Output = resSeven10265.Output
  28467. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28468. res.ErrMsg = resSeven10265.ErrMsg
  28469. res.Cainfo = resSeven10265.Cainfo
  28470. res.WarnMsg = resSeven10265.WarnMsg
  28471. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28472. res.Infcode = infocode
  28473. }
  28474. }
  28475. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28476. psn_info, _ := service.GetPsnByPatientId(id)
  28477. var verify_number string
  28478. if psn_info.IdCardType == 4 {
  28479. verify_number = psn_info.VerifyNumber
  28480. } else if psn_info.IdCardType == 1 {
  28481. bas := strings.Split(psn_info.CardInfo, "|")
  28482. cardNumber := bas[2]
  28483. verify_number = cardNumber
  28484. } else {
  28485. verify_number = psn_info.Certno
  28486. psn_info.IdCardType = 2
  28487. }
  28488. var api string
  28489. new_chrg_bchno := chrg_bchno
  28490. if adminUser.CurrentOrgId == 10265 {
  28491. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28492. new_chrg_bchno = "0000"
  28493. }
  28494. }
  28495. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28496. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28497. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28498. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28499. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28500. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28501. "&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
  28502. resp, requestErr := http.Get(api)
  28503. if requestErr != nil {
  28504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28505. return
  28506. }
  28507. body, ioErr := ioutil.ReadAll(resp.Body)
  28508. if ioErr != nil {
  28509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28511. return
  28512. }
  28513. var respJSON map[string]interface{}
  28514. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28517. return
  28518. }
  28519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28520. result, _ := json.Marshal(respJSON)
  28521. fmt.Println("log")
  28522. fmt.Println(string(result))
  28523. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28524. utils.ErrorLog("解析失败:%v", err)
  28525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28526. return
  28527. }
  28528. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28529. res.Output = resSeven10265.Output
  28530. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28531. res.ErrMsg = resSeven10265.ErrMsg
  28532. res.Cainfo = resSeven10265.Cainfo
  28533. res.WarnMsg = resSeven10265.WarnMsg
  28534. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28535. res.Infcode = infocode
  28536. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28537. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28538. var cert_no string
  28539. if his.IdCardType == 1 {
  28540. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28541. } else {
  28542. cert_no = psn_info.VerifyNumber
  28543. }
  28544. 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)
  28545. var dat map[string]interface{}
  28546. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28547. fmt.Println(dat)
  28548. } else {
  28549. fmt.Println(err)
  28550. }
  28551. saveLog(result2, src_resquest, "2207", "结算")
  28552. userJSONBytes, _ := json.Marshal(dat)
  28553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28554. utils.ErrorLog("解析失败:%v", err)
  28555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28556. return
  28557. }
  28558. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28559. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28560. var cert_no string
  28561. var card_sn string
  28562. if his.IdCardType == 1 {
  28563. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28564. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28565. bas := strings.Split(psn_info.CardInfo, "|")
  28566. card_sn = bas[3]
  28567. } else if his.IdCardType == 2 {
  28568. cert_no = his.IdCardNo
  28569. } else {
  28570. cert_no = psn_info.VerifyNumber
  28571. }
  28572. var rf []*ResultFive
  28573. json.Unmarshal([]byte(his.Iinfo), &rf)
  28574. var psn_type string
  28575. for _, item := range rf {
  28576. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28577. psn_type = item.PsnType
  28578. }
  28579. }
  28580. 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)
  28581. var dat map[string]interface{}
  28582. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28583. fmt.Println(dat)
  28584. } else {
  28585. fmt.Println(err)
  28586. }
  28587. saveLog(result2, src_resquest, "2207", "结算")
  28588. userJSONBytes, _ := json.Marshal(dat)
  28589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28590. utils.ErrorLog("解析失败:%v", err)
  28591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28592. return
  28593. }
  28594. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28595. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28596. var cert_no string
  28597. var card_sn string
  28598. if his.IdCardType == 1 {
  28599. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28600. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28601. //bas := strings.Split(psn_info.CardInfo, "|")
  28602. card_sn = ""
  28603. } else if his.IdCardType == 2 {
  28604. cert_no = his.IdCardNo
  28605. } else {
  28606. cert_no = psn_info.VerifyNumber
  28607. }
  28608. var rf []*ResultFive
  28609. json.Unmarshal([]byte(his.Iinfo), &rf)
  28610. var psn_type string
  28611. for _, item := range rf {
  28612. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28613. psn_type = item.PsnType
  28614. }
  28615. }
  28616. 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)
  28617. var dat map[string]interface{}
  28618. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28619. fmt.Println(dat)
  28620. } else {
  28621. fmt.Println(err)
  28622. }
  28623. saveLog(result2, src_resquest, "2207", "结算")
  28624. userJSONBytes, _ := json.Marshal(dat)
  28625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28626. utils.ErrorLog("解析失败:%v", err)
  28627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28628. return
  28629. }
  28630. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28631. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28632. var cert_no string
  28633. var card_sn string
  28634. if his.IdCardType == 1 {
  28635. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28636. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28637. //bas := strings.Split(psn_info.CardInfo, "|")
  28638. card_sn = ""
  28639. } else if his.IdCardType == 2 {
  28640. cert_no = his.IdCardNo
  28641. } else {
  28642. cert_no = psn_info.VerifyNumber
  28643. }
  28644. var rf []*ResultFive
  28645. json.Unmarshal([]byte(his.Iinfo), &rf)
  28646. var psn_type string
  28647. for _, item := range rf {
  28648. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28649. psn_type = item.PsnType
  28650. }
  28651. }
  28652. 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)
  28653. var dat map[string]interface{}
  28654. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28655. fmt.Println(dat)
  28656. } else {
  28657. fmt.Println(err)
  28658. }
  28659. saveLog(result2, src_resquest, "2207", "结算")
  28660. userJSONBytes, _ := json.Marshal(dat)
  28661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28662. utils.ErrorLog("解析失败:%v", err)
  28663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28664. return
  28665. }
  28666. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28667. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28668. if his.IdCardType == 1 {
  28669. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28670. bas := strings.Split(psn_info.CardInfo, "|")
  28671. cert_no = bas[2]
  28672. } else if his.IdCardType == 3 {
  28673. cert_no = his.Certno
  28674. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28675. } else if his.IdCardType == 4 {
  28676. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28677. cert_no = psn_info.VerifyNumber
  28678. psn_info.VerifyNumber = psn_info.VerifyNumber
  28679. } else {
  28680. cert_no = his.Certno
  28681. psn_info.VerifyNumber = his.Certno
  28682. }
  28683. var api string
  28684. var med_type string
  28685. if his.Insutype == "390" {
  28686. if reg_type == 992102 {
  28687. med_type = "992102"
  28688. }
  28689. if reg_type == 1104 {
  28690. med_type = "1104"
  28691. }
  28692. if reg_type == 1104 {
  28693. med_type = "1104"
  28694. }
  28695. if reg_type == 140104 {
  28696. med_type = "140104"
  28697. }
  28698. if reg_type == 140201 {
  28699. med_type = "140201"
  28700. }
  28701. if reg_type == 14 {
  28702. med_type = "14"
  28703. }
  28704. } else if his.Insutype == "310" {
  28705. if reg_type == 1104 {
  28706. med_type = "1104"
  28707. }
  28708. if reg_type == 992102 {
  28709. med_type = "992102"
  28710. }
  28711. if reg_type == 140104 {
  28712. med_type = "140104"
  28713. }
  28714. if reg_type == 140201 {
  28715. med_type = "140201"
  28716. }
  28717. if reg_type == 14 {
  28718. med_type = "14"
  28719. }
  28720. }
  28721. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28722. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28723. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28725. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28726. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28727. "&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
  28728. resp, requestErr := http.Get(api)
  28729. if requestErr != nil {
  28730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28731. return
  28732. }
  28733. body, ioErr := ioutil.ReadAll(resp.Body)
  28734. if ioErr != nil {
  28735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28737. return
  28738. }
  28739. var respJSON map[string]interface{}
  28740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28743. return
  28744. }
  28745. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28746. if status == "0" {
  28747. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28748. c.ServeSuccessJSON(map[string]interface{}{
  28749. "failed_code": -10,
  28750. "msg": err_msg,
  28751. })
  28752. return
  28753. }
  28754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28755. result, _ := json.Marshal(respJSON)
  28756. fmt.Println("log")
  28757. fmt.Println(string(result))
  28758. if err := json.Unmarshal(result, &ahres); err != nil {
  28759. utils.ErrorLog("解析失败:%v", err)
  28760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28761. return
  28762. }
  28763. res.InfRefmsgid = ahres.InfRefmsgid
  28764. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28765. // 创建对应的Time类型
  28766. t := time.UnixMilli(timestamp)
  28767. // 格式化成指定的日期字符串
  28768. str := t.Format("2006-01-02 15:04:05")
  28769. res.Output.Setlinfo.SetlTime = str
  28770. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28771. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28772. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28773. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28774. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28775. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28776. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28777. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28778. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28779. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28780. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28781. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28782. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28783. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28784. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28785. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28786. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28787. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28788. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28789. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28790. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28791. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28792. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28793. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28794. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28795. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28796. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28797. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28798. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28799. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28800. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28801. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28802. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28803. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28804. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28805. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28806. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28807. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28808. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28809. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28810. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28811. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28812. res.Output.Setldetail = ahres.Output.Setldetail
  28813. res.ErrMsg = ahres.ErrMsg
  28814. res.Cainfo = ahres.Cainfo
  28815. res.WarnMsg = ahres.WarnMsg
  28816. res.Infcode = ahres.Infcode
  28817. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28818. res.Output.Setlinfo.ClrType = "11"
  28819. } else {
  28820. res.Output.Setlinfo.ClrType = "9903"
  28821. }
  28822. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28823. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28824. if his.IdCardType == 1 {
  28825. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28826. bas := strings.Split(psn_info.CardInfo, "|")
  28827. cert_no = bas[2]
  28828. } else if his.IdCardType == 3 {
  28829. cert_no = his.Certno
  28830. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28831. } else if his.IdCardType == 4 {
  28832. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28833. cert_no = his.Certno
  28834. psn_info.VerifyNumber = psn_info.VerifyNumber
  28835. } else {
  28836. cert_no = his.Certno
  28837. psn_info.VerifyNumber = his.Certno
  28838. }
  28839. var api string
  28840. var med_type string
  28841. if his.Insutype == "390" {
  28842. if reg_type == 1104 {
  28843. med_type = "1104"
  28844. }
  28845. if reg_type == 992102 {
  28846. med_type = "992102"
  28847. }
  28848. if reg_type == 140104 {
  28849. med_type = "140104"
  28850. }
  28851. if reg_type == 14 {
  28852. med_type = "14"
  28853. }
  28854. if reg_type == 140201 {
  28855. med_type = "140201"
  28856. }
  28857. } else if his.Insutype == "310" {
  28858. if reg_type == 1104 {
  28859. med_type = "1104"
  28860. }
  28861. if reg_type == 992102 {
  28862. med_type = "992102"
  28863. }
  28864. if reg_type == 14 {
  28865. med_type = "14"
  28866. }
  28867. if reg_type == 140104 {
  28868. med_type = "140104"
  28869. }
  28870. if reg_type == 140201 {
  28871. med_type = "140201"
  28872. }
  28873. }
  28874. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28875. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28876. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28878. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28879. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28880. "&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
  28881. resp, requestErr := http.Get(api)
  28882. if requestErr != nil {
  28883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28884. return
  28885. }
  28886. body, ioErr := ioutil.ReadAll(resp.Body)
  28887. if ioErr != nil {
  28888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28890. return
  28891. }
  28892. var respJSON map[string]interface{}
  28893. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28896. return
  28897. }
  28898. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28899. if status == "0" {
  28900. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28901. c.ServeSuccessJSON(map[string]interface{}{
  28902. "failed_code": -10,
  28903. "msg": err_msg,
  28904. })
  28905. return
  28906. }
  28907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28908. result, _ := json.Marshal(respJSON)
  28909. fmt.Println("log")
  28910. fmt.Println(string(result))
  28911. if err := json.Unmarshal(result, &ahres); err != nil {
  28912. utils.ErrorLog("解析失败:%v", err)
  28913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28914. return
  28915. }
  28916. res.InfRefmsgid = ahres.InfRefmsgid
  28917. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28918. // 创建对应的Time类型
  28919. t := time.UnixMilli(timestamp)
  28920. // 格式化成指定的日期字符串
  28921. str := t.Format("2006-01-02 15:04:05")
  28922. res.Output.Setlinfo.SetlTime = str
  28923. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28924. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28925. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28926. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28927. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28928. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28929. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28930. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28931. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28932. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28933. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28934. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28935. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28936. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28937. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28938. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28939. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28940. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28941. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28942. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28943. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28944. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28945. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28946. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28947. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28948. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28949. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28950. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28951. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28952. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28953. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28954. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28955. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28956. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28957. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28958. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28959. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28960. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28961. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28962. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28963. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28964. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28965. res.Output.Setldetail = ahres.Output.Setldetail
  28966. res.ErrMsg = ahres.ErrMsg
  28967. res.Cainfo = ahres.Cainfo
  28968. res.WarnMsg = ahres.WarnMsg
  28969. res.Infcode = ahres.Infcode
  28970. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28971. res.Output.Setlinfo.ClrType = "11"
  28972. } else {
  28973. res.Output.Setlinfo.ClrType = "9903"
  28974. }
  28975. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28976. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28977. var cert_no string
  28978. if his.IdCardType == 1 {
  28979. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28980. } else if his.IdCardType == 2 {
  28981. cert_no = his.IdCardNo
  28982. } else {
  28983. cert_no = psn_info.VerifyNumber
  28984. }
  28985. 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, "")
  28986. var dat map[string]interface{}
  28987. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28988. fmt.Println(dat)
  28989. } else {
  28990. fmt.Println(err)
  28991. }
  28992. saveLog(result2, src_resquest, "2207", "结算")
  28993. userJSONBytes, _ := json.Marshal(dat)
  28994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28995. utils.ErrorLog("解析失败:%v", err)
  28996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28997. return
  28998. }
  28999. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29000. psn_info, _ := service.GetPsnByPatientId(id)
  29001. var verify_number string
  29002. if psn_info.IdCardType == 4 {
  29003. verify_number = psn_info.VerifyNumber
  29004. } else if psn_info.IdCardType == 1 {
  29005. bas := strings.Split(psn_info.CardInfo, "|")
  29006. cardNumber := bas[2]
  29007. verify_number = cardNumber
  29008. } else {
  29009. verify_number = psn_info.Certno
  29010. psn_info.IdCardType = 2
  29011. }
  29012. var api string
  29013. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29014. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29015. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29016. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29017. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29018. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29019. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29020. resp, requestErr := http.Get(api)
  29021. if requestErr != nil {
  29022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29023. return
  29024. }
  29025. body, ioErr := ioutil.ReadAll(resp.Body)
  29026. if ioErr != nil {
  29027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29029. return
  29030. }
  29031. var respJSON map[string]interface{}
  29032. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29035. return
  29036. }
  29037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29038. result, _ := json.Marshal(respJSON)
  29039. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29040. utils.ErrorLog("解析失败:%v", err)
  29041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29042. return
  29043. }
  29044. } else {
  29045. var src_resquest string
  29046. if miConfig.Code == "H15049901371" {
  29047. //赤峰地区国家医保医疗类别
  29048. //职工透析:医疗类别选特殊情况门诊990502
  29049. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29050. var med_type string
  29051. if his.Insutype == "390" {
  29052. if reg_type == 14 {
  29053. med_type = "9933"
  29054. } else if reg_type == 11 {
  29055. med_type = "11"
  29056. }
  29057. } else if his.Insutype == "310" {
  29058. if reg_type == 14 {
  29059. med_type = "990502"
  29060. } else if reg_type == 11 {
  29061. med_type = "11"
  29062. }
  29063. }
  29064. 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)
  29065. } else {
  29066. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  29067. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29068. if result3101.Infcode == 0 {
  29069. if len(result3101.Output.Result) > 0 {
  29070. c.ServeSuccessJSON(map[string]interface{}{
  29071. "failed_code": -10,
  29072. "failed_type": 100,
  29073. "warm_type": 2,
  29074. "msg": result3101,
  29075. })
  29076. return
  29077. }
  29078. } else {
  29079. c.ServeSuccessJSON(map[string]interface{}{
  29080. "failed_code": -10,
  29081. "msg": result3101.ErrMsg,
  29082. })
  29083. return
  29084. }
  29085. }
  29086. if his.IdCardType == 4 {
  29087. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29088. token := psn_info.VerifyNumber
  29089. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token, admin_user_id)
  29090. } else {
  29091. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "", admin_user_id)
  29092. }
  29093. }
  29094. var dat map[string]interface{}
  29095. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29096. fmt.Println(dat)
  29097. } else {
  29098. fmt.Println(err)
  29099. }
  29100. saveLog(result2, src_resquest, "2207", "结算")
  29101. userJSONBytes, _ := json.Marshal(dat)
  29102. if miConfig.Code == "H15049901371" {
  29103. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29104. utils.ErrorLog("解析失败:%v", err)
  29105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29106. return
  29107. }
  29108. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29109. res.Output = resSeven10265.Output
  29110. res.ErrMsg = resSeven10265.ErrMsg
  29111. res.Cainfo = resSeven10265.Cainfo
  29112. res.WarnMsg = resSeven10265.WarnMsg
  29113. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29114. res.Infcode = infocode
  29115. } else {
  29116. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29117. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29118. utils.ErrorLog("解析失败:%v", err)
  29119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29120. return
  29121. }
  29122. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29123. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29124. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29125. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29126. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29127. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29128. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29129. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29130. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29131. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29132. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29133. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29134. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29135. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29136. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29137. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29138. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29139. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29140. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29141. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29142. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29143. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29144. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29145. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29146. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29147. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29148. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29149. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29150. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29151. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29152. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29153. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29154. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29155. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29156. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29157. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29158. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29159. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29160. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29161. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29162. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29163. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29164. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29165. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29166. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29167. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29168. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29169. res.Cainfo = gzresSeven10265Two.Cainfo
  29170. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29171. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29172. //res.Infcode = infocode
  29173. } else {
  29174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29175. utils.ErrorLog("解析失败:%v", err)
  29176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29177. return
  29178. }
  29179. }
  29180. }
  29181. }
  29182. if res.Infcode == -1 {
  29183. errlog := &models.HisOrderError{
  29184. UserOrgId: adminUser.CurrentOrgId,
  29185. Ctime: time.Now().Unix(),
  29186. Mtime: time.Now().Unix(),
  29187. Number: chrg_bchno,
  29188. ErrMsg: res.ErrMsg,
  29189. Status: 1,
  29190. PatientId: id,
  29191. RecordTime: recordDateTime,
  29192. Stage: 6,
  29193. }
  29194. service.CreateErrMsgLog(errlog)
  29195. c.ServeSuccessJSON(map[string]interface{}{
  29196. "failed_code": -10,
  29197. "msg": res.ErrMsg,
  29198. })
  29199. return
  29200. } else {
  29201. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29202. order.OrderStatus = 2
  29203. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29204. order.SetlId = res.Output.Setlinfo.SetlID
  29205. order.PsnNo = res.Output.Setlinfo.PsnNo
  29206. order.PsnName = res.Output.Setlinfo.PsnName
  29207. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29208. order.Certno = res.Output.Setlinfo.Certno
  29209. order.Gend = res.Output.Setlinfo.Gend
  29210. order.Naty = res.Output.Setlinfo.Naty
  29211. order.Age = res.Output.Setlinfo.Age
  29212. order.Insutype = res.Output.Setlinfo.Insutype
  29213. order.PsnType = res.Output.Setlinfo.PsnType
  29214. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29215. order.SetlTime = res.Output.Setlinfo.SetlTime
  29216. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29217. order.PayWays = pay_ways
  29218. order.AcctUsedFlag = acct_used_flag
  29219. order.WechatPay = wechat_pay
  29220. order.AliPay = ali_pay
  29221. order.JifenPay = jifen_pay
  29222. order.BandCardPay = band_card_pay
  29223. order.CashPay = cash_pay
  29224. order.OthDesc = oth_desc
  29225. //order.MedType = res.Output.Setlinfo.MedType
  29226. if reg_type == 1112 {
  29227. order.MedType = "1112"
  29228. }
  29229. if reg_type == 1111 {
  29230. order.MedType = "1111"
  29231. }
  29232. order.ClrType = res.Output.Setlinfo.ClrType
  29233. if adminUser.CurrentOrgId == 10480 {
  29234. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29235. order.ClrType = "11"
  29236. } else {
  29237. order.ClrType = "9903"
  29238. }
  29239. }
  29240. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29241. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29242. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29243. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29244. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29245. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29246. order.HifpPay = res.Output.Setlinfo.HifpPay
  29247. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29248. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29249. order.HifesPay = res.Output.Setlinfo.HifesPay
  29250. order.HifobPay = res.Output.Setlinfo.HifobPay
  29251. order.MafPay = res.Output.Setlinfo.MafPay
  29252. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29253. order.OthPay = res.Output.Setlinfo.OthPay
  29254. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29255. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29256. order.AcctPay = res.Output.Setlinfo.AcctPay
  29257. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29258. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29259. order.Balc = res.Output.Setlinfo.Balc
  29260. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29261. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29262. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29263. order.ClrWay = res.Output.Setlinfo.ClrWay
  29264. order.Creator = order.Creator
  29265. order.Modify = roles.AdminUserId
  29266. order.RequestLog = src_resquest
  29267. order.Diagnosis = diagnosis_id
  29268. order.FaPiaoNumber = fapiao_number
  29269. order.FaPiaoCode = fapiao_code
  29270. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29271. detailStr := string(setlDetail)
  29272. order.SetlDetail = detailStr
  29273. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29274. err = service.UpDateOrder(order)
  29275. if err == nil {
  29276. //判断是否使用了押金
  29277. if dec_way == "true" {
  29278. tmpstring := strconv.FormatInt(order.ID, 10)
  29279. //扣押金
  29280. order.Decimal = decimal
  29281. service.UpDateOrder(order)
  29282. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29283. if errmsg != nil {
  29284. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29285. return
  29286. }
  29287. }
  29288. c.ServeSuccessJSON(map[string]interface{}{
  29289. "msg": "结算成功",
  29290. })
  29291. } else {
  29292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29293. return
  29294. }
  29295. }
  29296. }
  29297. }
  29298. }
  29299. // 上传明细-预结算-
  29300. func (c *HisApiController) GetPreUploadInfo() {
  29301. id, _ := c.GetInt64("id")
  29302. record_time := c.GetString("record_time")
  29303. his_patient_id, _ := c.GetInt64("his_patient_id")
  29304. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29305. admin_user_id, _ := c.GetInt64("admin_user_id")
  29306. diagnosis_id := c.GetString("diagnosis")
  29307. sick_type, _ := c.GetInt64("sick_type")
  29308. reg_type, _ := c.GetInt64("p_type")
  29309. begin_time := c.GetString("begin_time")
  29310. acct_used_flag := c.GetString("acct_used_flag")
  29311. id_str := c.GetString("ids")
  29312. ids_arr := strings.Split(id_str, ",")
  29313. timeLayout := "2006-01-02"
  29314. loc, _ := time.LoadLocation("Local")
  29315. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29316. if err != nil {
  29317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29318. return
  29319. }
  29320. recordDateTime := theTime.Unix()
  29321. adminUser := c.GetAdminUserInfo()
  29322. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29323. var config []*models.HisXtDiagnoseConfig
  29324. for _, item := range diagnosis_ids {
  29325. id, _ := strconv.ParseInt(item, 10, 64)
  29326. if id > 0 {
  29327. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29328. config = append(config, &diagnosisConfig)
  29329. }
  29330. }
  29331. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29332. sickConfig, _ := service.FindSickById(sick_type)
  29333. var prescriptions []*models.HisPrescription
  29334. var start_time int64
  29335. var end_time int64
  29336. var isSuccess bool = true
  29337. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29338. fmt.Println(his_patient_id)
  29339. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29340. timestamp := time.Now().Unix()
  29341. tempTime := time.Unix(timestamp, 0)
  29342. timeFormat := tempTime.Format("20060102150405")
  29343. chrgBchno := rand.Intn(100000) + 10000
  29344. new_chrg_bchno := ""
  29345. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29346. new_chrg_bchno = chrg_bchno
  29347. if adminUser.CurrentOrgId == 10265 {
  29348. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29349. new_chrg_bchno = "0000"
  29350. }
  29351. }
  29352. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29353. var patientPrescription models.HisPrescriptionInfo
  29354. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29355. if patientPrescription.ID == 0 {
  29356. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29357. }
  29358. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29359. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29360. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29361. strconv.FormatInt(his.PatientId, 10)
  29362. var res2406 Result2406
  29363. //安徽单病种处理
  29364. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29365. data := make(map[string]interface{})
  29366. client := &http.Client{}
  29367. data["psn_no"] = his.PsnNo
  29368. data["mdtrt_id"] = his.Number
  29369. data["operator"] = roles.UserName
  29370. data["cert_no"] = his.IdCardNo
  29371. data["org_name"] = miConfig.OrgName
  29372. data["psn_name"] = his.Name
  29373. data["ipt_otp_no"] = his.IptOtpNo
  29374. data["ipt_psn_sp_flag_type"] = "0901"
  29375. data["ipt_psn_sp_flag"] = "1"
  29376. data["fixmedins_code"] = miConfig.Code
  29377. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29378. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29379. data["url"] = miConfig.Url
  29380. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29381. bytesData, _ := json.Marshal(data)
  29382. var req *http.Request
  29383. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29384. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29385. resp, _ := client.Do(req)
  29386. defer resp.Body.Close()
  29387. body, ioErr := ioutil.ReadAll(resp.Body)
  29388. if ioErr != nil {
  29389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29391. return
  29392. }
  29393. var respJSON map[string]interface{}
  29394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29397. return
  29398. }
  29399. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29400. if status == "0" {
  29401. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29402. c.ServeSuccessJSON(map[string]interface{}{
  29403. "failed_code": -10,
  29404. "msg": err_msg,
  29405. })
  29406. return
  29407. }
  29408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29409. userJSONBytes, _ := json.Marshal(respJSON)
  29410. fmt.Println("log")
  29411. fmt.Println(string(userJSONBytes))
  29412. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29413. utils.ErrorLog("解析失败:%v", err)
  29414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29415. return
  29416. }
  29417. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29418. data := make(map[string]interface{})
  29419. client := &http.Client{}
  29420. data["psn_no"] = his.PsnNo
  29421. data["mdtrt_id"] = his.Number
  29422. data["operator"] = roles.UserName
  29423. data["cert_no"] = his.IdCardNo
  29424. data["org_name"] = miConfig.OrgName
  29425. data["psn_name"] = his.Name
  29426. data["ipt_otp_no"] = his.IptOtpNo
  29427. data["ipt_psn_sp_flag_type"] = "0901"
  29428. data["ipt_psn_sp_flag"] = "1"
  29429. data["fixmedins_code"] = miConfig.Code
  29430. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29431. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29432. data["url"] = miConfig.Url
  29433. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29434. bytesData, _ := json.Marshal(data)
  29435. var req *http.Request
  29436. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29437. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29438. resp, _ := client.Do(req)
  29439. defer resp.Body.Close()
  29440. body, ioErr := ioutil.ReadAll(resp.Body)
  29441. if ioErr != nil {
  29442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29444. return
  29445. }
  29446. var respJSON map[string]interface{}
  29447. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29450. return
  29451. }
  29452. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29453. if status == "0" {
  29454. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29455. c.ServeSuccessJSON(map[string]interface{}{
  29456. "failed_code": -10,
  29457. "msg": err_msg,
  29458. })
  29459. return
  29460. }
  29461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29462. userJSONBytes, _ := json.Marshal(respJSON)
  29463. fmt.Println("log")
  29464. fmt.Println(string(userJSONBytes))
  29465. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29466. utils.ErrorLog("解析失败:%v", err)
  29467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29468. return
  29469. }
  29470. }
  29471. if res2406.Infcode != 0 {
  29472. adminUser := c.GetAdminUserInfo()
  29473. errlog := &models.HisOrderError{
  29474. UserOrgId: adminUser.CurrentOrgId,
  29475. Ctime: time.Now().Unix(),
  29476. Mtime: time.Now().Unix(),
  29477. ErrMsg: res2406.ErrMsg,
  29478. Status: 1,
  29479. PatientId: id,
  29480. RecordTime: recordDateTime,
  29481. Stage: 3,
  29482. }
  29483. service.CreateErrMsgLog(errlog)
  29484. c.ServeSuccessJSON(map[string]interface{}{
  29485. "failed_code": -10,
  29486. "msg": res2406.ErrMsg,
  29487. })
  29488. return
  29489. }
  29490. var res2 ResultSix
  29491. var res3 GZResultSix
  29492. var resSix10265 ResultSix10265
  29493. //var time_stamp string
  29494. if miConfig.MdtrtareaAdmvs == "421300" {
  29495. data := make(map[string]interface{})
  29496. client := &http.Client{}
  29497. data["psn_no"] = his.PsnNo
  29498. data["mdtrt_id"] = his.Number
  29499. data["department"] = department.Name
  29500. data["org_name"] = miConfig.OrgName
  29501. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29502. data["doctor_id"] = doctor_info.DoctorNumber
  29503. data["doctor_name"] = roles.UserName
  29504. data["fixmedins_code"] = miConfig.Code
  29505. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29506. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29507. data["secret_key"] = miConfig.SecretKey
  29508. data["sick_code"] = sickConfig.CountryCode
  29509. data["sick_name"] = sickConfig.ClassName
  29510. data["begin_time"] = begin_time
  29511. data["dept"] = strconv.FormatInt(department.ID, 10)
  29512. data["config"] = config
  29513. data["opter"] = roles.UserName
  29514. fmt.Println(data)
  29515. bytesData, _ := json.Marshal(data)
  29516. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29517. resp, _ := client.Do(req)
  29518. defer resp.Body.Close()
  29519. body, ioErr := ioutil.ReadAll(resp.Body)
  29520. if ioErr != nil {
  29521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29523. return
  29524. }
  29525. var respJSON map[string]interface{}
  29526. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29529. return
  29530. }
  29531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29532. userJSONBytes, _ := json.Marshal(respJSON)
  29533. fmt.Println("log")
  29534. fmt.Println(string(userJSONBytes))
  29535. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29536. utils.ErrorLog("解析失败:%v", err)
  29537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29538. return
  29539. }
  29540. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29541. data := make(map[string]interface{})
  29542. client := &http.Client{}
  29543. data["psn_no"] = his.PsnNo
  29544. data["mdtrt_id"] = his.Number
  29545. data["department"] = department.Name
  29546. data["org_name"] = miConfig.OrgName
  29547. if reg_type == 11 && his.Insutype == "390" {
  29548. data["med_type"] = "110104"
  29549. } else {
  29550. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29551. }
  29552. data["doctor_id"] = doctor_info.DoctorNumber
  29553. data["doctor_name"] = roles.UserName
  29554. data["fixmedins_code"] = miConfig.Code
  29555. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29556. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29557. data["secret_key"] = miConfig.SecretKey
  29558. data["sick_code"] = sickConfig.CountryCode
  29559. data["sick_name"] = sickConfig.ClassName
  29560. data["begin_time"] = begin_time
  29561. data["dept"] = strconv.FormatInt(department.ID, 10)
  29562. data["config"] = config
  29563. data["opter"] = roles.UserName
  29564. fmt.Println(data)
  29565. bytesData, _ := json.Marshal(data)
  29566. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29567. resp, _ := client.Do(req)
  29568. defer resp.Body.Close()
  29569. body, ioErr := ioutil.ReadAll(resp.Body)
  29570. if ioErr != nil {
  29571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29573. return
  29574. }
  29575. var respJSON map[string]interface{}
  29576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29579. return
  29580. }
  29581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29582. userJSONBytes, _ := json.Marshal(respJSON)
  29583. fmt.Println("log")
  29584. fmt.Println(string(userJSONBytes))
  29585. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29586. utils.ErrorLog("解析失败:%v", err)
  29587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29588. return
  29589. }
  29590. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29591. data := make(map[string]interface{})
  29592. client := &http.Client{}
  29593. data["psn_no"] = his.PsnNo
  29594. data["mdtrt_id"] = his.Number
  29595. data["department"] = department.Name
  29596. data["org_name"] = miConfig.OrgName
  29597. if reg_type == 11 && his.Insutype == "390" {
  29598. data["med_type"] = "110104"
  29599. } else {
  29600. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29601. }
  29602. data["doctor_id"] = doctor_info.DoctorNumber
  29603. data["doctor_name"] = roles.UserName
  29604. data["fixmedins_code"] = miConfig.Code
  29605. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29606. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29607. data["secret_key"] = miConfig.SecretKey
  29608. data["sick_code"] = sickConfig.CountryCode
  29609. data["sick_name"] = sickConfig.ClassName
  29610. data["begin_time"] = begin_time
  29611. data["dept"] = strconv.FormatInt(department.ID, 10)
  29612. data["config"] = config
  29613. data["opter"] = roles.UserName
  29614. fmt.Println(data)
  29615. bytesData, _ := json.Marshal(data)
  29616. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29617. resp, _ := client.Do(req)
  29618. defer resp.Body.Close()
  29619. body, ioErr := ioutil.ReadAll(resp.Body)
  29620. if ioErr != nil {
  29621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29623. return
  29624. }
  29625. var respJSON map[string]interface{}
  29626. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29629. return
  29630. }
  29631. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29632. userJSONBytes, _ := json.Marshal(respJSON)
  29633. fmt.Println("log")
  29634. fmt.Println(string(userJSONBytes))
  29635. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29636. utils.ErrorLog("解析失败:%v", err)
  29637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29638. return
  29639. }
  29640. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29641. data := make(map[string]interface{})
  29642. client := &http.Client{}
  29643. data["psn_no"] = his.PsnNo
  29644. data["mdtrt_id"] = his.Number
  29645. data["department"] = department.Name
  29646. data["org_name"] = miConfig.OrgName
  29647. if reg_type == 11 && his.Insutype == "390" {
  29648. data["med_type"] = "110104"
  29649. } else {
  29650. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29651. }
  29652. data["doctor_id"] = doctor_info.DoctorNumber
  29653. data["doctor_name"] = roles.UserName
  29654. data["fixmedins_code"] = miConfig.Code
  29655. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29656. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29657. data["secret_key"] = miConfig.SecretKey
  29658. data["sick_code"] = sickConfig.CountryCode
  29659. data["sick_name"] = sickConfig.ClassName
  29660. data["begin_time"] = begin_time
  29661. data["dept"] = strconv.FormatInt(department.ID, 10)
  29662. data["config"] = config
  29663. data["opter"] = roles.UserName
  29664. fmt.Println(data)
  29665. bytesData, _ := json.Marshal(data)
  29666. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29667. resp, _ := client.Do(req)
  29668. defer resp.Body.Close()
  29669. body, ioErr := ioutil.ReadAll(resp.Body)
  29670. if ioErr != nil {
  29671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29673. return
  29674. }
  29675. var respJSON map[string]interface{}
  29676. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29679. return
  29680. }
  29681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29682. userJSONBytes, _ := json.Marshal(respJSON)
  29683. fmt.Println("log")
  29684. fmt.Println(string(userJSONBytes))
  29685. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29686. utils.ErrorLog("解析失败:%v", err)
  29687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29688. return
  29689. }
  29690. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29691. data := make(map[string]interface{})
  29692. client := &http.Client{}
  29693. data["psn_no"] = his.PsnNo
  29694. data["mdtrt_id"] = his.Number
  29695. data["doctor"] = roles.UserName
  29696. data["department"] = department.Name
  29697. data["org_name"] = miConfig.OrgName
  29698. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29699. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29700. data["fixmedins_code"] = miConfig.Code
  29701. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29702. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29703. data["secret_key"] = miConfig.SecretKey
  29704. data["sick_code"] = sickConfig.CountryCode
  29705. data["sick_name"] = sickConfig.ClassName
  29706. data["begin_time"] = begin_time
  29707. data["dept"] = strconv.FormatInt(department.ID, 10)
  29708. data["config"] = config
  29709. data["url"] = miConfig.Url
  29710. data["ak"] = miConfig.AccessKey
  29711. data["cainfo"] = miConfig.Cainfo
  29712. bytesData, _ := json.Marshal(data)
  29713. var req *http.Request
  29714. if miConfig.MdtrtareaAdmvs == "320830" {
  29715. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29716. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29717. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29718. } else {
  29719. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29720. }
  29721. resp, _ := client.Do(req)
  29722. defer resp.Body.Close()
  29723. body, ioErr := ioutil.ReadAll(resp.Body)
  29724. if ioErr != nil {
  29725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29727. return
  29728. }
  29729. var respJSON map[string]interface{}
  29730. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29733. return
  29734. }
  29735. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29736. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29737. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29739. userJSONBytes, _ := json.Marshal(respJSON)
  29740. fmt.Println("log")
  29741. fmt.Println(string(userJSONBytes))
  29742. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29743. utils.ErrorLog("解析失败:%v", err)
  29744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29745. return
  29746. }
  29747. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29748. res2.Output = resSix10265.Output
  29749. res2.ErrMsg = resSix10265.ErrMsg
  29750. res2.Cainfo = resSix10265.Cainfo
  29751. res2.WarnMsg = resSix10265.WarnMsg
  29752. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29753. res2.Infcode = infocode
  29754. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29755. data := make(map[string]interface{})
  29756. client := &http.Client{}
  29757. data["psn_no"] = his.PsnNo
  29758. data["mdtrt_id"] = his.Number
  29759. data["doctor"] = roles.UserName
  29760. data["department"] = department.Name
  29761. data["org_name"] = miConfig.OrgName
  29762. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29763. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29764. data["fixmedins_code"] = miConfig.Code
  29765. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29766. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29767. data["secret_key"] = miConfig.SecretKey
  29768. data["sick_code"] = sickConfig.CountryCode
  29769. data["sick_name"] = sickConfig.ClassName
  29770. data["begin_time"] = begin_time
  29771. data["dept"] = strconv.FormatInt(department.ID, 10)
  29772. data["config"] = config
  29773. //data["url"] = miConfig.Url
  29774. //data["ak"] = miConfig.AccessKey
  29775. data["cainfo"] = miConfig.Cainfo
  29776. fmt.Println(data)
  29777. bytesData, _ := json.Marshal(data)
  29778. var req *http.Request
  29779. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29780. resp, _ := client.Do(req)
  29781. defer resp.Body.Close()
  29782. body, ioErr := ioutil.ReadAll(resp.Body)
  29783. if ioErr != nil {
  29784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29786. return
  29787. }
  29788. var respJSON map[string]interface{}
  29789. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29792. return
  29793. }
  29794. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29795. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29796. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29798. userJSONBytes, _ := json.Marshal(respJSON)
  29799. fmt.Println("log")
  29800. fmt.Println(string(userJSONBytes))
  29801. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29802. utils.ErrorLog("解析失败:%v", err)
  29803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29804. return
  29805. }
  29806. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29807. res2.Output = resSix10265.Output
  29808. res2.ErrMsg = resSix10265.ErrMsg
  29809. res2.Cainfo = resSix10265.Cainfo
  29810. res2.WarnMsg = resSix10265.WarnMsg
  29811. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29812. res2.Infcode = infocode
  29813. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29814. 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)
  29815. saveLog(result, requestLog, "2203", "上传就诊信息")
  29816. var respJSON2 map[string]interface{}
  29817. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29820. return
  29821. }
  29822. userJSONBytes2, _ := json.Marshal(respJSON2)
  29823. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29824. utils.ErrorLog("解析失败:%v", err)
  29825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29826. return
  29827. }
  29828. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29829. var result string
  29830. var requestLog string
  29831. 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, "")
  29832. saveLog(result, requestLog, "2203", "上传就诊信息")
  29833. var respJSON2 map[string]interface{}
  29834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29837. return
  29838. }
  29839. userJSONBytes2, _ := json.Marshal(respJSON2)
  29840. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29841. utils.ErrorLog("解析失败:%v", err)
  29842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29843. return
  29844. }
  29845. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29846. var result string
  29847. var requestLog string
  29848. 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, "")
  29849. saveLog(result, requestLog, "2203", "上传就诊信息")
  29850. var respJSON2 map[string]interface{}
  29851. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29854. return
  29855. }
  29856. userJSONBytes2, _ := json.Marshal(respJSON2)
  29857. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29858. utils.ErrorLog("解析失败:%v", err)
  29859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29860. return
  29861. }
  29862. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29863. var result string
  29864. var requestLog string
  29865. 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, "")
  29866. saveLog(result, requestLog, "2203", "上传就诊信息")
  29867. var respJSON2 map[string]interface{}
  29868. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29871. return
  29872. }
  29873. userJSONBytes2, _ := json.Marshal(respJSON2)
  29874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29875. utils.ErrorLog("解析失败:%v", err)
  29876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29877. return
  29878. }
  29879. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29880. data := make(map[string]interface{})
  29881. client := &http.Client{}
  29882. data["psn_no"] = his.PsnNo
  29883. data["mdtrt_id"] = his.Number
  29884. data["operator"] = roles.UserName
  29885. data["department"] = department.Name
  29886. data["org_name"] = miConfig.OrgName
  29887. var med_type string
  29888. if his.Insutype == "390" {
  29889. if reg_type == 992102 {
  29890. med_type = "992102"
  29891. data["sick_code"] = "ZDZ940"
  29892. data["sick_name"] = "慢性肾衰竭"
  29893. }
  29894. if reg_type == 140104 {
  29895. med_type = "140104"
  29896. data["sick_code"] = sickConfig.CountryCode
  29897. data["sick_name"] = sickConfig.ClassName
  29898. }
  29899. if reg_type == 14 {
  29900. med_type = "140104"
  29901. data["sick_code"] = sickConfig.CountryCode
  29902. data["sick_name"] = sickConfig.ClassName
  29903. }
  29904. if reg_type == 1104 {
  29905. med_type = "1104"
  29906. data["sick_code"] = sickConfig.CountryCode
  29907. data["sick_name"] = sickConfig.ClassName
  29908. }
  29909. } else if his.Insutype == "310" {
  29910. if reg_type == 992102 {
  29911. med_type = "992102"
  29912. data["sick_code"] = "ZDZ940"
  29913. data["sick_name"] = "慢性肾衰竭"
  29914. }
  29915. if reg_type == 140104 {
  29916. med_type = "140104"
  29917. data["sick_code"] = sickConfig.CountryCode
  29918. data["sick_name"] = sickConfig.ClassName
  29919. }
  29920. if reg_type == 14 {
  29921. med_type = "14"
  29922. data["sick_code"] = sickConfig.CountryCode
  29923. data["sick_name"] = sickConfig.ClassName
  29924. }
  29925. if reg_type == 1104 {
  29926. med_type = "1104"
  29927. data["sick_code"] = sickConfig.CountryCode
  29928. data["sick_name"] = sickConfig.ClassName
  29929. }
  29930. }
  29931. data["med_type"] = med_type
  29932. data["doctor_number"] = doctor_info.DoctorNumber
  29933. data["doctor_name"] = doctor_info.UserName
  29934. data["fixmedins_code"] = miConfig.Code
  29935. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29936. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29937. data["secret_key"] = miConfig.SecretKey
  29938. data["begin_time"] = begin_time
  29939. data["dept"] = strconv.FormatInt(department.ID, 10)
  29940. data["config"] = config
  29941. data["url"] = miConfig.Url
  29942. data["ak"] = miConfig.AccessKey
  29943. data["cainfo"] = miConfig.Cainfo
  29944. bytesData, _ := json.Marshal(data)
  29945. var req *http.Request
  29946. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29947. resp, _ := client.Do(req)
  29948. defer resp.Body.Close()
  29949. body, ioErr := ioutil.ReadAll(resp.Body)
  29950. if ioErr != nil {
  29951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29953. return
  29954. }
  29955. var respJSON map[string]interface{}
  29956. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29959. return
  29960. }
  29961. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29962. if status == "0" {
  29963. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29964. c.ServeSuccessJSON(map[string]interface{}{
  29965. "failed_code": -10,
  29966. "msg": err_msg,
  29967. })
  29968. return
  29969. }
  29970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29971. userJSONBytes, _ := json.Marshal(respJSON)
  29972. fmt.Println("log")
  29973. fmt.Println(string(userJSONBytes))
  29974. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29975. utils.ErrorLog("解析失败:%v", err)
  29976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29977. return
  29978. }
  29979. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29980. data := make(map[string]interface{})
  29981. client := &http.Client{}
  29982. data["psn_no"] = his.PsnNo
  29983. data["mdtrt_id"] = his.Number
  29984. data["operator"] = roles.UserName
  29985. data["department"] = department.Name
  29986. data["org_name"] = miConfig.OrgName
  29987. var med_type string
  29988. if his.Insutype == "390" {
  29989. if reg_type == 992102 {
  29990. med_type = "992102"
  29991. data["sick_code"] = sickConfig.CountryCode
  29992. data["sick_name"] = sickConfig.ClassName
  29993. }
  29994. if reg_type == 140104 {
  29995. med_type = "140104"
  29996. data["sick_code"] = sickConfig.CountryCode
  29997. data["sick_name"] = sickConfig.ClassName
  29998. }
  29999. if reg_type == 140201 {
  30000. med_type = "140201"
  30001. data["sick_code"] = sickConfig.CountryCode
  30002. data["sick_name"] = sickConfig.ClassName
  30003. }
  30004. if reg_type == 14 {
  30005. med_type = "14"
  30006. data["sick_code"] = sickConfig.CountryCode
  30007. data["sick_name"] = sickConfig.ClassName
  30008. }
  30009. if reg_type == 11 {
  30010. med_type = "11"
  30011. data["sick_code"] = sickConfig.CountryCode
  30012. data["sick_name"] = sickConfig.ClassName
  30013. }
  30014. } else if his.Insutype == "310" {
  30015. if reg_type == 992102 {
  30016. med_type = "992102"
  30017. data["sick_code"] = sickConfig.CountryCode
  30018. data["sick_name"] = sickConfig.ClassName
  30019. }
  30020. if reg_type == 140104 {
  30021. med_type = "140104"
  30022. data["sick_code"] = sickConfig.CountryCode
  30023. data["sick_name"] = sickConfig.ClassName
  30024. }
  30025. if reg_type == 140201 {
  30026. med_type = "140201"
  30027. data["sick_code"] = sickConfig.CountryCode
  30028. data["sick_name"] = sickConfig.ClassName
  30029. }
  30030. if reg_type == 14 {
  30031. med_type = "14"
  30032. data["sick_code"] = sickConfig.CountryCode
  30033. data["sick_name"] = sickConfig.ClassName
  30034. }
  30035. if reg_type == 11 {
  30036. med_type = "11"
  30037. data["sick_code"] = sickConfig.CountryCode
  30038. data["sick_name"] = sickConfig.ClassName
  30039. }
  30040. }
  30041. data["med_type"] = med_type
  30042. data["doctor_number"] = doctor_info.DoctorNumber
  30043. data["doctor_name"] = doctor_info.UserName
  30044. data["fixmedins_code"] = miConfig.Code
  30045. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30046. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30047. data["secret_key"] = miConfig.SecretKey
  30048. data["begin_time"] = begin_time
  30049. data["dept"] = strconv.FormatInt(department.ID, 10)
  30050. data["config"] = config
  30051. data["url"] = miConfig.Url
  30052. data["ak"] = miConfig.AccessKey
  30053. data["cainfo"] = miConfig.Cainfo
  30054. bytesData, _ := json.Marshal(data)
  30055. var req *http.Request
  30056. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30057. resp, _ := client.Do(req)
  30058. defer resp.Body.Close()
  30059. body, ioErr := ioutil.ReadAll(resp.Body)
  30060. if ioErr != nil {
  30061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30063. return
  30064. }
  30065. var respJSON map[string]interface{}
  30066. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30069. return
  30070. }
  30071. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30072. if status == "0" {
  30073. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30074. c.ServeSuccessJSON(map[string]interface{}{
  30075. "failed_code": -10,
  30076. "msg": err_msg,
  30077. })
  30078. return
  30079. }
  30080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30081. userJSONBytes, _ := json.Marshal(respJSON)
  30082. fmt.Println("log")
  30083. fmt.Println(string(userJSONBytes))
  30084. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30085. utils.ErrorLog("解析失败:%v", err)
  30086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30087. return
  30088. }
  30089. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30090. var result string
  30091. var requestLog string
  30092. result, requestLog = service.Hnyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "", begin_time)
  30093. saveLog(result, requestLog, "2203", "上传就诊信息")
  30094. var respJSON2 map[string]interface{}
  30095. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30098. return
  30099. }
  30100. userJSONBytes2, _ := json.Marshal(respJSON2)
  30101. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30102. utils.ErrorLog("解析失败:%v", err)
  30103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30104. return
  30105. }
  30106. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30107. data := make(map[string]interface{})
  30108. client := &http.Client{}
  30109. data["psn_no"] = his.PsnNo
  30110. data["mdtrt_id"] = his.Number
  30111. data["doctor"] = roles.UserName
  30112. data["department"] = department.Name
  30113. data["org_name"] = miConfig.OrgName
  30114. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30115. data["doctor_id"] = doctor_info.DoctorNumber
  30116. data["fixmedins_code"] = miConfig.Code
  30117. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30118. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30119. data["secret_key"] = miConfig.SecretKey
  30120. data["sick_code"] = sickConfig.CountryCode
  30121. data["sick_name"] = sickConfig.ClassName
  30122. data["begin_time"] = begin_time
  30123. data["new_doctor_name"] = doctor_info.UserName
  30124. data["dept"] = strconv.FormatInt(department.ID, 10)
  30125. data["config"] = config
  30126. bytesData, _ := json.Marshal(data)
  30127. var req *http.Request
  30128. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30129. resp, _ := client.Do(req)
  30130. defer resp.Body.Close()
  30131. body, ioErr := ioutil.ReadAll(resp.Body)
  30132. if ioErr != nil {
  30133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30135. return
  30136. }
  30137. var respJSON map[string]interface{}
  30138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30141. return
  30142. }
  30143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30144. userJSONBytes, _ := json.Marshal(respJSON)
  30145. fmt.Println("log")
  30146. fmt.Println(string(userJSONBytes))
  30147. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30148. utils.ErrorLog("解析失败:%v", err)
  30149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30150. return
  30151. }
  30152. } else {
  30153. var result string
  30154. var requestLog string
  30155. if miConfig.MdtrtareaAdmvs == "440781" { //
  30156. 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)
  30157. } else {
  30158. if miConfig.Code == "H15049901371" {
  30159. //赤峰地区国家医保医疗类别
  30160. //职工透析:医疗类别选特殊情况门诊990502
  30161. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30162. var med_type string
  30163. if his.Insutype == "390" {
  30164. if reg_type == 14 {
  30165. med_type = "9933"
  30166. } else if reg_type == 11 {
  30167. med_type = "11"
  30168. }
  30169. } else if his.Insutype == "310" {
  30170. if reg_type == 14 {
  30171. med_type = "990502"
  30172. } else if reg_type == 11 {
  30173. med_type = "11"
  30174. }
  30175. }
  30176. 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)
  30177. } else {
  30178. 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)
  30179. }
  30180. saveLog(result, requestLog, "2203", "上传就诊信息")
  30181. var respJSON2 map[string]interface{}
  30182. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30185. return
  30186. }
  30187. userJSONBytes2, _ := json.Marshal(respJSON2)
  30188. if miConfig.Code == "H15049901371" {
  30189. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30190. utils.ErrorLog("解析失败:%v", err)
  30191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30192. return
  30193. }
  30194. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30195. res2.Output = resSix10265.Output
  30196. res2.ErrMsg = resSix10265.ErrMsg
  30197. res2.Cainfo = resSix10265.Cainfo
  30198. res2.WarnMsg = resSix10265.WarnMsg
  30199. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30200. res2.Infcode = infocode
  30201. } else {
  30202. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30203. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30204. utils.ErrorLog("解析失败:%v", err)
  30205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30206. return
  30207. }
  30208. res2.Infcode = res3.Infcode
  30209. } else {
  30210. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30211. utils.ErrorLog("解析失败:%v", err)
  30212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30213. return
  30214. }
  30215. }
  30216. }
  30217. }
  30218. }
  30219. if res2.Infcode == -1 {
  30220. adminUser := c.GetAdminUserInfo()
  30221. errlog := &models.HisOrderError{
  30222. UserOrgId: adminUser.CurrentOrgId,
  30223. Ctime: time.Now().Unix(),
  30224. Mtime: time.Now().Unix(),
  30225. ErrMsg: res2.ErrMsg,
  30226. Status: 1,
  30227. PatientId: id,
  30228. RecordTime: recordDateTime,
  30229. Stage: 3,
  30230. }
  30231. service.CreateErrMsgLog(errlog)
  30232. c.ServeSuccessJSON(map[string]interface{}{
  30233. "failed_code": -10,
  30234. "msg": res2.ErrMsg,
  30235. })
  30236. return
  30237. }
  30238. if res2.Infcode != 0 {
  30239. adminUser := c.GetAdminUserInfo()
  30240. errlog := &models.HisOrderError{
  30241. UserOrgId: adminUser.CurrentOrgId,
  30242. Ctime: time.Now().Unix(),
  30243. Mtime: time.Now().Unix(),
  30244. ErrMsg: res2.ErrMsg,
  30245. Status: 1,
  30246. PatientId: id,
  30247. RecordTime: recordDateTime,
  30248. Stage: 3,
  30249. }
  30250. service.CreateErrMsgLog(errlog)
  30251. c.ServeSuccessJSON(map[string]interface{}{
  30252. "failed_code": -10,
  30253. "msg": res2.ErrMsg,
  30254. })
  30255. return
  30256. } else {
  30257. his.Diagnosis = diagnosis_id
  30258. his.SickType = sickConfig.ID
  30259. his.PType = fmt.Sprintf("%d", reg_type)
  30260. service.UpdateHisPatientThree(&his)
  30261. data := make(map[string]interface{})
  30262. if settle_accounts_type == 1 { //日结
  30263. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30264. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30265. } else {
  30266. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30267. }
  30268. data["pre"] = prescriptions
  30269. } else { //月结
  30270. start_time_str := c.GetString("start_time")
  30271. end_time_str := c.GetString("end_time")
  30272. timeLayout := "2006-01-02"
  30273. loc, _ := time.LoadLocation("Local")
  30274. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30275. if err != nil {
  30276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30277. return
  30278. }
  30279. recordStartTime := theStartTime.Unix()
  30280. start_time = recordStartTime
  30281. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30282. if err != nil {
  30283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30284. return
  30285. }
  30286. recordEndTime := theEndTime.Unix()
  30287. end_time = recordEndTime
  30288. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30289. data["pre"] = prescriptions
  30290. }
  30291. client := &http.Client{}
  30292. data["psn_no"] = his.PsnNo
  30293. data["mdtrt_id"] = his.Number
  30294. data["chrg_bchno"] = new_chrg_bchno
  30295. data["org_name"] = miConfig.OrgName
  30296. data["doctor"] = doctor_info.UserName
  30297. data["doctor_id"] = doctor_info.DoctorNumber
  30298. data["dept"] = department.Name
  30299. data["fixmedins_code"] = miConfig.Code
  30300. data["opter"] = roles.UserName
  30301. data["dept_code"] = department.Number
  30302. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30303. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30304. data["secret_key"] = miConfig.SecretKey
  30305. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30306. data["url"] = miConfig.Url
  30307. data["ak"] = miConfig.AccessKey
  30308. data["new_doctor_name"] = patientPrescription.Doctor
  30309. if his.Insutype == "390" {
  30310. if reg_type == 992102 {
  30311. data["diag_code"] = "ZDZ940"
  30312. }
  30313. if reg_type == 140104 {
  30314. data["diag_code"] = sickConfig.CountryCode
  30315. }
  30316. if reg_type == 140201 {
  30317. data["diag_code"] = sickConfig.CountryCode
  30318. }
  30319. if reg_type == 14 {
  30320. data["diag_code"] = sickConfig.CountryCode
  30321. }
  30322. if reg_type == 1104 {
  30323. data["diag_code"] = sickConfig.CountryCode
  30324. }
  30325. } else if his.Insutype == "310" {
  30326. if miConfig.MdtrtareaAdmvs == "341203" {
  30327. if reg_type == 992102 {
  30328. data["diag_code"] = "ZDZ940"
  30329. }
  30330. if reg_type != 992102 {
  30331. data["diag_code"] = sickConfig.CountryCode
  30332. }
  30333. } else {
  30334. data["diag_code"] = sickConfig.CountryCode
  30335. }
  30336. }
  30337. data["cainfo"] = miConfig.Cainfo
  30338. data["opter"] = roles.UserName
  30339. var ids []int64
  30340. for _, item := range prescriptions {
  30341. ids = append(ids, item.ID)
  30342. }
  30343. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30344. if config.IsOpen == 1 { //对接了医保,走医保流程
  30345. var res ResultFour
  30346. var resFour10265 ResultFour10265
  30347. if miConfig.MdtrtareaAdmvs == "421300" {
  30348. bytesData, _ := json.Marshal(data)
  30349. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30350. resp, _ := client.Do(req)
  30351. defer resp.Body.Close()
  30352. body, ioErr := ioutil.ReadAll(resp.Body)
  30353. if ioErr != nil {
  30354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30356. return
  30357. }
  30358. var respJSON map[string]interface{}
  30359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30362. return
  30363. }
  30364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30365. userJSONBytes, _ := json.Marshal(respJSON)
  30366. fmt.Println("log")
  30367. fmt.Println(string(userJSONBytes))
  30368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30369. utils.ErrorLog("解析失败:%v", err)
  30370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30371. return
  30372. }
  30373. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30374. bytesData, _ := json.Marshal(data)
  30375. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30376. resp, _ := client.Do(req)
  30377. defer resp.Body.Close()
  30378. body, ioErr := ioutil.ReadAll(resp.Body)
  30379. if ioErr != nil {
  30380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30382. return
  30383. }
  30384. var respJSON map[string]interface{}
  30385. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30388. return
  30389. }
  30390. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30391. userJSONBytes, _ := json.Marshal(respJSON)
  30392. fmt.Println("log")
  30393. fmt.Println(string(userJSONBytes))
  30394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30395. utils.ErrorLog("解析失败:%v", err)
  30396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30397. return
  30398. }
  30399. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30400. bytesData, _ := json.Marshal(data)
  30401. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30402. resp, _ := client.Do(req)
  30403. defer resp.Body.Close()
  30404. body, ioErr := ioutil.ReadAll(resp.Body)
  30405. if ioErr != nil {
  30406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30408. return
  30409. }
  30410. var respJSON map[string]interface{}
  30411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30414. return
  30415. }
  30416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30417. userJSONBytes, _ := json.Marshal(respJSON)
  30418. fmt.Println("log")
  30419. fmt.Println(string(userJSONBytes))
  30420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30421. utils.ErrorLog("解析失败:%v", err)
  30422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30423. return
  30424. }
  30425. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30426. bytesData, _ := json.Marshal(data)
  30427. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30428. resp, _ := client.Do(req)
  30429. defer resp.Body.Close()
  30430. body, ioErr := ioutil.ReadAll(resp.Body)
  30431. if ioErr != nil {
  30432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30434. return
  30435. }
  30436. var respJSON map[string]interface{}
  30437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30440. return
  30441. }
  30442. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30443. userJSONBytes, _ := json.Marshal(respJSON)
  30444. fmt.Println("log")
  30445. fmt.Println(string(userJSONBytes))
  30446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30447. utils.ErrorLog("解析失败:%v", err)
  30448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30449. return
  30450. }
  30451. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30452. var result3101 Result3101
  30453. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30454. result3101.Infcode = "0"
  30455. if result3101.Infcode == "0" {
  30456. if len(result3101.Output.Result) > 0 {
  30457. var errMsgs []string
  30458. for _, item := range result3101.Output.Result {
  30459. errMsgs = append(errMsgs, item.VolaCont)
  30460. }
  30461. c.ServeSuccessJSON(map[string]interface{}{
  30462. "failed_code": -10,
  30463. "msg": errMsgs,
  30464. })
  30465. return
  30466. } else {
  30467. if miConfig.MdtrtareaAdmvs == "320921" {
  30468. data["doctor_id"] = doctor_info.DoctorNumber
  30469. } else {
  30470. data["doctor_id"] = doctor_info.DoctorNumber
  30471. }
  30472. bytesData, _ := json.Marshal(data)
  30473. var req *http.Request
  30474. if miConfig.MdtrtareaAdmvs == "320830" {
  30475. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30476. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30477. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30478. } else {
  30479. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30480. }
  30481. resp, _ := client.Do(req)
  30482. defer resp.Body.Close()
  30483. body, ioErr := ioutil.ReadAll(resp.Body)
  30484. if ioErr != nil {
  30485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30487. return
  30488. }
  30489. var respJSON map[string]interface{}
  30490. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30493. return
  30494. }
  30495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30496. userJSONBytes, _ := json.Marshal(respJSON)
  30497. fmt.Println("log")
  30498. fmt.Println(string(userJSONBytes))
  30499. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30500. utils.ErrorLog("解析失败:%v", err)
  30501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30502. return
  30503. }
  30504. res.InfRefmsgid = resFour10265.InfRefmsgid
  30505. res.Output = resFour10265.Output
  30506. res.ErrMsg = resFour10265.ErrMsg
  30507. res.Cainfo = resFour10265.Cainfo
  30508. res.WarnMsg = resFour10265.WarnMsg
  30509. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30510. res.Infcode = infocode
  30511. }
  30512. }
  30513. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30514. var pagesize int = 5
  30515. var start int = 1
  30516. var stop int
  30517. var pagecount int
  30518. var curpage int
  30519. data["doctor_id"] = doctor_info.DoctorNumber
  30520. var res2 ResultFour
  30521. //var result res.
  30522. //总页数,向上取整,注意除之前要先转换类型为float64
  30523. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30524. for curpage = 1; curpage <= pagecount; curpage++ {
  30525. if curpage == 1 {
  30526. start = 1
  30527. } else {
  30528. start = (curpage-1)*pagesize + 1
  30529. }
  30530. stop = curpage * pagesize
  30531. if stop > len(prescriptions) {
  30532. stop = len(prescriptions)
  30533. }
  30534. //var requestLog string
  30535. data["pre"] = prescriptions[start-1 : stop]
  30536. fmt.Println(data["pre"])
  30537. bytesData, _ := json.Marshal(data)
  30538. var req *http.Request
  30539. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30540. resp, _ := client.Do(req)
  30541. defer resp.Body.Close()
  30542. body, ioErr := ioutil.ReadAll(resp.Body)
  30543. if ioErr != nil {
  30544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30546. return
  30547. }
  30548. var respJSON map[string]interface{}
  30549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30552. return
  30553. }
  30554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30555. userJSONBytes, _ := json.Marshal(respJSON)
  30556. fmt.Println("log")
  30557. fmt.Println(string(userJSONBytes))
  30558. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30559. utils.ErrorLog("解析失败:%v", err)
  30560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30561. return
  30562. }
  30563. res.InfRefmsgid = resFour10265.InfRefmsgid
  30564. res.Output = resFour10265.Output
  30565. res.ErrMsg = resFour10265.ErrMsg
  30566. res.Cainfo = resFour10265.Cainfo
  30567. res.WarnMsg = resFour10265.WarnMsg
  30568. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30569. res.Infcode = infocode
  30570. if infocode == 0 {
  30571. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30572. } else {
  30573. isSuccess = false
  30574. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30575. res.Infcode = -1
  30576. res.ErrMsg = resFour10265.ErrMsg
  30577. errlog := &models.HisOrderError{
  30578. UserOrgId: adminUser.CurrentOrgId,
  30579. Ctime: time.Now().Unix(),
  30580. Mtime: time.Now().Unix(),
  30581. Number: chrg_bchno,
  30582. ErrMsg: "",
  30583. Status: 1,
  30584. PatientId: id,
  30585. RecordTime: recordDateTime,
  30586. Stage: 4,
  30587. }
  30588. service.CreateErrMsgLog(errlog)
  30589. }
  30590. }
  30591. if isSuccess {
  30592. res.Infcode = 0
  30593. res.Output.Result = res2.Output.Result
  30594. } else {
  30595. order := &models.HisOrder{
  30596. UserOrgId: adminUser.CurrentOrgId,
  30597. HisPatientId: his.ID,
  30598. PatientId: his.PatientId,
  30599. SettleAccountsDate: recordDateTime,
  30600. Ctime: time.Now().Unix(),
  30601. Mtime: time.Now().Unix(),
  30602. MdtrtId: his.Number,
  30603. PsnNo: his.PsnNo,
  30604. MedType: strconv.FormatInt(reg_type, 10),
  30605. Status: 1,
  30606. Number: chrg_bchno,
  30607. Infcode: res.Infcode,
  30608. WarnMsg: res.WarnMsg,
  30609. Cainfo: res.Cainfo,
  30610. ErrMsg: res.ErrMsg,
  30611. RespondTime: res.RefmsgTime,
  30612. InfRefmsgid: res.InfRefmsgid,
  30613. OrderStatus: 1,
  30614. IsMedicineInsurance: 1,
  30615. SettleType: settle_accounts_type,
  30616. SettleStartTime: start_time,
  30617. SettleEndTime: end_time,
  30618. Creator: roles.AdminUserId,
  30619. Modify: roles.AdminUserId,
  30620. PType: 2,
  30621. Diagnosis: diagnosis_id,
  30622. }
  30623. err = service.CreateOrder(order)
  30624. if err != nil {
  30625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30626. return
  30627. }
  30628. c.ServeSuccessJSON(map[string]interface{}{
  30629. "failed_code": -10,
  30630. "msg": res2.ErrMsg,
  30631. })
  30632. return
  30633. }
  30634. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30635. 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)
  30636. var dat map[string]interface{}
  30637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30638. fmt.Println(dat)
  30639. } else {
  30640. fmt.Println(err)
  30641. }
  30642. saveLog(result, request_log, "2204", "上传费用明细")
  30643. userJSONBytes, _ := json.Marshal(dat)
  30644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30645. utils.ErrorLog("解析失败:%v", err)
  30646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30647. return
  30648. }
  30649. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30650. 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, "", "")
  30651. var dat map[string]interface{}
  30652. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30653. fmt.Println(dat)
  30654. } else {
  30655. fmt.Println(err)
  30656. }
  30657. saveLog(result, request_log, "2204", "上传费用明细")
  30658. userJSONBytes, _ := json.Marshal(dat)
  30659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30660. utils.ErrorLog("解析失败:%v", err)
  30661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30662. return
  30663. }
  30664. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30665. 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, "", "")
  30666. var dat map[string]interface{}
  30667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30668. fmt.Println(dat)
  30669. } else {
  30670. fmt.Println(err)
  30671. }
  30672. saveLog(result, request_log, "2204", "上传费用明细")
  30673. userJSONBytes, _ := json.Marshal(dat)
  30674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30675. utils.ErrorLog("解析失败:%v", err)
  30676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30677. return
  30678. }
  30679. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30680. 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, "", "")
  30681. var dat map[string]interface{}
  30682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30683. fmt.Println(dat)
  30684. } else {
  30685. fmt.Println(err)
  30686. }
  30687. saveLog(result, request_log, "2204", "上传费用明细")
  30688. userJSONBytes, _ := json.Marshal(dat)
  30689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30690. utils.ErrorLog("解析失败:%v", err)
  30691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30692. return
  30693. }
  30694. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30695. bytesData, _ := json.Marshal(data)
  30696. var req *http.Request
  30697. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30698. resp, _ := client.Do(req)
  30699. defer resp.Body.Close()
  30700. body, ioErr := ioutil.ReadAll(resp.Body)
  30701. if ioErr != nil {
  30702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30704. return
  30705. }
  30706. var respJSON map[string]interface{}
  30707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30710. return
  30711. }
  30712. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30713. if status == "0" {
  30714. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30715. c.ServeSuccessJSON(map[string]interface{}{
  30716. "failed_code": -10,
  30717. "msg": err_msg,
  30718. })
  30719. return
  30720. }
  30721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30722. userJSONBytes, _ := json.Marshal(respJSON)
  30723. fmt.Println("log")
  30724. fmt.Println(string(userJSONBytes))
  30725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30726. utils.ErrorLog("解析失败:%v", err)
  30727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30728. return
  30729. }
  30730. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30731. bytesData, _ := json.Marshal(data)
  30732. var req *http.Request
  30733. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30734. resp, _ := client.Do(req)
  30735. defer resp.Body.Close()
  30736. body, ioErr := ioutil.ReadAll(resp.Body)
  30737. if ioErr != nil {
  30738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30740. return
  30741. }
  30742. var respJSON map[string]interface{}
  30743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30746. return
  30747. }
  30748. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30749. if status == "0" {
  30750. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30751. c.ServeSuccessJSON(map[string]interface{}{
  30752. "failed_code": -10,
  30753. "msg": err_msg,
  30754. })
  30755. return
  30756. }
  30757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30758. userJSONBytes, _ := json.Marshal(respJSON)
  30759. fmt.Println("log")
  30760. fmt.Println(string(userJSONBytes))
  30761. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30762. utils.ErrorLog("解析失败:%v", err)
  30763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30764. return
  30765. }
  30766. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30767. 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, "", "")
  30768. var dat map[string]interface{}
  30769. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30770. fmt.Println(dat)
  30771. } else {
  30772. fmt.Println(err)
  30773. }
  30774. saveLog(result, request_log, "2204", "上传费用明细")
  30775. userJSONBytes, _ := json.Marshal(dat)
  30776. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30777. utils.ErrorLog("解析失败:%v", err)
  30778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30779. return
  30780. }
  30781. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30782. bytesData, _ := json.Marshal(data)
  30783. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30784. resp, _ := client.Do(req)
  30785. defer resp.Body.Close()
  30786. body, ioErr := ioutil.ReadAll(resp.Body)
  30787. if ioErr != nil {
  30788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30790. return
  30791. }
  30792. var respJSON map[string]interface{}
  30793. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30796. return
  30797. }
  30798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30799. userJSONBytes, _ := json.Marshal(respJSON)
  30800. fmt.Println("log")
  30801. fmt.Println(string(userJSONBytes))
  30802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30803. utils.ErrorLog("解析失败:%v", err)
  30804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30805. return
  30806. }
  30807. } else {
  30808. if miConfig.MdtrtareaAdmvs == "441202" {
  30809. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30810. if result3101.Infcode == 0 {
  30811. if len(result3101.Output.Result) > 0 {
  30812. var errMsgs []string
  30813. for _, item := range result3101.Output.Result {
  30814. errMsgs = append(errMsgs, item.VolaCont)
  30815. }
  30816. c.ServeSuccessJSON(map[string]interface{}{
  30817. "failed_code": -10,
  30818. "msg": errMsgs,
  30819. })
  30820. return
  30821. } else {
  30822. 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)
  30823. var dat map[string]interface{}
  30824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30825. fmt.Println(dat)
  30826. } else {
  30827. fmt.Println(err)
  30828. }
  30829. saveLog(result, request_log, "2204", "上传费用明细")
  30830. userJSONBytes, _ := json.Marshal(dat)
  30831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30832. utils.ErrorLog("解析失败:%v", err)
  30833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30834. return
  30835. }
  30836. }
  30837. } else {
  30838. c.ServeSuccessJSON(map[string]interface{}{
  30839. "failed_code": -10,
  30840. "msg": result3101.ErrMsg,
  30841. })
  30842. return
  30843. }
  30844. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30845. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30846. if result3101.Infcode == 0 {
  30847. if len(result3101.Output.Result) > 0 {
  30848. var errMsgs []string
  30849. for _, item := range result3101.Output.Result {
  30850. errMsgs = append(errMsgs, item.VolaCont)
  30851. }
  30852. c.ServeSuccessJSON(map[string]interface{}{
  30853. "failed_code": -10,
  30854. "msg": errMsgs,
  30855. })
  30856. return
  30857. } else {
  30858. 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)
  30859. var dat map[string]interface{}
  30860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30861. fmt.Println(dat)
  30862. } else {
  30863. fmt.Println(err)
  30864. }
  30865. saveLog(result, request_log, "2204", "上传费用明细")
  30866. userJSONBytes, _ := json.Marshal(dat)
  30867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30868. utils.ErrorLog("解析失败:%v", err)
  30869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30870. return
  30871. }
  30872. }
  30873. } else {
  30874. c.ServeSuccessJSON(map[string]interface{}{
  30875. "failed_code": -10,
  30876. "msg": result3101.ErrMsg,
  30877. })
  30878. return
  30879. }
  30880. } else {
  30881. if miConfig.Code == "H15049901371" {
  30882. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode, admin_user_id)
  30883. var dat map[string]interface{}
  30884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30885. fmt.Println(dat)
  30886. } else {
  30887. fmt.Println(err)
  30888. }
  30889. saveLog(result, request_log, "2204", "上传费用明细")
  30890. userJSONBytes, _ := json.Marshal(dat)
  30891. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30892. utils.ErrorLog("解析失败:%v", err)
  30893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30894. return
  30895. }
  30896. res.InfRefmsgid = resFour10265.InfRefmsgid
  30897. res.Output = resFour10265.Output
  30898. res.ErrMsg = resFour10265.ErrMsg
  30899. res.Cainfo = resFour10265.Cainfo
  30900. res.WarnMsg = resFour10265.WarnMsg
  30901. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30902. res.Infcode = infocode
  30903. } else {
  30904. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  30905. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30906. if result3101.Infcode == 0 {
  30907. if len(result3101.Output.Result) > 0 {
  30908. c.ServeSuccessJSON(map[string]interface{}{
  30909. "failed_code": -10,
  30910. "failed_type": 100,
  30911. "warm_type": 1,
  30912. "msg": result3101,
  30913. })
  30914. return
  30915. } else {
  30916. 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)
  30917. var dat map[string]interface{}
  30918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30919. fmt.Println(dat)
  30920. } else {
  30921. fmt.Println(err)
  30922. }
  30923. saveLog(result, request_log, "2204", "上传费用明细")
  30924. userJSONBytes, _ := json.Marshal(dat)
  30925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30926. utils.ErrorLog("解析失败:%v", err)
  30927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30928. return
  30929. }
  30930. }
  30931. } else {
  30932. c.ServeSuccessJSON(map[string]interface{}{
  30933. "failed_code": -10,
  30934. "msg": result3101.ErrMsg,
  30935. })
  30936. return
  30937. }
  30938. } else {
  30939. 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)
  30940. var dat map[string]interface{}
  30941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30942. fmt.Println(dat)
  30943. } else {
  30944. fmt.Println(err)
  30945. }
  30946. saveLog(result, request_log, "2204", "上传费用明细")
  30947. userJSONBytes, _ := json.Marshal(dat)
  30948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30949. utils.ErrorLog("解析失败:%v", err)
  30950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30951. return
  30952. }
  30953. }
  30954. }
  30955. }
  30956. }
  30957. var total_two float64
  30958. if res.Infcode == -1 {
  30959. errlog := &models.HisOrderError{
  30960. UserOrgId: adminUser.CurrentOrgId,
  30961. Ctime: time.Now().Unix(),
  30962. Mtime: time.Now().Unix(),
  30963. Number: chrg_bchno,
  30964. ErrMsg: res.ErrMsg,
  30965. Status: 1,
  30966. PatientId: id,
  30967. RecordTime: recordDateTime,
  30968. Stage: 4,
  30969. }
  30970. service.CreateErrMsgLog(errlog)
  30971. c.ServeSuccessJSON(map[string]interface{}{
  30972. "failed_code": -10,
  30973. "msg": res.ErrMsg,
  30974. })
  30975. return
  30976. }
  30977. if res.Infcode == 0 {
  30978. order := &models.HisOrder{
  30979. UserOrgId: adminUser.CurrentOrgId,
  30980. HisPatientId: his.ID,
  30981. PatientId: his.PatientId,
  30982. SettleAccountsDate: recordDateTime,
  30983. Ctime: time.Now().Unix(),
  30984. Mtime: time.Now().Unix(),
  30985. MdtrtId: his.Number,
  30986. PsnNo: his.PsnNo,
  30987. MedType: strconv.FormatInt(reg_type, 10),
  30988. Status: 1,
  30989. Number: chrg_bchno,
  30990. Infcode: res.Infcode,
  30991. WarnMsg: res.WarnMsg,
  30992. Cainfo: res.Cainfo,
  30993. ErrMsg: res.ErrMsg,
  30994. RespondTime: res.RefmsgTime,
  30995. InfRefmsgid: res.InfRefmsgid,
  30996. OrderStatus: 1,
  30997. IsMedicineInsurance: 1,
  30998. SettleType: settle_accounts_type,
  30999. SettleStartTime: start_time,
  31000. SettleEndTime: end_time,
  31001. Creator: roles.AdminUserId,
  31002. Modify: roles.AdminUserId,
  31003. PType: 2,
  31004. Diagnosis: diagnosis_id,
  31005. }
  31006. err = service.CreateOrder(order)
  31007. if err != nil {
  31008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31009. return
  31010. }
  31011. for _, item := range res.Output.Result {
  31012. temp := strings.Split(item.FeedetlSn, "-")
  31013. var advice_id int64 = 0
  31014. var project_id int64 = 0
  31015. var types int64 = 0
  31016. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31017. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31018. if temp[1] == "1" {
  31019. advice_id = id
  31020. project_id = 0
  31021. } else if temp[1] == "2" {
  31022. advice_id = 0
  31023. project_id = id
  31024. }
  31025. total_two = total_two + item.DetItemFeeSumamt
  31026. info := &models.HisOrderInfo{
  31027. OrderNumber: order.Number,
  31028. FeedetlSn: item.FeedetlSn,
  31029. UploadDate: time.Now().Unix(),
  31030. AdviceId: advice_id,
  31031. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31032. Cnt: item.Cnt,
  31033. Pric: float64(item.Pric),
  31034. PatientId: his.PatientId,
  31035. PricUplmtAmt: item.PricUplmtAmt,
  31036. SelfpayProp: item.SelfpayProp,
  31037. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31038. OverlmtAmt: item.OverlmtAmt,
  31039. PreselfpayAmt: item.PreselfpayAmt,
  31040. BasMednFlag: item.BasMednFlag,
  31041. MedChrgitmType: item.MedChrgitmType,
  31042. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31043. Status: 1,
  31044. Memo: item.Memo,
  31045. Mtime: time.Now().Unix(),
  31046. InscpScpAmt: item.InscpScpAmt,
  31047. DrtReimFlag: item.DrtReimFlag,
  31048. Ctime: time.Now().Unix(),
  31049. ListSpItemFlag: item.ListSpItemFlag,
  31050. ChldMedcFlag: item.ChldMedcFlag,
  31051. LmtUsedFlag: item.LmtUsedFlag,
  31052. ChrgitmLv: item.ChrgitmLv,
  31053. UserOrgId: adminUser.CurrentOrgId,
  31054. HisPatientId: his.ID,
  31055. OrderId: order.ID,
  31056. ProjectId: project_id,
  31057. Type: types,
  31058. }
  31059. service.CreateOrderInfo(info)
  31060. }
  31061. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31062. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31063. var total float64
  31064. for _, item := range prescriptions {
  31065. if item.Type == 1 { //药品
  31066. for _, subItem := range item.HisDoctorAdviceInfo {
  31067. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31068. total_one := price * subItem.PrescribingNumber
  31069. fmt.Println("subItem")
  31070. fmt.Println(subItem.Price)
  31071. fmt.Println("price")
  31072. fmt.Println(price)
  31073. fmt.Println("total_one")
  31074. fmt.Println(total_one)
  31075. total = total + total_one
  31076. fmt.Println(total)
  31077. }
  31078. }
  31079. if item.Type == 2 { //项目
  31080. for _, subItem := range item.HisPrescriptionProject {
  31081. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31082. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31083. total_one := price * cnt
  31084. total = total + total_one
  31085. }
  31086. }
  31087. }
  31088. allTotal := fmt.Sprintf("%.2f", total)
  31089. if res.Infcode == 0 {
  31090. var rf []*ResultFive
  31091. json.Unmarshal([]byte(his.Iinfo), &rf)
  31092. chrg_bchno := chrg_bchno
  31093. cert_no := his.Certno
  31094. var insutypes []string
  31095. var insutype string
  31096. var is390 int = 0
  31097. var is310 int = 0
  31098. for _, item := range rf {
  31099. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31100. insutypes = append(insutypes, item.Insutype)
  31101. }
  31102. }
  31103. if len(insutypes) == 1 {
  31104. insutype = insutypes[0]
  31105. } else {
  31106. for _, i := range insutypes {
  31107. if i == "390" {
  31108. is390 = 1
  31109. }
  31110. if i == "310" {
  31111. is310 = 1
  31112. }
  31113. }
  31114. }
  31115. if is390 == 1 {
  31116. insutype = "390"
  31117. }
  31118. if is310 == 1 {
  31119. insutype = "310"
  31120. }
  31121. if len(insutypes) == 0 {
  31122. insutype = "390"
  31123. }
  31124. if len(insutypes) == 2 {
  31125. insutype = strconv.FormatInt(his.SocialType, 10)
  31126. }
  31127. //insutype = "390"
  31128. if his.IdCardType == 1 {
  31129. cert_no = his.MedicalInsuranceNumber
  31130. } else {
  31131. cert_no = his.Certno
  31132. }
  31133. var res ResultSeven
  31134. var ahres ResultSevenAH
  31135. var resSeven10265 ResultSeven10265
  31136. var resSeven10265Two ResultSeven10265Two
  31137. var resSeven10633Two ResultSeven10633Two
  31138. var gzresSeven10265Two GZResultSeven10265Two
  31139. if miConfig.MdtrtareaAdmvs == "421300" {
  31140. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31141. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31142. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31143. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31144. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31145. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31146. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31147. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31148. resp, requestErr := http.Get(api)
  31149. if requestErr != nil {
  31150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31151. return
  31152. }
  31153. body, ioErr := ioutil.ReadAll(resp.Body)
  31154. if ioErr != nil {
  31155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31157. return
  31158. }
  31159. var respJSON map[string]interface{}
  31160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31163. return
  31164. }
  31165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31166. result, _ := json.Marshal(respJSON)
  31167. fmt.Println("log")
  31168. fmt.Println(string(result))
  31169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31170. utils.ErrorLog("解析失败:%v", err)
  31171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31172. return
  31173. }
  31174. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31175. if reg_type == 11 && his.Insutype == "390" {
  31176. reg_type = 110104
  31177. }
  31178. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31179. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31180. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31181. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31182. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31183. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31184. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31185. resp, requestErr := http.Get(api)
  31186. if requestErr != nil {
  31187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31188. return
  31189. }
  31190. body, ioErr := ioutil.ReadAll(resp.Body)
  31191. if ioErr != nil {
  31192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31194. return
  31195. }
  31196. var respJSON map[string]interface{}
  31197. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31200. return
  31201. }
  31202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31203. result, _ := json.Marshal(respJSON)
  31204. fmt.Println("log")
  31205. fmt.Println(string(result))
  31206. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31207. utils.ErrorLog("解析失败:%v", err)
  31208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31209. return
  31210. }
  31211. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31212. if reg_type == 11 && his.Insutype == "390" {
  31213. reg_type = 110104
  31214. }
  31215. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31216. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31217. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31218. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31219. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31220. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31221. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31222. resp, requestErr := http.Get(api)
  31223. if requestErr != nil {
  31224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31225. return
  31226. }
  31227. body, ioErr := ioutil.ReadAll(resp.Body)
  31228. if ioErr != nil {
  31229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. var respJSON map[string]interface{}
  31234. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31237. return
  31238. }
  31239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31240. result, _ := json.Marshal(respJSON)
  31241. fmt.Println("log")
  31242. fmt.Println(string(result))
  31243. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31244. utils.ErrorLog("解析失败:%v", err)
  31245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31246. return
  31247. }
  31248. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31249. if reg_type == 11 && his.Insutype == "390" {
  31250. reg_type = 110104
  31251. }
  31252. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31253. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31254. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31256. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31257. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31258. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31259. resp, requestErr := http.Get(api)
  31260. if requestErr != nil {
  31261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31262. return
  31263. }
  31264. body, ioErr := ioutil.ReadAll(resp.Body)
  31265. if ioErr != nil {
  31266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31268. return
  31269. }
  31270. var respJSON map[string]interface{}
  31271. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31274. return
  31275. }
  31276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31277. result, _ := json.Marshal(respJSON)
  31278. fmt.Println("log")
  31279. fmt.Println(string(result))
  31280. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31281. utils.ErrorLog("解析失败:%v", err)
  31282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31283. return
  31284. }
  31285. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31286. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31287. var result3101 Result3101
  31288. //utils.ErrorLog("解析失败:%v", result3101)
  31289. result3101.Infcode = "0"
  31290. if result3101.Infcode == "0" {
  31291. if len(result3101.Output.Result) > 0 {
  31292. var errMsgs []string
  31293. for _, item := range result3101.Output.Result {
  31294. errMsgs = append(errMsgs, item.VolaCont)
  31295. }
  31296. c.ServeSuccessJSON(map[string]interface{}{
  31297. "failed_code": -10,
  31298. "msg": errMsgs,
  31299. })
  31300. return
  31301. } else {
  31302. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31303. if his.IdCardType != 4 {
  31304. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31305. bas := strings.Split(psn_info.CardInfo, "|")
  31306. if his.IdCardType == 1 {
  31307. cert_no = bas[2]
  31308. } else {
  31309. cert_no = bas[1]
  31310. }
  31311. } else {
  31312. cert_no = his.Certno
  31313. }
  31314. //江苏地区国家医保医疗类别
  31315. //职工透析:医疗类别选特殊情况门诊9933
  31316. //居民血透门慢: 医疗类别选门诊慢病1402
  31317. //var med_type string
  31318. //if his.Insutype == "310" {
  31319. // if reg_type == 14 {
  31320. // med_type = "9933"
  31321. // } else if reg_type == 11 {
  31322. // med_type = "11"
  31323. //
  31324. // }
  31325. //} else if his.Insutype == "390" {
  31326. // if reg_type == 14 {
  31327. // med_type = "1402"
  31328. // } else if reg_type == 11 {
  31329. // med_type = "11"
  31330. // }
  31331. //}
  31332. var api string
  31333. if miConfig.MdtrtareaAdmvs == "320830" {
  31334. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31335. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31336. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31337. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31338. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31339. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31340. "&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
  31341. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31342. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31343. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31344. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31345. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31346. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31347. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31348. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31349. "&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
  31350. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31351. } else {
  31352. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31353. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31354. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31355. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31356. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31357. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31358. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31359. "&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
  31360. }
  31361. resp, requestErr := http.Get(api)
  31362. if requestErr != nil {
  31363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31364. return
  31365. }
  31366. body, ioErr := ioutil.ReadAll(resp.Body)
  31367. if ioErr != nil {
  31368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31370. return
  31371. }
  31372. var respJSON map[string]interface{}
  31373. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31376. return
  31377. }
  31378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31379. result, _ := json.Marshal(respJSON)
  31380. fmt.Println("log")
  31381. fmt.Println(string(result))
  31382. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31383. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31384. utils.ErrorLog("解析失败:%v", err)
  31385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31386. return
  31387. }
  31388. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31389. res.Output = resSeven10265.Output
  31390. res.ErrMsg = resSeven10265.ErrMsg
  31391. res.Cainfo = resSeven10265.Cainfo
  31392. res.WarnMsg = resSeven10265.WarnMsg
  31393. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31394. res.Infcode = infocode
  31395. } else {
  31396. if miConfig.MdtrtareaAdmvs == "320830"{
  31397. if err := json.Unmarshal([]byte(result), &resSeven10633Two); err != nil {
  31398. utils.ErrorLog("解析失败:%v", err)
  31399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31400. return
  31401. }
  31402. res.InfRefmsgid = resSeven10633Two.InfRefmsgid
  31403. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31404. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31405. res.Output.Setlinfo.AcctPay = resSeven10633Two.Output.Setlinfo.AcctPay
  31406. res.Output.Setlinfo.CvlservPay = resSeven10633Two.Output.Setlinfo.CvlservPay
  31407. res.Output.Setlinfo.ActPayDedc = resSeven10633Two.Output.Setlinfo.ActPayDedc
  31408. res.Output.Setlinfo.Age = resSeven10633Two.Output.Setlinfo.Age
  31409. res.Output.Setlinfo.Balc = resSeven10633Two.Output.Setlinfo.Balc
  31410. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31411. res.Output.Setlinfo.Certno = resSeven10633Two.Output.Setlinfo.Certno
  31412. res.Output.Setlinfo.ClrOptins = resSeven10633Two.Output.Setlinfo.ClrOptins
  31413. res.Output.Setlinfo.ClrType = resSeven10633Two.Output.Setlinfo.ClrOptins
  31414. res.Output.Setlinfo.ClrWay = resSeven10633Two.Output.Setlinfo.ClrOptins
  31415. res.Output.Setlinfo.CvlservFlag = resSeven10633Two.Output.Setlinfo.ClrOptins
  31416. res.Output.Setlinfo.CvlservPay = resSeven10633Two.Output.Setlinfo.CvlservPay
  31417. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Two.Output.Setlinfo.FulamtOwnpayAmt
  31418. res.Output.Setlinfo.FundPaySumamt = resSeven10633Two.Output.Setlinfo.FundPaySumamt
  31419. res.Output.Setlinfo.Gend = resSeven10633Two.Output.Setlinfo.Gend
  31420. res.Output.Setlinfo.HifesPay = resSeven10633Two.Output.Setlinfo.HifesPay
  31421. res.Output.Setlinfo.HifmiPay = resSeven10633Two.Output.Setlinfo.HifmiPay
  31422. res.Output.Setlinfo.HifpPay = resSeven10633Two.Output.Setlinfo.HifpPay
  31423. //HospPartAmt, _ := strconv.ParseFloat(resSeven10633Two.Output.Setlinfo.HospPartAmt, 64)
  31424. res.Output.Setlinfo.HospPartAmt = resSeven10633Two.Output.Setlinfo.HospPartAmt
  31425. res.Output.Setlinfo.InscpScpAmt = resSeven10633Two.Output.Setlinfo.InscpScpAmt
  31426. res.Output.Setlinfo.Insutype = resSeven10633Two.Output.Setlinfo.Insutype
  31427. res.Output.Setlinfo.MafPay = resSeven10633Two.Output.Setlinfo.MafPay
  31428. res.Output.Setlinfo.MdtrtCertType = resSeven10633Two.Output.Setlinfo.MdtrtCertType
  31429. res.Output.Setlinfo.HifobPay = resSeven10633Two.Output.Setlinfo.HifobPay
  31430. res.Output.Setlinfo.MdtrtID = resSeven10633Two.Output.Setlinfo.MdtrtID
  31431. res.Output.Setlinfo.MedType = resSeven10633Two.Output.Setlinfo.MedType
  31432. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Two.Output.Setlinfo.MedfeeSumamt
  31433. res.Output.Setlinfo.MedinsSetlID = resSeven10633Two.Output.Setlinfo.MedinsSetlID
  31434. res.Output.Setlinfo.Naty = resSeven10633Two.Output.Setlinfo.Naty
  31435. res.Output.Setlinfo.OthPay = resSeven10633Two.Output.Setlinfo.OthPay
  31436. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Two.Output.Setlinfo.OverlmtSelfpay
  31437. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31438. res.Output.Setlinfo.PoolPropSelfpay = resSeven10633Two.Output.Setlinfo.PoolPropSelfpay
  31439. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Two.Output.Setlinfo.PreselfpayAmt
  31440. res.Output.Setlinfo.PsnCashPay = resSeven10633Two.Output.Setlinfo.PsnCashPay
  31441. res.Output.Setlinfo.PsnCertType = resSeven10633Two.Output.Setlinfo.ClrOptins
  31442. res.Output.Setlinfo.PsnName = resSeven10633Two.Output.Setlinfo.PsnName
  31443. res.Output.Setlinfo.PsnNo = resSeven10633Two.Output.Setlinfo.PsnNo
  31444. res.Output.Setlinfo.PsnPartAmt = resSeven10633Two.Output.Setlinfo.PsnPartAmt
  31445. res.Output.Setlinfo.PsnType = resSeven10633Two.Output.Setlinfo.PsnType
  31446. res.Output.Setlinfo.SetlID = resSeven10633Two.Output.Setlinfo.SetlID
  31447. res.Output.Setlinfo.SetlTime = resSeven10633Two.Output.Setlinfo.SetlTime
  31448. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31449. res.ErrMsg = resSeven10633Two.ErrMsg
  31450. res.Cainfo = resSeven10633Two.Cainfo
  31451. res.WarnMsg = resSeven10633Two.WarnMsg
  31452. infocode, _ := strconv.ParseInt(resSeven10633Two.Infcode, 10, 64)
  31453. res.Infcode = infocode
  31454. }else{
  31455. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31456. utils.ErrorLog("解析失败:%v", err)
  31457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31458. return
  31459. }
  31460. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31461. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31462. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31463. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31464. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31465. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31466. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31467. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31468. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31469. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31470. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31471. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31472. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31473. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31474. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31475. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31476. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31477. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31478. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31479. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31480. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31481. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31482. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31483. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31484. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31485. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31486. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31487. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31488. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31489. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31490. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31491. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31492. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31493. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31494. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31495. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31496. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31497. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31498. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31499. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31500. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31501. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31502. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31503. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31504. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31505. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31506. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31507. res.ErrMsg = resSeven10265Two.ErrMsg
  31508. res.Cainfo = resSeven10265Two.Cainfo
  31509. res.WarnMsg = resSeven10265Two.WarnMsg
  31510. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31511. res.Infcode = infocode
  31512. }
  31513. }
  31514. }
  31515. }
  31516. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31517. psn_info, _ := service.GetPsnByPatientId(id)
  31518. var verify_number string
  31519. if psn_info.IdCardType == 4 {
  31520. verify_number = psn_info.VerifyNumber
  31521. } else if psn_info.IdCardType == 1 {
  31522. bas := strings.Split(psn_info.CardInfo, "|")
  31523. cardNumber := bas[2]
  31524. verify_number = cardNumber
  31525. } else {
  31526. psn_info.IdCardType = 2
  31527. verify_number = psn_info.Certno
  31528. }
  31529. var api string
  31530. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31531. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31532. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31533. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31534. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31535. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31536. "&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
  31537. resp, requestErr := http.Get(api)
  31538. if requestErr != nil {
  31539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31540. return
  31541. }
  31542. body, ioErr := ioutil.ReadAll(resp.Body)
  31543. if ioErr != nil {
  31544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31546. return
  31547. }
  31548. var respJSON map[string]interface{}
  31549. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31552. return
  31553. }
  31554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31555. result, _ := json.Marshal(respJSON)
  31556. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31557. utils.ErrorLog("解析失败:%v", err)
  31558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31559. return
  31560. }
  31561. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31562. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31563. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31564. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31565. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31566. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31567. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31568. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31569. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31570. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31571. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31572. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31573. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31574. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31575. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31576. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31577. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31578. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31579. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31580. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31581. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31582. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31583. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31584. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31585. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31586. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31587. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31588. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31589. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31590. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31591. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31592. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31593. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31594. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31595. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31596. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31597. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31598. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31599. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31600. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31601. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31602. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31603. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31604. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31605. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31606. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31607. res.ErrMsg = resSeven10265.ErrMsg
  31608. res.Cainfo = resSeven10265.Cainfo
  31609. res.WarnMsg = resSeven10265.WarnMsg
  31610. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31611. res.Infcode = infocode
  31612. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31613. acct_used_flag := "1"
  31614. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31615. var result string
  31616. var request_log string
  31617. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31618. 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)
  31619. } else {
  31620. 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)
  31621. }
  31622. var dat map[string]interface{}
  31623. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31624. fmt.Println(dat)
  31625. } else {
  31626. fmt.Println(err)
  31627. }
  31628. saveLog(result, request_log, "2206", "预结算")
  31629. userJSONBytes, _ := json.Marshal(dat)
  31630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31631. utils.ErrorLog("解析失败:%v", err)
  31632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31633. return
  31634. }
  31635. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31636. var result string
  31637. var request_log string
  31638. if his.IdCardType == 2 {
  31639. insutype = strconv.FormatInt(his.SocialType, 10)
  31640. 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, "")
  31641. } else if his.IdCardType == 1 {
  31642. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31643. bas := strings.Split(psn_info.CardInfo, "|")
  31644. basNumber := bas[2]
  31645. card_sn := bas[3]
  31646. var rf []*ResultFive
  31647. json.Unmarshal([]byte(his.Iinfo), &rf)
  31648. var psn_type string
  31649. for _, item := range rf {
  31650. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31651. psn_type = item.PsnType
  31652. }
  31653. }
  31654. insutype = strconv.FormatInt(his.SocialType, 10)
  31655. 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)
  31656. } else {
  31657. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31658. //bas := strings.Split(psn_info.CardInfo, "|")
  31659. //basNumber := bas[2]
  31660. //card_sn := bas[3]
  31661. var rf []*ResultFive
  31662. json.Unmarshal([]byte(his.Iinfo), &rf)
  31663. var psn_type string
  31664. for _, item := range rf {
  31665. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31666. psn_type = item.PsnType
  31667. }
  31668. }
  31669. insutype = strconv.FormatInt(his.SocialType, 10)
  31670. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31671. 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)
  31672. }
  31673. var dat map[string]interface{}
  31674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31675. fmt.Println(dat)
  31676. } else {
  31677. fmt.Println(err)
  31678. }
  31679. saveLog(result, request_log, "2206", "预结算")
  31680. userJSONBytes, _ := json.Marshal(dat)
  31681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31682. utils.ErrorLog("解析失败:%v", err)
  31683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31684. return
  31685. }
  31686. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31687. var result string
  31688. var request_log string
  31689. if his.IdCardType == 2 {
  31690. insutype = strconv.FormatInt(his.SocialType, 10)
  31691. 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, "")
  31692. } else if his.IdCardType == 1 {
  31693. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31694. bas := strings.Split(psn_info.CardInfo, "|")
  31695. basNumber := bas[0]
  31696. card_sn := ""
  31697. var rf []*ResultFive
  31698. json.Unmarshal([]byte(his.Iinfo), &rf)
  31699. var psn_type string
  31700. for _, item := range rf {
  31701. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31702. psn_type = item.PsnType
  31703. }
  31704. }
  31705. insutype = strconv.FormatInt(his.SocialType, 10)
  31706. 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)
  31707. } else {
  31708. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31709. //bas := strings.Split(psn_info.CardInfo, "|")
  31710. //basNumber := bas[2]
  31711. //card_sn := bas[3]
  31712. var rf []*ResultFive
  31713. json.Unmarshal([]byte(his.Iinfo), &rf)
  31714. var psn_type string
  31715. for _, item := range rf {
  31716. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31717. psn_type = item.PsnType
  31718. }
  31719. }
  31720. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31721. 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)
  31722. }
  31723. var dat map[string]interface{}
  31724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31725. fmt.Println(dat)
  31726. } else {
  31727. fmt.Println(err)
  31728. }
  31729. saveLog(result, request_log, "2206", "预结算")
  31730. userJSONBytes, _ := json.Marshal(dat)
  31731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31732. utils.ErrorLog("解析失败:%v", err)
  31733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31734. return
  31735. }
  31736. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31737. var result string
  31738. var request_log string
  31739. if his.IdCardType == 2 {
  31740. insutype = strconv.FormatInt(his.SocialType, 10)
  31741. 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, "")
  31742. } else if his.IdCardType == 1 {
  31743. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31744. bas := strings.Split(psn_info.CardInfo, "|")
  31745. basNumber := bas[0]
  31746. card_sn := ""
  31747. var rf []*ResultFive
  31748. json.Unmarshal([]byte(his.Iinfo), &rf)
  31749. var psn_type string
  31750. for _, item := range rf {
  31751. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31752. psn_type = item.PsnType
  31753. }
  31754. }
  31755. insutype = strconv.FormatInt(his.SocialType, 10)
  31756. 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)
  31757. } else {
  31758. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31759. //bas := strings.Split(psn_info.CardInfo, "|")
  31760. //basNumber := bas[2]
  31761. //card_sn := bas[3]
  31762. var rf []*ResultFive
  31763. json.Unmarshal([]byte(his.Iinfo), &rf)
  31764. var psn_type string
  31765. for _, item := range rf {
  31766. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31767. psn_type = item.PsnType
  31768. }
  31769. }
  31770. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31771. 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)
  31772. }
  31773. var dat map[string]interface{}
  31774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31775. fmt.Println(dat)
  31776. } else {
  31777. fmt.Println(err)
  31778. }
  31779. saveLog(result, request_log, "2206", "预结算")
  31780. userJSONBytes, _ := json.Marshal(dat)
  31781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31782. utils.ErrorLog("解析失败:%v", err)
  31783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31784. return
  31785. }
  31786. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31787. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31788. if his.IdCardType == 4 {
  31789. psn_info.VerifyNumber = psn_info.VerifyNumber
  31790. cert_no = psn_info.VerifyNumber
  31791. } else if his.IdCardType == 2 {
  31792. cert_no = psn_info.Certno
  31793. psn_info.VerifyNumber = psn_info.Certno
  31794. } else {
  31795. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31796. bas := strings.Split(psn_info.CardInfo, "|")
  31797. if his.IdCardType == 1 {
  31798. cert_no = bas[2]
  31799. } else {
  31800. cert_no = bas[1]
  31801. }
  31802. }
  31803. var api string
  31804. var med_type string
  31805. if his.Insutype == "390" {
  31806. if reg_type == 992102 {
  31807. med_type = "992102"
  31808. }
  31809. if reg_type == 140104 {
  31810. med_type = "140104"
  31811. }
  31812. if reg_type == 140201 {
  31813. med_type = "140201"
  31814. }
  31815. if reg_type == 14 {
  31816. med_type = "140104"
  31817. }
  31818. if reg_type == 1104 {
  31819. med_type = "1104"
  31820. }
  31821. } else if his.Insutype == "310" {
  31822. if reg_type == 1104 {
  31823. med_type = "1104"
  31824. }
  31825. if reg_type == 992102 {
  31826. med_type = "992102"
  31827. }
  31828. if reg_type == 140104 {
  31829. med_type = "140104"
  31830. }
  31831. if reg_type == 140201 {
  31832. med_type = "140201"
  31833. }
  31834. if reg_type == 14 {
  31835. med_type = "140104"
  31836. }
  31837. }
  31838. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31839. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31840. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31841. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31842. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31843. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31844. "&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
  31845. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31846. resp, requestErr := http.Get(api)
  31847. if requestErr != nil {
  31848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31849. return
  31850. }
  31851. body, ioErr := ioutil.ReadAll(resp.Body)
  31852. if ioErr != nil {
  31853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31855. return
  31856. }
  31857. var respJSON map[string]interface{}
  31858. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31861. return
  31862. }
  31863. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31864. if status == "0" {
  31865. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31866. c.ServeSuccessJSON(map[string]interface{}{
  31867. "failed_code": -10,
  31868. "msg": err_msg,
  31869. })
  31870. return
  31871. }
  31872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31873. result, _ := json.Marshal(respJSON)
  31874. fmt.Println("log")
  31875. fmt.Println(string(result))
  31876. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31877. utils.ErrorLog("解析失败:%v", err)
  31878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31879. return
  31880. }
  31881. res.InfRefmsgid = ahres.InfRefmsgid
  31882. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31883. // 创建对应的Time类型
  31884. t := time.UnixMilli(timestamp)
  31885. // 格式化成指定的日期字符串
  31886. str := t.Format("2006-01-02 15:04:05")
  31887. res.Output.Setlinfo.SetlTime = str
  31888. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31889. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31890. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31891. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31892. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31893. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31894. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31895. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31896. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31897. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31898. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31899. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31900. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31901. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31902. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31903. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31904. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31905. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31906. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31907. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31908. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31909. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31910. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31911. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31912. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31913. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31914. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31915. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31916. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31917. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31918. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31919. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31920. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31921. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31922. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31923. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31924. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31925. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31926. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31927. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31928. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31929. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31930. //res.Output.Setldetail = ahres.Output.Setldetail
  31931. res.ErrMsg = ahres.ErrMsg
  31932. res.Cainfo = ahres.Cainfo
  31933. res.WarnMsg = ahres.WarnMsg
  31934. res.Infcode = ahres.Infcode
  31935. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31936. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31937. if his.IdCardType == 4 {
  31938. psn_info.VerifyNumber = psn_info.VerifyNumber
  31939. cert_no = psn_info.Certno
  31940. } else if his.IdCardType == 2 {
  31941. cert_no = psn_info.Certno
  31942. psn_info.VerifyNumber = psn_info.Certno
  31943. } else {
  31944. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31945. bas := strings.Split(psn_info.CardInfo, "|")
  31946. if his.IdCardType == 1 {
  31947. cert_no = bas[2]
  31948. } else {
  31949. cert_no = bas[1]
  31950. }
  31951. }
  31952. var api string
  31953. var med_type string
  31954. if his.Insutype == "390" {
  31955. if reg_type == 992102 {
  31956. med_type = "992102"
  31957. }
  31958. if reg_type == 140104 {
  31959. med_type = "140104"
  31960. }
  31961. if reg_type == 140201 {
  31962. med_type = "140201"
  31963. }
  31964. if reg_type == 14 {
  31965. med_type = "14"
  31966. }
  31967. } else if his.Insutype == "310" {
  31968. if reg_type == 992102 {
  31969. med_type = "992102"
  31970. }
  31971. if reg_type == 140104 {
  31972. med_type = "140104"
  31973. }
  31974. if reg_type == 140201 {
  31975. med_type = "140201"
  31976. }
  31977. if reg_type == 14 {
  31978. med_type = "14"
  31979. }
  31980. }
  31981. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31982. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31983. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31985. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31986. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31987. "&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
  31988. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31989. resp, requestErr := http.Get(api)
  31990. if requestErr != nil {
  31991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31992. return
  31993. }
  31994. body, ioErr := ioutil.ReadAll(resp.Body)
  31995. if ioErr != nil {
  31996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31998. return
  31999. }
  32000. var respJSON map[string]interface{}
  32001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32004. return
  32005. }
  32006. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32007. if status == "0" {
  32008. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32009. c.ServeSuccessJSON(map[string]interface{}{
  32010. "failed_code": -10,
  32011. "msg": err_msg,
  32012. })
  32013. return
  32014. }
  32015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32016. result, _ := json.Marshal(respJSON)
  32017. fmt.Println("log")
  32018. fmt.Println(string(result))
  32019. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32020. utils.ErrorLog("解析失败:%v", err)
  32021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32022. return
  32023. }
  32024. res.InfRefmsgid = ahres.InfRefmsgid
  32025. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32026. // 创建对应的Time类型
  32027. t := time.UnixMilli(timestamp)
  32028. // 格式化成指定的日期字符串
  32029. str := t.Format("2006-01-02 15:04:05")
  32030. res.Output.Setlinfo.SetlTime = str
  32031. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32032. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32033. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32034. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32035. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32036. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32037. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32038. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32039. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32040. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32041. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32042. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32043. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32044. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32045. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32046. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32047. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32048. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32049. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32050. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32051. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32052. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32053. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32054. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32055. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32056. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32057. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32058. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32059. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32060. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32061. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32062. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32063. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32064. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32065. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32066. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32067. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32068. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32069. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32070. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32071. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32072. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32073. //res.Output.Setldetail = ahres.Output.Setldetail
  32074. res.ErrMsg = ahres.ErrMsg
  32075. res.Cainfo = ahres.Cainfo
  32076. res.WarnMsg = ahres.WarnMsg
  32077. res.Infcode = ahres.Infcode
  32078. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32079. var result string
  32080. var request_log string
  32081. if his.IdCardType == 2 {
  32082. 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")
  32083. } else if his.IdCardType == 1 {
  32084. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32085. bas := strings.Split(psn_info.CardInfo, "|")
  32086. basNumber := bas[2]
  32087. card_sn := bas[3]
  32088. 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")
  32089. } else {
  32090. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32091. 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")
  32092. }
  32093. var dat map[string]interface{}
  32094. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32095. fmt.Println(dat)
  32096. } else {
  32097. fmt.Println(err)
  32098. }
  32099. saveLog(result, request_log, "2206", "预结算")
  32100. userJSONBytes, _ := json.Marshal(dat)
  32101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32102. utils.ErrorLog("解析失败:%v", err)
  32103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32104. return
  32105. }
  32106. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32107. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32108. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32109. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32110. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32111. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32112. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32113. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32114. resp, requestErr := http.Get(api)
  32115. if requestErr != nil {
  32116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32117. return
  32118. }
  32119. body, ioErr := ioutil.ReadAll(resp.Body)
  32120. if ioErr != nil {
  32121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32123. return
  32124. }
  32125. var respJSON map[string]interface{}
  32126. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32129. return
  32130. }
  32131. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32132. result, _ := json.Marshal(respJSON)
  32133. fmt.Println("log")
  32134. fmt.Println(string(result))
  32135. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32136. utils.ErrorLog("解析失败:%v", err)
  32137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32138. return
  32139. }
  32140. } else {
  32141. if miConfig.MdtrtareaAdmvs == "441202" {
  32142. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32143. if result3101.Infcode == 0 {
  32144. if len(result3101.Output.Result) > 0 {
  32145. c.ServeSuccessJSON(map[string]interface{}{
  32146. "failed_code": -10,
  32147. "failed_type": 100,
  32148. "msg": result3101.Output.Result,
  32149. })
  32150. return
  32151. } else {
  32152. var result string
  32153. var request_log string
  32154. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32155. allTotal = fmt.Sprintf("%.2f", total_two)
  32156. if his.IdCardType == 4 {
  32157. 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)
  32158. } else {
  32159. 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)
  32160. }
  32161. var dat map[string]interface{}
  32162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32163. fmt.Println(dat)
  32164. } else {
  32165. fmt.Println(err)
  32166. }
  32167. saveLog(result, request_log, "2206", "预结算")
  32168. //userJSONBytes, _ := json.Marshal(dat)
  32169. //
  32170. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32171. // utils.ErrorLog("解析失败:%v", err)
  32172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32173. // return
  32174. //}
  32175. userJSONBytes, _ := json.Marshal(dat)
  32176. if miConfig.Code == "H15049901371" {
  32177. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32178. utils.ErrorLog("解析失败:%v", err)
  32179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32180. return
  32181. }
  32182. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32183. res.Output = resSeven10265.Output
  32184. res.ErrMsg = resSeven10265.ErrMsg
  32185. res.Cainfo = resSeven10265.Cainfo
  32186. res.WarnMsg = resSeven10265.WarnMsg
  32187. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32188. res.Infcode = infocode
  32189. } else {
  32190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32191. utils.ErrorLog("解析失败:%v", err)
  32192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32193. return
  32194. }
  32195. }
  32196. }
  32197. } else {
  32198. c.ServeSuccessJSON(map[string]interface{}{
  32199. "failed_code": -10,
  32200. "msg": result3101.ErrMsg,
  32201. })
  32202. return
  32203. }
  32204. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32205. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32206. if result3101.Infcode == 0 {
  32207. if len(result3101.Output.Result) > 0 {
  32208. var errMsgs []string
  32209. for _, item := range result3101.Output.Result {
  32210. errMsgs = append(errMsgs, item.VolaCont)
  32211. }
  32212. c.ServeSuccessJSON(map[string]interface{}{
  32213. "failed_code": -10,
  32214. "msg": errMsgs,
  32215. })
  32216. return
  32217. } else {
  32218. var result string
  32219. var request_log string
  32220. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32221. allTotal = fmt.Sprintf("%.2f", total_two)
  32222. if his.IdCardType == 4 {
  32223. 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)
  32224. } else {
  32225. 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)
  32226. }
  32227. var dat map[string]interface{}
  32228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32229. fmt.Println(dat)
  32230. } else {
  32231. fmt.Println(err)
  32232. }
  32233. saveLog(result, request_log, "2206", "预结算")
  32234. //userJSONBytes, _ := json.Marshal(dat)
  32235. //
  32236. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32237. // utils.ErrorLog("解析失败:%v", err)
  32238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32239. // return
  32240. //}
  32241. userJSONBytes, _ := json.Marshal(dat)
  32242. if miConfig.Code == "H15049901371" {
  32243. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32244. utils.ErrorLog("解析失败:%v", err)
  32245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32246. return
  32247. }
  32248. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32249. res.Output = resSeven10265.Output
  32250. res.ErrMsg = resSeven10265.ErrMsg
  32251. res.Cainfo = resSeven10265.Cainfo
  32252. res.WarnMsg = resSeven10265.WarnMsg
  32253. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32254. res.Infcode = infocode
  32255. } else {
  32256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32257. utils.ErrorLog("解析失败:%v", err)
  32258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32259. return
  32260. }
  32261. }
  32262. }
  32263. } else {
  32264. c.ServeSuccessJSON(map[string]interface{}{
  32265. "failed_code": -10,
  32266. "msg": result3101.ErrMsg,
  32267. })
  32268. return
  32269. }
  32270. } else {
  32271. var result string
  32272. var request_log string
  32273. var dat map[string]interface{}
  32274. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32275. allTotal = fmt.Sprintf("%.2f", total_two)
  32276. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  32277. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32278. if result3101.Infcode == 0 {
  32279. if len(result3101.Output.Result) > 0 {
  32280. c.ServeSuccessJSON(map[string]interface{}{
  32281. "failed_code": -10,
  32282. "failed_type": 100,
  32283. "warm_type": 2,
  32284. "msg": result3101,
  32285. })
  32286. return
  32287. } else {
  32288. var result string
  32289. var request_log string
  32290. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32291. allTotal = fmt.Sprintf("%.2f", total_two)
  32292. if his.IdCardType == 4 {
  32293. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32294. } else {
  32295. if his.IdCardType == 2 {
  32296. cert_no = psn_info.Certno
  32297. psn_info.VerifyNumber = psn_info.Certno
  32298. } else {
  32299. bas := strings.Split(psn_info.CardInfo, "|")
  32300. cert_no = bas[2]
  32301. }
  32302. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32303. }
  32304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32305. fmt.Println(dat)
  32306. } else {
  32307. fmt.Println(err)
  32308. }
  32309. saveLog(result, request_log, "2206", "预结算")
  32310. }
  32311. } else {
  32312. c.ServeSuccessJSON(map[string]interface{}{
  32313. "failed_code": -10,
  32314. "msg": result3101.ErrMsg,
  32315. })
  32316. return
  32317. }
  32318. } else {
  32319. if his.IdCardType == 4 {
  32320. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32321. } else {
  32322. if his.IdCardType == 2 {
  32323. cert_no = psn_info.Certno
  32324. psn_info.VerifyNumber = psn_info.Certno
  32325. } else {
  32326. bas := strings.Split(psn_info.CardInfo, "|")
  32327. cert_no = bas[2]
  32328. }
  32329. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.Insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, admin_user_id)
  32330. }
  32331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32332. fmt.Println(dat)
  32333. } else {
  32334. fmt.Println(err)
  32335. }
  32336. saveLog(result, request_log, "2206", "预结算")
  32337. }
  32338. //userJSONBytes, _ := json.Marshal(dat)
  32339. //
  32340. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32341. // utils.ErrorLog("解析失败:%v", err)
  32342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32343. // return
  32344. //}
  32345. userJSONBytes, _ := json.Marshal(dat)
  32346. if miConfig.Code == "H15049901371" {
  32347. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32348. utils.ErrorLog("解析失败:%v", err)
  32349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32350. return
  32351. }
  32352. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32353. res.Output = resSeven10265.Output
  32354. res.ErrMsg = resSeven10265.ErrMsg
  32355. res.Cainfo = resSeven10265.Cainfo
  32356. res.WarnMsg = resSeven10265.WarnMsg
  32357. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32358. res.Infcode = infocode
  32359. } else {
  32360. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32361. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32362. utils.ErrorLog("解析失败:%v", err)
  32363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32364. return
  32365. }
  32366. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32367. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32368. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32369. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32370. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32371. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32372. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32373. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32374. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32375. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32376. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32377. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32378. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32379. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32380. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32381. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32382. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32383. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32384. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32385. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32386. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32387. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32388. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32389. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32390. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32391. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32392. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32393. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32394. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32395. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32396. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32397. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32398. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32399. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32400. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32401. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32402. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32403. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32404. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32405. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32406. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32407. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32408. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32409. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32410. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32411. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32412. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32413. res.Cainfo = gzresSeven10265Two.Cainfo
  32414. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32415. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32416. //res.Infcode = infocode
  32417. } else {
  32418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32419. utils.ErrorLog("解析失败:%v", err)
  32420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32421. return
  32422. }
  32423. }
  32424. }
  32425. }
  32426. }
  32427. utils.ErrorLog("解析失败:%v", res.Infcode)
  32428. if res.Infcode == -1 {
  32429. errlog := &models.HisOrderError{
  32430. UserOrgId: adminUser.CurrentOrgId,
  32431. Ctime: time.Now().Unix(),
  32432. Mtime: time.Now().Unix(),
  32433. Number: chrg_bchno,
  32434. ErrMsg: res.ErrMsg,
  32435. Status: 1,
  32436. PatientId: id,
  32437. RecordTime: recordDateTime,
  32438. Stage: 20,
  32439. }
  32440. service.CreateErrMsgLog(errlog)
  32441. c.ServeSuccessJSON(map[string]interface{}{
  32442. "failed_code": -10,
  32443. "msg": res.ErrMsg,
  32444. })
  32445. return
  32446. }
  32447. if res.Infcode != 0 {
  32448. errlog := &models.HisOrderError{
  32449. UserOrgId: adminUser.CurrentOrgId,
  32450. Ctime: time.Now().Unix(),
  32451. Mtime: time.Now().Unix(),
  32452. Number: chrg_bchno,
  32453. ErrMsg: res.ErrMsg,
  32454. Status: 1,
  32455. PatientId: id,
  32456. RecordTime: recordDateTime,
  32457. Stage: 20,
  32458. }
  32459. service.CreateErrMsgLog(errlog)
  32460. c.ServeSuccessJSON(map[string]interface{}{
  32461. "failed_code": -10,
  32462. "msg": res.ErrMsg,
  32463. })
  32464. return
  32465. } else {
  32466. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32467. order.OrderStatus = 1
  32468. order.IsPre = 1
  32469. order.Status = 1
  32470. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32471. order.SetlId = res.Output.Setlinfo.SetlID
  32472. order.PsnNo = res.Output.Setlinfo.PsnNo
  32473. order.PsnName = res.Output.Setlinfo.PsnName
  32474. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32475. order.Certno = res.Output.Setlinfo.Certno
  32476. order.Gend = res.Output.Setlinfo.Gend
  32477. order.Naty = res.Output.Setlinfo.Naty
  32478. order.Age = res.Output.Setlinfo.Age
  32479. order.Insutype = res.Output.Setlinfo.Insutype
  32480. order.PsnType = res.Output.Setlinfo.PsnType
  32481. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32482. order.SetlTime = res.Output.Setlinfo.SetlTime
  32483. order.AcctUsedFlag = acct_used_flag
  32484. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32485. if res.Output.Setlinfo.MedType == "140101" {
  32486. order.MedType = "14"
  32487. } else {
  32488. if res.Output.Setlinfo.MedType == "110104" {
  32489. order.MedType = "11"
  32490. } else {
  32491. order.MedType = res.Output.Setlinfo.MedType
  32492. }
  32493. }
  32494. if res.Output.Setlinfo.MedType == "992102" {
  32495. order.MedType = "992102"
  32496. }
  32497. if res.Output.Setlinfo.MedType == "140104" {
  32498. order.MedType = "140104"
  32499. }
  32500. if res.Output.Setlinfo.MedType == "1104" {
  32501. order.MedType = "1104"
  32502. }
  32503. if res.Output.Setlinfo.MedType == "140201" {
  32504. order.MedType = "140201"
  32505. }
  32506. if res.Output.Setlinfo.MedType == "14" {
  32507. order.MedType = "14"
  32508. }
  32509. if reg_type == 1112 {
  32510. order.MedType = "1112"
  32511. }
  32512. if reg_type == 1111 {
  32513. order.MedType = "1111"
  32514. }
  32515. order.ClrType = res.Output.Setlinfo.ClrType
  32516. if adminUser.CurrentOrgId == 10480 {
  32517. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32518. order.ClrType = "11"
  32519. } else {
  32520. order.ClrType = "9903"
  32521. }
  32522. }
  32523. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32524. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32525. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32526. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32527. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32528. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32529. order.HifpPay = res.Output.Setlinfo.HifpPay
  32530. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32531. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32532. order.HifesPay = res.Output.Setlinfo.HifesPay
  32533. order.HifobPay = res.Output.Setlinfo.HifobPay
  32534. order.MafPay = res.Output.Setlinfo.MafPay
  32535. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32536. order.OthPay = res.Output.Setlinfo.OthPay
  32537. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32538. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32539. order.AcctPay = res.Output.Setlinfo.AcctPay
  32540. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32541. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32542. order.Balc = res.Output.Setlinfo.Balc
  32543. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32544. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32545. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32546. order.ClrWay = res.Output.Setlinfo.ClrWay
  32547. order.Creator = order.Creator
  32548. order.Modify = roles.AdminUserId
  32549. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32550. //detailStr := string(setlDetail)
  32551. //order.SetlDetail = detailStr
  32552. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32553. err = service.UpDateOrder(order)
  32554. if err == nil {
  32555. c.ServeSuccessJSON(map[string]interface{}{
  32556. "msg": "预结算成功",
  32557. })
  32558. } else {
  32559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32560. return
  32561. }
  32562. }
  32563. } else {
  32564. adminUser := c.GetAdminUserInfo()
  32565. errlog := &models.HisOrderError{
  32566. UserOrgId: adminUser.CurrentOrgId,
  32567. Ctime: time.Now().Unix(),
  32568. Mtime: time.Now().Unix(),
  32569. ErrMsg: res.ErrMsg,
  32570. Status: 1,
  32571. PatientId: id,
  32572. RecordTime: recordDateTime,
  32573. Stage: 4,
  32574. }
  32575. service.CreateErrMsgLog(errlog)
  32576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32577. return
  32578. }
  32579. } else {
  32580. if miConfig.MdtrtareaAdmvs == "150499" {
  32581. order := &models.HisOrder{
  32582. UserOrgId: adminUser.CurrentOrgId,
  32583. HisPatientId: his.ID,
  32584. PatientId: his.PatientId,
  32585. SettleAccountsDate: recordDateTime,
  32586. Ctime: time.Now().Unix(),
  32587. Mtime: time.Now().Unix(),
  32588. MdtrtId: his.Number,
  32589. PsnNo: his.PsnNo,
  32590. MedType: strconv.FormatInt(reg_type, 10),
  32591. Status: 1,
  32592. Number: chrg_bchno,
  32593. Infcode: res.Infcode,
  32594. WarnMsg: res.WarnMsg,
  32595. Cainfo: res.Cainfo,
  32596. ErrMsg: res.ErrMsg,
  32597. RespondTime: res.RefmsgTime,
  32598. InfRefmsgid: res.InfRefmsgid,
  32599. OrderStatus: 1,
  32600. IsMedicineInsurance: 1,
  32601. SettleType: settle_accounts_type,
  32602. SettleStartTime: start_time,
  32603. SettleEndTime: end_time,
  32604. Creator: roles.AdminUserId,
  32605. Modify: roles.AdminUserId,
  32606. PType: 2,
  32607. Diagnosis: diagnosis_id,
  32608. }
  32609. err = service.CreateOrder(order)
  32610. if err != nil {
  32611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32612. return
  32613. }
  32614. }
  32615. adminUser := c.GetAdminUserInfo()
  32616. errlog := &models.HisOrderError{
  32617. UserOrgId: adminUser.CurrentOrgId,
  32618. Ctime: time.Now().Unix(),
  32619. Mtime: time.Now().Unix(),
  32620. ErrMsg: res.ErrMsg,
  32621. Status: 1,
  32622. PatientId: id,
  32623. RecordTime: recordDateTime,
  32624. Stage: 4,
  32625. }
  32626. service.CreateErrMsgLog(errlog)
  32627. c.ServeSuccessJSON(map[string]interface{}{
  32628. "failed_code": -10,
  32629. "msg": res.ErrMsg,
  32630. })
  32631. return
  32632. }
  32633. }
  32634. }
  32635. }
  32636. // 退款
  32637. func (c *HisApiController) Refund() {
  32638. order_id, _ := c.GetInt64("order_id")
  32639. admin_user_id, _ := c.GetInt64("admin_user_id")
  32640. adminUser := c.GetAdminUserInfo()
  32641. var order models.HisOrder
  32642. order, _ = service.GetHisOrderByID(order_id)
  32643. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32644. if fapiao.ID > 0 {
  32645. c.ServeSuccessJSON(map[string]interface{}{
  32646. "failed_code": -10,
  32647. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32648. })
  32649. return
  32650. }
  32651. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32652. if order.ID == 0 {
  32653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32654. return
  32655. }
  32656. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32657. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32658. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32659. if config.IsOpen == 1 { //对接了医保,走医保流程
  32660. var res ResultSixteen
  32661. var ahres ResultSevenAH
  32662. var resSixteen10265 ResultSixteen10265
  32663. var resSixteen10265Two ResultSixteen10265Two
  32664. var gz ResultgzSixteen10265Two
  32665. var src_resquest string
  32666. var result string
  32667. if miConfig.MdtrtareaAdmvs == "421300" {
  32668. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32669. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32670. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32671. resp3, requestErr3 := http.Get(api3)
  32672. if requestErr3 != nil {
  32673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32674. return
  32675. }
  32676. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32677. if ioErr3 != nil {
  32678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32680. return
  32681. }
  32682. var respJSON3 map[string]interface{}
  32683. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32686. return
  32687. }
  32688. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32689. userJSONBytes3, _ := json.Marshal(respJSON3)
  32690. fmt.Println("log")
  32691. fmt.Println(string(userJSONBytes3))
  32692. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32693. utils.ErrorLog("解析失败:%v", err)
  32694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32695. return
  32696. }
  32697. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32698. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32699. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32700. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32701. resp3, requestErr3 := http.Get(api3)
  32702. if requestErr3 != nil {
  32703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32704. return
  32705. }
  32706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32707. if ioErr3 != nil {
  32708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32710. return
  32711. }
  32712. var respJSON3 map[string]interface{}
  32713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32716. return
  32717. }
  32718. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32719. userJSONBytes3, _ := json.Marshal(respJSON3)
  32720. fmt.Println("log")
  32721. fmt.Println(string(userJSONBytes3))
  32722. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32723. utils.ErrorLog("解析失败:%v", err)
  32724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32725. return
  32726. }
  32727. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32728. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32729. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32731. resp3, requestErr3 := http.Get(api3)
  32732. if requestErr3 != nil {
  32733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32734. return
  32735. }
  32736. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32737. if ioErr3 != nil {
  32738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32740. return
  32741. }
  32742. var respJSON3 map[string]interface{}
  32743. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32746. return
  32747. }
  32748. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32749. userJSONBytes3, _ := json.Marshal(respJSON3)
  32750. fmt.Println("log")
  32751. fmt.Println(string(userJSONBytes3))
  32752. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32753. utils.ErrorLog("解析失败:%v", err)
  32754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32755. return
  32756. }
  32757. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32758. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32759. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32760. "&insuplc_admdvs=" + miConfig.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, &res); err != nil {
  32783. utils.ErrorLog("解析失败:%v", err)
  32784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32785. return
  32786. }
  32787. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32788. var api3 string
  32789. if miConfig.MdtrtareaAdmvs == "320830" {
  32790. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  32791. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32792. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32793. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32794. } else if miConfig.MdtrtareaAdmvs == "320921" {
  32795. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32796. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32797. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32798. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32799. } else {
  32800. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32801. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32802. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32803. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32804. }
  32805. resp3, requestErr3 := http.Get(api3)
  32806. if requestErr3 != nil {
  32807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32808. return
  32809. }
  32810. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32811. if ioErr3 != nil {
  32812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32814. return
  32815. }
  32816. var respJSON3 map[string]interface{}
  32817. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32820. return
  32821. }
  32822. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32823. userJSONBytes3, _ := json.Marshal(respJSON3)
  32824. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32825. utils.ErrorLog("解析失败:%v", err)
  32826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32827. return
  32828. }
  32829. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32830. res.Output = resSixteen10265.Output
  32831. res.ErrMsg = resSixteen10265.ErrMsg
  32832. res.Cainfo = resSixteen10265.Cainfo
  32833. res.WarnMsg = resSixteen10265.WarnMsg
  32834. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32835. res.Infcode = infocode
  32836. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32837. var api3 string
  32838. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  32839. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32841. resp3, requestErr3 := http.Get(api3)
  32842. if requestErr3 != nil {
  32843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32844. return
  32845. }
  32846. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32847. if ioErr3 != nil {
  32848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32850. return
  32851. }
  32852. var respJSON3 map[string]interface{}
  32853. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32856. return
  32857. }
  32858. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32859. userJSONBytes3, _ := json.Marshal(respJSON3)
  32860. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32861. utils.ErrorLog("解析失败:%v", err)
  32862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32863. return
  32864. }
  32865. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32866. res.Output = resSixteen10265.Output
  32867. res.ErrMsg = resSixteen10265.ErrMsg
  32868. res.Cainfo = resSixteen10265.Cainfo
  32869. res.WarnMsg = resSixteen10265.WarnMsg
  32870. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32871. res.Infcode = infocode
  32872. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32873. 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)
  32874. var dat map[string]interface{}
  32875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32876. fmt.Println(dat)
  32877. } else {
  32878. fmt.Println(err)
  32879. }
  32880. saveLog(result, src_resquest, "2208", "退费")
  32881. userJSONBytes, _ := json.Marshal(dat)
  32882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32883. utils.ErrorLog("解析失败:%v", err)
  32884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32885. return
  32886. }
  32887. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32888. 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, "")
  32889. var dat map[string]interface{}
  32890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32891. fmt.Println(dat)
  32892. } else {
  32893. fmt.Println(err)
  32894. }
  32895. saveLog(result, src_resquest, "2208", "退费")
  32896. userJSONBytes, _ := json.Marshal(dat)
  32897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32898. utils.ErrorLog("解析失败:%v", err)
  32899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32900. return
  32901. }
  32902. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32903. 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, "")
  32904. var dat map[string]interface{}
  32905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32906. fmt.Println(dat)
  32907. } else {
  32908. fmt.Println(err)
  32909. }
  32910. saveLog(result, src_resquest, "2208", "退费")
  32911. userJSONBytes, _ := json.Marshal(dat)
  32912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32913. utils.ErrorLog("解析失败:%v", err)
  32914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32915. return
  32916. }
  32917. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32918. 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, "")
  32919. var dat map[string]interface{}
  32920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32921. fmt.Println(dat)
  32922. } else {
  32923. fmt.Println(err)
  32924. }
  32925. saveLog(result, src_resquest, "2208", "退费")
  32926. userJSONBytes, _ := json.Marshal(dat)
  32927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32928. utils.ErrorLog("解析失败:%v", err)
  32929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32930. return
  32931. }
  32932. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32933. var api3 string
  32934. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32935. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32936. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32937. resp3, requestErr3 := http.Get(api3)
  32938. if requestErr3 != nil {
  32939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32940. return
  32941. }
  32942. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32943. if ioErr3 != nil {
  32944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32946. return
  32947. }
  32948. var respJSON3 map[string]interface{}
  32949. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32952. return
  32953. }
  32954. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32955. if status == "0" {
  32956. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32957. c.ServeSuccessJSON(map[string]interface{}{
  32958. "failed_code": -10,
  32959. "msg": err_msg,
  32960. })
  32961. return
  32962. }
  32963. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32964. userJSONBytes3, _ := json.Marshal(respJSON3)
  32965. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32966. // utils.ErrorLog("解析失败:%v", err)
  32967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32968. // return
  32969. //}
  32970. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32971. utils.ErrorLog("解析失败:%v", err)
  32972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32973. return
  32974. }
  32975. res.InfRefmsgid = ahres.InfRefmsgid
  32976. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32977. // 创建对应的Time类型
  32978. t := time.UnixMilli(timestamp)
  32979. // 格式化成指定的日期字符串
  32980. str := t.Format("2006-01-02 15:04:05")
  32981. res.Output.Setlinfo.SetlTime = str
  32982. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32983. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32984. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32985. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32986. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32987. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32988. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32989. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32990. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32991. //
  32992. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32993. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32994. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32995. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32996. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32997. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32998. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32999. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33000. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33001. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33002. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33003. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33004. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33005. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33006. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33007. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33008. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33009. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33010. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33011. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33012. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33013. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33014. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33015. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33016. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33017. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33018. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33019. //res.Output.Setldetail = ahres.Output.Setldetail
  33020. res.ErrMsg = ahres.ErrMsg
  33021. res.Cainfo = ahres.Cainfo
  33022. res.WarnMsg = ahres.WarnMsg
  33023. res.Infcode = ahres.Infcode
  33024. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33025. var api3 string
  33026. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33027. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33028. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33029. resp3, requestErr3 := http.Get(api3)
  33030. if requestErr3 != nil {
  33031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33032. return
  33033. }
  33034. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33035. if ioErr3 != nil {
  33036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33038. return
  33039. }
  33040. var respJSON3 map[string]interface{}
  33041. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33044. return
  33045. }
  33046. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33047. if status == "0" {
  33048. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33049. c.ServeSuccessJSON(map[string]interface{}{
  33050. "failed_code": -10,
  33051. "msg": err_msg,
  33052. })
  33053. return
  33054. }
  33055. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33056. userJSONBytes3, _ := json.Marshal(respJSON3)
  33057. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33058. // utils.ErrorLog("解析失败:%v", err)
  33059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33060. // return
  33061. //}
  33062. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33063. utils.ErrorLog("解析失败:%v", err)
  33064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33065. return
  33066. }
  33067. res.InfRefmsgid = ahres.InfRefmsgid
  33068. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33069. // 创建对应的Time类型
  33070. t := time.UnixMilli(timestamp)
  33071. // 格式化成指定的日期字符串
  33072. str := t.Format("2006-01-02 15:04:05")
  33073. res.Output.Setlinfo.SetlTime = str
  33074. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33075. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33076. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33077. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33078. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33079. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33080. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33081. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33082. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33083. //
  33084. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33085. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33086. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33087. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33088. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33089. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33090. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33091. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33092. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33093. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33094. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33095. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33096. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33097. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33098. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33099. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33100. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33101. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33102. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33103. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33104. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33105. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33106. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33107. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33108. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33109. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33110. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33111. //res.Output.Setldetail = ahres.Output.Setldetail
  33112. res.ErrMsg = ahres.ErrMsg
  33113. res.Cainfo = ahres.Cainfo
  33114. res.WarnMsg = ahres.WarnMsg
  33115. res.Infcode = ahres.Infcode
  33116. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33117. 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, "")
  33118. var dat map[string]interface{}
  33119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33120. fmt.Println(dat)
  33121. } else {
  33122. fmt.Println(err)
  33123. }
  33124. saveLog(result, src_resquest, "2208", "退费")
  33125. userJSONBytes, _ := json.Marshal(dat)
  33126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33127. utils.ErrorLog("解析失败:%v", err)
  33128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33129. return
  33130. }
  33131. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33132. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33133. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33134. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33135. resp3, requestErr3 := http.Get(api3)
  33136. if requestErr3 != nil {
  33137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33138. return
  33139. }
  33140. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33141. if ioErr3 != nil {
  33142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33144. return
  33145. }
  33146. var respJSON3 map[string]interface{}
  33147. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33150. return
  33151. }
  33152. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33153. userJSONBytes3, _ := json.Marshal(respJSON3)
  33154. fmt.Println("log")
  33155. fmt.Println(string(userJSONBytes3))
  33156. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33157. utils.ErrorLog("解析失败:%v", err)
  33158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33159. return
  33160. }
  33161. } else {
  33162. if miConfig.Code == "H15049901371" {
  33163. 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)
  33164. var dat map[string]interface{}
  33165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33166. fmt.Println(dat)
  33167. } else {
  33168. fmt.Println(err)
  33169. }
  33170. saveLog(result, src_resquest, "2208", "退费")
  33171. if strings.Contains(result, "Post") {
  33172. res.Infcode = -1
  33173. res.ErrMsg = result
  33174. }
  33175. userJSONBytes, _ := json.Marshal(dat)
  33176. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33177. utils.ErrorLog("解析失败:%v", err)
  33178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33179. return
  33180. }
  33181. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33182. res.Output = resSixteen10265.Output
  33183. res.ErrMsg = resSixteen10265.ErrMsg
  33184. res.Cainfo = resSixteen10265.Cainfo
  33185. res.WarnMsg = resSixteen10265.WarnMsg
  33186. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33187. res.Infcode = infocode
  33188. } else {
  33189. 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)
  33190. var dat map[string]interface{}
  33191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33192. fmt.Println(dat)
  33193. } else {
  33194. fmt.Println(err)
  33195. }
  33196. saveLog(result, src_resquest, "2208", "退费")
  33197. userJSONBytes, _ := json.Marshal(dat)
  33198. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33199. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33200. utils.ErrorLog("解析失败:%v", err)
  33201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33202. return
  33203. }
  33204. res.Infcode = gz.Infcode
  33205. } else {
  33206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33207. utils.ErrorLog("解析失败:%v", err)
  33208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33209. return
  33210. }
  33211. }
  33212. if strings.Contains(result, "Post") {
  33213. res.Infcode = -1
  33214. res.ErrMsg = result
  33215. }
  33216. }
  33217. }
  33218. if res.Infcode == -1 {
  33219. c.ServeSuccessJSON(map[string]interface{}{
  33220. "failed_code": -10,
  33221. "msg": res.ErrMsg,
  33222. })
  33223. return
  33224. }
  33225. if res.Infcode != -1 {
  33226. var res2 ResultSix
  33227. var resSix10265 ResultSix10265
  33228. if miConfig.MdtrtareaAdmvs == "421300" {
  33229. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33230. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33231. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33232. resp3, requestErr3 := http.Get(api3)
  33233. if requestErr3 != nil {
  33234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33235. return
  33236. }
  33237. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33238. if ioErr3 != nil {
  33239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33241. return
  33242. }
  33243. var respJSON3 map[string]interface{}
  33244. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33247. return
  33248. }
  33249. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33250. userJSONBytes3, _ := json.Marshal(respJSON3)
  33251. fmt.Println("log")
  33252. fmt.Println(string(userJSONBytes3))
  33253. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33254. utils.ErrorLog("解析失败:%v", err)
  33255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33256. return
  33257. }
  33258. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33259. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33260. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33261. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33262. resp3, requestErr3 := http.Get(api3)
  33263. if requestErr3 != nil {
  33264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33265. return
  33266. }
  33267. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33268. if ioErr3 != nil {
  33269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33271. return
  33272. }
  33273. var respJSON3 map[string]interface{}
  33274. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33277. return
  33278. }
  33279. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33280. userJSONBytes3, _ := json.Marshal(respJSON3)
  33281. fmt.Println("log")
  33282. fmt.Println(string(userJSONBytes3))
  33283. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33284. utils.ErrorLog("解析失败:%v", err)
  33285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33286. return
  33287. }
  33288. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33289. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33290. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33291. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33292. resp3, requestErr3 := http.Get(api3)
  33293. if requestErr3 != nil {
  33294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33295. return
  33296. }
  33297. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33298. if ioErr3 != nil {
  33299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33301. return
  33302. }
  33303. var respJSON3 map[string]interface{}
  33304. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33307. return
  33308. }
  33309. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33310. userJSONBytes3, _ := json.Marshal(respJSON3)
  33311. fmt.Println("log")
  33312. fmt.Println(string(userJSONBytes3))
  33313. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33314. utils.ErrorLog("解析失败:%v", err)
  33315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33316. return
  33317. }
  33318. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33319. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33320. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33321. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33322. resp3, requestErr3 := http.Get(api3)
  33323. if requestErr3 != nil {
  33324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33325. return
  33326. }
  33327. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33328. if ioErr3 != nil {
  33329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33331. return
  33332. }
  33333. var respJSON3 map[string]interface{}
  33334. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33337. return
  33338. }
  33339. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33340. userJSONBytes3, _ := json.Marshal(respJSON3)
  33341. fmt.Println("log")
  33342. fmt.Println(string(userJSONBytes3))
  33343. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33344. utils.ErrorLog("解析失败:%v", err)
  33345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33346. return
  33347. }
  33348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33349. var api3 string
  33350. if miConfig.MdtrtareaAdmvs == "320830" {
  33351. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33352. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33353. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33354. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33355. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33356. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33357. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33358. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33359. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33360. } else {
  33361. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33362. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33363. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33364. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33365. }
  33366. resp3, requestErr3 := http.Get(api3)
  33367. if requestErr3 != nil {
  33368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33369. return
  33370. }
  33371. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33372. if ioErr3 != nil {
  33373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33375. return
  33376. }
  33377. var respJSON3 map[string]interface{}
  33378. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33381. return
  33382. }
  33383. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33384. userJSONBytes3, _ := json.Marshal(respJSON3)
  33385. fmt.Println("log")
  33386. fmt.Println(string(userJSONBytes3))
  33387. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33388. utils.ErrorLog("解析失败:%v", err)
  33389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33390. return
  33391. }
  33392. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33393. res2.Output = resSix10265.Output
  33394. res2.ErrMsg = resSix10265.ErrMsg
  33395. res2.Cainfo = resSix10265.Cainfo
  33396. res2.WarnMsg = resSix10265.WarnMsg
  33397. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33398. res2.Infcode = infocode
  33399. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33400. var api3 string
  33401. new_chrg_bchno := order.Number
  33402. if adminUser.CurrentOrgId == 10265 {
  33403. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33404. new_chrg_bchno = "0000"
  33405. }
  33406. }
  33407. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33408. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33409. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33410. resp3, requestErr3 := http.Get(api3)
  33411. if requestErr3 != nil {
  33412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33413. return
  33414. }
  33415. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33416. if ioErr3 != nil {
  33417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. var respJSON3 map[string]interface{}
  33422. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33425. return
  33426. }
  33427. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33428. userJSONBytes3, _ := json.Marshal(respJSON3)
  33429. fmt.Println("log")
  33430. fmt.Println(string(userJSONBytes3))
  33431. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33432. utils.ErrorLog("解析失败:%v", err)
  33433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33434. return
  33435. }
  33436. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33437. res2.Output = resSix10265.Output
  33438. res2.ErrMsg = resSix10265.ErrMsg
  33439. res2.Cainfo = resSix10265.Cainfo
  33440. res2.WarnMsg = resSix10265.WarnMsg
  33441. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33442. res2.Infcode = infocode
  33443. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33444. 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)
  33445. var dat map[string]interface{}
  33446. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33447. fmt.Println(dat)
  33448. } else {
  33449. fmt.Println(err)
  33450. }
  33451. saveLog(result2, src_request, "2205", "撤销明细")
  33452. userJSONBytes, _ := json.Marshal(dat)
  33453. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33454. utils.ErrorLog("解析失败:%v", err)
  33455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33456. return
  33457. }
  33458. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33459. 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, "")
  33460. var dat map[string]interface{}
  33461. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33462. fmt.Println(dat)
  33463. } else {
  33464. fmt.Println(err)
  33465. }
  33466. saveLog(result2, src_request, "2205", "撤销明细")
  33467. userJSONBytes, _ := json.Marshal(dat)
  33468. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33469. utils.ErrorLog("解析失败:%v", err)
  33470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33471. return
  33472. }
  33473. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33474. 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, "")
  33475. var dat map[string]interface{}
  33476. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33477. fmt.Println(dat)
  33478. } else {
  33479. fmt.Println(err)
  33480. }
  33481. saveLog(result2, src_request, "2205", "撤销明细")
  33482. userJSONBytes, _ := json.Marshal(dat)
  33483. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33484. utils.ErrorLog("解析失败:%v", err)
  33485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33486. return
  33487. }
  33488. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33489. 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, "")
  33490. var dat map[string]interface{}
  33491. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33492. fmt.Println(dat)
  33493. } else {
  33494. fmt.Println(err)
  33495. }
  33496. saveLog(result2, src_request, "2205", "撤销明细")
  33497. userJSONBytes, _ := json.Marshal(dat)
  33498. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33499. utils.ErrorLog("解析失败:%v", err)
  33500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33501. return
  33502. }
  33503. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33504. var api3 string
  33505. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33506. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33507. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33508. resp3, requestErr3 := http.Get(api3)
  33509. if requestErr3 != nil {
  33510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33511. return
  33512. }
  33513. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33514. if ioErr3 != nil {
  33515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33517. return
  33518. }
  33519. var respJSON3 map[string]interface{}
  33520. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33523. return
  33524. }
  33525. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33526. if status == "0" {
  33527. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33528. c.ServeSuccessJSON(map[string]interface{}{
  33529. "failed_code": -10,
  33530. "msg": err_msg,
  33531. })
  33532. return
  33533. }
  33534. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33535. userJSONBytes3, _ := json.Marshal(respJSON3)
  33536. fmt.Println("log")
  33537. fmt.Println(string(userJSONBytes3))
  33538. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33539. utils.ErrorLog("解析失败:%v", err)
  33540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33541. return
  33542. }
  33543. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33544. 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, "")
  33545. var dat map[string]interface{}
  33546. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33547. fmt.Println(dat)
  33548. } else {
  33549. fmt.Println(err)
  33550. }
  33551. saveLog(result2, src_request, "2205", "撤销明细")
  33552. userJSONBytes, _ := json.Marshal(dat)
  33553. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33554. utils.ErrorLog("解析失败:%v", err)
  33555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33556. return
  33557. }
  33558. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33559. 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, "")
  33560. var dat map[string]interface{}
  33561. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33562. fmt.Println(dat)
  33563. } else {
  33564. fmt.Println(err)
  33565. }
  33566. saveLog(result2, src_request, "2205", "撤销明细")
  33567. userJSONBytes, _ := json.Marshal(dat)
  33568. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33569. utils.ErrorLog("解析失败:%v", err)
  33570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33571. return
  33572. }
  33573. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33574. 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, "")
  33575. var dat map[string]interface{}
  33576. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33577. fmt.Println(dat)
  33578. } else {
  33579. fmt.Println(err)
  33580. }
  33581. saveLog(result2, src_request, "2205", "撤销明细")
  33582. userJSONBytes, _ := json.Marshal(dat)
  33583. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33584. utils.ErrorLog("解析失败:%v", err)
  33585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33586. return
  33587. }
  33588. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33589. var api3 string
  33590. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33591. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33592. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33593. resp3, requestErr3 := http.Get(api3)
  33594. if requestErr3 != nil {
  33595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33596. return
  33597. }
  33598. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33599. if ioErr3 != nil {
  33600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33602. return
  33603. }
  33604. var respJSON3 map[string]interface{}
  33605. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33608. return
  33609. }
  33610. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33611. if status == "0" {
  33612. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33613. c.ServeSuccessJSON(map[string]interface{}{
  33614. "failed_code": -10,
  33615. "msg": err_msg,
  33616. })
  33617. return
  33618. }
  33619. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33620. userJSONBytes3, _ := json.Marshal(respJSON3)
  33621. fmt.Println("log")
  33622. fmt.Println(string(userJSONBytes3))
  33623. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33624. utils.ErrorLog("解析失败:%v", err)
  33625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33626. return
  33627. }
  33628. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33629. 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, "")
  33630. var dat map[string]interface{}
  33631. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33632. fmt.Println(dat)
  33633. } else {
  33634. fmt.Println(err)
  33635. }
  33636. saveLog(result2, src_request, "2205", "撤销明细")
  33637. userJSONBytes, _ := json.Marshal(dat)
  33638. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33639. utils.ErrorLog("解析失败:%v", err)
  33640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33641. return
  33642. }
  33643. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33644. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33645. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33647. resp3, requestErr3 := http.Get(api3)
  33648. if requestErr3 != nil {
  33649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33650. return
  33651. }
  33652. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33653. if ioErr3 != nil {
  33654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33656. return
  33657. }
  33658. var respJSON3 map[string]interface{}
  33659. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33662. return
  33663. }
  33664. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33665. userJSONBytes3, _ := json.Marshal(respJSON3)
  33666. fmt.Println("log")
  33667. fmt.Println(string(userJSONBytes3))
  33668. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33669. utils.ErrorLog("解析失败:%v", err)
  33670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33671. return
  33672. }
  33673. } else {
  33674. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33675. res2.Infcode = 0
  33676. } else {
  33677. 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)
  33678. var dat map[string]interface{}
  33679. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33680. fmt.Println(dat)
  33681. } else {
  33682. fmt.Println(err)
  33683. }
  33684. saveLog(result2, src_request, "2205", "撤销明细")
  33685. userJSONBytes, _ := json.Marshal(dat)
  33686. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33687. utils.ErrorLog("解析失败:%v", err)
  33688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33689. return
  33690. }
  33691. }
  33692. }
  33693. if res2.Infcode == -1 {
  33694. c.ServeSuccessJSON(map[string]interface{}{
  33695. "failed_code": -10,
  33696. "msg": res2.ErrMsg,
  33697. })
  33698. return
  33699. }
  33700. if res2.Infcode == 0 {
  33701. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  33702. if err == nil {
  33703. //当押金不为零时产生退费记录
  33704. if order.Decimal != 0 {
  33705. tmp := strconv.FormatInt(order.ID, 10)
  33706. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  33707. if err != nil {
  33708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33709. return
  33710. }
  33711. }
  33712. c.ServeSuccessJSON(map[string]interface{}{
  33713. "msg": "退费成功",
  33714. })
  33715. } else {
  33716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33717. return
  33718. }
  33719. } else {
  33720. c.ServeSuccessJSON(map[string]interface{}{
  33721. "failed_code": -10,
  33722. "msg": res2.ErrMsg,
  33723. })
  33724. }
  33725. } else {
  33726. c.ServeSuccessJSON(map[string]interface{}{
  33727. "failed_code": -10,
  33728. "msg": res.ErrMsg,
  33729. })
  33730. }
  33731. }
  33732. }
  33733. func (c *HisApiController) RefundNumber() {
  33734. record_time := c.GetString("record_time")
  33735. //patient_id, _ := c.GetInt64("patient_id")
  33736. admin_user_id, _ := c.GetInt64("admin_user_id")
  33737. his_patient_id, _ := c.GetInt64("id")
  33738. timeLayout := "2006-01-02"
  33739. loc, _ := time.LoadLocation("Local")
  33740. adminUser := c.GetAdminUserInfo()
  33741. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33742. fmt.Println(err)
  33743. if err != nil {
  33744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33745. return
  33746. }
  33747. recordDateTime := theTime.Unix()
  33748. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33749. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  33750. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33751. //order, _ := service.GetHisOrderByID(order_id)
  33752. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33753. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33754. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33755. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  33756. if count > 0 {
  33757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  33758. return
  33759. }
  33760. if config.IsOpen == 1 { //对接了医保,走医保流程
  33761. var res2 ResultSix
  33762. var res3 GZResultSix
  33763. var resSix10265 ResultSix10265
  33764. if miConfig.MdtrtareaAdmvs == "421300" {
  33765. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33766. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33767. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33768. resp3, requestErr3 := http.Get(api3)
  33769. if requestErr3 != nil {
  33770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33771. return
  33772. }
  33773. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33774. if ioErr3 != nil {
  33775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33777. return
  33778. }
  33779. var respJSON3 map[string]interface{}
  33780. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33783. return
  33784. }
  33785. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33786. userJSONBytes3, _ := json.Marshal(respJSON3)
  33787. fmt.Println("log")
  33788. fmt.Println(string(userJSONBytes3))
  33789. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33790. utils.ErrorLog("解析失败:%v", err)
  33791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33792. return
  33793. }
  33794. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33795. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33796. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33798. resp3, requestErr3 := http.Get(api3)
  33799. if requestErr3 != nil {
  33800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33801. return
  33802. }
  33803. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33804. if ioErr3 != nil {
  33805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33807. return
  33808. }
  33809. var respJSON3 map[string]interface{}
  33810. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33813. return
  33814. }
  33815. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33816. userJSONBytes3, _ := json.Marshal(respJSON3)
  33817. fmt.Println("log")
  33818. fmt.Println(string(userJSONBytes3))
  33819. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33820. utils.ErrorLog("解析失败:%v", err)
  33821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33822. return
  33823. }
  33824. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33825. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33826. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33827. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33828. resp3, requestErr3 := http.Get(api3)
  33829. if requestErr3 != nil {
  33830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33831. return
  33832. }
  33833. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33834. if ioErr3 != nil {
  33835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33837. return
  33838. }
  33839. var respJSON3 map[string]interface{}
  33840. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33843. return
  33844. }
  33845. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33846. userJSONBytes3, _ := json.Marshal(respJSON3)
  33847. fmt.Println("log")
  33848. fmt.Println(string(userJSONBytes3))
  33849. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33850. utils.ErrorLog("解析失败:%v", err)
  33851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33852. return
  33853. }
  33854. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33855. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33856. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33857. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33858. resp3, requestErr3 := http.Get(api3)
  33859. if requestErr3 != nil {
  33860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33861. return
  33862. }
  33863. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33864. if ioErr3 != nil {
  33865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33867. return
  33868. }
  33869. var respJSON3 map[string]interface{}
  33870. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33873. return
  33874. }
  33875. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33876. userJSONBytes3, _ := json.Marshal(respJSON3)
  33877. fmt.Println("log")
  33878. fmt.Println(string(userJSONBytes3))
  33879. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33880. utils.ErrorLog("解析失败:%v", err)
  33881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33882. return
  33883. }
  33884. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33885. var api3 string
  33886. if miConfig.MdtrtareaAdmvs == "320830" {
  33887. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  33888. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33889. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33890. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33891. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33892. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  33893. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33894. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33895. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33896. } else {
  33897. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33898. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  33899. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33901. }
  33902. resp3, requestErr3 := http.Get(api3)
  33903. if requestErr3 != nil {
  33904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33905. return
  33906. }
  33907. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33908. if ioErr3 != nil {
  33909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33911. return
  33912. }
  33913. var respJSON3 map[string]interface{}
  33914. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33917. return
  33918. }
  33919. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33920. userJSONBytes3, _ := json.Marshal(respJSON3)
  33921. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33922. utils.ErrorLog("解析失败:%v", err)
  33923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33924. return
  33925. }
  33926. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33927. res2.Output = resSix10265.Output
  33928. res2.ErrMsg = resSix10265.ErrMsg
  33929. res2.Cainfo = resSix10265.Cainfo
  33930. res2.WarnMsg = resSix10265.WarnMsg
  33931. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33932. res2.Infcode = infocode
  33933. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33934. var api3 string
  33935. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  33936. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33938. resp3, requestErr3 := http.Get(api3)
  33939. if requestErr3 != nil {
  33940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33941. return
  33942. }
  33943. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33944. if ioErr3 != nil {
  33945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33947. return
  33948. }
  33949. var respJSON3 map[string]interface{}
  33950. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33953. return
  33954. }
  33955. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33956. userJSONBytes3, _ := json.Marshal(respJSON3)
  33957. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33958. utils.ErrorLog("解析失败:%v", err)
  33959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33960. return
  33961. }
  33962. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33963. res2.Output = resSix10265.Output
  33964. res2.ErrMsg = resSix10265.ErrMsg
  33965. res2.Cainfo = resSix10265.Cainfo
  33966. res2.WarnMsg = resSix10265.WarnMsg
  33967. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33968. res2.Infcode = infocode
  33969. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33970. 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)
  33971. var dat map[string]interface{}
  33972. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33973. fmt.Println(dat)
  33974. } else {
  33975. fmt.Println(err)
  33976. }
  33977. saveLog(result, request, "2202", "退号")
  33978. userJSONBytes, _ := json.Marshal(dat)
  33979. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33980. utils.ErrorLog("解析失败:%v", err)
  33981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33982. return
  33983. }
  33984. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33985. 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, "")
  33986. var dat map[string]interface{}
  33987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33988. fmt.Println(dat)
  33989. } else {
  33990. fmt.Println(err)
  33991. }
  33992. saveLog(result, request, "2202", "退号")
  33993. userJSONBytes, _ := json.Marshal(dat)
  33994. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33995. utils.ErrorLog("解析失败:%v", err)
  33996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33997. return
  33998. }
  33999. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34000. 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, "")
  34001. var dat map[string]interface{}
  34002. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34003. fmt.Println(dat)
  34004. } else {
  34005. fmt.Println(err)
  34006. }
  34007. saveLog(result, request, "2202", "退号")
  34008. userJSONBytes, _ := json.Marshal(dat)
  34009. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34010. utils.ErrorLog("解析失败:%v", err)
  34011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34012. return
  34013. }
  34014. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34015. 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, "")
  34016. var dat map[string]interface{}
  34017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34018. fmt.Println(dat)
  34019. } else {
  34020. fmt.Println(err)
  34021. }
  34022. saveLog(result, request, "2202", "退号")
  34023. userJSONBytes, _ := json.Marshal(dat)
  34024. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34025. utils.ErrorLog("解析失败:%v", err)
  34026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34027. return
  34028. }
  34029. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34030. var api3 string
  34031. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34032. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34034. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34035. resp3, requestErr3 := http.Get(api3)
  34036. if requestErr3 != nil {
  34037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34038. return
  34039. }
  34040. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34041. if ioErr3 != nil {
  34042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34044. return
  34045. }
  34046. var respJSON3 map[string]interface{}
  34047. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34050. return
  34051. }
  34052. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34053. if status == "0" {
  34054. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34055. c.ServeSuccessJSON(map[string]interface{}{
  34056. "failed_code": -10,
  34057. "msg": err_msg,
  34058. })
  34059. return
  34060. }
  34061. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34062. userJSONBytes3, _ := json.Marshal(respJSON3)
  34063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34064. utils.ErrorLog("解析失败:%v", err)
  34065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34066. return
  34067. }
  34068. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34069. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34070. var api3 string
  34071. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34072. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34073. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34074. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34075. resp3, requestErr3 := http.Get(api3)
  34076. if requestErr3 != nil {
  34077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34078. return
  34079. }
  34080. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34081. if ioErr3 != nil {
  34082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34084. return
  34085. }
  34086. var respJSON3 map[string]interface{}
  34087. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34090. return
  34091. }
  34092. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34093. if status == "0" {
  34094. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34095. c.ServeSuccessJSON(map[string]interface{}{
  34096. "failed_code": -10,
  34097. "msg": err_msg,
  34098. })
  34099. return
  34100. }
  34101. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34102. userJSONBytes3, _ := json.Marshal(respJSON3)
  34103. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34104. utils.ErrorLog("解析失败:%v", err)
  34105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34106. return
  34107. }
  34108. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34109. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34110. 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, "")
  34111. var dat map[string]interface{}
  34112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34113. fmt.Println(dat)
  34114. } else {
  34115. fmt.Println(err)
  34116. }
  34117. saveLog(result, request, "2202", "退号")
  34118. userJSONBytes, _ := json.Marshal(dat)
  34119. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34120. utils.ErrorLog("解析失败:%v", err)
  34121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34122. return
  34123. }
  34124. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34125. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34126. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34127. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34128. resp3, requestErr3 := http.Get(api3)
  34129. if requestErr3 != nil {
  34130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34131. return
  34132. }
  34133. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34134. if ioErr3 != nil {
  34135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34137. return
  34138. }
  34139. var respJSON3 map[string]interface{}
  34140. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34143. return
  34144. }
  34145. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34146. userJSONBytes3, _ := json.Marshal(respJSON3)
  34147. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34148. utils.ErrorLog("解析失败:%v", err)
  34149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34150. return
  34151. }
  34152. } else {
  34153. var api3 string
  34154. if miConfig.Code == "H15049901371" {
  34155. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34156. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34157. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34158. } else {
  34159. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34160. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34161. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34162. }
  34163. resp3, requestErr3 := http.Get(api3)
  34164. if requestErr3 != nil {
  34165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34166. return
  34167. }
  34168. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34169. if ioErr3 != nil {
  34170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34172. return
  34173. }
  34174. var respJSON3 map[string]interface{}
  34175. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34178. return
  34179. }
  34180. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34181. userJSONBytes3, _ := json.Marshal(respJSON3)
  34182. if miConfig.Code == "H15049901371" {
  34183. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34184. utils.ErrorLog("解析失败:%v", err)
  34185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34186. return
  34187. }
  34188. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34189. res2.Output = resSix10265.Output
  34190. res2.ErrMsg = resSix10265.ErrMsg
  34191. res2.Cainfo = resSix10265.Cainfo
  34192. res2.WarnMsg = resSix10265.WarnMsg
  34193. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34194. res2.Infcode = infocode
  34195. } else {
  34196. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34197. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34198. utils.ErrorLog("解析失败:%v", err)
  34199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34200. return
  34201. }
  34202. res2.Infcode = res3.Infcode
  34203. } else {
  34204. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34205. utils.ErrorLog("解析失败:%v", err)
  34206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34207. return
  34208. }
  34209. }
  34210. }
  34211. }
  34212. if res2.Infcode == -1 {
  34213. c.ServeSuccessJSON(map[string]interface{}{
  34214. "failed_code": -10,
  34215. "msg": res2.ErrMsg,
  34216. })
  34217. return
  34218. }
  34219. if res2.Infcode == 0 {
  34220. if err == nil {
  34221. c.ServeSuccessJSON(map[string]interface{}{
  34222. "msg": "退号成功",
  34223. })
  34224. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34225. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34226. } else {
  34227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34228. return
  34229. }
  34230. }
  34231. } else {
  34232. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34233. //if err == nil {
  34234. // c.ServeSuccessJSON(map[string]interface{}{
  34235. // "msg": "退费成功",
  34236. // })
  34237. //} else {
  34238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34239. // return
  34240. //}
  34241. }
  34242. }
  34243. func (c *HisApiController) RefundDetail() {
  34244. order_id, _ := c.GetInt64("order_id")
  34245. admin_user_id, _ := c.GetInt64("admin_user_id")
  34246. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34247. number := c.GetString("number")
  34248. record_time := c.GetString("record_time")
  34249. patient_id, _ := c.GetInt64("patient_id")
  34250. //med_type, _ := c.GetInt64("med_type")
  34251. timeLayout := "2006-01-02"
  34252. loc, _ := time.LoadLocation("Local")
  34253. adminUser := c.GetAdminUserInfo()
  34254. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34255. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34256. fmt.Println(err)
  34257. if err != nil {
  34258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34259. return
  34260. }
  34261. recordDateTime := theTime.Unix()
  34262. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34263. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34264. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34265. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34266. var order models.HisOrder
  34267. order, _ = service.GetHisOrderByID(order_id)
  34268. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34269. if config.IsOpen == 1 { //对接了医保,走医保流程
  34270. var res2 ResultSix
  34271. if miConfig.MdtrtareaAdmvs == "421300" {
  34272. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34273. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34274. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34275. resp3, requestErr3 := http.Get(api3)
  34276. if requestErr3 != nil {
  34277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34278. return
  34279. }
  34280. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34281. if ioErr3 != nil {
  34282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34284. return
  34285. }
  34286. var respJSON3 map[string]interface{}
  34287. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34290. return
  34291. }
  34292. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34293. userJSONBytes3, _ := json.Marshal(respJSON3)
  34294. fmt.Println("log")
  34295. fmt.Println(string(userJSONBytes3))
  34296. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34297. utils.ErrorLog("解析失败:%v", err)
  34298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34299. return
  34300. }
  34301. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34302. if err == nil {
  34303. c.ServeSuccessJSON(map[string]interface{}{
  34304. "msg": "撤销明细成功",
  34305. })
  34306. return
  34307. } else {
  34308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34309. return
  34310. }
  34311. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34312. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34313. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34314. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34315. resp3, requestErr3 := http.Get(api3)
  34316. if requestErr3 != nil {
  34317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34318. return
  34319. }
  34320. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34321. if ioErr3 != nil {
  34322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34324. return
  34325. }
  34326. var respJSON3 map[string]interface{}
  34327. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34330. return
  34331. }
  34332. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34333. userJSONBytes3, _ := json.Marshal(respJSON3)
  34334. fmt.Println("log")
  34335. fmt.Println(string(userJSONBytes3))
  34336. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34337. utils.ErrorLog("解析失败:%v", err)
  34338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34339. return
  34340. }
  34341. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34342. if err == nil {
  34343. c.ServeSuccessJSON(map[string]interface{}{
  34344. "msg": "撤销明细成功",
  34345. })
  34346. return
  34347. } else {
  34348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34349. return
  34350. }
  34351. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34352. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34353. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34355. resp3, requestErr3 := http.Get(api3)
  34356. if requestErr3 != nil {
  34357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34358. return
  34359. }
  34360. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34361. if ioErr3 != nil {
  34362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34364. return
  34365. }
  34366. var respJSON3 map[string]interface{}
  34367. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34370. return
  34371. }
  34372. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34373. userJSONBytes3, _ := json.Marshal(respJSON3)
  34374. fmt.Println("log")
  34375. fmt.Println(string(userJSONBytes3))
  34376. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34377. utils.ErrorLog("解析失败:%v", err)
  34378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34379. return
  34380. }
  34381. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34382. if err == nil {
  34383. c.ServeSuccessJSON(map[string]interface{}{
  34384. "msg": "撤销明细成功",
  34385. })
  34386. return
  34387. } else {
  34388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34389. return
  34390. }
  34391. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34392. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34393. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34394. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34395. resp3, requestErr3 := http.Get(api3)
  34396. if requestErr3 != nil {
  34397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34398. return
  34399. }
  34400. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34401. if ioErr3 != nil {
  34402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34404. return
  34405. }
  34406. var respJSON3 map[string]interface{}
  34407. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34410. return
  34411. }
  34412. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34413. userJSONBytes3, _ := json.Marshal(respJSON3)
  34414. fmt.Println("log")
  34415. fmt.Println(string(userJSONBytes3))
  34416. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34417. utils.ErrorLog("解析失败:%v", err)
  34418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34419. return
  34420. }
  34421. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34422. if err == nil {
  34423. c.ServeSuccessJSON(map[string]interface{}{
  34424. "msg": "撤销明细成功",
  34425. })
  34426. return
  34427. } else {
  34428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34429. return
  34430. }
  34431. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34432. var resSix10265 ResultSix10265
  34433. var api3 string
  34434. if miConfig.MdtrtareaAdmvs == "320830" {
  34435. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34436. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34437. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34438. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34439. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34440. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34441. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34442. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34443. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34444. } else {
  34445. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34446. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34447. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34448. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34449. }
  34450. resp3, requestErr3 := http.Get(api3)
  34451. utils.ErrorLog("接口: %v", requestErr3)
  34452. if requestErr3 != nil {
  34453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34454. return
  34455. }
  34456. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34457. if ioErr3 != nil {
  34458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34460. return
  34461. }
  34462. var respJSON3 map[string]interface{}
  34463. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34466. return
  34467. }
  34468. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34469. userJSONBytes3, _ := json.Marshal(respJSON3)
  34470. fmt.Println("log")
  34471. fmt.Println(string(userJSONBytes3))
  34472. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34473. utils.ErrorLog("解析失败:%v", err)
  34474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34475. return
  34476. }
  34477. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34478. res2.Output = resSix10265.Output
  34479. res2.ErrMsg = resSix10265.ErrMsg
  34480. res2.Cainfo = resSix10265.Cainfo
  34481. res2.WarnMsg = resSix10265.WarnMsg
  34482. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34483. res2.Infcode = infocode
  34484. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34485. if err == nil {
  34486. c.ServeSuccessJSON(map[string]interface{}{
  34487. "msg": "撤销明细成功",
  34488. })
  34489. return
  34490. } else {
  34491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34492. return
  34493. }
  34494. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34495. var api3 string
  34496. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34497. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34498. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34499. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34500. resp3, requestErr3 := http.Get(api3)
  34501. utils.ErrorLog("接口: %v", requestErr3)
  34502. if requestErr3 != nil {
  34503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34504. return
  34505. }
  34506. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34507. if ioErr3 != nil {
  34508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34510. return
  34511. }
  34512. var respJSON3 map[string]interface{}
  34513. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34516. return
  34517. }
  34518. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34519. if status == "0" {
  34520. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34521. c.ServeSuccessJSON(map[string]interface{}{
  34522. "failed_code": -10,
  34523. "msg": err_msg,
  34524. })
  34525. return
  34526. }
  34527. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34528. userJSONBytes3, _ := json.Marshal(respJSON3)
  34529. fmt.Println("log")
  34530. fmt.Println(string(userJSONBytes3))
  34531. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34532. utils.ErrorLog("解析失败:%v", err)
  34533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34534. return
  34535. }
  34536. fmt.Println(res2.Infcode)
  34537. if res2.Infcode == -1 {
  34538. c.ServeSuccessJSON(map[string]interface{}{
  34539. "failed_code": -10,
  34540. "msg": res2.ErrMsg,
  34541. })
  34542. return
  34543. }
  34544. if res2.Infcode == 0 {
  34545. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34546. if err == nil {
  34547. c.ServeSuccessJSON(map[string]interface{}{
  34548. "msg": "撤销明细成功",
  34549. })
  34550. return
  34551. } else {
  34552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34553. return
  34554. }
  34555. } else {
  34556. c.ServeSuccessJSON(map[string]interface{}{
  34557. "failed_code": -10,
  34558. "msg": res2.ErrMsg,
  34559. })
  34560. }
  34561. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34562. if err == nil {
  34563. c.ServeSuccessJSON(map[string]interface{}{
  34564. "msg": "撤销明细成功",
  34565. })
  34566. return
  34567. } else {
  34568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34569. return
  34570. }
  34571. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34572. var api3 string
  34573. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34574. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34575. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34576. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34577. resp3, requestErr3 := http.Get(api3)
  34578. utils.ErrorLog("接口: %v", requestErr3)
  34579. if requestErr3 != nil {
  34580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34581. return
  34582. }
  34583. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34584. if ioErr3 != nil {
  34585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34587. return
  34588. }
  34589. var respJSON3 map[string]interface{}
  34590. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34593. return
  34594. }
  34595. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34596. if status == "0" {
  34597. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34598. c.ServeSuccessJSON(map[string]interface{}{
  34599. "failed_code": -10,
  34600. "msg": err_msg,
  34601. })
  34602. return
  34603. }
  34604. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34605. userJSONBytes3, _ := json.Marshal(respJSON3)
  34606. fmt.Println("log")
  34607. fmt.Println(string(userJSONBytes3))
  34608. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34609. utils.ErrorLog("解析失败:%v", err)
  34610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34611. return
  34612. }
  34613. fmt.Println(res2.Infcode)
  34614. if res2.Infcode == -1 {
  34615. c.ServeSuccessJSON(map[string]interface{}{
  34616. "failed_code": -10,
  34617. "msg": res2.ErrMsg,
  34618. })
  34619. return
  34620. }
  34621. if res2.Infcode == 0 {
  34622. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34623. if err == nil {
  34624. c.ServeSuccessJSON(map[string]interface{}{
  34625. "msg": "撤销明细成功",
  34626. })
  34627. return
  34628. } else {
  34629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34630. return
  34631. }
  34632. } else {
  34633. c.ServeSuccessJSON(map[string]interface{}{
  34634. "failed_code": -10,
  34635. "msg": res2.ErrMsg,
  34636. })
  34637. }
  34638. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34639. if err == nil {
  34640. c.ServeSuccessJSON(map[string]interface{}{
  34641. "msg": "撤销明细成功",
  34642. })
  34643. return
  34644. } else {
  34645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34646. return
  34647. }
  34648. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34649. var resSix10265 ResultSix10265
  34650. new_chrg_bchno := order.Number
  34651. if adminUser.CurrentOrgId == 10265 {
  34652. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34653. new_chrg_bchno = "0000"
  34654. }
  34655. }
  34656. var api3 string
  34657. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34658. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34659. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34660. resp3, requestErr3 := http.Get(api3)
  34661. if requestErr3 != nil {
  34662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34663. return
  34664. }
  34665. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34666. if ioErr3 != nil {
  34667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34669. return
  34670. }
  34671. var respJSON3 map[string]interface{}
  34672. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34675. return
  34676. }
  34677. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34678. userJSONBytes3, _ := json.Marshal(respJSON3)
  34679. fmt.Println("log")
  34680. fmt.Println(string(userJSONBytes3))
  34681. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34682. utils.ErrorLog("解析失败:%v", err)
  34683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34684. return
  34685. }
  34686. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34687. res2.Output = resSix10265.Output
  34688. res2.ErrMsg = resSix10265.ErrMsg
  34689. res2.Cainfo = resSix10265.Cainfo
  34690. res2.WarnMsg = resSix10265.WarnMsg
  34691. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34692. res2.Infcode = infocode
  34693. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34694. if err == nil {
  34695. c.ServeSuccessJSON(map[string]interface{}{
  34696. "msg": "撤销明细成功",
  34697. })
  34698. return
  34699. } else {
  34700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34701. return
  34702. }
  34703. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34704. 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)
  34705. var dat map[string]interface{}
  34706. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34707. fmt.Println(dat)
  34708. } else {
  34709. fmt.Println(err)
  34710. }
  34711. saveLog(result2, src_request, "2205", "撤销明细")
  34712. userJSONBytes, _ := json.Marshal(dat)
  34713. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34714. utils.ErrorLog("解析失败:%v", err)
  34715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34716. return
  34717. }
  34718. if res2.Infcode == 0 {
  34719. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34720. if err == nil {
  34721. c.ServeSuccessJSON(map[string]interface{}{
  34722. "msg": "撤销明细成功",
  34723. })
  34724. return
  34725. } else {
  34726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34727. return
  34728. }
  34729. } else {
  34730. c.ServeSuccessJSON(map[string]interface{}{
  34731. "failed_code": -10,
  34732. "msg": res2.ErrMsg,
  34733. })
  34734. }
  34735. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34736. 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, "")
  34737. var dat map[string]interface{}
  34738. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34739. fmt.Println(dat)
  34740. } else {
  34741. fmt.Println(err)
  34742. }
  34743. saveLog(result2, src_request, "2205", "撤销明细")
  34744. userJSONBytes, _ := json.Marshal(dat)
  34745. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34746. utils.ErrorLog("解析失败:%v", err)
  34747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34748. return
  34749. }
  34750. if res2.Infcode == 0 {
  34751. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34752. if err == nil {
  34753. c.ServeSuccessJSON(map[string]interface{}{
  34754. "msg": "撤销明细成功",
  34755. })
  34756. return
  34757. } else {
  34758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34759. return
  34760. }
  34761. } else {
  34762. c.ServeSuccessJSON(map[string]interface{}{
  34763. "failed_code": -10,
  34764. "msg": res2.ErrMsg,
  34765. })
  34766. }
  34767. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34768. 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, "")
  34769. var dat map[string]interface{}
  34770. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34771. fmt.Println(dat)
  34772. } else {
  34773. fmt.Println(err)
  34774. }
  34775. saveLog(result2, src_request, "2205", "撤销明细")
  34776. userJSONBytes, _ := json.Marshal(dat)
  34777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34778. utils.ErrorLog("解析失败:%v", err)
  34779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34780. return
  34781. }
  34782. if res2.Infcode == 0 {
  34783. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34784. if err == nil {
  34785. c.ServeSuccessJSON(map[string]interface{}{
  34786. "msg": "撤销明细成功",
  34787. })
  34788. return
  34789. } else {
  34790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34791. return
  34792. }
  34793. } else {
  34794. c.ServeSuccessJSON(map[string]interface{}{
  34795. "failed_code": -10,
  34796. "msg": res2.ErrMsg,
  34797. })
  34798. }
  34799. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34800. 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, "")
  34801. var dat map[string]interface{}
  34802. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34803. fmt.Println(dat)
  34804. } else {
  34805. fmt.Println(err)
  34806. }
  34807. saveLog(result2, src_request, "2205", "撤销明细")
  34808. userJSONBytes, _ := json.Marshal(dat)
  34809. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34810. utils.ErrorLog("解析失败:%v", err)
  34811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34812. return
  34813. }
  34814. if res2.Infcode == 0 {
  34815. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34816. if err == nil {
  34817. c.ServeSuccessJSON(map[string]interface{}{
  34818. "msg": "撤销明细成功",
  34819. })
  34820. return
  34821. } else {
  34822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34823. return
  34824. }
  34825. } else {
  34826. c.ServeSuccessJSON(map[string]interface{}{
  34827. "failed_code": -10,
  34828. "msg": res2.ErrMsg,
  34829. })
  34830. }
  34831. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34832. 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, "")
  34833. var dat map[string]interface{}
  34834. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34835. fmt.Println(dat)
  34836. } else {
  34837. fmt.Println(err)
  34838. }
  34839. saveLog(result2, src_request, "2205", "撤销明细")
  34840. userJSONBytes, _ := json.Marshal(dat)
  34841. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34842. utils.ErrorLog("解析失败:%v", err)
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. if res2.Infcode == 0 {
  34847. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34848. if err == nil {
  34849. c.ServeSuccessJSON(map[string]interface{}{
  34850. "msg": "撤销明细成功",
  34851. })
  34852. return
  34853. } else {
  34854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34855. return
  34856. }
  34857. } else {
  34858. c.ServeSuccessJSON(map[string]interface{}{
  34859. "failed_code": -10,
  34860. "msg": res2.ErrMsg,
  34861. })
  34862. }
  34863. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34864. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  34865. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34867. resp2, requestErr2 := http.Get(api2)
  34868. if requestErr2 != nil {
  34869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34870. return
  34871. }
  34872. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  34873. if ioErr2 != nil {
  34874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  34875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34876. return
  34877. }
  34878. var respJSON2 map[string]interface{}
  34879. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  34880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34882. return
  34883. }
  34884. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34885. userJSONBytes3, _ := json.Marshal(respJSON2)
  34886. fmt.Println("log")
  34887. fmt.Println(string(userJSONBytes3))
  34888. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34889. utils.ErrorLog("解析失败:%v", err)
  34890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34891. return
  34892. }
  34893. if res2.Infcode == 0 {
  34894. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34895. if err == nil {
  34896. c.ServeSuccessJSON(map[string]interface{}{
  34897. "msg": "撤销明细成功",
  34898. })
  34899. return
  34900. } else {
  34901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34902. return
  34903. }
  34904. } else {
  34905. c.ServeSuccessJSON(map[string]interface{}{
  34906. "failed_code": -10,
  34907. "msg": res2.ErrMsg,
  34908. })
  34909. }
  34910. } else {
  34911. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  34912. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34913. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34914. resp2, requestErr2 := http.Get(api2)
  34915. if requestErr2 != nil {
  34916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34917. return
  34918. }
  34919. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  34920. if ioErr2 != nil {
  34921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  34922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34923. return
  34924. }
  34925. var respJSON2 map[string]interface{}
  34926. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  34927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34929. return
  34930. }
  34931. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34932. userJSONBytes3, _ := json.Marshal(respJSON2)
  34933. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34934. utils.ErrorLog("解析失败:%v", err)
  34935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34936. return
  34937. }
  34938. if res2.Infcode == -1 {
  34939. c.ServeSuccessJSON(map[string]interface{}{
  34940. "failed_code": -10,
  34941. "msg": res2.ErrMsg,
  34942. })
  34943. return
  34944. } else {
  34945. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34946. if err == nil {
  34947. c.ServeSuccessJSON(map[string]interface{}{
  34948. "msg": "撤销明细成功",
  34949. })
  34950. return
  34951. } else {
  34952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34953. return
  34954. }
  34955. }
  34956. }
  34957. } else {
  34958. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34959. if err == nil {
  34960. c.ServeSuccessJSON(map[string]interface{}{
  34961. "msg": "退费成功",
  34962. })
  34963. } else {
  34964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34965. return
  34966. }
  34967. }
  34968. }
  34969. // 对账
  34970. func (c *HisApiController) GetCheckAccount() {
  34971. start_time := c.GetString("start_time")
  34972. end_time := c.GetString("end_time")
  34973. insutype := c.GetString("insutype")
  34974. clr_type := c.GetString("clr_type")
  34975. clr_org := c.GetString("clr_optins")
  34976. admin_user_id, _ := c.GetInt64("admin_user_id")
  34977. adminUser := c.GetAdminUserInfo()
  34978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34979. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34980. if len(clr_org) == 0 {
  34981. clr_org = miConfig.InsuplcAdmdvs
  34982. }
  34983. timeLayout := "2006-01-02"
  34984. loc, _ := time.LoadLocation("Local")
  34985. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34986. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34987. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34988. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34989. fixmedins_setl_cnt := int64(len(orders))
  34990. var medfee_sumamt float64
  34991. var acct_pay float64
  34992. var fund_pay_sumamt float64
  34993. for _, item := range orders {
  34994. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34995. acct_pay = acct_pay + item.AcctPay
  34996. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  34997. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  34998. } else {
  34999. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35000. }
  35001. }
  35002. var user_name string
  35003. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35004. if role.ID == 0 {
  35005. user_name = "xxx"
  35006. } else {
  35007. user_name = role.UserName
  35008. }
  35009. var res ResultEight
  35010. var res10188 ResultEightFor10188
  35011. if config.IsOpen == 1 {
  35012. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35013. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  35014. "insutype=" + insutype +
  35015. "&clr_type=" + clr_type +
  35016. "&setl_optins=" + clr_org +
  35017. "&stmt_begndate=" + start_time +
  35018. "&stm_enddate=" + end_time +
  35019. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35020. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35021. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35022. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35023. "&fixmedins_code=" + miConfig.Code +
  35024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35025. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35026. "&secret_key=" + miConfig.SecretKey +
  35027. "&org_name=" + miConfig.OrgName +
  35028. "&doctor=" + user_name +
  35029. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35030. fmt.Println(api)
  35031. resp, requestErr := http.Get(api)
  35032. if requestErr != nil {
  35033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35034. return
  35035. }
  35036. body, ioErr := ioutil.ReadAll(resp.Body)
  35037. fmt.Println(body)
  35038. if ioErr != nil {
  35039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35041. return
  35042. }
  35043. var respJSON map[string]interface{}
  35044. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35047. return
  35048. }
  35049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35050. userJSONBytes, _ := json.Marshal(respJSON)
  35051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35052. utils.ErrorLog("解析失败:%v", err)
  35053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35054. return
  35055. }
  35056. res.InfRefmsgid = res10188.InfRefmsgid
  35057. res.Output = res10188.Output
  35058. res.ErrMsg = res10188.ErrMsg
  35059. res.Cainfo = res10188.Cainfo
  35060. res.WarnMsg = res10188.WarnMsg
  35061. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35062. res.Infcode = infocode
  35063. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35064. if clr_type != "9903" {
  35065. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35066. }
  35067. if clr_type == "9903" {
  35068. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35069. }
  35070. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35071. "insutype=" + insutype +
  35072. "&clr_type=" + clr_type +
  35073. "&setl_optins=" + clr_org +
  35074. "&stmt_begndate=" + start_time +
  35075. "&stm_enddate=" + end_time +
  35076. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35077. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35078. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35079. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35080. "&fixmedins_code=" + miConfig.Code +
  35081. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35082. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35083. "&secret_key=" + miConfig.SecretKey +
  35084. "&org_name=" + miConfig.OrgName +
  35085. "&doctor=" + user_name
  35086. resp, requestErr := http.Get(api)
  35087. if requestErr != nil {
  35088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35089. return
  35090. }
  35091. body, ioErr := ioutil.ReadAll(resp.Body)
  35092. if ioErr != nil {
  35093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35095. return
  35096. }
  35097. var respJSON map[string]interface{}
  35098. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35101. return
  35102. }
  35103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35104. result, _ := json.Marshal(respJSON)
  35105. fmt.Println("log")
  35106. fmt.Println(string(result))
  35107. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35108. utils.ErrorLog("解析失败:%v", err)
  35109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35110. return
  35111. }
  35112. res.InfRefmsgid = res10188.InfRefmsgid
  35113. res.Output = res10188.Output
  35114. res.ErrMsg = res10188.ErrMsg
  35115. res.Cainfo = res10188.Cainfo
  35116. res.WarnMsg = res10188.WarnMsg
  35117. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35118. res.Infcode = infocode
  35119. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35120. var baseParams models.BaseParams
  35121. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35122. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35123. baseParams.SecretKey = miConfig.SecretKey
  35124. baseParams.OrgName = miConfig.OrgName
  35125. baseParams.FixmedinsCode = miConfig.Code
  35126. baseParams.EncKey = miConfig.EncKey
  35127. baseParams.AppSecret = miConfig.AppSecret
  35128. baseParams.SignKey = miConfig.SignKey
  35129. baseParams.AppID = miConfig.Code
  35130. baseParams.Doctor = role.UserName
  35131. baseParams.RequestUrl = miConfig.Url
  35132. businessParams := models.BusinessParams{
  35133. Insutype: insutype,
  35134. ClrType: clr_type,
  35135. SetlOptins: clr_org,
  35136. StmtBegndate: start_time,
  35137. StmtEnddate: end_time,
  35138. MedfeeSumamt: medfee_sumamt,
  35139. FundPaySumamt: fund_pay_sumamt,
  35140. AcctPay: acct_pay,
  35141. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35142. }
  35143. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35144. fmt.Println(requestLog)
  35145. fmt.Println(result)
  35146. fmt.Println(err_msg)
  35147. var dat map[string]interface{}
  35148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35149. fmt.Println(dat)
  35150. } else {
  35151. fmt.Println(err)
  35152. }
  35153. userJSONBytes, _ := json.Marshal(dat)
  35154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35155. utils.ErrorLog("解析失败:%v", err)
  35156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35157. return
  35158. }
  35159. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35160. var baseParams models.BaseParams
  35161. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35162. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35163. baseParams.SecretKey = miConfig.SecretKey
  35164. baseParams.OrgName = miConfig.OrgName
  35165. baseParams.FixmedinsCode = miConfig.Code
  35166. baseParams.EncKey = miConfig.EncKey
  35167. baseParams.AppSecret = miConfig.AppSecret
  35168. baseParams.SignKey = miConfig.SignKey
  35169. baseParams.AppID = miConfig.Code
  35170. baseParams.Doctor = role.UserName
  35171. baseParams.RequestUrl = miConfig.Url
  35172. baseParams.AccessKey = miConfig.AccessKey
  35173. businessParams := models.BusinessParams{
  35174. Insutype: insutype,
  35175. ClrType: clr_type,
  35176. SetlOptins: "430822",
  35177. StmtBegndate: start_time,
  35178. StmtEnddate: end_time,
  35179. MedfeeSumamt: medfee_sumamt,
  35180. FundPaySumamt: fund_pay_sumamt,
  35181. AcctPay: acct_pay,
  35182. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35183. }
  35184. 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)
  35185. fmt.Println(requestLog)
  35186. fmt.Println(result)
  35187. var dat map[string]interface{}
  35188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35189. fmt.Println(dat)
  35190. } else {
  35191. fmt.Println(err)
  35192. }
  35193. userJSONBytes, _ := json.Marshal(dat)
  35194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35195. utils.ErrorLog("解析失败:%v", err)
  35196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35197. return
  35198. }
  35199. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35200. var baseParams models.BaseParams
  35201. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35202. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35203. baseParams.SecretKey = miConfig.SecretKey
  35204. baseParams.OrgName = miConfig.OrgName
  35205. baseParams.FixmedinsCode = miConfig.Code
  35206. baseParams.EncKey = miConfig.EncKey
  35207. baseParams.AppSecret = miConfig.AppSecret
  35208. baseParams.SignKey = miConfig.SignKey
  35209. baseParams.AppID = miConfig.Code
  35210. baseParams.Doctor = role.UserName
  35211. baseParams.RequestUrl = miConfig.Url
  35212. businessParams := models.BusinessParams{
  35213. Insutype: insutype,
  35214. ClrType: clr_type,
  35215. SetlOptins: clr_org,
  35216. StmtBegndate: start_time,
  35217. StmtEnddate: end_time,
  35218. MedfeeSumamt: medfee_sumamt,
  35219. FundPaySumamt: fund_pay_sumamt,
  35220. AcctPay: acct_pay,
  35221. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35222. }
  35223. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35224. fmt.Println(requestLog)
  35225. fmt.Println(result)
  35226. fmt.Println(err_msg)
  35227. var dat map[string]interface{}
  35228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35229. fmt.Println(dat)
  35230. } else {
  35231. fmt.Println(err)
  35232. }
  35233. userJSONBytes, _ := json.Marshal(dat)
  35234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35235. utils.ErrorLog("解析失败:%v", err)
  35236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35237. return
  35238. }
  35239. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35240. if len(clr_type) == 0 {
  35241. clr_type = "11"
  35242. }
  35243. api := miConfig.Url + "gdyb/ten?" +
  35244. "insutype=" + insutype +
  35245. "&clr_type=" + clr_type +
  35246. "&setl_optins=" + clr_org +
  35247. "&stmt_begndate=" + start_time +
  35248. "&stm_enddate=" + end_time +
  35249. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35250. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35251. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35252. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35253. "&fixmedins_code=" + miConfig.Code +
  35254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35255. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35256. "&secret_key=" + miConfig.SecretKey +
  35257. "&org_name=" + miConfig.OrgName +
  35258. "&doctor=" + user_name
  35259. fmt.Println(api)
  35260. resp, requestErr := http.Get(api)
  35261. if requestErr != nil {
  35262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35263. return
  35264. }
  35265. body, ioErr := ioutil.ReadAll(resp.Body)
  35266. fmt.Println(body)
  35267. if ioErr != nil {
  35268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35270. return
  35271. }
  35272. var respJSON map[string]interface{}
  35273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35276. return
  35277. }
  35278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35279. userJSONBytes, _ := json.Marshal(respJSON)
  35280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35281. utils.ErrorLog("解析失败:%v", err)
  35282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35283. return
  35284. }
  35285. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35286. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35287. //fixmedins_setl_cnt := int64(len(orders_two))
  35288. //var medfee_sumamt float64
  35289. //var acct_pay float64
  35290. //var fund_pay_sumamt float64
  35291. //for _, item := range orders_two {
  35292. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35293. // acct_pay = acct_pay + item.AcctPay
  35294. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35295. //}
  35296. var baseParams models.BaseParams
  35297. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35298. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35299. baseParams.SecretKey = miConfig.SecretKey
  35300. baseParams.OrgName = miConfig.OrgName
  35301. baseParams.FixmedinsCode = miConfig.Code
  35302. baseParams.EncKey = miConfig.EncKey
  35303. baseParams.AppSecret = miConfig.AppSecret
  35304. baseParams.SignKey = miConfig.SignKey
  35305. baseParams.AppID = miConfig.Code
  35306. baseParams.Doctor = role.UserName
  35307. baseParams.RequestUrl = miConfig.Url
  35308. if clr_type == "9903" {
  35309. clr_type = "9901"
  35310. }
  35311. businessParams := models.BusinessParams{
  35312. Insutype: insutype,
  35313. ClrType: clr_type,
  35314. SetlOptins: "360302",
  35315. StmtBegndate: start_time,
  35316. StmtEnddate: end_time,
  35317. MedfeeSumamt: 0,
  35318. FundPaySumamt: 0,
  35319. AcctPay: 0,
  35320. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35321. }
  35322. 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))
  35323. fmt.Println(requestLog)
  35324. fmt.Println(result)
  35325. var dat map[string]interface{}
  35326. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35327. fmt.Println(dat)
  35328. } else {
  35329. fmt.Println(err)
  35330. }
  35331. userJSONBytes, _ := json.Marshal(dat)
  35332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35333. utils.ErrorLog("解析失败:%v", err)
  35334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35335. return
  35336. }
  35337. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35338. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35339. //fixmedins_setl_cnt := int64(len(orders_two))
  35340. //var medfee_sumamt float64
  35341. //var acct_pay float64
  35342. //var fund_pay_sumamt float64
  35343. //for _, item := range orders_two {
  35344. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35345. // acct_pay = acct_pay + item.AcctPay
  35346. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35347. //}
  35348. var baseParams models.BaseParams
  35349. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35350. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35351. baseParams.SecretKey = miConfig.SecretKey
  35352. baseParams.OrgName = miConfig.OrgName
  35353. baseParams.FixmedinsCode = miConfig.Code
  35354. baseParams.EncKey = miConfig.EncKey
  35355. baseParams.AppSecret = miConfig.AppSecret
  35356. baseParams.SignKey = miConfig.SignKey
  35357. baseParams.AppID = miConfig.Code
  35358. baseParams.Doctor = role.UserName
  35359. baseParams.RequestUrl = miConfig.Url
  35360. if clr_type == "9903" {
  35361. clr_type = "9994"
  35362. }
  35363. businessParams := models.BusinessParams{
  35364. Insutype: insutype,
  35365. ClrType: clr_type,
  35366. SetlOptins: "361025",
  35367. StmtBegndate: start_time,
  35368. StmtEnddate: end_time,
  35369. MedfeeSumamt: 0,
  35370. FundPaySumamt: 0,
  35371. AcctPay: 0,
  35372. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35373. }
  35374. result, requestLog := service.Jxyb32012(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  35375. fmt.Println(requestLog)
  35376. fmt.Println(result)
  35377. var dat map[string]interface{}
  35378. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35379. fmt.Println(dat)
  35380. } else {
  35381. fmt.Println(err)
  35382. }
  35383. userJSONBytes, _ := json.Marshal(dat)
  35384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35385. utils.ErrorLog("解析失败:%v", err)
  35386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35387. return
  35388. }
  35389. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35390. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35391. //fixmedins_setl_cnt := int64(len(orders_two))
  35392. //var medfee_sumamt float64
  35393. //var acct_pay float64
  35394. //var fund_pay_sumamt float64
  35395. //for _, item := range orders_two {
  35396. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35397. // acct_pay = acct_pay + item.AcctPay
  35398. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35399. //}
  35400. var baseParams models.BaseParams
  35401. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35402. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35403. baseParams.SecretKey = miConfig.SecretKey
  35404. baseParams.OrgName = miConfig.OrgName
  35405. baseParams.FixmedinsCode = miConfig.Code
  35406. baseParams.EncKey = miConfig.EncKey
  35407. baseParams.AppSecret = miConfig.AppSecret
  35408. baseParams.SignKey = miConfig.SignKey
  35409. baseParams.AppID = miConfig.Code
  35410. baseParams.Doctor = role.UserName
  35411. baseParams.RequestUrl = miConfig.Url
  35412. if clr_type == "9903" {
  35413. clr_type = "9994"
  35414. }
  35415. businessParams := models.BusinessParams{
  35416. Insutype: insutype,
  35417. ClrType: clr_type,
  35418. SetlOptins: "360100",
  35419. StmtBegndate: start_time,
  35420. StmtEnddate: end_time,
  35421. MedfeeSumamt: 0,
  35422. FundPaySumamt: 0,
  35423. AcctPay: 0,
  35424. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35425. }
  35426. result, requestLog := service.Jxyb32012(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  35427. fmt.Println(requestLog)
  35428. fmt.Println(result)
  35429. var dat map[string]interface{}
  35430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35431. fmt.Println(dat)
  35432. } else {
  35433. fmt.Println(err)
  35434. }
  35435. userJSONBytes, _ := json.Marshal(dat)
  35436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35437. utils.ErrorLog("解析失败:%v", err)
  35438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35439. return
  35440. }
  35441. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35442. var api string
  35443. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35444. "&clr_type=" + clr_type +
  35445. "&setl_optins=" + clr_org +
  35446. "&stmt_begndate=" + start_time +
  35447. "&stm_enddate=" + end_time +
  35448. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35449. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35450. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35451. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35452. "&fixmedins_code=" + miConfig.Code +
  35453. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35454. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35455. "&secret_key=" + miConfig.SecretKey +
  35456. "&org_name=" + miConfig.OrgName +
  35457. "&doctor=" + user_name + "&url=" + miConfig.Url
  35458. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35459. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35460. resp, requestErr := http.Get(api)
  35461. if requestErr != nil {
  35462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35463. return
  35464. }
  35465. body, ioErr := ioutil.ReadAll(resp.Body)
  35466. if ioErr != nil {
  35467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35469. return
  35470. }
  35471. var respJSON map[string]interface{}
  35472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35475. return
  35476. }
  35477. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35478. if status == "0" {
  35479. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35480. c.ServeSuccessJSON(map[string]interface{}{
  35481. "failed_code": -10,
  35482. "msg": err_msg,
  35483. })
  35484. return
  35485. }
  35486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35487. userJSONBytes, _ := json.Marshal(respJSON)
  35488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35489. utils.ErrorLog("解析失败:%v", err)
  35490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35491. return
  35492. }
  35493. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35494. var api string
  35495. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35496. "&clr_type=" + clr_type +
  35497. "&setl_optins=" + clr_org +
  35498. "&stmt_begndate=" + start_time +
  35499. "&stm_enddate=" + end_time +
  35500. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35501. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35502. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35503. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35504. "&fixmedins_code=" + miConfig.Code +
  35505. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35506. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35507. "&secret_key=" + miConfig.SecretKey +
  35508. "&org_name=" + miConfig.OrgName +
  35509. "&doctor=" + user_name + "&url=" + miConfig.Url
  35510. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35511. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35512. resp, requestErr := http.Get(api)
  35513. if requestErr != nil {
  35514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35515. return
  35516. }
  35517. body, ioErr := ioutil.ReadAll(resp.Body)
  35518. if ioErr != nil {
  35519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35521. return
  35522. }
  35523. var respJSON map[string]interface{}
  35524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35527. return
  35528. }
  35529. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35530. if status == "0" {
  35531. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35532. c.ServeSuccessJSON(map[string]interface{}{
  35533. "failed_code": -10,
  35534. "msg": err_msg,
  35535. })
  35536. return
  35537. }
  35538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35539. userJSONBytes, _ := json.Marshal(respJSON)
  35540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35541. utils.ErrorLog("解析失败:%v", err)
  35542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35543. return
  35544. }
  35545. } else {
  35546. if len(clr_type) == 0 {
  35547. clr_type = "11"
  35548. }
  35549. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35550. "insutype=" + insutype +
  35551. "&clr_type=" + clr_type +
  35552. "&setl_optins=" + clr_org +
  35553. "&stmt_begndate=" + start_time +
  35554. "&stm_enddate=" + end_time +
  35555. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35556. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35557. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35558. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35559. "&fixmedins_code=" + miConfig.Code +
  35560. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35561. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35562. "&secret_key=" + miConfig.SecretKey +
  35563. "&org_name=" + miConfig.OrgName +
  35564. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35565. fmt.Println(api)
  35566. resp, requestErr := http.Get(api)
  35567. if requestErr != nil {
  35568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35569. return
  35570. }
  35571. body, ioErr := ioutil.ReadAll(resp.Body)
  35572. fmt.Println(body)
  35573. if ioErr != nil {
  35574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35576. return
  35577. }
  35578. var respJSON map[string]interface{}
  35579. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35582. return
  35583. }
  35584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35585. userJSONBytes, _ := json.Marshal(respJSON)
  35586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35587. utils.ErrorLog("解析失败:%v", err)
  35588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35589. return
  35590. }
  35591. }
  35592. if res.Infcode == 0 {
  35593. if res.Output.Stmtinfo.StmtRslt == "0" {
  35594. micc := &models.MedicalInsuranceCostCompare{
  35595. StartTime: startime.Unix(),
  35596. EndTime: endtime.Unix(),
  35597. Insutype: insutype,
  35598. CheckType: 1,
  35599. Num: fixmedins_setl_cnt,
  35600. Mtime: time.Now().Unix(),
  35601. Status: 1,
  35602. UserOrgId: adminUser.CurrentOrgId,
  35603. CostTotal: medfee_sumamt,
  35604. FuncTotal: fund_pay_sumamt,
  35605. PsnPay: acct_pay,
  35606. Creator: admin_user_id,
  35607. Ctime: time.Now().Unix(),
  35608. ClrType: clr_type,
  35609. }
  35610. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35611. if err == nil {
  35612. c.ServeSuccessJSON(map[string]interface{}{
  35613. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35614. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35615. })
  35616. } else {
  35617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35618. }
  35619. } else {
  35620. c.ServeSuccessJSON(map[string]interface{}{
  35621. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35622. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35623. })
  35624. }
  35625. } else {
  35626. c.ServeSuccessJSON(map[string]interface{}{
  35627. "failed_code": -10,
  35628. "msg": res.ErrMsg,
  35629. })
  35630. }
  35631. }
  35632. }
  35633. func (c *HisApiController) Check310() {
  35634. adminUser := c.GetAdminUserInfo()
  35635. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35636. var user_name string
  35637. user_name = "高慧裕"
  35638. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35639. "insutype=" + "310" +
  35640. "&clr_type=" + "" +
  35641. "&setl_optins=" + "441202" +
  35642. "&stmt_begndate=" + "2022-03-01" +
  35643. "&stm_enddate=" + "2022-03-31" +
  35644. "&medfee_sumamt=" + "194930.12" +
  35645. "&fund_pay_sumamt=" + "188741.46" +
  35646. "&acct_pay=" + "0" +
  35647. "&fixmedins_setl_cnt=" + "452" +
  35648. "&fixmedins_code=" + miConfig.Code +
  35649. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35650. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35651. "&secret_key=" + miConfig.SecretKey +
  35652. "&org_name=" + miConfig.OrgName +
  35653. "&doctor=" + user_name
  35654. fmt.Println(api)
  35655. resp, requestErr := http.Get(api)
  35656. if requestErr != nil {
  35657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35658. return
  35659. }
  35660. body, ioErr := ioutil.ReadAll(resp.Body)
  35661. fmt.Println(body)
  35662. if ioErr != nil {
  35663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35665. return
  35666. }
  35667. var respJSON map[string]interface{}
  35668. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35671. return
  35672. }
  35673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35674. userJSONBytes, _ := json.Marshal(respJSON)
  35675. var res ResultEight
  35676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35677. utils.ErrorLog("解析失败:%v", err)
  35678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35679. return
  35680. }
  35681. }
  35682. func (c *HisApiController) Check390() {
  35683. adminUser := c.GetAdminUserInfo()
  35684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35685. var user_name string
  35686. user_name = "高慧裕"
  35687. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35688. "insutype=" + "390" +
  35689. "&clr_type=" + "" +
  35690. "&setl_optins=" + "441202" +
  35691. "&stmt_begndate=" + "2022-03-01" +
  35692. "&stm_enddate=" + "2022-03-31" +
  35693. "&medfee_sumamt=" + "1068448.89" +
  35694. "&fund_pay_sumamt=" + "1014677.62" +
  35695. "&acct_pay=" + "0" +
  35696. "&fixmedins_setl_cnt=" + "1950" +
  35697. "&fixmedins_code=" + miConfig.Code +
  35698. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35699. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35700. "&secret_key=" + miConfig.SecretKey +
  35701. "&org_name=" + miConfig.OrgName +
  35702. "&doctor=" + user_name
  35703. fmt.Println(api)
  35704. resp, requestErr := http.Get(api)
  35705. if requestErr != nil {
  35706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35707. return
  35708. }
  35709. body, ioErr := ioutil.ReadAll(resp.Body)
  35710. fmt.Println(body)
  35711. if ioErr != nil {
  35712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35714. return
  35715. }
  35716. var respJSON map[string]interface{}
  35717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35720. return
  35721. }
  35722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35723. userJSONBytes, _ := json.Marshal(respJSON)
  35724. var res ResultEight
  35725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35726. utils.ErrorLog("解析失败:%v", err)
  35727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35728. return
  35729. }
  35730. }
  35731. // 对账明细
  35732. func (c *HisApiController) GetCheckDetailAccount() {
  35733. start_time := c.GetString("start_time")
  35734. end_time := c.GetString("end_time")
  35735. admin_user_id, _ := c.GetInt64("admin_user_id")
  35736. adminUser := c.GetAdminUserInfo()
  35737. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35738. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35739. timeLayout := "2006-01-02"
  35740. loc, _ := time.LoadLocation("Local")
  35741. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35742. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35743. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35744. rand.Seed(time.Now().UnixNano())
  35745. num := rand.Intn(30000)
  35746. Mkdir(miConfig.OrgName)
  35747. file := strconv.FormatInt(int64(num), 10)
  35748. file_name := file + ".txt"
  35749. zip_name := file + ".zip"
  35750. zip_path := miConfig.OrgName + "/" + zip_name
  35751. file_path := miConfig.OrgName + "/" + file_name
  35752. decimal.DivisionPrecision = 2
  35753. var medfee_sumamt float64
  35754. var psn_cash_pay float64
  35755. var fund_pay_sumamt float64
  35756. fixmedins_setl_cnt := int64(len(orders))
  35757. for _, item := range orders {
  35758. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35759. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  35760. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35761. }
  35762. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  35763. defer f.Close()
  35764. if err != nil {
  35765. fmt.Println(err.Error())
  35766. } else {
  35767. for _, item := range orders {
  35768. var refd_setl_flag string
  35769. if item.OrderStatus == 2 {
  35770. refd_setl_flag = "0"
  35771. var str string
  35772. str = item.SetlId + " " +
  35773. item.MdtrtId + " " +
  35774. item.PsnNo + " " +
  35775. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35776. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35777. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  35778. _, err = f.Write([]byte(str))
  35779. }
  35780. if item.OrderStatus == 3 {
  35781. var str string
  35782. str = item.SetlId + " " +
  35783. item.MdtrtId + " " +
  35784. item.PsnNo + " " +
  35785. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35786. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35787. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  35788. _, err = f.Write([]byte(str))
  35789. var str2 string
  35790. str2 = item.SetlId + " " +
  35791. item.MdtrtId + " " +
  35792. item.PsnNo + " " +
  35793. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  35794. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  35795. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  35796. _, err = f.Write([]byte(str2))
  35797. }
  35798. }
  35799. }
  35800. Zip(file_path, zip_path)
  35801. fmt.Println(ReadFile(zip_path))
  35802. fmt.Println(string(ReadFile(zip_path)))
  35803. if config.IsOpen == 1 {
  35804. var user_name string
  35805. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35806. if role.ID == 0 {
  35807. user_name = "管理员"
  35808. } else {
  35809. user_name = role.UserName
  35810. }
  35811. baseParams := models.BaseParams{
  35812. SecretKey: miConfig.SecretKey,
  35813. FixmedinsCode: miConfig.Code,
  35814. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35815. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35816. OrgName: miConfig.OrgName,
  35817. Doctor: user_name,
  35818. }
  35819. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  35820. var dat map[string]interface{}
  35821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35822. fmt.Println(dat)
  35823. } else {
  35824. fmt.Println(err)
  35825. }
  35826. userJSONBytes, _ := json.Marshal(dat)
  35827. var res ResultNine
  35828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35829. utils.ErrorLog("解析失败:%v", err)
  35830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35831. return
  35832. }
  35833. if res.Infcode == 0 {
  35834. fileNo := res.Output.FileQuryNo
  35835. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  35836. "file_qury_no=" + fileNo +
  35837. "&setl_optins=" + "定点医保中心" +
  35838. "&stmt_begndate=" + start_time +
  35839. "&stm_enddate=" + end_time +
  35840. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35841. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35842. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  35843. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35844. "&fixmedins_code=" + miConfig.Code +
  35845. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35846. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35847. "&secret_key=" + miConfig.SecretKey +
  35848. "&org_name=" + miConfig.OrgName +
  35849. "&doctor=" + user_name
  35850. resp, requestErr := http.Get(api)
  35851. if requestErr != nil {
  35852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35853. return
  35854. }
  35855. body, ioErr := ioutil.ReadAll(resp.Body)
  35856. if ioErr != nil {
  35857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35859. return
  35860. }
  35861. var respJSON map[string]interface{}
  35862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35865. return
  35866. }
  35867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35868. userJSONBytes, _ := json.Marshal(respJSON)
  35869. var res ResultTen
  35870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35871. utils.ErrorLog("解析失败:%v", err)
  35872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35873. return
  35874. }
  35875. if res.Infcode == 0 {
  35876. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  35877. micc := &models.MedicalInsuranceCostCompare{
  35878. StartTime: startime.Unix(),
  35879. EndTime: endtime.Unix(),
  35880. Insutype: "0",
  35881. CheckType: 2,
  35882. Num: fixmedins_setl_cnt,
  35883. Mtime: time.Now().Unix(),
  35884. Status: 1,
  35885. UserOrgId: adminUser.CurrentOrgId,
  35886. CostTotal: medfee_sumamt,
  35887. FuncTotal: fund_pay_sumamt,
  35888. PsnPay: psn_cash_pay,
  35889. Creator: admin_user_id,
  35890. Ctime: time.Now().Unix(),
  35891. }
  35892. service.CreateMedicalInsuranceCostCompareRecord(micc)
  35893. c.ServeSuccessJSON(map[string]interface{}{
  35894. "msg": "明细对账成功",
  35895. })
  35896. }
  35897. } else {
  35898. }
  35899. }
  35900. }
  35901. type CustomOrderInfo struct {
  35902. Name string
  35903. Spec string
  35904. Unit string
  35905. Count float64
  35906. Price float64
  35907. Total float64
  35908. }
  35909. func (c *HisApiController) GetBatchSettleAccounts() {
  35910. admin_user_id, _ := c.GetInt64("admin_user_id")
  35911. order_ids := c.GetString("order_ids")
  35912. order_ids_arr := strings.Split(order_ids, ",")
  35913. data3 := []map[string]interface{}{}
  35914. for _, item := range order_ids_arr {
  35915. id, _ := strconv.ParseInt(item, 10, 64)
  35916. order_id := id
  35917. adminUser := c.GetAdminUserInfo()
  35918. order, _ := service.GetHisOrderByID(order_id)
  35919. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35920. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  35921. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  35922. orderInfos = append(orderInfos, orderInfos_two...)
  35923. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  35924. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  35925. var diagnosis_ids []string
  35926. if his.ID > 0 {
  35927. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  35928. } else {
  35929. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  35930. }
  35931. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  35932. var dia_config []*models.HisXtDiagnoseConfig
  35933. var name string
  35934. for _, item := range diagnosis_ids {
  35935. id, _ := strconv.ParseInt(item, 10, 64)
  35936. diagnosisConfig, _ := service.FindDiagnoseById(id)
  35937. dia_config = append(dia_config, &diagnosisConfig)
  35938. if len(name) == 0 {
  35939. name = diagnosisConfig.ClassName
  35940. }
  35941. //} else {
  35942. // name = name + "," + diagnosisConfig.ClassName
  35943. //}
  35944. }
  35945. var bedCostTotal float64 = 0 //床位总费
  35946. var bedCostSelfTotal float64 = 0 //床位自费
  35947. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  35948. var bedSelfTotal float64 = 0 //床位部分项目自费
  35949. var bedInscpTotal float64 = 0 //床位部分项目自费
  35950. var operationCostTotal float64 = 0 //手术费
  35951. var operationCostSelfTotal float64 = 0 //手术费
  35952. var operationCostPartSelfTotal float64 = 0 //手术费
  35953. var operationSelfTotal float64 = 0 //床位部分项目自费
  35954. var operationInscpTotal float64 = 0 //床位部分项目自费
  35955. var otherCostTotal float64 = 0 //其他费用
  35956. var otherCostSelfTotal float64 = 0 //其他费用
  35957. var otherCostPartSelfTotal float64 = 0 //其他费用
  35958. var otherSelfTotal float64 = 0 //床位部分项目自费
  35959. var otherInscpTotal float64 = 0 //床位部分项目自费
  35960. var materialCostTotal float64 = 0 //材料费
  35961. var materialCostSelfTotal float64 = 0 //材料费
  35962. var materialCostPartSelfTotal float64 = 0 //材料费
  35963. var materialSelfTotal float64 = 0 //床位部分项目自费
  35964. var materialInscpTotal float64 = 0 //床位部分项目自费
  35965. var westernMedicineCostTotal float64 = 0 //西药费
  35966. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35967. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35968. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35969. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35970. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35971. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35972. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35973. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35974. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35975. var checkCostTotal float64 = 0 //检查费
  35976. var checkCostSelfTotal float64 = 0 //检查费
  35977. var checkCostPartSelfTotal float64 = 0 //检查费
  35978. var checkSelfTotal float64 = 0 //床位部分项目自费
  35979. var checkInscpTotal float64 = 0 //床位部分项目自费
  35980. var laboratoryCostTotal float64 = 0 //化验费
  35981. var laboratoryCostSelfTotal float64 = 0 //化验费
  35982. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35983. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35984. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35985. var treatCostTotal float64 = 0 //治疗费用
  35986. var treatCostSelfTotal float64 = 0 //治疗费用
  35987. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35988. var treatSelfTotal float64 = 0 //床位部分项目自费
  35989. var treatInscpTotal float64 = 0 //床位部分项目自费
  35990. decimal.DivisionPrecision = 2
  35991. for _, item := range orderInfos {
  35992. if item.MedChrgitmType == "01" { //床位费
  35993. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35994. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35995. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35996. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35997. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35998. }
  35999. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36000. if item.MedChrgitmType == "03" { //检查费
  36001. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36002. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36003. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36004. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36005. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36006. }
  36007. } else {
  36008. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36009. fmt.Println("------------")
  36010. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36011. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36012. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36013. }
  36014. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36015. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36016. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36017. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36018. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36019. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36020. }
  36021. }
  36022. if item.MedChrgitmType == "04" { //化验费
  36023. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36024. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36025. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36026. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36027. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36028. }
  36029. if item.MedChrgitmType == "05" { //治疗费
  36030. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36031. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36032. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36033. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36034. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36035. }
  36036. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36037. fmt.Println("------------")
  36038. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36039. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36040. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36041. }
  36042. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36043. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36044. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36045. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36046. }
  36047. //if item.MedChrgitmType == "06" { //手术费
  36048. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36049. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36050. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36051. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36052. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36053. //
  36054. //}
  36055. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36056. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36057. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36058. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36059. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36060. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36061. }
  36062. if item.MedChrgitmType == "09" { //西药费
  36063. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36064. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36065. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36066. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36067. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36068. }
  36069. if item.MedChrgitmType == "11" { //中成费
  36070. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36071. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36072. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36073. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36074. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36075. }
  36076. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36077. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36078. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36079. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36080. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36081. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36082. }
  36083. }
  36084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36085. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36086. var user_name string
  36087. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36088. if role.ID == 0 {
  36089. user_name = "管理员"
  36090. } else {
  36091. user_name = role.UserName
  36092. }
  36093. baseParams := models.BaseParams{
  36094. SecretKey: miConfig.SecretKey,
  36095. FixmedinsCode: miConfig.Code,
  36096. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36097. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36098. OrgName: miConfig.OrgName,
  36099. Doctor: user_name,
  36100. RequestUrl: miConfig.Url,
  36101. AccessKey: miConfig.AccessKey,
  36102. }
  36103. businessParams := models.BusinessParams{
  36104. PsnNo: order.PsnNo,
  36105. MdtrtId: order.MdtrtId,
  36106. SetlId: order.SetlId,
  36107. }
  36108. var res ResultEleven
  36109. var resEleven10265 ResultEleven10265
  36110. if config.IsOpen == 1 {
  36111. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36112. result := service.Gdyb5203(baseParams, businessParams)
  36113. service.Gdyb5204(baseParams, businessParams)
  36114. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36115. var dat map[string]interface{}
  36116. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36117. fmt.Println(dat)
  36118. } else {
  36119. fmt.Println(err)
  36120. }
  36121. userJSONBytes, _ := json.Marshal(dat)
  36122. if miConfig.Code == "H15049901371" {
  36123. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36124. utils.ErrorLog("解析失败:%v", err)
  36125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36126. return
  36127. }
  36128. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36129. res.Output = resEleven10265.Output
  36130. res.ErrMsg = resEleven10265.ErrMsg
  36131. res.Cainfo = resEleven10265.Cainfo
  36132. res.WarnMsg = resEleven10265.WarnMsg
  36133. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36134. res.Infcode = infocode
  36135. } else {
  36136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36137. utils.ErrorLog("解析失败:%v", err)
  36138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36139. return
  36140. }
  36141. }
  36142. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36143. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36144. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36145. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36146. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36147. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36148. var doctor_name string
  36149. if roles.ID == 0 {
  36150. doctor_name = "管理员"
  36151. } else {
  36152. doctor_name = roles.UserName
  36153. }
  36154. yiliao_leibie := ""
  36155. switch order.MedType {
  36156. case "11":
  36157. yiliao_leibie = "普通门诊"
  36158. break
  36159. case "12":
  36160. yiliao_leibie = "门诊挂号"
  36161. break
  36162. case "13":
  36163. yiliao_leibie = "急诊"
  36164. break
  36165. case "14":
  36166. yiliao_leibie = "门诊特殊病"
  36167. break
  36168. case "15":
  36169. yiliao_leibie = "门诊统筹"
  36170. break
  36171. case "16":
  36172. yiliao_leibie = "门诊慢性病"
  36173. break
  36174. case "21":
  36175. yiliao_leibie = "普通住院"
  36176. break
  36177. }
  36178. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36179. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36180. if res.Infcode == 0 {
  36181. data2 := map[string]interface{}{
  36182. "diagnosis": name,
  36183. "order_infos": orderInfos,
  36184. "number": order.MdtrtId,
  36185. "date": order.SettleAccountsDate,
  36186. "charge_admin": charge_admin,
  36187. "printor_admin": printor_admin,
  36188. "info": res.Output.Setlinfo,
  36189. "order": order,
  36190. "bedCostTotal": bedCostTotal,
  36191. "bedCostSelfTotal": bedCostSelfTotal,
  36192. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36193. "bedSelfTotal": bedSelfTotal,
  36194. "bedInscpTotal": bedInscpTotal,
  36195. "operationCostTotal": operationCostTotal,
  36196. "operationCostSelfTotal": operationCostSelfTotal,
  36197. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36198. "operationSelfTotal": operationSelfTotal,
  36199. "operationInscpTotal": operationInscpTotal,
  36200. "otherCostTotal": otherCostTotal,
  36201. "otherCostSelfTotal": otherCostSelfTotal,
  36202. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36203. "otherSelfTotal": otherSelfTotal,
  36204. "otherInscpTotal": otherInscpTotal,
  36205. "materialCostTotal": materialCostTotal,
  36206. "materialCostSelfTotal": materialCostSelfTotal,
  36207. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36208. "materialSelfTotal": materialSelfTotal,
  36209. "materialInscpTotal": materialInscpTotal,
  36210. "westernMedicineCostTotal": westernMedicineCostTotal,
  36211. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36212. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36213. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36214. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36215. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36216. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36217. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36218. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36219. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36220. "checkCostTotal": checkCostTotal,
  36221. "checkCostSelfTotal": checkCostSelfTotal,
  36222. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36223. "checkSelfTotal": checkSelfTotal,
  36224. "checkInscpTotal": checkInscpTotal,
  36225. "laboratoryCostTotal": laboratoryCostTotal,
  36226. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36227. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36228. "laboratorySelfTotal": laboratorySelfTotal,
  36229. "laboratoryInscpTotal": laboratoryInscpTotal,
  36230. "treatCostTotal": treatCostTotal,
  36231. "treatCostSelfTotal": treatCostSelfTotal,
  36232. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36233. "treatSelfTotal": treatSelfTotal,
  36234. "treatInscpTotal": treatInscpTotal,
  36235. "doctor_info": doctor_info,
  36236. "doctor_code": adminRole_two.DoctorCode,
  36237. "doctor_name": doctor_name,
  36238. "health_card_no": order.PsnNo,
  36239. "department": departments.Name,
  36240. "yiliao_leibie": yiliao_leibie,
  36241. "after_money": order.AccountPrice,
  36242. "patient": patient,
  36243. "org_name": miConfig.OrgName,
  36244. "org_code": miConfig.Code,
  36245. "order_number": order.Number,
  36246. "his_hospital": his_hospital,
  36247. "his": his,
  36248. "dia_config": dia_config,
  36249. "psn_cash_pay": order.PsnCashPay,
  36250. //"check_order_info": cus_slice,
  36251. }
  36252. data3 = append(data3, data2)
  36253. }
  36254. }
  36255. }
  36256. c.ServeSuccessJSON(map[string]interface{}{
  36257. "infos": data3,
  36258. })
  36259. }
  36260. func (c *HisApiController) GetSettleAccounts() {
  36261. //id, _ := c.GetInt64("id")
  36262. //record_time := c.GetString("record_time")
  36263. order_id, _ := c.GetInt64("order_id")
  36264. admin_user_id, _ := c.GetInt64("admin_user_id")
  36265. //timeLayout := "2006-01-02"
  36266. //loc, _ := time.LoadLocation("Local")
  36267. //
  36268. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36269. //if err != nil {
  36270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36271. // return
  36272. //}Hbyb5203
  36273. //recordDateTime := theTime.Unix()
  36274. adminUser := c.GetAdminUserInfo()
  36275. order, _ := service.GetHisOrderByID(order_id)
  36276. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36277. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36278. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36279. orderInfos = append(orderInfos, orderInfos_two...)
  36280. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36281. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36282. var diagnosis_ids []string
  36283. if his.ID > 0 {
  36284. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36285. } else {
  36286. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36287. }
  36288. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36289. var dia_config []*models.HisXtDiagnoseConfig
  36290. var name string
  36291. for _, item := range diagnosis_ids {
  36292. id, _ := strconv.ParseInt(item, 10, 64)
  36293. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36294. dia_config = append(dia_config, &diagnosisConfig)
  36295. if len(name) == 0 {
  36296. name = diagnosisConfig.ClassName
  36297. } else {
  36298. name = name + "," + diagnosisConfig.ClassName
  36299. }
  36300. }
  36301. if patient.UserOrgId == 10215 {
  36302. name = "慢性肾功能不全(血透治疗)"
  36303. }
  36304. var bedCostTotal float64 = 0 //床位总费
  36305. var bedCostSelfTotal float64 = 0 //床位自费
  36306. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36307. var bedSelfTotal float64 = 0 //床位部分项目自费
  36308. var bedInscpTotal float64 = 0 //床位部分项目自费
  36309. var operationCostTotal float64 = 0 //手术费
  36310. var operationCostSelfTotal float64 = 0 //手术费
  36311. var operationCostPartSelfTotal float64 = 0 //手术费
  36312. var operationSelfTotal float64 = 0 //床位部分项目自费
  36313. var operationInscpTotal float64 = 0 //床位部分项目自费
  36314. var otherCostTotal float64 = 0 //其他费用
  36315. var otherCostSelfTotal float64 = 0 //其他费用
  36316. var otherCostPartSelfTotal float64 = 0 //其他费用
  36317. var otherSelfTotal float64 = 0 //床位部分项目自费
  36318. var otherInscpTotal float64 = 0 //床位部分项目自费
  36319. var materialCostTotal float64 = 0 //材料费
  36320. var materialCostSelfTotal float64 = 0 //材料费
  36321. var materialCostPartSelfTotal float64 = 0 //材料费
  36322. var materialSelfTotal float64 = 0 //床位部分项目自费
  36323. var materialInscpTotal float64 = 0 //床位部分项目自费
  36324. var westernMedicineCostTotal float64 = 0 //西药费
  36325. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36326. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36327. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36328. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36329. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36330. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36331. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36332. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36333. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36334. var checkCostTotal float64 = 0 //检查费
  36335. var checkCostSelfTotal float64 = 0 //检查费
  36336. var checkCostPartSelfTotal float64 = 0 //检查费
  36337. var checkSelfTotal float64 = 0 //床位部分项目自费
  36338. var checkInscpTotal float64 = 0 //床位部分项目自费
  36339. var laboratoryCostTotal float64 = 0 //化验费
  36340. var laboratoryCostSelfTotal float64 = 0 //化验费
  36341. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36342. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36343. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36344. var treatCostTotal float64 = 0 //治疗费用
  36345. var treatCostSelfTotal float64 = 0 //治疗费用
  36346. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36347. var treatSelfTotal float64 = 0 //床位部分项目自费
  36348. var treatInscpTotal float64 = 0 //床位部分项目自费
  36349. var zcCostTotal float64 = 0 //治疗费用
  36350. var zcCostSelfTotal float64 = 0 //治疗费用
  36351. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36352. var zcSelfTotal float64 = 0 //床位部分项目自费
  36353. var zcInscpTotal float64 = 0 //床位部分项目自费
  36354. var huliCostTotal float64 = 0 //治疗费用
  36355. var huliCostSelfTotal float64 = 0 //治疗费用
  36356. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36357. var huliSelfTotal float64 = 0 //床位部分项目自费
  36358. var huliInscpTotal float64 = 0 //床位部分项目自费
  36359. decimal.DivisionPrecision = 2
  36360. for _, item := range orderInfos {
  36361. if item.MedChrgitmType == "01" { //床位费
  36362. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36363. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36364. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36365. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36366. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36367. }
  36368. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36369. if item.MedChrgitmType == "03" { //检查费
  36370. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36371. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36372. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36373. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36374. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36375. }
  36376. } else {
  36377. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36378. fmt.Println("------------")
  36379. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36380. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36381. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36382. }
  36383. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36384. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36385. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36386. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36387. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36388. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36389. }
  36390. }
  36391. if item.MedChrgitmType == "04" { //化验费
  36392. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36393. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36394. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36395. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36396. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36397. }
  36398. if item.MedChrgitmType == "05" { //治疗费
  36399. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36400. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36401. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36402. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36403. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36404. }
  36405. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36406. fmt.Println("------------")
  36407. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36408. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36409. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36410. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36411. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36412. }
  36413. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36414. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36415. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36416. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36417. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36418. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36419. }
  36420. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36421. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36422. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36423. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36424. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36425. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36426. }
  36427. if item.MedChrgitmType == "09" { //西药费
  36428. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36429. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36430. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36431. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36432. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36433. }
  36434. if item.MedChrgitmType == "11" { //中成费
  36435. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36436. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36437. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36438. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36439. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36440. }
  36441. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36442. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36443. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36444. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36445. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36446. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36447. }
  36448. if item.MedChrgitmType == "02" { //其他费
  36449. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36450. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36451. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36452. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36453. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36454. }
  36455. if item.MedChrgitmType == "07" { //其他费
  36456. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36457. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36458. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36459. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36460. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36461. }
  36462. }
  36463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36464. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36465. var user_name string
  36466. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36467. if role.ID == 0 {
  36468. user_name = "管理员"
  36469. } else {
  36470. user_name = role.UserName
  36471. }
  36472. baseParams := models.BaseParams{
  36473. SecretKey: miConfig.SecretKey,
  36474. FixmedinsCode: miConfig.Code,
  36475. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36476. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36477. OrgName: miConfig.OrgName,
  36478. Doctor: user_name,
  36479. RequestUrl: miConfig.Url,
  36480. AccessKey: miConfig.AccessKey,
  36481. }
  36482. businessParams := models.BusinessParams{
  36483. PsnNo: order.PsnNo,
  36484. MdtrtId: order.MdtrtId,
  36485. SetlId: order.SetlId,
  36486. }
  36487. var res ResultEleven
  36488. var resah ResultElevenah
  36489. var resEleven10265 ResultEleven10265
  36490. if config.IsOpen == 1 {
  36491. if miConfig.MdtrtareaAdmvs == "421300" {
  36492. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36493. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36494. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36495. resp, requestErr := http.Get(api)
  36496. if requestErr != nil {
  36497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36498. return
  36499. }
  36500. body, ioErr := ioutil.ReadAll(resp.Body)
  36501. if ioErr != nil {
  36502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36504. return
  36505. }
  36506. var respJSON map[string]interface{}
  36507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36510. return
  36511. }
  36512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36513. result, _ := json.Marshal(respJSON)
  36514. fmt.Println("log")
  36515. fmt.Println(string(result))
  36516. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36517. utils.ErrorLog("解析失败:%v", err)
  36518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36519. return
  36520. }
  36521. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36522. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36523. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36524. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36525. resp, requestErr := http.Get(api)
  36526. if requestErr != nil {
  36527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36528. return
  36529. }
  36530. body, ioErr := ioutil.ReadAll(resp.Body)
  36531. if ioErr != nil {
  36532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36534. return
  36535. }
  36536. var respJSON map[string]interface{}
  36537. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36540. return
  36541. }
  36542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36543. result, _ := json.Marshal(respJSON)
  36544. fmt.Println("log")
  36545. fmt.Println(string(result))
  36546. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36547. utils.ErrorLog("解析失败:%v", err)
  36548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36549. return
  36550. }
  36551. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36552. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36553. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36554. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36555. resp, requestErr := http.Get(api)
  36556. if requestErr != nil {
  36557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36558. return
  36559. }
  36560. body, ioErr := ioutil.ReadAll(resp.Body)
  36561. if ioErr != nil {
  36562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36564. return
  36565. }
  36566. var respJSON map[string]interface{}
  36567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36570. return
  36571. }
  36572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36573. result, _ := json.Marshal(respJSON)
  36574. fmt.Println("log")
  36575. fmt.Println(string(result))
  36576. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36577. utils.ErrorLog("解析失败:%v", err)
  36578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36579. return
  36580. }
  36581. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36582. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36583. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36584. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36585. resp, requestErr := http.Get(api)
  36586. if requestErr != nil {
  36587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36588. return
  36589. }
  36590. body, ioErr := ioutil.ReadAll(resp.Body)
  36591. if ioErr != nil {
  36592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36594. return
  36595. }
  36596. var respJSON map[string]interface{}
  36597. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36600. return
  36601. }
  36602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36603. result, _ := json.Marshal(respJSON)
  36604. fmt.Println("log")
  36605. fmt.Println(string(result))
  36606. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36607. utils.ErrorLog("解析失败:%v", err)
  36608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36609. return
  36610. }
  36611. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  36612. var api string
  36613. if miConfig.MdtrtareaAdmvs == "320830" {
  36614. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36615. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36616. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36617. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36618. } else if miConfig.MdtrtareaAdmvs == "320921" {
  36619. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36620. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36621. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36622. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36623. } else {
  36624. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36625. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36626. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36627. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36628. }
  36629. resp, requestErr := http.Get(api)
  36630. if requestErr != nil {
  36631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36632. return
  36633. }
  36634. body, ioErr := ioutil.ReadAll(resp.Body)
  36635. if ioErr != nil {
  36636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36638. return
  36639. }
  36640. var respJSON map[string]interface{}
  36641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36644. return
  36645. }
  36646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36647. result, _ := json.Marshal(respJSON)
  36648. fmt.Println("log")
  36649. fmt.Println(string(result))
  36650. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36651. utils.ErrorLog("解析失败:%v", err)
  36652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36653. return
  36654. }
  36655. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36656. res.Output = resEleven10265.Output
  36657. res.ErrMsg = resEleven10265.ErrMsg
  36658. res.Cainfo = resEleven10265.Cainfo
  36659. res.WarnMsg = resEleven10265.WarnMsg
  36660. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36661. res.Infcode = infocode
  36662. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36663. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36664. saveLog(result, requestLog, "5203", "结算单")
  36665. var dat map[string]interface{}
  36666. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36667. fmt.Println(dat)
  36668. } else {
  36669. fmt.Println(err)
  36670. }
  36671. userJSONBytes, _ := json.Marshal(dat)
  36672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36673. utils.ErrorLog("解析失败:%v", err)
  36674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36675. return
  36676. }
  36677. } else if miConfig.MdtrtareaAdmvs == "360302" {
  36678. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36679. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36680. saveLog(result, requestLog, "5203", "结算单")
  36681. var dat map[string]interface{}
  36682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36683. fmt.Println(dat)
  36684. } else {
  36685. fmt.Println(err)
  36686. }
  36687. userJSONBytes, _ := json.Marshal(dat)
  36688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36689. utils.ErrorLog("解析失败:%v", err)
  36690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36691. return
  36692. }
  36693. } else if miConfig.MdtrtareaAdmvs == "361025" {
  36694. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36695. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36696. saveLog(result, requestLog, "5203", "结算单")
  36697. var dat map[string]interface{}
  36698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36699. fmt.Println(dat)
  36700. } else {
  36701. fmt.Println(err)
  36702. }
  36703. userJSONBytes, _ := json.Marshal(dat)
  36704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36705. utils.ErrorLog("解析失败:%v", err)
  36706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36707. return
  36708. }
  36709. } else if miConfig.MdtrtareaAdmvs == "360100" {
  36710. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36711. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36712. saveLog(result, requestLog, "5203", "结算单")
  36713. var dat map[string]interface{}
  36714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36715. fmt.Println(dat)
  36716. } else {
  36717. fmt.Println(err)
  36718. }
  36719. userJSONBytes, _ := json.Marshal(dat)
  36720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36721. utils.ErrorLog("解析失败:%v", err)
  36722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36723. return
  36724. }
  36725. } else if miConfig.MdtrtareaAdmvs == "341203" {
  36726. var api string
  36727. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36728. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36729. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36730. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36731. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36732. resp, requestErr := http.Get(api)
  36733. if requestErr != nil {
  36734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36735. return
  36736. }
  36737. body, ioErr := ioutil.ReadAll(resp.Body)
  36738. if ioErr != nil {
  36739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36741. return
  36742. }
  36743. var respJSON map[string]interface{}
  36744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36747. return
  36748. }
  36749. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36750. if status == "0" {
  36751. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36752. c.ServeSuccessJSON(map[string]interface{}{
  36753. "failed_code": -10,
  36754. "msg": err_msg,
  36755. })
  36756. return
  36757. }
  36758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36759. result, _ := json.Marshal(respJSON)
  36760. fmt.Println("log")
  36761. fmt.Println(string(result))
  36762. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36763. utils.ErrorLog("解析失败:%v", err)
  36764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36765. return
  36766. }
  36767. res.InfRefmsgid = resah.InfRefmsgid
  36768. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36769. // 创建对应的Time类型
  36770. t := time.UnixMilli(timestamp)
  36771. // 格式化成指定的日期字符串
  36772. str := t.Format("2006-01-02 15:04:05")
  36773. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36774. // 创建对应的Time类型
  36775. t3 := time.UnixMilli(timestamp2)
  36776. // 格式化成指定的日期字符串
  36777. str2 := t3.Format("2006-01-02 15:04:05")
  36778. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36779. // 创建对应的Time类型
  36780. t4 := time.UnixMilli(timestamp3)
  36781. // 格式化成指定的日期字符串
  36782. str3 := t4.Format("2006-01-02 15:04:05")
  36783. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36784. // 创建对应的Time类型
  36785. t5 := time.UnixMilli(timestamp4)
  36786. // 格式化成指定的日期字符串
  36787. str5 := t5.Format("2006-01-02 15:04:05")
  36788. res.Output.Setlinfo.Brdy = str2
  36789. res.Output.Setlinfo.SetlTime = str
  36790. res.Output.Setlinfo.Begndate = str3
  36791. res.Output.Setlinfo.Enddate = str5
  36792. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36793. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36794. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36795. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36796. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36797. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36798. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36799. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36800. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36801. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36802. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36803. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36804. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36805. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36806. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36807. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36808. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36809. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36810. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36811. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36812. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36813. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36814. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  36815. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  36816. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  36817. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  36818. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  36819. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  36820. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  36821. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  36822. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  36823. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  36824. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36825. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  36826. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  36827. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  36828. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  36829. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  36830. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  36831. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  36832. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  36833. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  36834. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  36835. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  36836. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  36837. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  36838. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  36839. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  36840. //res.Output.Setldetail = resah.Output.Setldetail
  36841. res.ErrMsg = resah.ErrMsg
  36842. res.Cainfo = resah.Cainfo
  36843. res.WarnMsg = resah.WarnMsg
  36844. } else if miConfig.MdtrtareaAdmvs == "340699" {
  36845. var api string
  36846. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36847. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36848. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36849. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36850. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36851. resp, requestErr := http.Get(api)
  36852. if requestErr != nil {
  36853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36854. return
  36855. }
  36856. body, ioErr := ioutil.ReadAll(resp.Body)
  36857. if ioErr != nil {
  36858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36860. return
  36861. }
  36862. var respJSON map[string]interface{}
  36863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36866. return
  36867. }
  36868. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36869. if status == "0" {
  36870. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36871. c.ServeSuccessJSON(map[string]interface{}{
  36872. "failed_code": -10,
  36873. "msg": err_msg,
  36874. })
  36875. return
  36876. }
  36877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36878. result, _ := json.Marshal(respJSON)
  36879. fmt.Println("log")
  36880. fmt.Println(string(result))
  36881. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36882. utils.ErrorLog("解析失败:%v", err)
  36883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36884. return
  36885. }
  36886. res.InfRefmsgid = resah.InfRefmsgid
  36887. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36888. // 创建对应的Time类型
  36889. t := time.UnixMilli(timestamp)
  36890. // 格式化成指定的日期字符串
  36891. str := t.Format("2006-01-02 15:04:05")
  36892. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36893. // 创建对应的Time类型
  36894. t3 := time.UnixMilli(timestamp2)
  36895. // 格式化成指定的日期字符串
  36896. str2 := t3.Format("2006-01-02 15:04:05")
  36897. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36898. // 创建对应的Time类型
  36899. t4 := time.UnixMilli(timestamp3)
  36900. // 格式化成指定的日期字符串
  36901. str3 := t4.Format("2006-01-02 15:04:05")
  36902. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36903. // 创建对应的Time类型
  36904. t5 := time.UnixMilli(timestamp4)
  36905. // 格式化成指定的日期字符串
  36906. str5 := t5.Format("2006-01-02 15:04:05")
  36907. res.Output.Setlinfo.Brdy = str2
  36908. res.Output.Setlinfo.SetlTime = str
  36909. res.Output.Setlinfo.Begndate = str3
  36910. res.Output.Setlinfo.Enddate = str5
  36911. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36912. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36913. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36914. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36915. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36916. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36917. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36918. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36919. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36920. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36921. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36922. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36923. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36924. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36925. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36926. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36927. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36928. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36929. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36930. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36931. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36932. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36933. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  36934. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  36935. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  36936. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  36937. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  36938. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  36939. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  36940. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  36941. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  36942. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  36943. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36944. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  36945. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  36946. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  36947. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  36948. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  36949. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  36950. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  36951. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  36952. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  36953. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  36954. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  36955. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  36956. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  36957. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  36958. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  36959. //res.Output.Setldetail = resah.Output.Setldetail
  36960. res.ErrMsg = resah.ErrMsg
  36961. res.Cainfo = resah.Cainfo
  36962. res.WarnMsg = resah.WarnMsg
  36963. } else if miConfig.MdtrtareaAdmvs == "430800" {
  36964. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  36965. saveLog(result, requestLog, "5203", "结算单")
  36966. var dat map[string]interface{}
  36967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36968. fmt.Println(dat)
  36969. } else {
  36970. fmt.Println(err)
  36971. }
  36972. userJSONBytes, _ := json.Marshal(dat)
  36973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36974. utils.ErrorLog("解析失败:%v", err)
  36975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36976. return
  36977. }
  36978. } else if miConfig.MdtrtareaAdmvs == "150499" {
  36979. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36980. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36981. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36982. resp, requestErr := http.Get(api)
  36983. if requestErr != nil {
  36984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36985. return
  36986. }
  36987. body, ioErr := ioutil.ReadAll(resp.Body)
  36988. if ioErr != nil {
  36989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36991. return
  36992. }
  36993. var respJSON map[string]interface{}
  36994. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36997. return
  36998. }
  36999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37000. result, _ := json.Marshal(respJSON)
  37001. fmt.Println("log")
  37002. fmt.Println(string(result))
  37003. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37004. utils.ErrorLog("解析失败:%v", err)
  37005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37006. return
  37007. }
  37008. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37009. res.Output = resEleven10265.Output
  37010. res.ErrMsg = resEleven10265.ErrMsg
  37011. res.Cainfo = resEleven10265.Cainfo
  37012. res.WarnMsg = resEleven10265.WarnMsg
  37013. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37014. res.Infcode = infocode
  37015. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37016. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37017. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37018. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37019. resp, requestErr := http.Get(api)
  37020. if requestErr != nil {
  37021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37022. return
  37023. }
  37024. body, ioErr := ioutil.ReadAll(resp.Body)
  37025. if ioErr != nil {
  37026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37028. return
  37029. }
  37030. var respJSON map[string]interface{}
  37031. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37034. return
  37035. }
  37036. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37037. result, _ := json.Marshal(respJSON)
  37038. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37039. utils.ErrorLog("解析失败:%v", err)
  37040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37041. return
  37042. }
  37043. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37044. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37045. //return
  37046. } else {
  37047. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37048. if len(his.InsuplcAdmdvs) == 0 {
  37049. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37050. } else {
  37051. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37052. }
  37053. result := service.Gdyb5203(baseParams, businessParams)
  37054. //service.Gdyb5204(baseParams, businessParams)
  37055. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37056. var dat map[string]interface{}
  37057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37058. fmt.Println(dat)
  37059. } else {
  37060. fmt.Println(err)
  37061. }
  37062. userJSONBytes, _ := json.Marshal(dat)
  37063. if miConfig.Code == "H15049901371" {
  37064. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37065. utils.ErrorLog("解析失败:%v", err)
  37066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37067. return
  37068. }
  37069. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37070. res.Output = resEleven10265.Output
  37071. res.ErrMsg = resEleven10265.ErrMsg
  37072. res.Cainfo = resEleven10265.Cainfo
  37073. res.WarnMsg = resEleven10265.WarnMsg
  37074. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37075. res.Infcode = infocode
  37076. } else {
  37077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37078. utils.ErrorLog("解析失败:%v", err)
  37079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37080. return
  37081. }
  37082. }
  37083. }
  37084. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37085. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37086. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37087. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37088. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37089. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37090. var doctor_name string
  37091. if roles.ID == 0 {
  37092. doctor_name = "管理员"
  37093. } else {
  37094. doctor_name = roles.UserName
  37095. }
  37096. yiliao_leibie := ""
  37097. switch order.MedType {
  37098. case "11":
  37099. yiliao_leibie = "普通门诊"
  37100. break
  37101. case "12":
  37102. yiliao_leibie = "门诊挂号"
  37103. break
  37104. case "13":
  37105. yiliao_leibie = "急诊"
  37106. break
  37107. case "14":
  37108. yiliao_leibie = "门诊特殊病"
  37109. break
  37110. case "15":
  37111. yiliao_leibie = "门诊统筹"
  37112. break
  37113. case "16":
  37114. yiliao_leibie = "门诊慢性病"
  37115. break
  37116. case "21":
  37117. yiliao_leibie = "普通住院"
  37118. break
  37119. }
  37120. //var rf []CustomFundPay
  37121. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37122. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37123. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37124. if res.Infcode == 0 {
  37125. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 || adminUser.CurrentOrgId == 10210 || adminUser.CurrentOrgId == 10571 || adminUser.CurrentOrgId == 10752 {
  37126. c.ServeSuccessJSON(map[string]interface{}{
  37127. "diagnosis": name,
  37128. "order_infos": orderInfos,
  37129. "number": order.MdtrtId,
  37130. "date": order.SettleAccountsDate,
  37131. "charge_admin": charge_admin,
  37132. "printor_admin": printor_admin,
  37133. "info": res.Output.Setlinfo,
  37134. "order": order,
  37135. "bedCostTotal": bedCostTotal,
  37136. "bedCostSelfTotal": bedCostSelfTotal,
  37137. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37138. "bedSelfTotal": bedSelfTotal,
  37139. "bedInscpTotal": bedInscpTotal,
  37140. "operationCostTotal": operationCostTotal,
  37141. "operationCostSelfTotal": operationCostSelfTotal,
  37142. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37143. "operationSelfTotal": operationSelfTotal,
  37144. "operationInscpTotal": operationInscpTotal,
  37145. "otherCostTotal": otherCostTotal,
  37146. "otherCostSelfTotal": otherCostSelfTotal,
  37147. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37148. "otherSelfTotal": otherSelfTotal,
  37149. "otherInscpTotal": otherInscpTotal,
  37150. "materialCostTotal": materialCostTotal,
  37151. "materialCostSelfTotal": materialCostSelfTotal,
  37152. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37153. "materialSelfTotal": materialSelfTotal,
  37154. "materialInscpTotal": materialInscpTotal,
  37155. "westernMedicineCostTotal": westernMedicineCostTotal,
  37156. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37157. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37158. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37159. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37160. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37161. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37162. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37163. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37164. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37165. "checkCostTotal": checkCostTotal,
  37166. "checkCostSelfTotal": checkCostSelfTotal,
  37167. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37168. "checkSelfTotal": checkSelfTotal,
  37169. "checkInscpTotal": checkInscpTotal,
  37170. "laboratoryCostTotal": laboratoryCostTotal,
  37171. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37172. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37173. "laboratorySelfTotal": laboratorySelfTotal,
  37174. "laboratoryInscpTotal": laboratoryInscpTotal,
  37175. "treatCostTotal": treatCostTotal,
  37176. "treatCostSelfTotal": treatCostSelfTotal,
  37177. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37178. "treatSelfTotal": treatSelfTotal,
  37179. "treatInscpTotal": treatInscpTotal,
  37180. "doctor_info": doctor_info,
  37181. "doctor_code": adminRole_two.DoctorCode,
  37182. "doctor_name": doctor_name,
  37183. "health_card_no": order.PsnNo,
  37184. "department": departments.Name,
  37185. "yiliao_leibie": yiliao_leibie,
  37186. "after_money": order.AccountPrice,
  37187. "patient": patient,
  37188. "org_name": miConfig.OrgName,
  37189. "org_code": miConfig.Code,
  37190. "order_number": order.Number,
  37191. "his_hospital": his_hospital,
  37192. "his": his,
  37193. "dia_config": dia_config,
  37194. "psn_cash_pay": order.PsnCashPay,
  37195. "zcCostTotal": zcCostTotal,
  37196. "zcCostSelfTotal": zcCostSelfTotal,
  37197. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37198. "zcSelfTotal": zcSelfTotal,
  37199. "zcInscpTotal": zcInscpTotal,
  37200. "huliCostTotal": huliCostTotal,
  37201. "huliCostSelfTotal": huliCostSelfTotal,
  37202. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37203. "huliSelfTotal": huliSelfTotal,
  37204. "huliInscpTotal": huliInscpTotal,
  37205. //"funds": rf,
  37206. //"check_order_info": cus_slice,
  37207. })
  37208. } else {
  37209. c.ServeSuccessJSON(map[string]interface{}{
  37210. "diagnosis": name,
  37211. "order_infos": orderInfos,
  37212. "number": order.MdtrtId,
  37213. "date": order.SettleAccountsDate,
  37214. "charge_admin": charge_admin,
  37215. "printor_admin": printor_admin,
  37216. "info": order,
  37217. "order": order,
  37218. "bedCostTotal": bedCostTotal,
  37219. "bedCostSelfTotal": bedCostSelfTotal,
  37220. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37221. "bedSelfTotal": bedSelfTotal,
  37222. "bedInscpTotal": bedInscpTotal,
  37223. "operationCostTotal": operationCostTotal,
  37224. "operationCostSelfTotal": operationCostSelfTotal,
  37225. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37226. "operationSelfTotal": operationSelfTotal,
  37227. "operationInscpTotal": operationInscpTotal,
  37228. "otherCostTotal": otherCostTotal,
  37229. "otherCostSelfTotal": otherCostSelfTotal,
  37230. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37231. "otherSelfTotal": otherSelfTotal,
  37232. "otherInscpTotal": otherInscpTotal,
  37233. "materialCostTotal": materialCostTotal,
  37234. "materialCostSelfTotal": materialCostSelfTotal,
  37235. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37236. "materialSelfTotal": materialSelfTotal,
  37237. "materialInscpTotal": materialInscpTotal,
  37238. "westernMedicineCostTotal": westernMedicineCostTotal,
  37239. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37240. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37241. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37242. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37243. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37244. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37245. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37246. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37247. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37248. "checkCostTotal": checkCostTotal,
  37249. "checkCostSelfTotal": checkCostSelfTotal,
  37250. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37251. "checkSelfTotal": checkSelfTotal,
  37252. "checkInscpTotal": checkInscpTotal,
  37253. "laboratoryCostTotal": laboratoryCostTotal,
  37254. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37255. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37256. "laboratorySelfTotal": laboratorySelfTotal,
  37257. "laboratoryInscpTotal": laboratoryInscpTotal,
  37258. "treatCostTotal": treatCostTotal,
  37259. "treatCostSelfTotal": treatCostSelfTotal,
  37260. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37261. "treatSelfTotal": treatSelfTotal,
  37262. "treatInscpTotal": treatInscpTotal,
  37263. "doctor_info": doctor_info,
  37264. "doctor_code": adminRole_two.DoctorCode,
  37265. "doctor_name": doctor_name,
  37266. "health_card_no": order.PsnNo,
  37267. "department": departments.Name,
  37268. "yiliao_leibie": yiliao_leibie,
  37269. "after_money": order.AccountPrice,
  37270. "patient": patient,
  37271. "org_name": miConfig.OrgName,
  37272. "org_code": miConfig.Code,
  37273. "order_number": order.Number,
  37274. "his_hospital": his_hospital,
  37275. "his": his,
  37276. "dia_config": dia_config,
  37277. "psn_cash_pay": order.PsnCashPay,
  37278. "zcCostTotal": zcCostTotal,
  37279. "zcCostSelfTotal": zcCostSelfTotal,
  37280. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37281. "zcSelfTotal": zcSelfTotal,
  37282. "zcInscpTotal": zcInscpTotal,
  37283. "huliCostTotal": huliCostTotal,
  37284. "huliCostSelfTotal": huliCostSelfTotal,
  37285. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37286. "huliSelfTotal": huliSelfTotal,
  37287. "huliInscpTotal": huliInscpTotal,
  37288. //"funds": rf,
  37289. //"check_order_info": cus_slice,
  37290. })
  37291. }
  37292. }
  37293. }
  37294. }
  37295. //func (c *HisApiController) CheckTreatment() {
  37296. // patient_id, _ := c.GetInt64("patient_id")
  37297. // id_card_no := c.GetString("id_card_no")
  37298. // insutype := c.GetString("insutype")
  37299. // med_type := c.GetString("med_type")
  37300. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37301. //
  37302. // adminUser := c.GetAdminUserInfo()
  37303. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37304. //
  37305. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37306. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37307. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37308. //
  37309. // if miConfig.MdtrtareaAdmvs == "421300" {
  37310. // var res ResultTwo
  37311. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37312. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37313. // "&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)
  37314. // resp, requestErr := http.Get(api)
  37315. // if requestErr != nil {
  37316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37317. // return
  37318. // }
  37319. //
  37320. // body, ioErr := ioutil.ReadAll(resp.Body)
  37321. // if ioErr != nil {
  37322. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37324. // return
  37325. // }
  37326. // var respJSON map[string]interface{}
  37327. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37328. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37330. // return
  37331. // }
  37332. //
  37333. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37334. // result, _ := json.Marshal(respJSON)
  37335. //
  37336. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37337. // utils.ErrorLog("解析失败:%v", err)
  37338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37339. // return
  37340. // }
  37341. //
  37342. // if res.Infcode == 0 {
  37343. //
  37344. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37345. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37346. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37347. // resp, requestErr := http.Get(api)
  37348. // if requestErr != nil {
  37349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37350. // return
  37351. // }
  37352. //
  37353. // body, ioErr := ioutil.ReadAll(resp.Body)
  37354. // if ioErr != nil {
  37355. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37357. // return
  37358. // }
  37359. // var respJSON map[string]interface{}
  37360. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37361. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37363. // return
  37364. // }
  37365. // var res Result2001
  37366. //
  37367. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37368. // result2, _ := json.Marshal(respJSON)
  37369. //
  37370. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37371. // utils.ErrorLog("解析失败:%v", err)
  37372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37373. // return
  37374. // }
  37375. //
  37376. // if res.Infcode == 0 {
  37377. // c.ServeSuccessJSON(map[string]interface{}{
  37378. // "msg": res.Output.Trtinfo,
  37379. // })
  37380. // }
  37381. //
  37382. // } else {
  37383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37384. // return
  37385. // }
  37386. //
  37387. // } else {
  37388. //
  37389. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37390. // var dat map[string]interface{}
  37391. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37392. // fmt.Println(dat)
  37393. // } else {
  37394. // fmt.Println(err)
  37395. // }
  37396. // userJSONBytes, _ := json.Marshal(dat)
  37397. // var res ResultTwo
  37398. // var res10265 ResultTwo10265
  37399. // if miConfig.Code == "H15049901371" {
  37400. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37401. // utils.ErrorLog("解析失败:%v", err)
  37402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37403. // return
  37404. // }
  37405. // res.ErrMsg = res10265.ErrMsg
  37406. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37407. // res.Infcode = infocode
  37408. // res.Output = res10265.Output
  37409. // res.InfRefmsgid = res10265.InfRefmsgid
  37410. // } else {
  37411. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37412. // utils.ErrorLog("解析失败:%v", err)
  37413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37414. // return
  37415. // }
  37416. // }
  37417. //
  37418. // var user_name string
  37419. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37420. // if role.ID == 0 {
  37421. // user_name = "xxx"
  37422. // } else {
  37423. // user_name = role.UserName
  37424. // }
  37425. //
  37426. // baseParams := models.BaseParams{
  37427. // SecretKey: miConfig.SecretKey,
  37428. // FixmedinsCode: miConfig.Code,
  37429. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37430. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37431. // OrgName: miConfig.OrgName,
  37432. // Doctor: user_name,
  37433. // }
  37434. //
  37435. // if config.IsOpen == 1 {
  37436. // if miConfig.Code == "H15049901371" {
  37437. // if med_type == "14" {
  37438. // if insutype == "390" {
  37439. // med_type = "9933"
  37440. // } else if insutype == "310" {
  37441. // med_type = "990502"
  37442. // }
  37443. // } else if med_type == "11" {
  37444. // med_type = "11"
  37445. // }
  37446. // }
  37447. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37448. // var dat map[string]interface{}
  37449. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37450. // fmt.Println(dat)
  37451. // } else {
  37452. // fmt.Println(err)
  37453. // }
  37454. // var res Result2001
  37455. // var res10265 Result2001Org10265
  37456. // if miConfig.Code == "H15049901371" {
  37457. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37458. // utils.ErrorLog("解析失败:%v", err)
  37459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37460. // return
  37461. // }
  37462. // res.ErrMsg = res10265.ErrMsg
  37463. // res.Output = res10265.Output
  37464. // res.InfRefmsgid = res10265.InfRefmsgid
  37465. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37466. // res.Infcode = infocode
  37467. // } else {
  37468. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37469. // utils.ErrorLog("解析失败:%v", err)
  37470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37471. // return
  37472. // }
  37473. // }
  37474. // if res.Infcode == 0 {
  37475. // c.ServeSuccessJSON(map[string]interface{}{
  37476. // "msg": res.Output.Trtinfo,
  37477. // })
  37478. // }
  37479. // }
  37480. // }
  37481. //}
  37482. //func (c *HisApiController) PutRecord() {
  37483. // id, _ := c.GetInt64("id")
  37484. // record_time := c.GetString("record_time")
  37485. // timeLayout := "2006-01-02"
  37486. // loc, _ := time.LoadLocation("Local")
  37487. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37488. // if err != nil {
  37489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37490. // return
  37491. // }
  37492. // recordDateTime := theTime.Unix()
  37493. //
  37494. // adminInfo := c.GetAdminUserInfo()
  37495. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37496. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37497. //
  37498. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37499. //
  37500. // fmt.Println(miConfig.SecretKey)
  37501. //
  37502. // if patient == nil {
  37503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37504. // return
  37505. // }
  37506. // if len(patient.IdCardNo) == 0 {
  37507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37508. // return
  37509. // }
  37510. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37511. // if config.IsOpen == 1 {
  37512. // 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
  37513. // resp, requestErr := http.Get(api)
  37514. // if requestErr != nil {
  37515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37516. // return
  37517. // }
  37518. // defer resp.Body.Close()
  37519. // body, ioErr := ioutil.ReadAll(resp.Body)
  37520. // if ioErr != nil {
  37521. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37523. // return
  37524. // }
  37525. // var respJSON map[string]interface{}
  37526. //
  37527. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37528. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37530. // return
  37531. // }
  37532. //
  37533. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37534. // userJSONBytes, _ := json.Marshal(userJSON)
  37535. // var res ResultTwo
  37536. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37537. // utils.ErrorLog("解析失败:%v", err)
  37538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37539. // return
  37540. // }
  37541. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37542. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37543. // infoStr := string(Iinfos)
  37544. // idetinfoStr := string(Idetinfos)
  37545. //
  37546. // if res.Infcode == 0 {
  37547. // his := models.VMHisPatient{
  37548. // Status: 1,
  37549. // Ctime: time.Now().Unix(),
  37550. // Mtime: time.Now().Unix(),
  37551. // PsnNo: res.Output.Baseinfo.PsnNo,
  37552. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37553. // Certno: res.Output.Baseinfo.Certno,
  37554. // PsnName: res.Output.Baseinfo.PsnName,
  37555. // Gend: res.Output.Baseinfo.Gend,
  37556. // Naty: res.Output.Baseinfo.Naty,
  37557. // Brdy: res.Output.Baseinfo.Brdy,
  37558. // Age: res.Output.Baseinfo.Age,
  37559. // Iinfo: infoStr,
  37560. // Idetinfo: idetinfoStr,
  37561. // PatientId: patient.ID,
  37562. // RecordDate: theTime.Unix(),
  37563. // UserOrgId: adminInfo.CurrentOrgId,
  37564. // AdminUserId: adminInfo.AdminUser.Id,
  37565. // IsReturn: 1,
  37566. // }
  37567. //
  37568. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37569. // //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")
  37570. // //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")
  37571. //
  37572. // //var dat map[string]interface{}
  37573. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37574. // // fmt.Println(dat)
  37575. // //} else {
  37576. // // fmt.Println(err)
  37577. // //}
  37578. //
  37579. // var dat2 map[string]interface{}
  37580. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37581. // fmt.Println(dat2)
  37582. // } else {
  37583. // fmt.Println(err)
  37584. // }
  37585. //
  37586. // } else {
  37587. // adminUser := c.GetAdminUserInfo()
  37588. // errlog := &models.HisOrderError{
  37589. // UserOrgId: adminUser.CurrentOrgId,
  37590. // Ctime: time.Now().Unix(),
  37591. // Mtime: time.Now().Unix(),
  37592. // ErrMsg: res.ErrMsg,
  37593. // Status: 1,
  37594. // PatientId: id,
  37595. // RecordTime: recordDateTime,
  37596. // Stage: 1,
  37597. // }
  37598. // service.CreateErrMsgLog(errlog)
  37599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37600. // return
  37601. // }
  37602. // }
  37603. //
  37604. //}
  37605. //func (c *HisApiController) GetUploadDiag() {
  37606. // id, _ := c.GetInt64("id")
  37607. // record_time := c.GetString("record_time")
  37608. //
  37609. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37610. // sick_type, _ := c.GetInt64("sick_type")
  37611. // reg_type, _ := c.GetInt64("reg_type")
  37612. //
  37613. // timeLayout := "2006-01-02"
  37614. // loc, _ := time.LoadLocation("Local")
  37615. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37616. // if err != nil {
  37617. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37618. // return
  37619. // }
  37620. //
  37621. // var patientPrescription models.HisPrescriptionInfo
  37622. // recordDateTime := theTime.Unix()
  37623. // adminInfo := c.GetAdminUserInfo()
  37624. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37625. //
  37626. // if patientPrescription.ID == 0 {
  37627. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37628. // }
  37629. //
  37630. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37631. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37632. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37633. // sickConfig, _ := service.FindSickById(sick_type)
  37634. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37635. //
  37636. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37637. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37638. // "&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 +
  37639. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37640. // resp2, requestErr2 := http.Get(api2)
  37641. // if requestErr2 != nil {
  37642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37643. // return
  37644. // }
  37645. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37646. // if ioErr2 != nil {
  37647. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37649. // return
  37650. // }
  37651. // var respJSON2 map[string]interface{}
  37652. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37653. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37655. // return
  37656. // }
  37657. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37658. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37659. //
  37660. // var res2 ResultSix
  37661. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37662. // utils.ErrorLog("解析失败:%v", err)
  37663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37664. // return
  37665. // }
  37666. // if res2.Infcode != 0 {
  37667. // adminUser := c.GetAdminUserInfo()
  37668. // errlog := &models.HisOrderError{
  37669. // UserOrgId: adminUser.CurrentOrgId,
  37670. // Ctime: time.Now().Unix(),
  37671. // Mtime: time.Now().Unix(),
  37672. // ErrMsg: res2.ErrMsg,
  37673. // Status: 1,
  37674. // PatientId: id,
  37675. // RecordTime: recordDateTime,
  37676. // Stage: 3,
  37677. // }
  37678. // service.CreateErrMsgLog(errlog)
  37679. //
  37680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  37681. // return
  37682. // }
  37683. //
  37684. // c.ServeSuccessJSON(map[string]interface{}{
  37685. // "msg": "上传成功",
  37686. // })
  37687. //
  37688. //}
  37689. type QueryResult struct {
  37690. ID int64
  37691. Name string
  37692. Code string
  37693. List_type_code string
  37694. }
  37695. func (c *HisApiController) GetCheckCode() {
  37696. ids_str := c.GetString("ids")
  37697. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37698. ids_arr := strings.Split(ids_str, ",")
  37699. var queryResult []QueryResult
  37700. ids := make([]int64, 0)
  37701. for _, item := range ids_arr {
  37702. id, _ := strconv.ParseInt(item, 10, 64)
  37703. ids = append(ids, id)
  37704. }
  37705. if record_type == 1 {
  37706. drugs, _ := service.GetBatchDrugList(ids)
  37707. for _, item := range drugs {
  37708. result := QueryResult{
  37709. ID: item.ID,
  37710. Name: item.DrugName,
  37711. Code: item.MedicalInsuranceNumber,
  37712. List_type_code: "101",
  37713. }
  37714. queryResult = append(queryResult, result)
  37715. }
  37716. } else if record_type == 2 {
  37717. goods, _ := service.GetBatchGoodInformationList(ids)
  37718. fmt.Println(goods)
  37719. for _, item := range goods {
  37720. result := QueryResult{
  37721. ID: item.ID,
  37722. Name: item.GoodName,
  37723. Code: item.SocialSecurityDirectoryCode,
  37724. List_type_code: "301",
  37725. }
  37726. queryResult = append(queryResult, result)
  37727. }
  37728. } else if record_type == 3 {
  37729. projects, _ := service.GetBathchMyPorjecgList(ids)
  37730. for _, item := range projects {
  37731. result := QueryResult{
  37732. ID: item.ID,
  37733. Name: item.ProjectName,
  37734. Code: item.MedicalCode,
  37735. List_type_code: "201",
  37736. }
  37737. queryResult = append(queryResult, result)
  37738. }
  37739. }
  37740. admin_user_id, _ := c.GetInt64("admin_user_id")
  37741. adminUser := c.GetAdminUserInfo()
  37742. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37743. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37744. var user_name string
  37745. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37746. if role.ID == 0 {
  37747. user_name = "管理员"
  37748. } else {
  37749. user_name = role.UserName
  37750. }
  37751. baseParams := models.BaseParams{
  37752. SecretKey: miConfig.SecretKey,
  37753. FixmedinsCode: miConfig.Code,
  37754. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37755. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37756. OrgName: miConfig.OrgName,
  37757. Doctor: user_name,
  37758. }
  37759. var result string
  37760. if miConfig.MdtrtareaAdmvs == "430800" {
  37761. for _, item := range queryResult {
  37762. if record_type == 1 {
  37763. 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)
  37764. } else if record_type == 2 {
  37765. fmt.Println(item.Code)
  37766. 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)
  37767. } else if record_type == 3 {
  37768. 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)
  37769. }
  37770. var dat map[string]interface{}
  37771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37772. fmt.Println(dat)
  37773. } else {
  37774. fmt.Println(err)
  37775. }
  37776. userJSONBytes, _ := json.Marshal(dat)
  37777. var res ResultSix
  37778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37779. utils.ErrorLog("解析失败:%v", err)
  37780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37781. return
  37782. }
  37783. if res.Infcode == 0 {
  37784. if record_type == 1 {
  37785. service.UpdateBaseDrugById(item.ID)
  37786. } else if record_type == 2 {
  37787. service.UpdateGoodInformaitonByDetail(item.ID)
  37788. } else if record_type == 3 {
  37789. service.UpdateProjectById(item.ID)
  37790. }
  37791. c.ServeSuccessJSON(map[string]interface{}{
  37792. "failed_code": 0,
  37793. "msg": "目录对照成功",
  37794. })
  37795. } else {
  37796. c.ServeSuccessJSON(map[string]interface{}{
  37797. "failed_code": -10,
  37798. "msg": res.ErrMsg,
  37799. })
  37800. }
  37801. }
  37802. } else {
  37803. for _, item := range queryResult {
  37804. var result string
  37805. if record_type == 1 {
  37806. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37807. } else if record_type == 2 {
  37808. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37809. } else if record_type == 3 {
  37810. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37811. }
  37812. var dat map[string]interface{}
  37813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37814. fmt.Println(dat)
  37815. } else {
  37816. fmt.Println(err)
  37817. }
  37818. userJSONBytes, _ := json.Marshal(dat)
  37819. var res ResultSix
  37820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37821. utils.ErrorLog("解析失败:%v", err)
  37822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37823. return
  37824. }
  37825. if res.Infcode == 0 {
  37826. if record_type == 1 {
  37827. service.UpdateBaseDrugById(item.ID)
  37828. } else if record_type == 2 {
  37829. service.UpdateGoodInformaitonByDetail(item.ID)
  37830. } else if record_type == 3 {
  37831. service.UpdateProjectById(item.ID)
  37832. }
  37833. c.ServeSuccessJSON(map[string]interface{}{
  37834. "failed_code": 0,
  37835. "msg": "目录对照成功",
  37836. })
  37837. } else {
  37838. c.ServeSuccessJSON(map[string]interface{}{
  37839. "failed_code": -10,
  37840. "msg": res.ErrMsg,
  37841. })
  37842. }
  37843. }
  37844. }
  37845. }
  37846. func (c *HisApiController) UnCheckCode() {
  37847. ids_str := c.GetString("ids")
  37848. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37849. admin_user_id, _ := c.GetInt64("admin_user_id")
  37850. ids_arr := strings.Split(ids_str, ",")
  37851. var queryResult []QueryResult
  37852. ids := make([]int64, 0)
  37853. for _, item := range ids_arr {
  37854. id, _ := strconv.ParseInt(item, 10, 64)
  37855. ids = append(ids, id)
  37856. }
  37857. if record_type == 1 {
  37858. drugs, _ := service.GetBatchDrugList(ids)
  37859. for _, item := range drugs {
  37860. result := QueryResult{
  37861. ID: item.ID,
  37862. Name: item.DrugName,
  37863. Code: item.MedicalInsuranceNumber,
  37864. List_type_code: "101",
  37865. }
  37866. queryResult = append(queryResult, result)
  37867. }
  37868. } else if record_type == 2 {
  37869. goods, _ := service.GetBatchGoodInformationList(ids)
  37870. for _, item := range goods {
  37871. result := QueryResult{
  37872. ID: item.ID,
  37873. Name: item.GoodName,
  37874. Code: item.SocialSecurityDirectoryCode,
  37875. List_type_code: "301",
  37876. }
  37877. queryResult = append(queryResult, result)
  37878. }
  37879. } else if record_type == 3 {
  37880. projects, _ := service.GetBathchMyPorjecgList(ids)
  37881. for _, item := range projects {
  37882. result := QueryResult{
  37883. ID: item.ID,
  37884. Name: item.ProjectName,
  37885. Code: item.MedicalCode,
  37886. List_type_code: "201",
  37887. }
  37888. queryResult = append(queryResult, result)
  37889. }
  37890. }
  37891. adminUser := c.GetAdminUserInfo()
  37892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37893. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37894. var user_name string
  37895. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37896. if role.ID == 0 {
  37897. user_name = "xxx"
  37898. } else {
  37899. user_name = role.UserName
  37900. }
  37901. baseParams := &models.BaseParams{
  37902. SecretKey: miConfig.SecretKey,
  37903. FixmedinsCode: miConfig.Code,
  37904. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37905. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37906. OrgName: miConfig.OrgName,
  37907. Doctor: user_name,
  37908. }
  37909. if config.IsOpen == 1 {
  37910. if miConfig.MdtrtareaAdmvs == "430800" {
  37911. for _, item := range queryResult {
  37912. var result string
  37913. if record_type == 1 {
  37914. 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)
  37915. } else if record_type == 2 {
  37916. fmt.Println(item.Code)
  37917. 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)
  37918. } else if record_type == 3 {
  37919. 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)
  37920. }
  37921. var dat map[string]interface{}
  37922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37923. fmt.Println(dat)
  37924. } else {
  37925. fmt.Println(err)
  37926. }
  37927. userJSONBytes, _ := json.Marshal(dat)
  37928. var res ResultSix
  37929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37930. utils.ErrorLog("解析失败:%v", err)
  37931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37932. return
  37933. }
  37934. if res.Infcode == 0 {
  37935. if record_type == 1 {
  37936. service.UpdateBaseDrugById(item.ID)
  37937. } else if record_type == 2 {
  37938. service.UpdateGoodInformaitonByDetail(item.ID)
  37939. } else if record_type == 3 {
  37940. service.UpdateProjectById(item.ID)
  37941. }
  37942. c.ServeSuccessJSON(map[string]interface{}{
  37943. "failed_code": 0,
  37944. "msg": "目录对照成功",
  37945. })
  37946. } else {
  37947. c.ServeSuccessJSON(map[string]interface{}{
  37948. "failed_code": -10,
  37949. "msg": res.ErrMsg,
  37950. })
  37951. }
  37952. }
  37953. } else {
  37954. for _, item := range queryResult {
  37955. var result string
  37956. if record_type == 1 {
  37957. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37958. } else if record_type == 2 {
  37959. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37960. } else if record_type == 3 {
  37961. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37962. }
  37963. var dat2 map[string]interface{}
  37964. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37965. fmt.Println(dat2)
  37966. } else {
  37967. fmt.Println(err)
  37968. }
  37969. userJSONBytes, _ := json.Marshal(dat2)
  37970. var res ResultSix
  37971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37972. utils.ErrorLog("解析失败:%v", err)
  37973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37974. return
  37975. }
  37976. if res.Infcode == 0 {
  37977. if record_type == 1 {
  37978. service.UpdateDrugByIdDetail(item.ID)
  37979. } else if record_type == 2 {
  37980. service.UpdateGoodInfoById(item.ID)
  37981. } else if record_type == 3 {
  37982. service.UpdateMyProjectById(item.ID)
  37983. }
  37984. c.ServeSuccessJSON(map[string]interface{}{
  37985. "failed_code": 0,
  37986. "msg": "撤销目录对照成功",
  37987. })
  37988. } else {
  37989. c.ServeSuccessJSON(map[string]interface{}{
  37990. "failed_code": -10,
  37991. "msg": res.ErrMsg,
  37992. })
  37993. }
  37994. }
  37995. }
  37996. }
  37997. }
  37998. func (c *HisApiController) GetPatientInfo() {
  37999. id_card_no := c.GetString("id_card_no")
  38000. admin_user_id, _ := c.GetInt64("admin_user_id")
  38001. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38002. if patient.ID == 0 {
  38003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38004. return
  38005. }
  38006. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38008. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38009. var res ResultTwo
  38010. var res10265 ResultTwo10265
  38011. if config.IsOpen == 1 {
  38012. if miConfig.MdtrtareaAdmvs == "150499" {
  38013. //请求内网数据
  38014. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38015. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38016. "&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
  38017. resp, requestErr := http.Get(api)
  38018. if requestErr != nil {
  38019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38020. return
  38021. }
  38022. body, ioErr := ioutil.ReadAll(resp.Body)
  38023. if ioErr != nil {
  38024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38026. return
  38027. }
  38028. var respJSON map[string]interface{}
  38029. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38032. return
  38033. }
  38034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38035. result_byte, _ := json.Marshal(respJSON)
  38036. result := string(result_byte)
  38037. var dat map[string]interface{}
  38038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38039. fmt.Println(dat)
  38040. } else {
  38041. fmt.Println(err)
  38042. }
  38043. userJSONBytes, _ := json.Marshal(dat)
  38044. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38045. utils.ErrorLog("解析失败:%v", err)
  38046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38047. return
  38048. }
  38049. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38050. res.Infcode = Infcode
  38051. res.ErrMsg = res10265.ErrMsg
  38052. res.Output = res10265.Output
  38053. res.InfRefmsgid = res10265.InfRefmsgid
  38054. res.RespondTime = res10265.RespondTime
  38055. res.WarnInfo = res10265.WarnInfo
  38056. } else {
  38057. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38058. var dat map[string]interface{}
  38059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38060. fmt.Println(dat)
  38061. } else {
  38062. fmt.Println(err)
  38063. }
  38064. userJSONBytes, _ := json.Marshal(dat)
  38065. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38066. utils.ErrorLog("解析失败:%v", err)
  38067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38068. return
  38069. }
  38070. }
  38071. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38072. // utils.ErrorLog("解析失败:%v", err)
  38073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38074. // return
  38075. //}
  38076. for index, item := range res.Output.Iinfo {
  38077. if item.PsnInsuStas == "2" {
  38078. fmt.Println("--------")
  38079. res.Output.Iinfo[index].Insutype = "300"
  38080. res.Output.Iinfo[index].PsnInsuStas = "1"
  38081. }
  38082. }
  38083. fmt.Println(res.Output.Iinfo)
  38084. if res.Infcode != 0 {
  38085. c.ServeSuccessJSON(map[string]interface{}{
  38086. "failed_code": -10,
  38087. "msg": res.ErrMsg,
  38088. })
  38089. } else {
  38090. c.ServeSuccessJSON(map[string]interface{}{
  38091. "failed_code": 0,
  38092. "info": res,
  38093. })
  38094. }
  38095. }
  38096. }
  38097. func (c *HisApiController) PsnPutOnRecord() {
  38098. record_type, _ := c.GetInt64("type")
  38099. patient_id, _ := c.GetInt64("patient_id")
  38100. admin_user_id, _ := c.GetInt64("admin_user_id")
  38101. start_time := c.GetString("start_time")
  38102. end_time := c.GetString("end_time")
  38103. adminUser := c.GetAdminUserInfo()
  38104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38105. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38106. var patients []*models.Patients
  38107. if record_type == 1 { //全部备案
  38108. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38109. patients = append(patients, patient...)
  38110. } else { //单个备案
  38111. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38112. patients = append(patients, patient)
  38113. }
  38114. var user_name string
  38115. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38116. if role.ID == 0 {
  38117. user_name = "xxx"
  38118. } else {
  38119. user_name = role.UserName
  38120. }
  38121. if config.IsOpen == 1 {
  38122. for _, item := range patients {
  38123. 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
  38124. resp, requestErr := http.Get(api)
  38125. if requestErr != nil {
  38126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38127. return
  38128. }
  38129. defer resp.Body.Close()
  38130. body, ioErr := ioutil.ReadAll(resp.Body)
  38131. if ioErr != nil {
  38132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38134. return
  38135. }
  38136. var respJSON map[string]interface{}
  38137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38140. return
  38141. }
  38142. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38143. userJSONBytes, _ := json.Marshal(userJSON)
  38144. var res ResultTwo
  38145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38146. utils.ErrorLog("解析失败:%v", err)
  38147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38148. return
  38149. }
  38150. if res.Infcode == 0 {
  38151. 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)
  38152. var dat map[string]interface{}
  38153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38154. fmt.Println(dat)
  38155. } else {
  38156. fmt.Println(err)
  38157. }
  38158. userJSONBytes, _ := json.Marshal(dat)
  38159. var res2 ResultThirteen
  38160. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38161. utils.ErrorLog("解析失败:%v", err)
  38162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38163. return
  38164. }
  38165. if res2.Infcode == 0 {
  38166. psnResult := &models.GdybPsnRecord{
  38167. UserOrgId: adminUser.CurrentOrgId,
  38168. PatientId: item.ID,
  38169. PsnNo: res.Output.Baseinfo.PsnNo,
  38170. Ctime: time.Now().Unix(),
  38171. Mtime: time.Now().Unix(),
  38172. Status: 1,
  38173. IsCancel: 1,
  38174. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38175. }
  38176. service.CreatePsnRecord(psnResult)
  38177. } else {
  38178. c.ServeSuccessJSON(map[string]interface{}{
  38179. "failed_code": -10,
  38180. "msg": res2.ErrMsg,
  38181. })
  38182. return
  38183. }
  38184. }
  38185. }
  38186. }
  38187. }
  38188. func (c *HisApiController) PsnUnPutOnRecord() {
  38189. id, _ := c.GetInt64("id")
  38190. //record_type, _ := c.GetInt64("type")
  38191. admin_user_id, _ := c.GetInt64("admin_user_id")
  38192. adminUser := c.GetAdminUserInfo()
  38193. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38194. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38195. var user_name string
  38196. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38197. if role.ID == 0 {
  38198. user_name = "xxx"
  38199. } else {
  38200. user_name = role.UserName
  38201. }
  38202. psn_record, _ := service.GetPsnRecordById(id)
  38203. if psn_record.ID == 0 {
  38204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38205. return
  38206. }
  38207. if config.IsOpen == 1 {
  38208. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38209. var dat map[string]interface{}
  38210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38211. fmt.Println(dat)
  38212. } else {
  38213. fmt.Println(err)
  38214. }
  38215. userJSONBytes, _ := json.Marshal(dat)
  38216. var res ResultFourteen
  38217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38218. utils.ErrorLog("解析失败:%v", err)
  38219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38220. return
  38221. }
  38222. if res.Infcode == 0 {
  38223. psn_record.IsCancel = 2
  38224. service.CreatePsnRecord(&psn_record)
  38225. } else {
  38226. c.ServeSuccessJSON(map[string]interface{}{
  38227. "failed_code": -10,
  38228. "msg": res.ErrMsg,
  38229. })
  38230. return
  38231. }
  38232. }
  38233. }
  38234. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38235. patient_id, _ := c.GetInt64("patient_id")
  38236. insutype_two := c.GetString("insutype")
  38237. psn_no := c.GetString("psn_no")
  38238. doctor_id, _ := c.GetInt64("doctor_id")
  38239. sick_id, _ := c.GetInt64("sick_id")
  38240. department_id, _ := c.GetInt64("department_id")
  38241. start_time := c.GetString("start_time")
  38242. end_time := c.GetString("end_time")
  38243. check_time := c.GetString("check_time")
  38244. hospital_code := c.GetString("hospital_code")
  38245. hospital_name := c.GetString("hospital_name")
  38246. adminUser := c.GetAdminUserInfo()
  38247. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38248. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38249. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38250. sick, _ := service.FindSickById(sick_id)
  38251. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38252. if len(hospital_code) == 0 {
  38253. hospital_code = miConfig.Code
  38254. }
  38255. if len(hospital_name) == 0 {
  38256. hospital_name = miConfig.OrgName
  38257. }
  38258. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38259. var res ResultTwo
  38260. var res10265 ResultTwo10265
  38261. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38262. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38263. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38264. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38265. "&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
  38266. resp, requestErr := http.Get(api)
  38267. if requestErr != nil {
  38268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38269. return
  38270. }
  38271. body, ioErr := ioutil.ReadAll(resp.Body)
  38272. if ioErr != nil {
  38273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38275. return
  38276. }
  38277. var respJSON map[string]interface{}
  38278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38281. return
  38282. }
  38283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38284. result, _ := json.Marshal(respJSON)
  38285. fmt.Println("log")
  38286. fmt.Println(string(result))
  38287. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38288. utils.ErrorLog("解析失败:%v", err)
  38289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38290. return
  38291. }
  38292. res.ErrMsg = res10265.ErrMsg
  38293. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38294. res.Infcode = infocode
  38295. res.Output = res10265.Output
  38296. res.InfRefmsgid = res10265.InfRefmsgid
  38297. } else {
  38298. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38299. if miConfig.Code == "H15049901371" {
  38300. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38301. utils.ErrorLog("解析失败:%v", err)
  38302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38303. return
  38304. }
  38305. res.ErrMsg = res10265.ErrMsg
  38306. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38307. res.Infcode = infocode
  38308. res.Output = res10265.Output
  38309. res.InfRefmsgid = res10265.InfRefmsgid
  38310. } else {
  38311. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38312. utils.ErrorLog("解析失败:%v", err)
  38313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38314. return
  38315. }
  38316. }
  38317. }
  38318. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38319. infoStr := string(Iinfos)
  38320. var rf []*ResultFive
  38321. json.Unmarshal([]byte(infoStr), &rf)
  38322. var insuplc_admdvs string
  38323. var insutype string
  38324. var is390 int = 0
  38325. var is310 int = 0
  38326. var insutypes []*ResultFive
  38327. for _, item := range rf {
  38328. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38329. insutypes = append(insutypes, item)
  38330. }
  38331. }
  38332. if len(insutypes) == 1 {
  38333. insutype = insutypes[0].Insutype
  38334. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38335. } else {
  38336. for _, i := range insutypes {
  38337. if i.Insutype == "390" {
  38338. is390 = 1
  38339. }
  38340. if i.Insutype == "310" {
  38341. is310 = 1
  38342. }
  38343. }
  38344. }
  38345. if is390 == 1 {
  38346. insutype = "390"
  38347. }
  38348. if is310 == 1 {
  38349. insutype = "310"
  38350. }
  38351. if len(insutypes) == 2 {
  38352. insutype = insutype_two
  38353. }
  38354. if len(insutypes) == 0 {
  38355. insutype = "310"
  38356. }
  38357. insutype = insutype_two
  38358. fmt.Println(insutype)
  38359. for _, item := range rf {
  38360. fmt.Println(item.Insutype)
  38361. fmt.Println(insutype)
  38362. if item.Insutype == insutype {
  38363. fmt.Println(item.Insutype)
  38364. fmt.Println(insutype)
  38365. insuplc_admdvs = item.InsuplcAdmdvs
  38366. }
  38367. }
  38368. fmt.Println(insuplc_admdvs)
  38369. var res2 ResultThirteen
  38370. var res10265_2 ResultThirteen10265
  38371. if config.IsOpen == 1 {
  38372. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38373. } else {
  38374. if miConfig.MdtrtareaAdmvs == "150499" {
  38375. //
  38376. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38377. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38378. // "&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
  38379. //resp, requestErr := http.Get(api)
  38380. //if requestErr != nil {
  38381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38382. // return
  38383. //}
  38384. //
  38385. //body, ioErr := ioutil.ReadAll(resp.Body)
  38386. //if ioErr != nil {
  38387. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38389. // return
  38390. //}
  38391. //var respJSON map[string]interface{}
  38392. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38393. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38395. // return
  38396. //}
  38397. //
  38398. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38399. //result, _ := json.Marshal(respJSON)
  38400. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38401. // utils.ErrorLog("解析失败:%v", err)
  38402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38403. // return
  38404. //}
  38405. //infocode = resThree.Infcode
  38406. //result, _ := json.Marshal(respJSON)
  38407. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38408. // utils.ErrorLog("解析失败:%v", err)
  38409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38410. // return
  38411. //}
  38412. //
  38413. //resThree.ErrMsg = resThree10265.ErrMsg
  38414. //
  38415. //resThree.Output = resThree10265.Output
  38416. //
  38417. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38418. //
  38419. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38420. //
  38421. } else {
  38422. 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)
  38423. var dat map[string]interface{}
  38424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38425. fmt.Println(dat)
  38426. } else {
  38427. fmt.Println(err)
  38428. }
  38429. userJSONBytes, _ := json.Marshal(dat)
  38430. if miConfig.Code == "H15049901371" {
  38431. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38432. utils.ErrorLog("解析失败:%v", err)
  38433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38434. return
  38435. }
  38436. res2.ErrMsg = res10265_2.ErrMsg
  38437. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38438. res2.Infcode = infocode
  38439. res2.Output = res10265_2.Output
  38440. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38441. } else {
  38442. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38443. utils.ErrorLog("解析失败:%v", err)
  38444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38445. return
  38446. }
  38447. }
  38448. }
  38449. }
  38450. if res2.Infcode == 0 {
  38451. psnResult := &models.GdybPsnNcdsRecord{
  38452. UserOrgId: adminUser.CurrentOrgId,
  38453. PatientId: patient.ID,
  38454. PsnNo: psn_no,
  38455. DoctorId: doctor.AdminUserId,
  38456. DepartmentId: department_id,
  38457. SickType: sick_id,
  38458. Insutype: insutype,
  38459. Ctime: time.Now().Unix(),
  38460. Mtime: time.Now().Unix(),
  38461. Status: 1,
  38462. IsCancel: 1,
  38463. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38464. }
  38465. service.CreatePsnNCDSRecord(psnResult)
  38466. c.ServeSuccessJSON(map[string]interface{}{
  38467. "failed_code": 0,
  38468. "msg": "备案成功",
  38469. "result": psnResult,
  38470. })
  38471. } else {
  38472. c.ServeSuccessJSON(map[string]interface{}{
  38473. "failed_code": -10,
  38474. "msg": res2.ErrMsg,
  38475. })
  38476. return
  38477. }
  38478. }
  38479. }
  38480. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38481. id, _ := c.GetInt64("id")
  38482. admin_user_id, _ := c.GetInt64("admin_user_id")
  38483. adminUser := c.GetAdminUserInfo()
  38484. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38485. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38486. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38487. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38488. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38489. //var user_name string
  38490. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38491. //if role.ID == 0 {
  38492. // user_name = "xxx"
  38493. //} else {
  38494. // user_name = role.UserName
  38495. //}
  38496. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38497. if psn_record.ID == 0 {
  38498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38499. return
  38500. }
  38501. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38502. var res ResultTwo
  38503. var res10265 ResultTwo10265
  38504. if miConfig.Code == "H15049901371" {
  38505. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38506. utils.ErrorLog("解析失败:%v", err)
  38507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38508. return
  38509. }
  38510. res.ErrMsg = res10265.ErrMsg
  38511. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38512. res.Infcode = infocode
  38513. res.Output = res10265.Output
  38514. res.InfRefmsgid = res10265.InfRefmsgid
  38515. } else {
  38516. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38517. utils.ErrorLog("解析失败:%v", err)
  38518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38519. return
  38520. }
  38521. }
  38522. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38523. infoStr := string(Iinfos)
  38524. var rf []*ResultFive
  38525. json.Unmarshal([]byte(infoStr), &rf)
  38526. var insuplc_admdvs string
  38527. var insutype string
  38528. var is390 int = 0
  38529. var is310 int = 0
  38530. var insutypes []*ResultFive
  38531. for _, item := range rf {
  38532. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38533. insutypes = append(insutypes, item)
  38534. }
  38535. }
  38536. if len(insutypes) == 1 {
  38537. insutype = insutypes[0].Insutype
  38538. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38539. } else {
  38540. for _, i := range insutypes {
  38541. if i.Insutype == "390" {
  38542. is390 = 1
  38543. }
  38544. if i.Insutype == "310" {
  38545. is310 = 1
  38546. }
  38547. }
  38548. }
  38549. if is390 == 1 {
  38550. insutype = "390"
  38551. }
  38552. if is310 == 1 {
  38553. insutype = "310"
  38554. }
  38555. if len(insutypes) == 0 {
  38556. insutype = "310"
  38557. }
  38558. insutype = psn_record.Insutype
  38559. for _, item := range rf {
  38560. if item.Insutype == insutype {
  38561. insuplc_admdvs = item.InsuplcAdmdvs
  38562. }
  38563. }
  38564. if config.IsOpen == 1 {
  38565. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38566. var dat map[string]interface{}
  38567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38568. fmt.Println(dat)
  38569. } else {
  38570. fmt.Println(err)
  38571. }
  38572. userJSONBytes, _ := json.Marshal(dat)
  38573. var res ResultFourteen
  38574. var res10265 ResultFourteen10265
  38575. if miConfig.Code == "H15049901371" {
  38576. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38577. utils.ErrorLog("解析失败:%v", err)
  38578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38579. return
  38580. }
  38581. res.ErrMsg = res10265.ErrMsg
  38582. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38583. res.Infcode = infocode
  38584. res.Output = res10265.Output
  38585. res.InfRefmsgid = res10265.InfRefmsgid
  38586. } else {
  38587. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38588. utils.ErrorLog("解析失败:%v", err)
  38589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38590. return
  38591. }
  38592. }
  38593. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38594. // utils.ErrorLog("解析失败:%v", err)
  38595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38596. // return
  38597. //}
  38598. if res.Infcode == 0 {
  38599. psn_record.IsCancel = 2
  38600. service.CreatePsnNCDSRecord(&psn_record)
  38601. c.ServeSuccessJSON(map[string]interface{}{
  38602. "failed_code": 0,
  38603. "msg": "撤销备案成功",
  38604. })
  38605. } else {
  38606. c.ServeSuccessJSON(map[string]interface{}{
  38607. "failed_code": -10,
  38608. "msg": res.ErrMsg,
  38609. })
  38610. return
  38611. }
  38612. }
  38613. }
  38614. func (c *HisApiController) TestTest() {
  38615. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38616. fmt.Println(patient.Iinfo)
  38617. }
  38618. type CustomData struct {
  38619. MsgId string
  38620. PsnNo string
  38621. Info string
  38622. }
  38623. func (c *HisApiController) ReversalData() {
  38624. var customData []*CustomData
  38625. custom := &CustomData{
  38626. MsgId: "H44022900158202103301714472004",
  38627. PsnNo: "44020000001101329945",
  38628. Info: "2207",
  38629. }
  38630. customData = append(customData, custom)
  38631. custom1 := &CustomData{
  38632. MsgId: "H4402290015820210330172057803",
  38633. PsnNo: "44020000001101161813",
  38634. Info: "2207",
  38635. }
  38636. customData = append(customData, custom1)
  38637. custom2 := &CustomData{
  38638. MsgId: "H44022900158202103301705198813",
  38639. PsnNo: "44190000133097375417",
  38640. Info: "2207",
  38641. }
  38642. customData = append(customData, custom2)
  38643. custom3 := &CustomData{
  38644. MsgId: "H44022900158202103301715524756",
  38645. PsnNo: "44020000001100187221",
  38646. Info: "2207",
  38647. }
  38648. customData = append(customData, custom3)
  38649. custom4 := &CustomData{
  38650. MsgId: "H44022900158202103301730376224",
  38651. PsnNo: "44020000001101959155",
  38652. Info: "2207",
  38653. }
  38654. customData = append(customData, custom4)
  38655. custom5 := &CustomData{
  38656. MsgId: "H44022900158202103301748008725",
  38657. PsnNo: "44020000001104246641",
  38658. Info: "2207",
  38659. }
  38660. customData = append(customData, custom5)
  38661. custom6 := &CustomData{
  38662. MsgId: "H44022900158202103301718096755",
  38663. PsnNo: "44020000001102211860",
  38664. Info: "2207",
  38665. }
  38666. customData = append(customData, custom6)
  38667. custom7 := &CustomData{
  38668. MsgId: "H44022900158202103301736551640",
  38669. PsnNo: "44020000001102687718",
  38670. Info: "2207",
  38671. }
  38672. customData = append(customData, custom7)
  38673. custom8 := &CustomData{
  38674. MsgId: "H44022900158202103301743097676",
  38675. PsnNo: "44020000001102127785",
  38676. Info: "2207",
  38677. }
  38678. customData = append(customData, custom8)
  38679. custom9 := &CustomData{
  38680. MsgId: "H44022900158202103301712304203",
  38681. PsnNo: "44020000001101518097",
  38682. Info: "2207",
  38683. }
  38684. customData = append(customData, custom9)
  38685. custom10 := &CustomData{
  38686. MsgId: "H44022900158202103301738448785",
  38687. PsnNo: "44020000001100500813",
  38688. Info: "2207",
  38689. }
  38690. customData = append(customData, custom10)
  38691. custom11 := &CustomData{
  38692. MsgId: "H44022900158202103301732455843",
  38693. PsnNo: "44020000001102690557",
  38694. Info: "2207",
  38695. }
  38696. customData = append(customData, custom11)
  38697. custom12 := &CustomData{
  38698. MsgId: "H44022900158202103301745421708",
  38699. PsnNo: "44020000001102211928",
  38700. Info: "2207",
  38701. }
  38702. customData = append(customData, custom12)
  38703. custom1212 := &CustomData{
  38704. MsgId: "H440229001582021033017351627",
  38705. PsnNo: "44020000001102481733",
  38706. Info: "2207",
  38707. }
  38708. customData = append(customData, custom1212)
  38709. custom13 := &CustomData{
  38710. MsgId: "H44022900158202103301740327951",
  38711. PsnNo: "44020000001103174866",
  38712. Info: "2207",
  38713. }
  38714. customData = append(customData, custom13)
  38715. custom14 := &CustomData{
  38716. MsgId: "H4402290015820210330174922668",
  38717. PsnNo: "44020000001102927272",
  38718. Info: "2207",
  38719. }
  38720. customData = append(customData, custom14)
  38721. custom15 := &CustomData{
  38722. MsgId: "H44022900158202103301752362273",
  38723. PsnNo: "44020000001102942890",
  38724. Info: "2207",
  38725. }
  38726. customData = append(customData, custom15)
  38727. custom16 := &CustomData{
  38728. MsgId: "H44022900158202103301751082917",
  38729. PsnNo: "44020000001101662162",
  38730. Info: "2207",
  38731. }
  38732. customData = append(customData, custom16)
  38733. custom17 := &CustomData{
  38734. MsgId: "H44022900158202103301754147728",
  38735. PsnNo: "44020000000229014511",
  38736. Info: "2207",
  38737. }
  38738. customData = append(customData, custom17)
  38739. adminUser := c.GetAdminUserInfo()
  38740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38741. for _, item := range customData {
  38742. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38743. fmt.Println(result)
  38744. }
  38745. }
  38746. func (c *HisApiController) GetAllopatry() {
  38747. year := c.GetString("year")
  38748. month := c.GetString("month")
  38749. admin_user_id, _ := c.GetInt64("admin_user_id")
  38750. adminUser := c.GetAdminUserInfo()
  38751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38752. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38753. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38754. var dat map[string]interface{}
  38755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38756. fmt.Println(dat)
  38757. } else {
  38758. fmt.Println(err)
  38759. }
  38760. userJSONBytes, _ := json.Marshal(dat)
  38761. var res models.Result9001
  38762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38763. utils.ErrorLog("解析失败:%v", err)
  38764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38765. return
  38766. }
  38767. fmt.Println(res.Output.Signinoutb)
  38768. fmt.Println(res.Output.Signinoutb.SignNo)
  38769. fmt.Println(string(userJSONBytes))
  38770. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38771. var dat3 map[string]interface{}
  38772. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  38773. fmt.Println(dat3)
  38774. } else {
  38775. fmt.Println(err)
  38776. }
  38777. userJSONBytes3, _ := json.Marshal(dat3)
  38778. var res3 models.Result3260
  38779. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  38780. utils.ErrorLog("解析失败:%v", err)
  38781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38782. return
  38783. }
  38784. var curpage int
  38785. var pagesize int = 100
  38786. var start int = 1
  38787. //var stop int
  38788. //pagecount := 10
  38789. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  38790. var res22 []models.Result3260
  38791. for curpage = 1; curpage <= pagecount; curpage++ {
  38792. if curpage == 1 {
  38793. start = 0
  38794. } else {
  38795. start = (curpage-1)*pagesize + 1
  38796. }
  38797. fmt.Println(start)
  38798. //stop = curpage * pagesize
  38799. //if stop > int(res3.Output.Totalrow) {
  38800. // stop =int(res3.Output.Totalrow)
  38801. //}
  38802. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  38803. var dat2 map[string]interface{}
  38804. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38805. fmt.Println(dat)
  38806. } else {
  38807. fmt.Println(err)
  38808. }
  38809. userJSONBytes2, _ := json.Marshal(dat2)
  38810. var res2 models.Result3260
  38811. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38812. utils.ErrorLog("解析失败:%v", err)
  38813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38814. return
  38815. }
  38816. if res2.Infcode == 0 {
  38817. res22 = append(res22, res2)
  38818. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38819. //var dat2 map[string]interface{}
  38820. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38821. // fmt.Println(dat)
  38822. //} else {
  38823. // fmt.Println(err)
  38824. //}
  38825. //c.ServeSuccessJSON(map[string]interface{}{
  38826. // "list": res2.Output.Data,
  38827. //})
  38828. //continue
  38829. }
  38830. }
  38831. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38832. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38833. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  38834. //var dat2 map[string]interface{}
  38835. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38836. // fmt.Println(dat)
  38837. //} else {
  38838. // fmt.Println(err)
  38839. //}
  38840. //userJSONBytes2, _ := json.Marshal(dat2)
  38841. //var res2 models.Result3260
  38842. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38843. // utils.ErrorLog("解析失败:%v", err)
  38844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38845. // return
  38846. //}
  38847. //if res2.Infcode == 0 {
  38848. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38849. // var dat2 map[string]interface{}
  38850. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38851. // fmt.Println(dat)
  38852. // } else {
  38853. // fmt.Println(err)
  38854. // }
  38855. // c.ServeSuccessJSON(map[string]interface{}{
  38856. // "list": res2.Output.Data,
  38857. // })
  38858. //}
  38859. }
  38860. func (c *HisApiController) ComfirmAllopatry() {
  38861. year := c.GetString("year")
  38862. month := c.GetString("month")
  38863. admin_user_id, _ := c.GetInt64("admin_user_id")
  38864. adminUser := c.GetAdminUserInfo()
  38865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38866. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38867. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38868. var dat map[string]interface{}
  38869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38870. fmt.Println(dat)
  38871. } else {
  38872. fmt.Println(err)
  38873. }
  38874. userJSONBytes, _ := json.Marshal(dat)
  38875. var res models.Result9001
  38876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38877. utils.ErrorLog("解析失败:%v", err)
  38878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38879. return
  38880. }
  38881. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38882. var dat2 map[string]interface{}
  38883. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38884. fmt.Println(dat)
  38885. } else {
  38886. fmt.Println(err)
  38887. }
  38888. userJSONBytes2, _ := json.Marshal(dat2)
  38889. var res2 models.Result3260
  38890. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38891. utils.ErrorLog("解析失败:%v", err)
  38892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38893. return
  38894. }
  38895. //if res2.Infcode == 0 {
  38896. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38897. // var dat map[string]interface{}
  38898. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38899. // fmt.Println(dat)
  38900. // } else {
  38901. // fmt.Println(err)
  38902. // }
  38903. // userJSONBytes, _ := json.Marshal(dat)
  38904. // var res3 models.Result3261
  38905. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  38906. // utils.ErrorLog("解析失败:%v", err)
  38907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38908. // return
  38909. // }
  38910. //
  38911. // if res3.Infcode == 0 {
  38912. // record := &models.HisYidiClearRecord{
  38913. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38914. // Ctime: time.Now().Unix(),
  38915. // Mtime: time.Now().Unix(),
  38916. // Status: 1,
  38917. // MsgId: msgId,
  38918. // }
  38919. // service.SaveClearRecord(record)
  38920. // c.ServeSuccessJSON(map[string]interface{}{
  38921. // "msg": "提取成功",
  38922. // })
  38923. // }
  38924. //}
  38925. }
  38926. func (c *HisApiController) RefundAllopatry() {
  38927. year := c.GetString("year")
  38928. month := c.GetString("month")
  38929. //id, _ := c.GetInt64("id")
  38930. admin_user_id, _ := c.GetInt64("admin_user_id")
  38931. adminUser := c.GetAdminUserInfo()
  38932. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38933. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38934. //record, _ := service.GetClearRecordById(id)
  38935. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38936. var dat map[string]interface{}
  38937. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  38938. fmt.Println(dat)
  38939. } else {
  38940. fmt.Println(err)
  38941. }
  38942. userJSONBytes, _ := json.Marshal(dat)
  38943. var res models.Result9001
  38944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38945. utils.ErrorLog("解析失败:%v", err)
  38946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38947. return
  38948. }
  38949. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  38950. var dat2 map[string]interface{}
  38951. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38952. fmt.Println(dat)
  38953. } else {
  38954. fmt.Println(err)
  38955. }
  38956. userJSONBytes2, _ := json.Marshal(dat2)
  38957. var empty ResultFourteen
  38958. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  38959. utils.ErrorLog("解析失败:%v", err)
  38960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38961. return
  38962. }
  38963. if empty.Infcode == 0 {
  38964. c.ServeSuccessJSON(map[string]interface{}{
  38965. "msg": "撤销成功",
  38966. })
  38967. return
  38968. }
  38969. }
  38970. func (c *HisApiController) ReversalOtherData() {
  38971. var customData []*CustomData
  38972. custom := &CustomData{
  38973. MsgId: "H44022900158202103301714472004",
  38974. PsnNo: "44020000001101329945",
  38975. Info: "2208",
  38976. }
  38977. customData = append(customData, custom)
  38978. custom1 := &CustomData{
  38979. MsgId: "H4402290015820210330172057803",
  38980. PsnNo: "44020000001101161813",
  38981. Info: "2208",
  38982. }
  38983. customData = append(customData, custom1)
  38984. custom2 := &CustomData{
  38985. MsgId: "H44022900158202103301705198813",
  38986. PsnNo: "44190000133097375417",
  38987. Info: "2208",
  38988. }
  38989. customData = append(customData, custom2)
  38990. custom3 := &CustomData{
  38991. MsgId: "H44022900158202103301715524756",
  38992. PsnNo: "44020000001100187221",
  38993. Info: "2208",
  38994. }
  38995. customData = append(customData, custom3)
  38996. custom4 := &CustomData{
  38997. MsgId: "H44022900158202103301730376224",
  38998. PsnNo: "44020000001101959155",
  38999. Info: "2208",
  39000. }
  39001. customData = append(customData, custom4)
  39002. custom5 := &CustomData{
  39003. MsgId: "H44022900158202103301748008725",
  39004. PsnNo: "44020000001104246641",
  39005. Info: "2208",
  39006. }
  39007. customData = append(customData, custom5)
  39008. custom6 := &CustomData{
  39009. MsgId: "H44022900158202103301718096755",
  39010. PsnNo: "44020000001102211860",
  39011. Info: "2208",
  39012. }
  39013. customData = append(customData, custom6)
  39014. custom7 := &CustomData{
  39015. MsgId: "H44022900158202103301736551640",
  39016. PsnNo: "44020000001102687718",
  39017. Info: "2208",
  39018. }
  39019. customData = append(customData, custom7)
  39020. custom8 := &CustomData{
  39021. MsgId: "H44022900158202103301743097676",
  39022. PsnNo: "44020000001102127785",
  39023. Info: "2208",
  39024. }
  39025. customData = append(customData, custom8)
  39026. custom9 := &CustomData{
  39027. MsgId: "H44022900158202103301712304203",
  39028. PsnNo: "44020000001101518097",
  39029. Info: "2208",
  39030. }
  39031. customData = append(customData, custom9)
  39032. custom10 := &CustomData{
  39033. MsgId: "H44022900158202103301738448785",
  39034. PsnNo: "44020000001100500813",
  39035. Info: "2208",
  39036. }
  39037. customData = append(customData, custom10)
  39038. custom11 := &CustomData{
  39039. MsgId: "H44022900158202103301732455843",
  39040. PsnNo: "44020000001102690557",
  39041. Info: "2208",
  39042. }
  39043. customData = append(customData, custom11)
  39044. custom12 := &CustomData{
  39045. MsgId: "H44022900158202103301745421708",
  39046. PsnNo: "44020000001102211928",
  39047. Info: "2208",
  39048. }
  39049. customData = append(customData, custom12)
  39050. custom1212 := &CustomData{
  39051. MsgId: "H440229001582021033017351627",
  39052. PsnNo: "44020000001102481733",
  39053. Info: "2208",
  39054. }
  39055. customData = append(customData, custom1212)
  39056. custom13 := &CustomData{
  39057. MsgId: "H44022900158202103301740327951",
  39058. PsnNo: "44020000001103174866",
  39059. Info: "2208",
  39060. }
  39061. customData = append(customData, custom13)
  39062. custom14 := &CustomData{
  39063. MsgId: "H4402290015820210330174922668",
  39064. PsnNo: "44020000001102927272",
  39065. Info: "2208",
  39066. }
  39067. customData = append(customData, custom14)
  39068. custom15 := &CustomData{
  39069. MsgId: "H44022900158202103301752362273",
  39070. PsnNo: "44020000001102942890",
  39071. Info: "2208",
  39072. }
  39073. customData = append(customData, custom15)
  39074. custom16 := &CustomData{
  39075. MsgId: "H44022900158202103301751082917",
  39076. PsnNo: "44020000001101662162",
  39077. Info: "2208",
  39078. }
  39079. customData = append(customData, custom16)
  39080. custom17 := &CustomData{
  39081. MsgId: "H44022900158202103301754147728",
  39082. PsnNo: "44020000000229014511",
  39083. Info: "2208",
  39084. }
  39085. customData = append(customData, custom17)
  39086. adminUser := c.GetAdminUserInfo()
  39087. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39088. for _, item := range customData {
  39089. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39090. fmt.Println(result)
  39091. }
  39092. }
  39093. func PathExists(path string) (bool, error) {
  39094. _, err := os.Stat(path)
  39095. if err == nil {
  39096. return true, nil
  39097. }
  39098. if os.IsNotExist(err) {
  39099. return false, nil
  39100. }
  39101. return false, err
  39102. }
  39103. // 创建文件夹
  39104. func Mkdir(dir string) {
  39105. // 创建文件夹
  39106. exist, err := PathExists(dir)
  39107. if err != nil {
  39108. fmt.Println(err.Error())
  39109. } else {
  39110. if exist {
  39111. fmt.Println(dir + "文件夹已存在!")
  39112. } else {
  39113. // 文件夹名称,权限
  39114. err := os.Mkdir(dir, os.ModePerm)
  39115. if err != nil {
  39116. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39117. } else {
  39118. fmt.Println(dir + "文件夹创建成功!")
  39119. }
  39120. }
  39121. }
  39122. }
  39123. // 压缩文件
  39124. func Zip(srcFile string, destZip string) error {
  39125. zipfile, err := os.Create(destZip)
  39126. if err != nil {
  39127. return err
  39128. }
  39129. defer zipfile.Close()
  39130. archive := zip.NewWriter(zipfile)
  39131. defer archive.Close()
  39132. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39133. if err != nil {
  39134. return err
  39135. }
  39136. header, err := zip.FileInfoHeader(info)
  39137. if err != nil {
  39138. return err
  39139. }
  39140. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39141. // header.Name = path
  39142. if info.IsDir() {
  39143. header.Name += "/"
  39144. } else {
  39145. header.Method = zip.Deflate
  39146. }
  39147. writer, err := archive.CreateHeader(header)
  39148. if err != nil {
  39149. return err
  39150. }
  39151. if !info.IsDir() {
  39152. file, err := os.Open(path)
  39153. if err != nil {
  39154. return err
  39155. }
  39156. defer file.Close()
  39157. _, err = io.Copy(writer, file)
  39158. }
  39159. return err
  39160. })
  39161. return err
  39162. }
  39163. func ReadFile(filePath string) []byte {
  39164. f, err := os.Open(filePath)
  39165. if err != nil {
  39166. fmt.Println("read file fail", err)
  39167. return nil
  39168. }
  39169. defer f.Close()
  39170. fd, err := ioutil.ReadAll(f)
  39171. if err != nil {
  39172. fmt.Println("read to fd fail", err)
  39173. return nil
  39174. }
  39175. return fd
  39176. }
  39177. func saveLogq(result string, request string, infno string, desc string) {
  39178. dir := "日志"
  39179. utils.Mkdir(dir)
  39180. month := time.Unix(1557042972, 0).Format("1")
  39181. year := time.Now().Format("2006")
  39182. month = time.Now().Format("01")
  39183. day := time.Now().Format("02")
  39184. hour := time.Now().Format("15")
  39185. min := time.Now().Format("04")
  39186. sec := time.Now().Format("05")
  39187. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39188. file := year + month + day + "_log"
  39189. file_name := file + ".txt"
  39190. file_path := "日志" + "/" + file_name
  39191. exist, _ := utils.PathExists(file_path)
  39192. if exist { //存在
  39193. fmt.Println("存在")
  39194. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39195. if err != nil {
  39196. fmt.Println("read fail")
  39197. }
  39198. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39199. n, _ := f.Seek(0, 2)
  39200. _, err = f.WriteAt([]byte(content), n)
  39201. } else { //不存在
  39202. fmt.Println("文件不存在,创建文件")
  39203. f, err := os.Create("日志" + "/" + file_name)
  39204. defer f.Close()
  39205. if err != nil {
  39206. } else {
  39207. _, err = f.Write([]byte("记录日志"))
  39208. }
  39209. }
  39210. }
  39211. func saveLog(result string, request string, infno string, desc string) {
  39212. org_id, _ := beego.AppConfig.Int64("org_id")
  39213. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39214. dir := miConfig.OrgName + "日志"
  39215. utils.Mkdir(dir)
  39216. month := time.Unix(1557042972, 0).Format("1")
  39217. year := time.Now().Format("2006")
  39218. month = time.Now().Format("01")
  39219. day := time.Now().Format("02")
  39220. hour := time.Now().Format("15")
  39221. min := time.Now().Format("04")
  39222. sec := time.Now().Format("05")
  39223. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39224. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39225. file_name := file + ".txt"
  39226. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39227. exist, _ := utils.PathExists(file_path)
  39228. if exist { //存在
  39229. fmt.Println("存在")
  39230. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39231. if err != nil {
  39232. fmt.Println("read fail")
  39233. }
  39234. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39235. n, _ := f.Seek(0, 2)
  39236. _, err = f.WriteAt([]byte(content), n)
  39237. } else { //不存在
  39238. fmt.Println("文件不存在,创建文件")
  39239. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39240. defer f.Close()
  39241. if err != nil {
  39242. } else {
  39243. _, err = f.Write([]byte("记录日志"))
  39244. }
  39245. }
  39246. }
  39247. type Charset string
  39248. const (
  39249. UTF8 = Charset("UTF-8")
  39250. GB18030 = Charset("GB18030")
  39251. )
  39252. func ConvertToString(src string, srcCode string, tagCode string) string {
  39253. srcCoder := mahonia.NewDecoder(srcCode)
  39254. srcResult := srcCoder.ConvertString(src)
  39255. tagCoder := mahonia.NewDecoder(tagCode)
  39256. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39257. result := string(cdata)
  39258. return result
  39259. }
  39260. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39261. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39262. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39263. var token string
  39264. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39265. var api string
  39266. if miConfig.MdtrtareaAdmvs == "320830" {
  39267. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39268. "&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
  39269. fmt.Println(api)
  39270. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39271. 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 +
  39272. "&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
  39273. fmt.Println(api)
  39274. } else {
  39275. 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 +
  39276. "&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
  39277. }
  39278. resp, requestErr := http.Get(api)
  39279. if requestErr != nil {
  39280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39281. return ""
  39282. }
  39283. body, ioErr := ioutil.ReadAll(resp.Body)
  39284. if ioErr != nil {
  39285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39287. return ""
  39288. }
  39289. var respJSON map[string]interface{}
  39290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39293. return ""
  39294. }
  39295. var status string
  39296. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39297. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39298. var res ResultTwo //1101结果
  39299. var res10265 ResultTwo10265 //1101结果
  39300. if status == "0" { //读卡成功
  39301. var card_info string //卡信息
  39302. var busi_card_info string
  39303. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39304. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39305. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39306. fmt.Println(card_info)
  39307. fmt.Println(busi_card_info)
  39308. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39309. result, _ := json.Marshal(respJSON)
  39310. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39311. utils.ErrorLog("解析失败:%v", err)
  39312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39313. return ""
  39314. }
  39315. res.ErrMsg = res10265.ErrMsg
  39316. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39317. res.Infcode = infocode
  39318. res.Output = res10265.Output
  39319. res.InfRefmsgid = res10265.InfRefmsgid
  39320. if res.Infcode == 0 {
  39321. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39322. if err == gorm.ErrRecordNotFound {
  39323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39324. return ""
  39325. } else if err != nil {
  39326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39327. return ""
  39328. } else {
  39329. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39330. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39331. infoStr := string(Iinfos)
  39332. idetinfoStr := string(Idetinfos)
  39333. psn := &models.HisPsn{
  39334. PsnNo: res.Output.Baseinfo.PsnNo,
  39335. PatientId: patient.ID,
  39336. Certno: res.Output.Baseinfo.Certno,
  39337. Gend: res.Output.Baseinfo.Gend,
  39338. Naty: res.Output.Baseinfo.Naty,
  39339. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39340. PsnName: res.Output.Baseinfo.PsnName,
  39341. Idetinfo: idetinfoStr,
  39342. Insuinfo: infoStr,
  39343. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39344. CardInfo: card_info,
  39345. VerifyNumber: token,
  39346. }
  39347. service.CreateHisPsn(psn)
  39348. return token
  39349. }
  39350. }
  39351. } else {
  39352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39353. return ""
  39354. }
  39355. } else { //读卡失败
  39356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39357. return ""
  39358. }
  39359. return token
  39360. }
  39361. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39362. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39363. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39364. var token string
  39365. var api string
  39366. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39367. "&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
  39368. fmt.Println(api)
  39369. resp, requestErr := http.Get(api)
  39370. if requestErr != nil {
  39371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39372. return ""
  39373. }
  39374. body, ioErr := ioutil.ReadAll(resp.Body)
  39375. if ioErr != nil {
  39376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39378. return ""
  39379. }
  39380. var respJSON map[string]interface{}
  39381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39384. return ""
  39385. }
  39386. var status string
  39387. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39388. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39389. var res ResultTwo //1101结果
  39390. if status == "1" { //读卡成功
  39391. var card_info string //卡信息
  39392. var busi_card_info string
  39393. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39394. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39395. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39396. fmt.Println(card_info)
  39397. fmt.Println(busi_card_info)
  39398. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39399. result, _ := json.Marshal(respJSON)
  39400. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39401. utils.ErrorLog("解析失败:%v", err)
  39402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39403. return ""
  39404. }
  39405. if res.Infcode == 0 {
  39406. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39407. if err == gorm.ErrRecordNotFound {
  39408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39409. return ""
  39410. } else if err != nil {
  39411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39412. return ""
  39413. } else {
  39414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39416. infoStr := string(Iinfos)
  39417. idetinfoStr := string(Idetinfos)
  39418. psn := &models.HisPsn{
  39419. PsnNo: res.Output.Baseinfo.PsnNo,
  39420. PatientId: patient.ID,
  39421. Certno: res.Output.Baseinfo.Certno,
  39422. Gend: res.Output.Baseinfo.Gend,
  39423. Naty: res.Output.Baseinfo.Naty,
  39424. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39425. PsnName: res.Output.Baseinfo.PsnName,
  39426. Idetinfo: idetinfoStr,
  39427. Insuinfo: infoStr,
  39428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39429. CardInfo: card_info,
  39430. VerifyNumber: token,
  39431. }
  39432. service.CreateHisPsn(psn)
  39433. return token
  39434. }
  39435. }
  39436. } else {
  39437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39438. return ""
  39439. }
  39440. return token
  39441. }
  39442. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39443. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39444. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39445. var token string
  39446. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39447. var api string
  39448. if miConfig.MdtrtareaAdmvs == "320830" {
  39449. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39450. "&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
  39451. fmt.Println(api)
  39452. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39453. 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 +
  39454. "&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
  39455. fmt.Println(api)
  39456. } else {
  39457. 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 +
  39458. "&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
  39459. }
  39460. resp, requestErr := http.Get(api)
  39461. if requestErr != nil {
  39462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39463. return ""
  39464. }
  39465. body, ioErr := ioutil.ReadAll(resp.Body)
  39466. if ioErr != nil {
  39467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39469. return ""
  39470. }
  39471. var respJSON map[string]interface{}
  39472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39475. return ""
  39476. }
  39477. var status string
  39478. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39479. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39480. var res ResultTwo //1101结果
  39481. var res10265 ResultTwo10265 //1101结果
  39482. if status == "0" { //读卡成功
  39483. var card_info string //卡信息
  39484. var busi_card_info string
  39485. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39486. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39487. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39488. fmt.Println(card_info)
  39489. fmt.Println(busi_card_info)
  39490. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39491. result, _ := json.Marshal(respJSON)
  39492. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39493. utils.ErrorLog("解析失败:%v", err)
  39494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39495. return ""
  39496. }
  39497. res.ErrMsg = res10265.ErrMsg
  39498. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39499. res.Infcode = infocode
  39500. res.Output = res10265.Output
  39501. res.InfRefmsgid = res10265.InfRefmsgid
  39502. if res.Infcode == 0 {
  39503. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39504. if err == gorm.ErrRecordNotFound {
  39505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39506. return ""
  39507. } else if err != nil {
  39508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39509. return ""
  39510. } else {
  39511. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39512. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39513. infoStr := string(Iinfos)
  39514. idetinfoStr := string(Idetinfos)
  39515. psn := &models.HisPsn{
  39516. PsnNo: res.Output.Baseinfo.PsnNo,
  39517. PatientId: patient.ID,
  39518. Certno: res.Output.Baseinfo.Certno,
  39519. Gend: res.Output.Baseinfo.Gend,
  39520. Naty: res.Output.Baseinfo.Naty,
  39521. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39522. PsnName: res.Output.Baseinfo.PsnName,
  39523. Idetinfo: idetinfoStr,
  39524. Insuinfo: infoStr,
  39525. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39526. CardInfo: card_info,
  39527. VerifyNumber: token,
  39528. }
  39529. service.CreateHisPsn(psn)
  39530. return token
  39531. }
  39532. }
  39533. } else {
  39534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39535. return ""
  39536. }
  39537. } else { //读卡失败
  39538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39539. return ""
  39540. }
  39541. return token
  39542. }
  39543. func DeleteExtraSpaceTwo(s string) string {
  39544. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39545. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39546. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39547. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39548. s2 := make([]byte, len(s1)) //定义字符数组切片
  39549. copy(s2, s1) //将字符串复制到切片
  39550. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39551. for len(spc_index) > 0 { //找到适配项
  39552. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39553. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39554. }
  39555. return string(s2)
  39556. }
  39557. func Remove0000(s string) string {
  39558. str := make([]rune, 0, len(s))
  39559. for _, v := range []rune(s) {
  39560. if v == 0 {
  39561. continue
  39562. }
  39563. str = append(str, v)
  39564. }
  39565. return string(str)
  39566. }
  39567. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39568. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39569. readCard := DllDef.MustFindProc("EcQuery")
  39570. pCardInfo := make([]byte, 8192)
  39571. pBusiCardInfo := make([]byte, 8192)
  39572. data := make(map[string]interface{})
  39573. //pData := make(map[string]interface{})
  39574. inputData := make(map[string]interface{})
  39575. inputData["orgId"] = code
  39576. inputData["businessType"] = "01101"
  39577. inputData["operatorId"] = operator_id
  39578. inputData["operatorName"] = operator_name
  39579. inputData["officeId"] = "001"
  39580. inputData["officeName"] = "血透室"
  39581. //
  39582. data["data"] = inputData
  39583. data["transType"] = "ec.query"
  39584. data["orgId"] = code
  39585. bytesData, _ := json.Marshal(data)
  39586. pCardInfo = bytesData
  39587. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39588. fmt.Println(ret2)
  39589. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39590. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39591. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39592. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39593. if ret2 != 0 {
  39594. return "", ""
  39595. }
  39596. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39597. }
  39598. func DeleteExtraSpace(s string) string {
  39599. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39600. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39601. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39602. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39603. s2 := make([]byte, len(s1)) //定义字符数组切片
  39604. copy(s2, s1) //将字符串复制到切片
  39605. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39606. for len(spc_index) > 0 { //找到适配项
  39607. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39608. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39609. }
  39610. return string(s2)
  39611. }
  39612. // 对账
  39613. func (c *HisApiController) Post3202() {
  39614. start_time := c.GetString("start_time")
  39615. end_time := c.GetString("end_time")
  39616. //insutype := c.GetString("insutype")
  39617. clr_type := c.GetString("clr_type")
  39618. clr_org := c.GetString("clr_optins")
  39619. admin_user_id, _ := c.GetInt64("admin_user_id")
  39620. adminUser := c.GetAdminUserInfo()
  39621. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39622. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39623. if len(clr_org) == 0 {
  39624. clr_org = miConfig.MdtrtareaAdmvs
  39625. }
  39626. timeLayout := "2006-01-02"
  39627. loc, _ := time.LoadLocation("Local")
  39628. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39629. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39630. var orders []*models.HisOrder
  39631. if clr_org == "421300" {
  39632. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39633. } else if clr_org == "420902" {
  39634. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39635. } else {
  39636. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39637. }
  39638. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39639. //fixmedins_setl_cnt := int64(len(orders))
  39640. var medfee_sumamt float64
  39641. var acct_pay float64
  39642. var fund_pay_sumamt float64
  39643. for _, item := range orders {
  39644. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39645. acct_pay = acct_pay + item.AcctPay
  39646. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39647. }
  39648. //var medfee_sumamt_two float64
  39649. //var acct_pay_two float64
  39650. //var fund_pay_sumamt_two float64
  39651. //for _, item := range orders_two {
  39652. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39653. // acct_pay_two = acct_pay_two + item.AcctPay
  39654. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39655. //}
  39656. //var user_name string
  39657. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39658. //if role.ID == 0 {
  39659. // user_name = "xxx"
  39660. //} else {
  39661. // user_name = role.UserName
  39662. //}
  39663. var res ResultSix
  39664. if config.IsOpen == 1 {
  39665. var bps []*models.BusinessParamsTwo
  39666. var bp models.BusinessParamsTwo
  39667. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39668. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39669. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39670. bp.MedfeeSumamt = medfee_sumamt_str
  39671. bp.AcctPay = acct_pay_str
  39672. bp.FundPaySumamt = fund_pay_sumamt_str
  39673. bp.Insutype = ""
  39674. bp.StmtBegndate = start_time
  39675. bp.ClrType = clr_type
  39676. bp.SetlOptins = clr_org
  39677. bp.StmtEnddate = end_time
  39678. bps = append(bps, &bp)
  39679. data := make(map[string]interface{})
  39680. data["bps"] = bps
  39681. data["org_name"] = miConfig.OrgName
  39682. data["doctor"] = role.UserName
  39683. data["fixmedins_code"] = miConfig.Code
  39684. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39685. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39686. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39687. if miConfig.MdtrtareaAdmvs == "421300" {
  39688. client := &http.Client{}
  39689. bytesData, _ := json.Marshal(data)
  39690. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39691. resp, _ := client.Do(req)
  39692. defer resp.Body.Close()
  39693. body, ioErr := ioutil.ReadAll(resp.Body)
  39694. if ioErr != nil {
  39695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39697. return
  39698. }
  39699. var respJSON map[string]interface{}
  39700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39703. return
  39704. }
  39705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39706. userJSONBytes, _ := json.Marshal(respJSON)
  39707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39708. utils.ErrorLog("解析失败:%v", err)
  39709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39710. return
  39711. }
  39712. }
  39713. if miConfig.MdtrtareaAdmvs == "420200" {
  39714. client := &http.Client{}
  39715. bytesData, _ := json.Marshal(data)
  39716. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39717. resp, _ := client.Do(req)
  39718. defer resp.Body.Close()
  39719. body, ioErr := ioutil.ReadAll(resp.Body)
  39720. if ioErr != nil {
  39721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39723. return
  39724. }
  39725. var respJSON map[string]interface{}
  39726. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39729. return
  39730. }
  39731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39732. userJSONBytes, _ := json.Marshal(respJSON)
  39733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39734. utils.ErrorLog("解析失败:%v", err)
  39735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39736. return
  39737. }
  39738. }
  39739. if miConfig.MdtrtareaAdmvs == "421182" {
  39740. client := &http.Client{}
  39741. bytesData, _ := json.Marshal(data)
  39742. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39743. resp, _ := client.Do(req)
  39744. defer resp.Body.Close()
  39745. body, ioErr := ioutil.ReadAll(resp.Body)
  39746. if ioErr != nil {
  39747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39749. return
  39750. }
  39751. var respJSON map[string]interface{}
  39752. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39755. return
  39756. }
  39757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39758. userJSONBytes, _ := json.Marshal(respJSON)
  39759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39760. utils.ErrorLog("解析失败:%v", err)
  39761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39762. return
  39763. }
  39764. }
  39765. if miConfig.MdtrtareaAdmvs == "420902" {
  39766. client := &http.Client{}
  39767. bytesData, _ := json.Marshal(data)
  39768. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39769. resp, _ := client.Do(req)
  39770. defer resp.Body.Close()
  39771. body, ioErr := ioutil.ReadAll(resp.Body)
  39772. if ioErr != nil {
  39773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39775. return
  39776. }
  39777. var respJSON map[string]interface{}
  39778. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39781. return
  39782. }
  39783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39784. userJSONBytes, _ := json.Marshal(respJSON)
  39785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39786. utils.ErrorLog("解析失败:%v", err)
  39787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39788. return
  39789. }
  39790. }
  39791. if res.Infcode == 0 {
  39792. c.ServeSuccessJSON(map[string]interface{}{
  39793. "msg": "发起成功",
  39794. })
  39795. } else {
  39796. c.ServeSuccessJSON(map[string]interface{}{
  39797. "failed_code": -10,
  39798. "msg": res.ErrMsg,
  39799. })
  39800. }
  39801. }
  39802. }
  39803. func (c *HisApiController) Post3204a() {
  39804. start_time := c.GetString("start_time")
  39805. end_time := c.GetString("end_time")
  39806. //insutype := c.GetString("insutype")
  39807. clr_type := c.GetString("clr_type")
  39808. clr_org := c.GetString("clr_optins")
  39809. admin_user_id, _ := c.GetInt64("admin_user_id")
  39810. adminUser := c.GetAdminUserInfo()
  39811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39813. if len(clr_org) == 0 {
  39814. clr_org = miConfig.MdtrtareaAdmvs
  39815. }
  39816. timeLayout := "2006-01-02"
  39817. loc, _ := time.LoadLocation("Local")
  39818. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39819. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39820. var orders []*models.HisOrder
  39821. if clr_org == "421300" {
  39822. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39823. } else if clr_org == "420902" {
  39824. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39825. } else {
  39826. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39827. }
  39828. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39829. //fixmedins_setl_cnt := int64(len(orders))
  39830. var medfee_sumamt float64
  39831. var acct_pay float64
  39832. var fund_pay_sumamt float64
  39833. for _, item := range orders {
  39834. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39835. acct_pay = acct_pay + item.AcctPay
  39836. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39837. }
  39838. //var medfee_sumamt_two float64
  39839. //var acct_pay_two float64
  39840. //var fund_pay_sumamt_two float64
  39841. //for _, item := range orders_two {
  39842. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39843. // acct_pay_two = acct_pay_two + item.AcctPay
  39844. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39845. //}
  39846. //var user_name string
  39847. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39848. //if role.ID == 0 {
  39849. // user_name = "xxx"
  39850. //} else {
  39851. // user_name = role.UserName
  39852. //}
  39853. var res ResultSix
  39854. if config.IsOpen == 1 {
  39855. var bps []*models.BusinessParamsTwo
  39856. var bp models.BusinessParamsTwo
  39857. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39858. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39859. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39860. bp.MedfeeSumamt = medfee_sumamt_str
  39861. bp.AcctPay = acct_pay_str
  39862. bp.FundPaySumamt = fund_pay_sumamt_str
  39863. bp.Insutype = ""
  39864. bp.StmtBegndate = start_time
  39865. bp.ClrType = clr_type
  39866. bp.SetlOptins = clr_org
  39867. bp.StmtEnddate = end_time
  39868. bps = append(bps, &bp)
  39869. data := make(map[string]interface{})
  39870. data["bps"] = bps
  39871. data["org_name"] = miConfig.OrgName
  39872. data["doctor"] = role.UserName
  39873. data["fixmedins_code"] = miConfig.Code
  39874. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39875. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39876. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39877. if miConfig.MdtrtareaAdmvs == "421300" {
  39878. client := &http.Client{}
  39879. bytesData, _ := json.Marshal(data)
  39880. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  39881. resp, _ := client.Do(req)
  39882. defer resp.Body.Close()
  39883. body, ioErr := ioutil.ReadAll(resp.Body)
  39884. if ioErr != nil {
  39885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39887. return
  39888. }
  39889. var respJSON map[string]interface{}
  39890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39893. return
  39894. }
  39895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39896. userJSONBytes, _ := json.Marshal(respJSON)
  39897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39898. utils.ErrorLog("解析失败:%v", err)
  39899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39900. return
  39901. }
  39902. }
  39903. if miConfig.MdtrtareaAdmvs == "420200" {
  39904. client := &http.Client{}
  39905. bytesData, _ := json.Marshal(data)
  39906. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  39907. resp, _ := client.Do(req)
  39908. defer resp.Body.Close()
  39909. body, ioErr := ioutil.ReadAll(resp.Body)
  39910. if ioErr != nil {
  39911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39913. return
  39914. }
  39915. var respJSON map[string]interface{}
  39916. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39919. return
  39920. }
  39921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39922. userJSONBytes, _ := json.Marshal(respJSON)
  39923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39924. utils.ErrorLog("解析失败:%v", err)
  39925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39926. return
  39927. }
  39928. }
  39929. if miConfig.MdtrtareaAdmvs == "421182" {
  39930. client := &http.Client{}
  39931. bytesData, _ := json.Marshal(data)
  39932. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  39933. resp, _ := client.Do(req)
  39934. defer resp.Body.Close()
  39935. body, ioErr := ioutil.ReadAll(resp.Body)
  39936. if ioErr != nil {
  39937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39939. return
  39940. }
  39941. var respJSON map[string]interface{}
  39942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39945. return
  39946. }
  39947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39948. userJSONBytes, _ := json.Marshal(respJSON)
  39949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39950. utils.ErrorLog("解析失败:%v", err)
  39951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39952. return
  39953. }
  39954. }
  39955. if miConfig.MdtrtareaAdmvs == "420902" {
  39956. client := &http.Client{}
  39957. bytesData, _ := json.Marshal(data)
  39958. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  39959. resp, _ := client.Do(req)
  39960. defer resp.Body.Close()
  39961. body, ioErr := ioutil.ReadAll(resp.Body)
  39962. if ioErr != nil {
  39963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39965. return
  39966. }
  39967. var respJSON map[string]interface{}
  39968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39971. return
  39972. }
  39973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39974. userJSONBytes, _ := json.Marshal(respJSON)
  39975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39976. utils.ErrorLog("解析失败:%v", err)
  39977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39978. return
  39979. }
  39980. }
  39981. if res.Infcode == 0 {
  39982. c.ServeSuccessJSON(map[string]interface{}{
  39983. "msg": "撤销成功",
  39984. })
  39985. } else {
  39986. c.ServeSuccessJSON(map[string]interface{}{
  39987. "failed_code": -10,
  39988. "msg": res.ErrMsg,
  39989. })
  39990. }
  39991. }
  39992. }
  39993. func (c *HisApiController) Post3204() {
  39994. admin_user_id, _ := c.GetInt64("admin_user_id")
  39995. id := c.GetString("id")
  39996. adminUser := c.GetAdminUserInfo()
  39997. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39998. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39999. //clr_org := miConfig.MdtrtareaAdmvs
  40000. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40001. var res ResultSix
  40002. if config.IsOpen == 1 {
  40003. data := make(map[string]interface{})
  40004. data["id"] = id
  40005. data["org_name"] = miConfig.OrgName
  40006. data["doctor"] = role.UserName
  40007. data["fixmedins_code"] = miConfig.Code
  40008. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40009. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40010. client := &http.Client{}
  40011. bytesData, _ := json.Marshal(data)
  40012. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40013. resp, _ := client.Do(req)
  40014. defer resp.Body.Close()
  40015. body, ioErr := ioutil.ReadAll(resp.Body)
  40016. if ioErr != nil {
  40017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40019. return
  40020. }
  40021. var respJSON map[string]interface{}
  40022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40025. return
  40026. }
  40027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40028. userJSONBytes, _ := json.Marshal(respJSON)
  40029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40030. utils.ErrorLog("解析失败:%v", err)
  40031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40032. return
  40033. }
  40034. if res.Infcode == 0 {
  40035. c.ServeSuccessJSON(map[string]interface{}{
  40036. "msg": "发起成功",
  40037. })
  40038. } else {
  40039. c.ServeSuccessJSON(map[string]interface{}{
  40040. "failed_code": -10,
  40041. "msg": res.ErrMsg,
  40042. })
  40043. }
  40044. }
  40045. }
  40046. func (c *HisApiController) Post8404() {
  40047. admin_user_id, _ := c.GetInt64("admin_user_id")
  40048. month := c.GetString("month")
  40049. adminUser := c.GetAdminUserInfo()
  40050. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40051. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40052. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40053. var res ResultSix
  40054. if config.IsOpen == 1 {
  40055. data := make(map[string]interface{})
  40056. data["month"] = month
  40057. data["org_name"] = miConfig.OrgName
  40058. data["doctor"] = role.UserName
  40059. data["fixmedins_code"] = miConfig.Code
  40060. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40061. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40062. client := &http.Client{}
  40063. bytesData, _ := json.Marshal(data)
  40064. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40065. resp, _ := client.Do(req)
  40066. defer resp.Body.Close()
  40067. body, ioErr := ioutil.ReadAll(resp.Body)
  40068. if ioErr != nil {
  40069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40071. return
  40072. }
  40073. var respJSON map[string]interface{}
  40074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40077. return
  40078. }
  40079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40080. userJSONBytes, _ := json.Marshal(respJSON)
  40081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40082. utils.ErrorLog("解析失败:%v", err)
  40083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40084. return
  40085. }
  40086. if res.Infcode == 0 {
  40087. c.ServeSuccessJSON(map[string]interface{}{
  40088. "msg": "查询成功",
  40089. })
  40090. } else {
  40091. c.ServeSuccessJSON(map[string]interface{}{
  40092. "failed_code": -10,
  40093. "msg": res.ErrMsg,
  40094. })
  40095. }
  40096. }
  40097. }
  40098. func (c *HisApiController) Post3202b() {
  40099. start_time := c.GetString("start_time")
  40100. end_time := c.GetString("end_time")
  40101. //insutype := c.GetString("insutype")
  40102. clr_type := c.GetString("clr_type")
  40103. clr_org := c.GetString("clr_optins")
  40104. admin_user_id, _ := c.GetInt64("admin_user_id")
  40105. adminUser := c.GetAdminUserInfo()
  40106. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40107. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40108. if len(clr_org) == 0 {
  40109. clr_org = miConfig.MdtrtareaAdmvs
  40110. }
  40111. timeLayout := "2006-01-02"
  40112. loc, _ := time.LoadLocation("Local")
  40113. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40114. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40115. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40116. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40117. //fixmedins_setl_cnt := int64(len(orders))
  40118. var medfee_sumamt float64
  40119. var acct_pay float64
  40120. var fund_pay_sumamt float64
  40121. for _, item := range orders {
  40122. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40123. acct_pay = acct_pay + item.AcctPay
  40124. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40125. }
  40126. //var medfee_sumamt_two float64
  40127. //var acct_pay_two float64
  40128. //var fund_pay_sumamt_two float64
  40129. //for _, item := range orders_two {
  40130. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40131. // acct_pay_two = acct_pay_two + item.AcctPay
  40132. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40133. //}
  40134. //var user_name string
  40135. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40136. //if role.ID == 0 {
  40137. // user_name = "xxx"
  40138. //} else {
  40139. // user_name = role.UserName
  40140. //}
  40141. var res ResultSix
  40142. if config.IsOpen == 1 {
  40143. var bps []*models.BusinessParamsTwo
  40144. var bp models.BusinessParamsTwo
  40145. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40146. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40147. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40148. bp.MedfeeSumamt = medfee_sumamt_str
  40149. bp.AcctPay = acct_pay_str
  40150. bp.FundPaySumamt = fund_pay_sumamt_str
  40151. bp.Insutype = "390"
  40152. bp.StmtBegndate = start_time
  40153. bp.ClrType = clr_type
  40154. bp.SetlOptins = clr_org
  40155. bp.StmtEnddate = end_time
  40156. bps = append(bps, &bp)
  40157. data := make(map[string]interface{})
  40158. data["bps"] = bps
  40159. data["org_name"] = miConfig.OrgName
  40160. data["doctor"] = role.UserName
  40161. data["fixmedins_code"] = miConfig.Code
  40162. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40163. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40164. if miConfig.MdtrtareaAdmvs == "421300" {
  40165. client := &http.Client{}
  40166. bytesData, _ := json.Marshal(data)
  40167. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40168. resp, _ := client.Do(req)
  40169. defer resp.Body.Close()
  40170. body, ioErr := ioutil.ReadAll(resp.Body)
  40171. if ioErr != nil {
  40172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40174. return
  40175. }
  40176. var respJSON map[string]interface{}
  40177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40180. return
  40181. }
  40182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40183. userJSONBytes, _ := json.Marshal(respJSON)
  40184. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40185. utils.ErrorLog("解析失败:%v", err)
  40186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40187. return
  40188. }
  40189. }
  40190. if miConfig.MdtrtareaAdmvs == "420200" {
  40191. client := &http.Client{}
  40192. bytesData, _ := json.Marshal(data)
  40193. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40194. resp, _ := client.Do(req)
  40195. defer resp.Body.Close()
  40196. body, ioErr := ioutil.ReadAll(resp.Body)
  40197. if ioErr != nil {
  40198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40200. return
  40201. }
  40202. var respJSON map[string]interface{}
  40203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40206. return
  40207. }
  40208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40209. userJSONBytes, _ := json.Marshal(respJSON)
  40210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40211. utils.ErrorLog("解析失败:%v", err)
  40212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40213. return
  40214. }
  40215. }
  40216. if miConfig.MdtrtareaAdmvs == "421182" {
  40217. client := &http.Client{}
  40218. bytesData, _ := json.Marshal(data)
  40219. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40220. resp, _ := client.Do(req)
  40221. defer resp.Body.Close()
  40222. body, ioErr := ioutil.ReadAll(resp.Body)
  40223. if ioErr != nil {
  40224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40226. return
  40227. }
  40228. var respJSON map[string]interface{}
  40229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40232. return
  40233. }
  40234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40235. userJSONBytes, _ := json.Marshal(respJSON)
  40236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40237. utils.ErrorLog("解析失败:%v", err)
  40238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40239. return
  40240. }
  40241. }
  40242. if res.Infcode == 0 {
  40243. c.ServeSuccessJSON(map[string]interface{}{
  40244. "msg": "发起成功",
  40245. })
  40246. } else {
  40247. c.ServeSuccessJSON(map[string]interface{}{
  40248. "failed_code": -10,
  40249. "msg": res.ErrMsg,
  40250. })
  40251. }
  40252. }
  40253. }
  40254. func (c *HisApiController) Post1608() {
  40255. start_time := c.GetString("start_time")
  40256. end_time := c.GetString("end_time")
  40257. admin_user_id, _ := c.GetInt64("admin_user_id")
  40258. adminUser := c.GetAdminUserInfo()
  40259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40260. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40261. timeLayout := "2006-01-02"
  40262. loc, _ := time.LoadLocation("Local")
  40263. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40264. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40265. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40266. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40267. fixmedins_setl_cnt := int64(len(orders))
  40268. var medfee_sumamt float64
  40269. var func_smamt float64
  40270. for _, item := range orders {
  40271. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40272. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40273. }
  40274. times := strings.Split(start_time, "-")
  40275. time_tows := strings.Split(end_time, "-")
  40276. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40277. var res ResultSix
  40278. if config.IsOpen == 1 {
  40279. //var bps []*models.BusinessParamsTwo
  40280. //var bp models.BusinessParamsTwo
  40281. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40282. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40283. data := make(map[string]interface{})
  40284. data["org_name"] = miConfig.OrgName
  40285. data["doctor"] = role.UserName
  40286. data["func_smamt"] = func_smamt_str
  40287. data["fixmedins_code"] = miConfig.Code
  40288. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40289. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40290. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40291. data["medfee_sumamt"] = medfee_sumamt_str
  40292. data["start_time"] = times[0] + times[1] + times[2]
  40293. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40294. if miConfig.MdtrtareaAdmvs == "421300" {
  40295. client := &http.Client{}
  40296. bytesData, _ := json.Marshal(data)
  40297. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40298. resp, _ := client.Do(req)
  40299. defer resp.Body.Close()
  40300. body, ioErr := ioutil.ReadAll(resp.Body)
  40301. if ioErr != nil {
  40302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40304. return
  40305. }
  40306. var respJSON map[string]interface{}
  40307. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40310. return
  40311. }
  40312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40313. userJSONBytes, _ := json.Marshal(respJSON)
  40314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40315. utils.ErrorLog("解析失败:%v", err)
  40316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40317. return
  40318. }
  40319. }
  40320. if miConfig.MdtrtareaAdmvs == "420200" {
  40321. client := &http.Client{}
  40322. bytesData, _ := json.Marshal(data)
  40323. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40324. resp, _ := client.Do(req)
  40325. defer resp.Body.Close()
  40326. body, ioErr := ioutil.ReadAll(resp.Body)
  40327. if ioErr != nil {
  40328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40330. return
  40331. }
  40332. var respJSON map[string]interface{}
  40333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40336. return
  40337. }
  40338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40339. userJSONBytes, _ := json.Marshal(respJSON)
  40340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40341. utils.ErrorLog("解析失败:%v", err)
  40342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40343. return
  40344. }
  40345. }
  40346. if miConfig.MdtrtareaAdmvs == "421182" {
  40347. client := &http.Client{}
  40348. bytesData, _ := json.Marshal(data)
  40349. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40350. resp, _ := client.Do(req)
  40351. defer resp.Body.Close()
  40352. body, ioErr := ioutil.ReadAll(resp.Body)
  40353. if ioErr != nil {
  40354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40356. return
  40357. }
  40358. var respJSON map[string]interface{}
  40359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40362. return
  40363. }
  40364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40365. userJSONBytes, _ := json.Marshal(respJSON)
  40366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40367. utils.ErrorLog("解析失败:%v", err)
  40368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40369. return
  40370. }
  40371. }
  40372. if res.Infcode == 0 {
  40373. c.ServeSuccessJSON(map[string]interface{}{
  40374. "msg": "发起成功",
  40375. })
  40376. } else {
  40377. c.ServeSuccessJSON(map[string]interface{}{
  40378. "failed_code": -10,
  40379. "msg": res.ErrMsg,
  40380. })
  40381. }
  40382. }
  40383. }
  40384. // 5.11.1.1【5262】结算信息按时间段查询
  40385. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40386. admin_user_id, _ := c.GetInt64("admin_user_id")
  40387. adminUser := c.GetAdminUserInfo()
  40388. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40389. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40390. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40391. var res Result5262
  40392. if config.IsOpen == 1 {
  40393. if miConfig.MdtrtareaAdmvs == "421300" {
  40394. data := make(map[string]interface{})
  40395. data["bps"] = bp
  40396. data["org_name"] = miConfig.OrgName
  40397. data["doctor"] = role.UserName
  40398. data["fixmedins_code"] = miConfig.Code
  40399. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40400. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40401. data["page"] = strconv.FormatInt(page, 10)
  40402. data["limit"] = strconv.FormatInt(limit, 10)
  40403. fmt.Println(data)
  40404. client := &http.Client{}
  40405. bytesData, _ := json.Marshal(data)
  40406. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40407. resp, _ := client.Do(req)
  40408. defer resp.Body.Close()
  40409. body, ioErr := ioutil.ReadAll(resp.Body)
  40410. if ioErr != nil {
  40411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40413. return
  40414. }
  40415. var respJSON map[string]interface{}
  40416. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40419. return
  40420. }
  40421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40422. userJSONBytes, _ := json.Marshal(respJSON)
  40423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40424. utils.ErrorLog("解析失败:%v", err)
  40425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40426. return
  40427. }
  40428. }
  40429. if miConfig.MdtrtareaAdmvs == "420200" {
  40430. data := make(map[string]interface{})
  40431. data["bps"] = bp
  40432. data["org_name"] = miConfig.OrgName
  40433. data["doctor"] = role.UserName
  40434. data["fixmedins_code"] = miConfig.Code
  40435. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40436. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40437. data["page"] = strconv.FormatInt(page, 10)
  40438. data["limit"] = strconv.FormatInt(limit, 10)
  40439. fmt.Println(data)
  40440. client := &http.Client{}
  40441. bytesData, _ := json.Marshal(data)
  40442. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40443. resp, _ := client.Do(req)
  40444. defer resp.Body.Close()
  40445. body, ioErr := ioutil.ReadAll(resp.Body)
  40446. if ioErr != nil {
  40447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40449. return
  40450. }
  40451. var respJSON map[string]interface{}
  40452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40455. return
  40456. }
  40457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40458. userJSONBytes, _ := json.Marshal(respJSON)
  40459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40460. utils.ErrorLog("解析失败:%v", err)
  40461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40462. return
  40463. }
  40464. }
  40465. if miConfig.MdtrtareaAdmvs == "421182" {
  40466. data := make(map[string]interface{})
  40467. data["bps"] = bp
  40468. data["org_name"] = miConfig.OrgName
  40469. data["doctor"] = role.UserName
  40470. data["fixmedins_code"] = miConfig.Code
  40471. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40472. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40473. data["page"] = strconv.FormatInt(page, 10)
  40474. data["limit"] = strconv.FormatInt(limit, 10)
  40475. fmt.Println(data)
  40476. client := &http.Client{}
  40477. bytesData, _ := json.Marshal(data)
  40478. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40479. resp, _ := client.Do(req)
  40480. defer resp.Body.Close()
  40481. body, ioErr := ioutil.ReadAll(resp.Body)
  40482. if ioErr != nil {
  40483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40485. return
  40486. }
  40487. var respJSON map[string]interface{}
  40488. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40491. return
  40492. }
  40493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40494. userJSONBytes, _ := json.Marshal(respJSON)
  40495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40496. utils.ErrorLog("解析失败:%v", err)
  40497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40498. return
  40499. }
  40500. }
  40501. if miConfig.MdtrtareaAdmvs == "420902" {
  40502. data := make(map[string]interface{})
  40503. data["bps"] = bp
  40504. data["org_name"] = miConfig.OrgName
  40505. data["doctor"] = role.UserName
  40506. data["fixmedins_code"] = miConfig.Code
  40507. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40508. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40509. data["page"] = strconv.FormatInt(page, 10)
  40510. data["limit"] = strconv.FormatInt(limit, 10)
  40511. fmt.Println(data)
  40512. client := &http.Client{}
  40513. bytesData, _ := json.Marshal(data)
  40514. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40515. resp, _ := client.Do(req)
  40516. defer resp.Body.Close()
  40517. body, ioErr := ioutil.ReadAll(resp.Body)
  40518. if ioErr != nil {
  40519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40521. return
  40522. }
  40523. var respJSON map[string]interface{}
  40524. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40527. return
  40528. }
  40529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40530. userJSONBytes, _ := json.Marshal(respJSON)
  40531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40532. utils.ErrorLog("解析失败:%v", err)
  40533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40534. return
  40535. }
  40536. }
  40537. if res.Infcode == 0 {
  40538. c.ServeSuccessJSON(map[string]interface{}{
  40539. "order": res.Output.Result,
  40540. "total": res.Output.PageInfo.RecordCounts,
  40541. })
  40542. } else {
  40543. c.ServeSuccessJSON(map[string]interface{}{
  40544. "failed_code": -10,
  40545. "msg": res.ErrMsg,
  40546. })
  40547. }
  40548. }
  40549. }
  40550. // 5.11.1.2【5267】异地结算信息时间段查询
  40551. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40552. admin_user_id, _ := c.GetInt64("admin_user_id")
  40553. adminUser := c.GetAdminUserInfo()
  40554. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40555. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40556. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40557. var res Result5267
  40558. if config.IsOpen == 1 {
  40559. if miConfig.MdtrtareaAdmvs == "421300" {
  40560. data := make(map[string]interface{})
  40561. data["bps"] = bp
  40562. data["org_name"] = miConfig.OrgName
  40563. data["doctor"] = role.UserName
  40564. data["fixmedins_code"] = miConfig.Code
  40565. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40566. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40567. data["page"] = page
  40568. data["limit"] = limit
  40569. fmt.Println(data)
  40570. client := &http.Client{}
  40571. bytesData, _ := json.Marshal(data)
  40572. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40573. resp, _ := client.Do(req)
  40574. defer resp.Body.Close()
  40575. body, ioErr := ioutil.ReadAll(resp.Body)
  40576. if ioErr != nil {
  40577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40579. return
  40580. }
  40581. var respJSON map[string]interface{}
  40582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40585. return
  40586. }
  40587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40588. userJSONBytes, _ := json.Marshal(respJSON)
  40589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40590. utils.ErrorLog("解析失败:%v", err)
  40591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40592. return
  40593. }
  40594. }
  40595. if miConfig.MdtrtareaAdmvs == "420200" {
  40596. data := make(map[string]interface{})
  40597. data["bps"] = bp
  40598. data["org_name"] = miConfig.OrgName
  40599. data["doctor"] = role.UserName
  40600. data["fixmedins_code"] = miConfig.Code
  40601. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40602. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40603. data["page"] = page
  40604. data["limit"] = limit
  40605. fmt.Println(data)
  40606. client := &http.Client{}
  40607. bytesData, _ := json.Marshal(data)
  40608. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40609. resp, _ := client.Do(req)
  40610. defer resp.Body.Close()
  40611. body, ioErr := ioutil.ReadAll(resp.Body)
  40612. if ioErr != nil {
  40613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40615. return
  40616. }
  40617. var respJSON map[string]interface{}
  40618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40621. return
  40622. }
  40623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40624. userJSONBytes, _ := json.Marshal(respJSON)
  40625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40626. utils.ErrorLog("解析失败:%v", err)
  40627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40628. return
  40629. }
  40630. }
  40631. if miConfig.MdtrtareaAdmvs == "421182" {
  40632. data := make(map[string]interface{})
  40633. data["bps"] = bp
  40634. data["org_name"] = miConfig.OrgName
  40635. data["doctor"] = role.UserName
  40636. data["fixmedins_code"] = miConfig.Code
  40637. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40639. data["page"] = page
  40640. data["limit"] = limit
  40641. fmt.Println(data)
  40642. client := &http.Client{}
  40643. bytesData, _ := json.Marshal(data)
  40644. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40645. resp, _ := client.Do(req)
  40646. defer resp.Body.Close()
  40647. body, ioErr := ioutil.ReadAll(resp.Body)
  40648. if ioErr != nil {
  40649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40651. return
  40652. }
  40653. var respJSON map[string]interface{}
  40654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40657. return
  40658. }
  40659. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40660. userJSONBytes, _ := json.Marshal(respJSON)
  40661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40662. utils.ErrorLog("解析失败:%v", err)
  40663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40664. return
  40665. }
  40666. }
  40667. if res.Infcode == 0 {
  40668. c.ServeSuccessJSON(map[string]interface{}{
  40669. "order": res.Output.Result,
  40670. "total": res.Output.PageInfo.RecordCounts,
  40671. })
  40672. } else {
  40673. c.ServeSuccessJSON(map[string]interface{}{
  40674. "failed_code": -10,
  40675. "msg": res.ErrMsg,
  40676. })
  40677. }
  40678. }
  40679. }
  40680. func (c *HisApiController) Post3501() {
  40681. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40682. data := make(map[string]interface{})
  40683. var struct3501s []models.Struct3501
  40684. var struct3501 models.Struct3501
  40685. struct3501.OrgName = miConfig.OrgName
  40686. struct3501.AccessKey = miConfig.AccessKey
  40687. struct3501.RequestUrl = miConfig.Url
  40688. struct3501.SecretKey = miConfig.SecretKey
  40689. struct3501.ManuDate = "2022-08-17"
  40690. struct3501.FixmedinsBchno = ""
  40691. struct3501.ManuLotnum = ""
  40692. struct3501.RxFlag = "0"
  40693. struct3501.ExpyEnd = "2022-08-17"
  40694. struct3501.Invdate = "2022-08-17"
  40695. struct3501.InvCnt = "20.25"
  40696. struct3501.Memo = ""
  40697. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40698. struct3501.FixmedinsHilistId = miConfig.Code
  40699. struct3501.FixmedinsHilistName = miConfig.OrgName
  40700. struct3501s = append(struct3501s, struct3501)
  40701. data["struct_3501s"] = struct3501s
  40702. client := &http.Client{}
  40703. bytesData, _ := json.Marshal(data)
  40704. var req *http.Request
  40705. if miConfig.MdtrtareaAdmvs == "320830" {
  40706. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40707. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40708. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40709. } else {
  40710. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40711. }
  40712. resp, _ := client.Do(req)
  40713. defer resp.Body.Close()
  40714. body, ioErr := ioutil.ReadAll(resp.Body)
  40715. if ioErr != nil {
  40716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40718. return
  40719. }
  40720. var respJSON map[string]interface{}
  40721. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40724. return
  40725. }
  40726. var res ResultSix
  40727. var resSix10265 ResultSix10265 //1101结果
  40728. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40729. result, _ := json.Marshal(respJSON)
  40730. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40731. utils.ErrorLog("解析失败:%v", err)
  40732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40733. return
  40734. }
  40735. res.InfRefmsgid = resSix10265.InfRefmsgid
  40736. res.Output = resSix10265.Output
  40737. res.ErrMsg = resSix10265.ErrMsg
  40738. res.Cainfo = resSix10265.Cainfo
  40739. res.WarnMsg = resSix10265.WarnMsg
  40740. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40741. res.Infcode = infocode
  40742. if infocode == 0 {
  40743. c.ServeSuccessJSON(map[string]interface{}{
  40744. "msg": "上传成功",
  40745. })
  40746. return
  40747. } else {
  40748. c.ServeSuccessJSON(map[string]interface{}{
  40749. "failed_code": -10,
  40750. "msg": res.ErrMsg,
  40751. })
  40752. return
  40753. }
  40754. }
  40755. func (c *HisApiController) Post3502() {
  40756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40757. data := make(map[string]interface{})
  40758. var struct3502s []models.Struct3502
  40759. var struct3502 models.Struct3502
  40760. struct3502.OrgName = miConfig.OrgName
  40761. struct3502.AccessKey = miConfig.AccessKey
  40762. struct3502.RequestUrl = miConfig.Url
  40763. struct3502.SecretKey = miConfig.SecretKey
  40764. struct3502.ManuDate = "2022-08-15"
  40765. struct3502.FixmedinsBchno = ""
  40766. struct3502.ManuLotnum = ""
  40767. struct3502.RxFlag = "0"
  40768. struct3502.ExpyEnd = "2022-08-15"
  40769. struct3502.Invdate = "2022-08-15"
  40770. struct3502.InvCnt = "20.25"
  40771. struct3502.Memo = ""
  40772. struct3502.MedListCodg = "XB01ABD056B002020200517"
  40773. struct3502.FixmedinsHilistId = miConfig.Code
  40774. struct3502.FixmedinsHilistName = miConfig.OrgName
  40775. struct3502s = append(struct3502s, struct3502)
  40776. data["struct_3502s"] = struct3502s
  40777. client := &http.Client{}
  40778. bytesData, _ := json.Marshal(data)
  40779. var req *http.Request
  40780. if miConfig.MdtrtareaAdmvs == "320830" {
  40781. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40782. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40783. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40784. } else {
  40785. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40786. }
  40787. resp, _ := client.Do(req)
  40788. defer resp.Body.Close()
  40789. body, ioErr := ioutil.ReadAll(resp.Body)
  40790. if ioErr != nil {
  40791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40793. return
  40794. }
  40795. var respJSON map[string]interface{}
  40796. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40799. return
  40800. }
  40801. var res ResultSix
  40802. var resSix10265 ResultSix10265 //1101结果
  40803. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40804. result, _ := json.Marshal(respJSON)
  40805. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40806. utils.ErrorLog("解析失败:%v", err)
  40807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40808. return
  40809. }
  40810. res.InfRefmsgid = resSix10265.InfRefmsgid
  40811. res.Output = resSix10265.Output
  40812. res.ErrMsg = resSix10265.ErrMsg
  40813. res.Cainfo = resSix10265.Cainfo
  40814. res.WarnMsg = resSix10265.WarnMsg
  40815. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40816. res.Infcode = infocode
  40817. if infocode == 0 {
  40818. c.ServeSuccessJSON(map[string]interface{}{
  40819. "msg": "上传成功",
  40820. })
  40821. return
  40822. } else {
  40823. c.ServeSuccessJSON(map[string]interface{}{
  40824. "failed_code": -10,
  40825. "msg": res.ErrMsg,
  40826. })
  40827. return
  40828. }
  40829. }
  40830. func (c *HisApiController) Post3503() {
  40831. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40832. data := make(map[string]interface{})
  40833. var struct3501s []models.Struct3501
  40834. var struct3501 models.Struct3501
  40835. struct3501.OrgName = miConfig.OrgName
  40836. struct3501.AccessKey = miConfig.AccessKey
  40837. struct3501.RequestUrl = miConfig.Url
  40838. struct3501.SecretKey = miConfig.SecretKey
  40839. struct3501.ManuDate = "2022-08-15"
  40840. struct3501.FixmedinsBchno = ""
  40841. struct3501.ManuLotnum = ""
  40842. struct3501.RxFlag = "0"
  40843. struct3501.ExpyEnd = "2022-08-15"
  40844. struct3501.Invdate = "2022-08-15"
  40845. struct3501.InvCnt = "20.25"
  40846. struct3501.Memo = ""
  40847. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40848. struct3501.FixmedinsHilistId = miConfig.Code
  40849. struct3501.FixmedinsHilistName = miConfig.OrgName
  40850. struct3501s = append(struct3501s, struct3501)
  40851. data["struct_3501s"] = struct3501s
  40852. client := &http.Client{}
  40853. bytesData, _ := json.Marshal(data)
  40854. var req *http.Request
  40855. if miConfig.MdtrtareaAdmvs == "320921" {
  40856. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40857. } else {
  40858. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40859. }
  40860. resp, _ := client.Do(req)
  40861. defer resp.Body.Close()
  40862. body, ioErr := ioutil.ReadAll(resp.Body)
  40863. if ioErr != nil {
  40864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40866. return
  40867. }
  40868. var respJSON map[string]interface{}
  40869. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40872. return
  40873. }
  40874. var res ResultSix
  40875. var resSix10265 ResultSix10265 //1101结果
  40876. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40877. result, _ := json.Marshal(respJSON)
  40878. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40879. utils.ErrorLog("解析失败:%v", err)
  40880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40881. return
  40882. }
  40883. res.InfRefmsgid = resSix10265.InfRefmsgid
  40884. res.Output = resSix10265.Output
  40885. res.ErrMsg = resSix10265.ErrMsg
  40886. res.Cainfo = resSix10265.Cainfo
  40887. res.WarnMsg = resSix10265.WarnMsg
  40888. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40889. res.Infcode = infocode
  40890. if infocode == 0 {
  40891. c.ServeSuccessJSON(map[string]interface{}{
  40892. "msg": "上传成功",
  40893. })
  40894. return
  40895. } else {
  40896. c.ServeSuccessJSON(map[string]interface{}{
  40897. "failed_code": -10,
  40898. "msg": res.ErrMsg,
  40899. })
  40900. return
  40901. }
  40902. }
  40903. func (c *HisApiController) Post3504() {
  40904. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40905. data := make(map[string]interface{})
  40906. var struct3501s []models.Struct3501
  40907. var struct3501 models.Struct3501
  40908. struct3501.OrgName = miConfig.OrgName
  40909. struct3501.AccessKey = miConfig.AccessKey
  40910. struct3501.RequestUrl = miConfig.Url
  40911. struct3501.SecretKey = miConfig.SecretKey
  40912. struct3501.ManuDate = "2022-08-15"
  40913. struct3501.FixmedinsBchno = ""
  40914. struct3501.ManuLotnum = ""
  40915. struct3501.RxFlag = "0"
  40916. struct3501.ExpyEnd = "2022-08-15"
  40917. struct3501.Invdate = "2022-08-15"
  40918. struct3501.InvCnt = "20.25"
  40919. struct3501.Memo = ""
  40920. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40921. struct3501.FixmedinsHilistId = miConfig.Code
  40922. struct3501.FixmedinsHilistName = miConfig.OrgName
  40923. struct3501s = append(struct3501s, struct3501)
  40924. data["struct_3501s"] = struct3501s
  40925. client := &http.Client{}
  40926. bytesData, _ := json.Marshal(data)
  40927. var req *http.Request
  40928. if miConfig.MdtrtareaAdmvs == "320921" {
  40929. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40930. } else {
  40931. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40932. }
  40933. resp, _ := client.Do(req)
  40934. defer resp.Body.Close()
  40935. body, ioErr := ioutil.ReadAll(resp.Body)
  40936. if ioErr != nil {
  40937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40939. return
  40940. }
  40941. var respJSON map[string]interface{}
  40942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40945. return
  40946. }
  40947. var res ResultSix
  40948. var resSix10265 ResultSix10265 //1101结果
  40949. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40950. result, _ := json.Marshal(respJSON)
  40951. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40952. utils.ErrorLog("解析失败:%v", err)
  40953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40954. return
  40955. }
  40956. res.InfRefmsgid = resSix10265.InfRefmsgid
  40957. res.Output = resSix10265.Output
  40958. res.ErrMsg = resSix10265.ErrMsg
  40959. res.Cainfo = resSix10265.Cainfo
  40960. res.WarnMsg = resSix10265.WarnMsg
  40961. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40962. res.Infcode = infocode
  40963. if infocode == 0 {
  40964. c.ServeSuccessJSON(map[string]interface{}{
  40965. "msg": "上传成功",
  40966. })
  40967. return
  40968. } else {
  40969. c.ServeSuccessJSON(map[string]interface{}{
  40970. "failed_code": -10,
  40971. "msg": res.ErrMsg,
  40972. })
  40973. return
  40974. }
  40975. }
  40976. func (c *HisApiController) Post3505() {
  40977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40978. data := make(map[string]interface{})
  40979. var struct3501s []models.Struct3501
  40980. var struct3501 models.Struct3501
  40981. struct3501.OrgName = miConfig.OrgName
  40982. struct3501.AccessKey = miConfig.AccessKey
  40983. struct3501.RequestUrl = miConfig.Url
  40984. struct3501.SecretKey = miConfig.SecretKey
  40985. struct3501.ManuDate = "2022-08-15"
  40986. struct3501.FixmedinsBchno = ""
  40987. struct3501.ManuLotnum = ""
  40988. struct3501.RxFlag = "0"
  40989. struct3501.ExpyEnd = "2022-08-15"
  40990. struct3501.Invdate = "2022-08-15"
  40991. struct3501.InvCnt = "20.25"
  40992. struct3501.Memo = ""
  40993. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40994. struct3501.FixmedinsHilistId = miConfig.Code
  40995. struct3501.FixmedinsHilistName = miConfig.OrgName
  40996. struct3501s = append(struct3501s, struct3501)
  40997. data["struct_3501s"] = struct3501s
  40998. client := &http.Client{}
  40999. bytesData, _ := json.Marshal(data)
  41000. var req *http.Request
  41001. if miConfig.MdtrtareaAdmvs == "320921" {
  41002. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41003. } else {
  41004. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41005. }
  41006. resp, _ := client.Do(req)
  41007. defer resp.Body.Close()
  41008. body, ioErr := ioutil.ReadAll(resp.Body)
  41009. if ioErr != nil {
  41010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41012. return
  41013. }
  41014. var respJSON map[string]interface{}
  41015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41018. return
  41019. }
  41020. var res ResultSix
  41021. var resSix10265 ResultSix10265 //1101结果
  41022. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41023. result, _ := json.Marshal(respJSON)
  41024. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41025. utils.ErrorLog("解析失败:%v", err)
  41026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41027. return
  41028. }
  41029. res.InfRefmsgid = resSix10265.InfRefmsgid
  41030. res.Output = resSix10265.Output
  41031. res.ErrMsg = resSix10265.ErrMsg
  41032. res.Cainfo = resSix10265.Cainfo
  41033. res.WarnMsg = resSix10265.WarnMsg
  41034. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41035. res.Infcode = infocode
  41036. if infocode == 0 {
  41037. c.ServeSuccessJSON(map[string]interface{}{
  41038. "msg": "上传成功",
  41039. })
  41040. return
  41041. } else {
  41042. c.ServeSuccessJSON(map[string]interface{}{
  41043. "failed_code": -10,
  41044. "msg": res.ErrMsg,
  41045. })
  41046. return
  41047. }
  41048. }
  41049. func (c *HisApiController) Post3506() {
  41050. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41051. data := make(map[string]interface{})
  41052. var struct3501s []models.Struct3501
  41053. var struct3501 models.Struct3501
  41054. struct3501.OrgName = miConfig.OrgName
  41055. struct3501.AccessKey = miConfig.AccessKey
  41056. struct3501.RequestUrl = miConfig.Url
  41057. struct3501.SecretKey = miConfig.SecretKey
  41058. struct3501.ManuDate = "2022-08-15"
  41059. struct3501.FixmedinsBchno = ""
  41060. struct3501.ManuLotnum = ""
  41061. struct3501.RxFlag = "0"
  41062. struct3501.ExpyEnd = "2022-08-15"
  41063. struct3501.Invdate = "2022-08-15"
  41064. struct3501.InvCnt = "20.25"
  41065. struct3501.Memo = ""
  41066. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41067. struct3501.FixmedinsHilistId = miConfig.Code
  41068. struct3501.FixmedinsHilistName = miConfig.OrgName
  41069. struct3501s = append(struct3501s, struct3501)
  41070. data["struct_3501s"] = struct3501s
  41071. client := &http.Client{}
  41072. bytesData, _ := json.Marshal(data)
  41073. var req *http.Request
  41074. if miConfig.MdtrtareaAdmvs == "320921" {
  41075. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41076. } else {
  41077. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41078. }
  41079. resp, _ := client.Do(req)
  41080. defer resp.Body.Close()
  41081. body, ioErr := ioutil.ReadAll(resp.Body)
  41082. if ioErr != nil {
  41083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41085. return
  41086. }
  41087. var respJSON map[string]interface{}
  41088. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41091. return
  41092. }
  41093. var res ResultSix
  41094. var resSix10265 ResultSix10265 //1101结果
  41095. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41096. result, _ := json.Marshal(respJSON)
  41097. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41098. utils.ErrorLog("解析失败:%v", err)
  41099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41100. return
  41101. }
  41102. res.InfRefmsgid = resSix10265.InfRefmsgid
  41103. res.Output = resSix10265.Output
  41104. res.ErrMsg = resSix10265.ErrMsg
  41105. res.Cainfo = resSix10265.Cainfo
  41106. res.WarnMsg = resSix10265.WarnMsg
  41107. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41108. res.Infcode = infocode
  41109. if infocode == 0 {
  41110. c.ServeSuccessJSON(map[string]interface{}{
  41111. "msg": "上传成功",
  41112. })
  41113. return
  41114. } else {
  41115. c.ServeSuccessJSON(map[string]interface{}{
  41116. "failed_code": -10,
  41117. "msg": res.ErrMsg,
  41118. })
  41119. return
  41120. }
  41121. }
  41122. func (c *HisApiController) Post3507() {
  41123. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41124. data := make(map[string]interface{})
  41125. var struct3501s []models.Struct3501
  41126. var struct3501 models.Struct3501
  41127. struct3501.OrgName = miConfig.OrgName
  41128. struct3501.AccessKey = miConfig.AccessKey
  41129. struct3501.RequestUrl = miConfig.Url
  41130. struct3501.SecretKey = miConfig.SecretKey
  41131. struct3501.ManuDate = "2022-08-15"
  41132. struct3501.FixmedinsBchno = ""
  41133. struct3501.ManuLotnum = ""
  41134. struct3501.RxFlag = "0"
  41135. struct3501.ExpyEnd = "2022-08-15"
  41136. struct3501.Invdate = "2022-08-15"
  41137. struct3501.InvCnt = "20.25"
  41138. struct3501.Memo = ""
  41139. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41140. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41141. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41142. struct3501s = append(struct3501s, struct3501)
  41143. data["struct_3501s"] = struct3501s
  41144. client := &http.Client{}
  41145. bytesData, _ := json.Marshal(data)
  41146. var req *http.Request
  41147. if miConfig.MdtrtareaAdmvs == "320921" {
  41148. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41149. } else {
  41150. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41151. }
  41152. resp, _ := client.Do(req)
  41153. defer resp.Body.Close()
  41154. body, ioErr := ioutil.ReadAll(resp.Body)
  41155. if ioErr != nil {
  41156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41158. return
  41159. }
  41160. var respJSON map[string]interface{}
  41161. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41164. return
  41165. }
  41166. var res ResultSix
  41167. var resSix10265 ResultSix10265 //1101结果
  41168. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41169. result, _ := json.Marshal(respJSON)
  41170. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41171. utils.ErrorLog("解析失败:%v", err)
  41172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41173. return
  41174. }
  41175. res.InfRefmsgid = resSix10265.InfRefmsgid
  41176. res.Output = resSix10265.Output
  41177. res.ErrMsg = resSix10265.ErrMsg
  41178. res.Cainfo = resSix10265.Cainfo
  41179. res.WarnMsg = resSix10265.WarnMsg
  41180. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41181. res.Infcode = infocode
  41182. if infocode == 0 {
  41183. c.ServeSuccessJSON(map[string]interface{}{
  41184. "msg": "上传成功",
  41185. })
  41186. return
  41187. } else {
  41188. c.ServeSuccessJSON(map[string]interface{}{
  41189. "failed_code": -10,
  41190. "msg": res.ErrMsg,
  41191. })
  41192. return
  41193. }
  41194. }
  41195. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41196. // WebSocket服务器地址
  41197. serverURL := "ws://127.0.0.1:8899"
  41198. // 解析WebSocket服务器地址
  41199. u, err := url.Parse(serverURL)
  41200. if err != nil {
  41201. }
  41202. // 建立WebSocket连接
  41203. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41204. if err != nil {
  41205. }
  41206. defer conn.Close()
  41207. input2 := make(map[string]interface{})
  41208. input := make(map[string]interface{})
  41209. inputData := make(map[string]interface{})
  41210. inputData["orgId"] = code
  41211. inputData["businessType"] = "01101"
  41212. inputData["operatorId"] = operator_id
  41213. inputData["operatorName"] = operator_name
  41214. inputData["officeId"] = "001"
  41215. inputData["officeName"] = "血透室"
  41216. inputData["deviceType"] = ""
  41217. input["data"] = inputData
  41218. input["orgId"] = code
  41219. input["transType"] = "ec.query"
  41220. //if md == ""
  41221. if md[:4] == "4403" {
  41222. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41223. } else if md[:4] == "4401" {
  41224. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41225. } else {
  41226. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41227. }
  41228. input2["indata"] = input
  41229. fmt.Println(input2)
  41230. bytesData, _ := json.Marshal(input2)
  41231. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41232. if err != nil {
  41233. fmt.Println(err)
  41234. }
  41235. // 接收消息
  41236. _, receivedMessage, err := conn.ReadMessage()
  41237. if err != nil {
  41238. fmt.Println(err)
  41239. }
  41240. return "", string(receivedMessage)
  41241. }
  41242. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41243. // WebSocket服务器地址
  41244. serverURL := "ws://127.0.0.1:8899"
  41245. // 解析WebSocket服务器地址
  41246. u, err := url.Parse(serverURL)
  41247. if err != nil {
  41248. }
  41249. // 建立WebSocket连接
  41250. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41251. if err != nil {
  41252. }
  41253. defer conn.Close()
  41254. input2 := make(map[string]interface{})
  41255. input := make(map[string]interface{})
  41256. inputData := make(map[string]interface{})
  41257. inputData["orgId"] = code
  41258. inputData["businessType"] = "01101"
  41259. inputData["operatorId"] = operator_id
  41260. inputData["operatorName"] = operator_name
  41261. inputData["officeId"] = "001"
  41262. inputData["officeName"] = "血透室"
  41263. inputData["deviceType"] = ""
  41264. input["data"] = inputData
  41265. input["orgId"] = code
  41266. input["transType"] = "ec.query"
  41267. //if md == ""
  41268. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41269. input2["indata"] = input
  41270. fmt.Println(input2)
  41271. bytesData, _ := json.Marshal(input2)
  41272. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41273. if err != nil {
  41274. fmt.Println(err)
  41275. }
  41276. // 接收消息
  41277. _, receivedMessage, err := conn.ReadMessage()
  41278. if err != nil {
  41279. fmt.Println(err)
  41280. }
  41281. return "", string(receivedMessage)
  41282. }
  41283. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41284. // WebSocket服务器地址
  41285. serverURL := "ws://127.0.0.1:8899"
  41286. // 解析WebSocket服务器地址
  41287. u, err := url.Parse(serverURL)
  41288. if err != nil {
  41289. }
  41290. // 建立WebSocket连接
  41291. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41292. if err != nil {
  41293. }
  41294. defer conn.Close()
  41295. input2 := make(map[string]interface{})
  41296. input := make(map[string]interface{})
  41297. inputData := make(map[string]interface{})
  41298. inputData["orgId"] = code
  41299. inputData["businessType"] = "01301"
  41300. inputData["operatorId"] = operator_id
  41301. inputData["operatorName"] = operator_name
  41302. inputData["officeId"] = "001"
  41303. inputData["officeName"] = "血透室"
  41304. inputData["deviceType"] = ""
  41305. input["data"] = inputData
  41306. input["orgId"] = code
  41307. input["transType"] = "ec.query"
  41308. //if md == ""
  41309. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41310. input2["indata"] = input
  41311. fmt.Println(input2)
  41312. bytesData, _ := json.Marshal(input2)
  41313. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41314. if err != nil {
  41315. fmt.Println(err)
  41316. }
  41317. // 接收消息
  41318. _, receivedMessage, err := conn.ReadMessage()
  41319. if err != nil {
  41320. fmt.Println(err)
  41321. }
  41322. return "", string(receivedMessage)
  41323. }
  41324. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41325. // WebSocket服务器地址
  41326. serverURL := "ws://127.0.0.1:8899"
  41327. // 解析WebSocket服务器地址
  41328. u, err := url.Parse(serverURL)
  41329. if err != nil {
  41330. }
  41331. // 建立WebSocket连接
  41332. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41333. if err != nil {
  41334. }
  41335. defer conn.Close()
  41336. input2 := make(map[string]interface{})
  41337. input := make(map[string]interface{})
  41338. inputData := make(map[string]interface{})
  41339. inputData["orgId"] = code
  41340. inputData["businessType"] = "01103"
  41341. inputData["operatorId"] = operator_id
  41342. inputData["operatorName"] = operator_name
  41343. inputData["officeId"] = "001"
  41344. inputData["officeName"] = "血透室"
  41345. inputData["deviceType"] = ""
  41346. input["data"] = inputData
  41347. input["orgId"] = code
  41348. input["transType"] = "ec.query"
  41349. //if md ==
  41350. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41351. input2["indata"] = input
  41352. fmt.Println(input2)
  41353. bytesData, _ := json.Marshal(input2)
  41354. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41355. if err != nil {
  41356. fmt.Println(err)
  41357. }
  41358. // 接收消息
  41359. _, receivedMessage, err := conn.ReadMessage()
  41360. if err != nil {
  41361. fmt.Println(err)
  41362. }
  41363. return "", string(receivedMessage)
  41364. }
  41365. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41366. // WebSocket服务器地址
  41367. serverURL := "ws://127.0.0.1:8899"
  41368. // 解析WebSocket服务器地址
  41369. u, err := url.Parse(serverURL)
  41370. if err != nil {
  41371. }
  41372. // 建立WebSocket连接
  41373. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41374. if err != nil {
  41375. }
  41376. defer conn.Close()
  41377. input2 := make(map[string]interface{})
  41378. input := make(map[string]interface{})
  41379. inputData := make(map[string]interface{})
  41380. inputData["orgId"] = code
  41381. inputData["businessType"] = "01101"
  41382. inputData["operatorId"] = operator_id
  41383. inputData["operatorName"] = operator_name
  41384. inputData["officeId"] = "001"
  41385. inputData["officeName"] = "血透室"
  41386. inputData["deviceType"] = ""
  41387. input["data"] = inputData
  41388. input["orgId"] = code
  41389. input["transType"] = "ec.query"
  41390. //if md == ""
  41391. if md[:4] == "4403" {
  41392. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41393. } else if md[:4] == "4401" {
  41394. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41395. } else {
  41396. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41397. }
  41398. input2["indata"] = input
  41399. fmt.Println(input2)
  41400. bytesData, _ := json.Marshal(input2)
  41401. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41402. if err != nil {
  41403. fmt.Println(err)
  41404. }
  41405. // 接收消息
  41406. _, receivedMessage, err := conn.ReadMessage()
  41407. if err != nil {
  41408. fmt.Println(err)
  41409. }
  41410. return "", string(receivedMessage)
  41411. }
  41412. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41413. // WebSocket服务器地址
  41414. serverURL := "ws://127.0.0.1:8899"
  41415. // 解析WebSocket服务器地址
  41416. u, err := url.Parse(serverURL)
  41417. if err != nil {
  41418. }
  41419. // 建立WebSocket连接
  41420. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41421. if err != nil {
  41422. }
  41423. defer conn.Close()
  41424. input2 := make(map[string]interface{})
  41425. input := make(map[string]interface{})
  41426. inputData := make(map[string]interface{})
  41427. inputData["orgId"] = code
  41428. inputData["businessType"] = "01301"
  41429. inputData["operatorId"] = operator_id
  41430. inputData["operatorName"] = operator_name
  41431. inputData["officeId"] = "001"
  41432. inputData["officeName"] = "血透室"
  41433. inputData["deviceType"] = ""
  41434. input["data"] = inputData
  41435. input["orgId"] = code
  41436. input["transType"] = "ec.query"
  41437. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41438. input2["indata"] = input
  41439. bytesData, _ := json.Marshal(input2)
  41440. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41441. if err != nil {
  41442. fmt.Println(err)
  41443. }
  41444. // 接收消息
  41445. _, receivedMessage, err := conn.ReadMessage()
  41446. if err != nil {
  41447. fmt.Println(err)
  41448. }
  41449. return "", string(receivedMessage)
  41450. }
  41451. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41452. newArr = make([]string, 0)
  41453. for i := 0; i < len(arr); i++ {
  41454. repeat := false
  41455. for j := i + 1; j < len(arr); j++ {
  41456. if arr[i] == arr[j] {
  41457. repeat = true
  41458. break
  41459. }
  41460. }
  41461. if !repeat {
  41462. newArr = append(newArr, arr[i])
  41463. }
  41464. }
  41465. return
  41466. }
  41467. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41468. if len(idNumber) != 18 {
  41469. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41470. }
  41471. // 提取出生日期
  41472. year, err := strconv.Atoi(idNumber[6:10])
  41473. if err != nil {
  41474. return "", 0, err
  41475. }
  41476. month, err := strconv.Atoi(idNumber[10:12])
  41477. if err != nil {
  41478. return "", 0, err
  41479. }
  41480. day, err := strconv.Atoi(idNumber[12:14])
  41481. if err != nil {
  41482. return "", 0, err
  41483. }
  41484. // 格式化生日字符串
  41485. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41486. birthdateFormatted := birthdate.Format("2006-01-02")
  41487. // 计算年龄
  41488. today := time.Now()
  41489. age := today.Year() - birthdate.Year()
  41490. if today.YearDay() < birthdate.YearDay() {
  41491. age--
  41492. }
  41493. return birthdateFormatted, age, nil
  41494. }
  41495. // 从身份证号码中提取出生年月日
  41496. func getBirthDateFromIDCard(idCard string) (string, error) {
  41497. // 身份证号码长度应为18位
  41498. if len(idCard) != 18 {
  41499. return "", fmt.Errorf("身份证号码长度应为18位")
  41500. }
  41501. // 提取出生日期部分 (YYYYMMDD)
  41502. birthDateStr := idCard[6:14]
  41503. // 解析出生日期
  41504. birthDate, err := time.Parse("20060102", birthDateStr)
  41505. if err != nil {
  41506. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41507. }
  41508. // 格式化出生日期为 YYYY-MM-DD
  41509. formattedDate := birthDate.Format("2006-01-02")
  41510. return formattedDate, nil
  41511. }